From 4de2749db8281c00aba37270fa9ae8d4bd2572d8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 May 2020 01:28:11 +0200 Subject: Explain the purpose of `ast::make` module more clearly --- crates/ra_syntax/src/ast/make.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index d0e960fb4..2db017038 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs @@ -1,5 +1,9 @@ //! This module contains free-standing functions for creating AST fragments out //! of smaller pieces. +//! +//! Note that all functions here intended to be stupid constructors, which just +//! assemble a finish node from immediate children. If you want to do something +//! smarter than that, it probably doesn't belong in this module. use itertools::Itertools; use stdx::format_to; @@ -95,6 +99,9 @@ pub fn expr_empty_block() -> ast::Expr { pub fn expr_unimplemented() -> ast::Expr { expr_from_text("unimplemented!()") } +pub fn expr_unreachable() -> ast::Expr { + expr_from_text("unreachable!()") +} pub fn expr_todo() -> ast::Expr { expr_from_text("todo!()") } @@ -264,10 +271,6 @@ pub fn token(kind: SyntaxKind) -> SyntaxToken { .unwrap_or_else(|| panic!("unhandled token: {:?}", kind)) } -pub fn unreachable_macro_call() -> ast::MacroCall { - ast_from_text(&format!("unreachable!()")) -} - pub fn param(name: String, ty: String) -> ast::Param { ast_from_text(&format!("fn f({}: {}) {{ }}", name, ty)) } -- cgit v1.2.3