mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 03:03:40 +00:00
Explain the purpose of ast::make
module more clearly
This commit is contained in:
parent
28f6b5b849
commit
4de2749db8
@ -51,7 +51,7 @@ pub(crate) fn replace_unwrap_with_match(acc: &mut Assists, ctx: &AssistContext)
|
||||
let bind_path = make::path_unqualified(make::path_segment(make::name_ref("a")));
|
||||
let ok_arm = make::match_arm(iter::once(ok_tuple), make::expr_path(bind_path));
|
||||
|
||||
let unreachable_call = make::unreachable_macro_call().into();
|
||||
let unreachable_call = make::expr_unreachable();
|
||||
let err_arm = make::match_arm(iter::once(make::placeholder_pat().into()), unreachable_call);
|
||||
|
||||
let match_arm_list = make::match_arm_list(vec![ok_arm, err_arm]);
|
||||
|
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user