aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/assists/early_return.rs10
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs4
-rw-r--r--crates/ra_hir_expand/src/builtin_macro.rs2
-rw-r--r--crates/ra_hir_expand/src/db.rs9
-rw-r--r--crates/ra_hir_ty/src/autoderef.rs4
-rw-r--r--crates/ra_hir_ty/src/lib.rs2
-rw-r--r--crates/ra_ide/src/completion/complete_postfix.rs2
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs17
-rw-r--r--crates/ra_ide/src/expand_macro.rs13
-rw-r--r--crates/ra_ide/src/extend_selection.rs2
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs54
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs2
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs2
-rw-r--r--crates/ra_lsp_server/src/world.rs20
-rw-r--r--crates/ra_mbe/src/lib.rs4
-rw-r--r--crates/ra_syntax/src/ast/make.rs3
16 files changed, 70 insertions, 80 deletions
diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs
index 264412526..023917aca 100644
--- a/crates/ra_assists/src/assists/early_return.rs
+++ b/crates/ra_assists/src/assists/early_return.rs
@@ -83,8 +83,8 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt
83 let parent_container = parent_block.syntax().parent()?.parent()?; 83 let parent_container = parent_block.syntax().parent()?.parent()?;
84 84
85 let early_expression: ast::Expr = match parent_container.kind() { 85 let early_expression: ast::Expr = match parent_container.kind() {
86 WHILE_EXPR | LOOP_EXPR => make::expr_continue().into(), 86 WHILE_EXPR | LOOP_EXPR => make::expr_continue(),
87 FN_DEF => make::expr_return().into(), 87 FN_DEF => make::expr_return(),
88 _ => return None, 88 _ => return None,
89 }; 89 };
90 90
@@ -116,13 +116,13 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt
116 ) 116 )
117 .into(), 117 .into(),
118 ), 118 ),
119 make::expr_path(make::path_from_name_ref(make::name_ref("it"))).into(), 119 make::expr_path(make::path_from_name_ref(make::name_ref("it"))),
120 ); 120 );
121 121
122 let sad_arm = make::match_arm( 122 let sad_arm = make::match_arm(
123 // FIXME: would be cool to use `None` or `Err(_)` if appropriate 123 // FIXME: would be cool to use `None` or `Err(_)` if appropriate
124 once(make::placeholder_pat().into()), 124 once(make::placeholder_pat().into()),
125 early_expression.into(), 125 early_expression,
126 ); 126 );
127 127
128 make::expr_match(cond_expr, make::match_arm_list(vec![happy_arm, sad_arm])) 128 make::expr_match(cond_expr, make::match_arm_list(vec![happy_arm, sad_arm]))
@@ -130,7 +130,7 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt
130 130
131 let let_stmt = make::let_stmt( 131 let let_stmt = make::let_stmt(
132 make::bind_pat(make::name(&bound_ident.syntax().to_string())).into(), 132 make::bind_pat(make::name(&bound_ident.syntax().to_string())).into(),
133 Some(match_expr.into()), 133 Some(match_expr),
134 ); 134 );
135 let let_stmt = if_indent_level.increase_indent(let_stmt); 135 let let_stmt = if_indent_level.increase_indent(let_stmt);
136 replace(let_stmt.syntax(), &then_block, &parent_block, &if_expr) 136 replace(let_stmt.syntax(), &then_block, &parent_block, &if_expr)
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 8b641d8b5..45199fa11 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -399,14 +399,14 @@ where
399 let resolutions = enum_data 399 let resolutions = enum_data
400 .variants 400 .variants
401 .iter() 401 .iter()
402 .filter_map(|(local_id, variant_data)| { 402 .map(|(local_id, variant_data)| {
403 let name = variant_data.name.clone(); 403 let name = variant_data.name.clone();
404 let variant = EnumVariantId { parent: e, local_id }; 404 let variant = EnumVariantId { parent: e, local_id };
405 let res = Resolution { 405 let res = Resolution {
406 def: PerNs::both(variant.into(), variant.into()), 406 def: PerNs::both(variant.into(), variant.into()),
407 import: Some(import_id), 407 import: Some(import_id),
408 }; 408 };
409 Some((name, res)) 409 (name, res)
410 }) 410 })
411 .collect::<Vec<_>>(); 411 .collect::<Vec<_>>();
412 self.update(module_id, Some(import_id), &resolutions); 412 self.update(module_id, Some(import_id), &resolutions);
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs
index 1749b491b..857f8a444 100644
--- a/crates/ra_hir_expand/src/builtin_macro.rs
+++ b/crates/ra_hir_expand/src/builtin_macro.rs
@@ -138,7 +138,7 @@ fn to_col_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize
138 if c == '\n' { 138 if c == '\n' {
139 break; 139 break;
140 } 140 }
141 col_num = col_num + 1; 141 col_num += 1;
142 } 142 }
143 col_num 143 col_num
144} 144}
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index d86445abf..2e12e126f 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -93,12 +93,11 @@ pub(crate) fn macro_def(
93 Some(Arc::new((TokenExpander::MacroRules(rules), tmap))) 93 Some(Arc::new((TokenExpander::MacroRules(rules), tmap)))
94 } 94 }
95 MacroDefKind::BuiltIn(expander) => { 95 MacroDefKind::BuiltIn(expander) => {
96 Some(Arc::new((TokenExpander::Builtin(expander.clone()), mbe::TokenMap::default()))) 96 Some(Arc::new((TokenExpander::Builtin(expander), mbe::TokenMap::default())))
97 }
98 MacroDefKind::BuiltInDerive(expander) => {
99 Some(Arc::new((TokenExpander::BuiltinDerive(expander), mbe::TokenMap::default())))
97 } 100 }
98 MacroDefKind::BuiltInDerive(expander) => Some(Arc::new((
99 TokenExpander::BuiltinDerive(expander.clone()),
100 mbe::TokenMap::default(),
101 ))),
102 } 101 }
103} 102}
104 103
diff --git a/crates/ra_hir_ty/src/autoderef.rs b/crates/ra_hir_ty/src/autoderef.rs
index ee48fa537..f32d5786a 100644
--- a/crates/ra_hir_ty/src/autoderef.rs
+++ b/crates/ra_hir_ty/src/autoderef.rs
@@ -48,7 +48,7 @@ fn deref_by_trait(
48 krate: CrateId, 48 krate: CrateId,
49 ty: InEnvironment<&Canonical<Ty>>, 49 ty: InEnvironment<&Canonical<Ty>>,
50) -> Option<Canonical<Ty>> { 50) -> Option<Canonical<Ty>> {
51 let deref_trait = match db.lang_item(krate.into(), "deref".into())? { 51 let deref_trait = match db.lang_item(krate, "deref".into())? {
52 LangItemTarget::TraitId(it) => it, 52 LangItemTarget::TraitId(it) => it,
53 _ => return None, 53 _ => return None,
54 }; 54 };
@@ -78,7 +78,7 @@ fn deref_by_trait(
78 78
79 let canonical = super::Canonical { num_vars: 1 + ty.value.num_vars, value: in_env }; 79 let canonical = super::Canonical { num_vars: 1 + ty.value.num_vars, value: in_env };
80 80
81 let solution = db.trait_solve(krate.into(), canonical)?; 81 let solution = db.trait_solve(krate, canonical)?;
82 82
83 match &solution { 83 match &solution {
84 Solution::Unique(vars) => { 84 Solution::Unique(vars) => {
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index 7310ef10d..48abf97c9 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -919,7 +919,7 @@ impl HirDisplay for ApplicationTy {
919 { 919 {
920 Option::None => self.parameters.0.as_ref(), 920 Option::None => self.parameters.0.as_ref(),
921 Option::Some(default_parameters) => { 921 Option::Some(default_parameters) => {
922 for (i, parameter) in self.parameters.into_iter().enumerate() { 922 for (i, parameter) in self.parameters.iter().enumerate() {
923 match (parameter, default_parameters.get(i)) { 923 match (parameter, default_parameters.get(i)) {
924 (&Ty::Unknown, _) | (_, None) => { 924 (&Ty::Unknown, _) | (_, None) => {
925 non_default_parameters.push(parameter.clone()) 925 non_default_parameters.push(parameter.clone())
diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs
index 646a30c76..5470dc291 100644
--- a/crates/ra_ide/src/completion/complete_postfix.rs
+++ b/crates/ra_ide/src/completion/complete_postfix.rs
@@ -12,7 +12,7 @@ use crate::{
12}; 12};
13 13
14pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { 14pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
15 if ctx.db.feature_flags.get("completion.enable-postfix") == false { 15 if !ctx.db.feature_flags.get("completion.enable-postfix") {
16 return; 16 return;
17 } 17 }
18 18
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 981da2b79..4894ea2f6 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -239,16 +239,15 @@ impl<'a> CompletionContext<'a> {
239 .expr() 239 .expr()
240 .map(|e| e.syntax().text_range()) 240 .map(|e| e.syntax().text_range())
241 .and_then(|r| find_node_with_range(original_file.syntax(), r)); 241 .and_then(|r| find_node_with_range(original_file.syntax(), r));
242 self.dot_receiver_is_ambiguous_float_literal = if let Some(ast::Expr::Literal(l)) = 242 self.dot_receiver_is_ambiguous_float_literal =
243 &self.dot_receiver 243 if let Some(ast::Expr::Literal(l)) = &self.dot_receiver {
244 { 244 match l.kind() {
245 match l.kind() { 245 ast::LiteralKind::FloatNumber { .. } => l.token().text().ends_with('.'),
246 ast::LiteralKind::FloatNumber { suffix: _ } => l.token().text().ends_with('.'), 246 _ => false,
247 _ => false, 247 }
248 } else {
249 false
248 } 250 }
249 } else {
250 false
251 }
252 } 251 }
253 if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) { 252 if let Some(method_call_expr) = ast::MethodCallExpr::cast(parent) {
254 // As above 253 // As above
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs
index 862c03304..bdbc31704 100644
--- a/crates/ra_ide/src/expand_macro.rs
+++ b/crates/ra_ide/src/expand_macro.rs
@@ -86,21 +86,18 @@ fn insert_whitespaces(syn: SyntaxNode) -> String {
86 let mut is_next = |f: fn(SyntaxKind) -> bool, default| -> bool { 86 let mut is_next = |f: fn(SyntaxKind) -> bool, default| -> bool {
87 token_iter.peek().map(|it| f(it.kind())).unwrap_or(default) 87 token_iter.peek().map(|it| f(it.kind())).unwrap_or(default)
88 }; 88 };
89 let is_last = |f: fn(SyntaxKind) -> bool, default| -> bool { 89 let is_last =
90 last.map(|it| f(it)).unwrap_or(default) 90 |f: fn(SyntaxKind) -> bool, default| -> bool { last.map(f).unwrap_or(default) };
91 };
92 91
93 res += &match token.kind() { 92 res += &match token.kind() {
94 k @ _ if is_text(k) && is_next(|it| !it.is_punct(), true) => { 93 k if is_text(k) && is_next(|it| !it.is_punct(), true) => token.text().to_string() + " ",
95 token.text().to_string() + " "
96 }
97 L_CURLY if is_next(|it| it != R_CURLY, true) => { 94 L_CURLY if is_next(|it| it != R_CURLY, true) => {
98 indent += 1; 95 indent += 1;
99 let leading_space = if is_last(|it| is_text(it), false) { " " } else { "" }; 96 let leading_space = if is_last(is_text, false) { " " } else { "" };
100 format!("{}{{\n{}", leading_space, " ".repeat(indent)) 97 format!("{}{{\n{}", leading_space, " ".repeat(indent))
101 } 98 }
102 R_CURLY if is_last(|it| it != L_CURLY, true) => { 99 R_CURLY if is_last(|it| it != L_CURLY, true) => {
103 indent = indent.checked_sub(1).unwrap_or(0); 100 indent = indent.saturating_sub(1);
104 format!("\n{}}}", " ".repeat(indent)) 101 format!("\n{}}}", " ".repeat(indent))
105 } 102 }
106 R_CURLY => format!("}}\n{}", " ".repeat(indent)), 103 R_CURLY => format!("}}\n{}", " ".repeat(indent)),
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs
index c096ca6ae..1ec41a117 100644
--- a/crates/ra_ide/src/extend_selection.rs
+++ b/crates/ra_ide/src/extend_selection.rs
@@ -138,7 +138,7 @@ fn extend_ws(root: &SyntaxNode, ws: SyntaxToken, offset: TextUnit) -> TextRange
138 ws.text_range() 138 ws.text_range()
139} 139}
140 140
141fn pick_best<'a>(l: SyntaxToken, r: SyntaxToken) -> SyntaxToken { 141fn pick_best(l: SyntaxToken, r: SyntaxToken) -> SyntaxToken {
142 return if priority(&r) > priority(&l) { r } else { l }; 142 return if priority(&r) > priority(&l) { r } else { l };
143 fn priority(n: &SyntaxToken) -> usize { 143 fn priority(n: &SyntaxToken) -> usize {
144 match n.kind() { 144 match n.kind() {
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 657c7b21a..0228ee7e9 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -17,31 +17,31 @@ use crate::{
17}; 17};
18 18
19pub mod tags { 19pub mod tags {
20 pub(crate) const FIELD: &'static str = "field"; 20 pub(crate) const FIELD: &str = "field";
21 pub(crate) const FUNCTION: &'static str = "function"; 21 pub(crate) const FUNCTION: &str = "function";
22 pub(crate) const MODULE: &'static str = "module"; 22 pub(crate) const MODULE: &str = "module";
23 pub(crate) const TYPE: &'static str = "type"; 23 pub(crate) const TYPE: &str = "type";
24 pub(crate) const CONSTANT: &'static str = "constant"; 24 pub(crate) const CONSTANT: &str = "constant";
25 pub(crate) const MACRO: &'static str = "macro"; 25 pub(crate) const MACRO: &str = "macro";
26 pub(crate) const VARIABLE: &'static str = "variable"; 26 pub(crate) const VARIABLE: &str = "variable";
27 pub(crate) const VARIABLE_MUT: &'static str = "variable.mut"; 27 pub(crate) const VARIABLE_MUT: &str = "variable.mut";
28 pub(crate) const TEXT: &'static str = "text"; 28 pub(crate) const TEXT: &str = "text";
29 29
30 pub(crate) const TYPE_BUILTIN: &'static str = "type.builtin"; 30 pub(crate) const TYPE_BUILTIN: &str = "type.builtin";
31 pub(crate) const TYPE_SELF: &'static str = "type.self"; 31 pub(crate) const TYPE_SELF: &str = "type.self";
32 pub(crate) const TYPE_PARAM: &'static str = "type.param"; 32 pub(crate) const TYPE_PARAM: &str = "type.param";
33 pub(crate) const TYPE_LIFETIME: &'static str = "type.lifetime"; 33 pub(crate) const TYPE_LIFETIME: &str = "type.lifetime";
34 34
35 pub(crate) const LITERAL_BYTE: &'static str = "literal.byte"; 35 pub(crate) const LITERAL_BYTE: &str = "literal.byte";
36 pub(crate) const LITERAL_NUMERIC: &'static str = "literal.numeric"; 36 pub(crate) const LITERAL_NUMERIC: &str = "literal.numeric";
37 pub(crate) const LITERAL_CHAR: &'static str = "literal.char"; 37 pub(crate) const LITERAL_CHAR: &str = "literal.char";
38 pub(crate) const LITERAL_COMMENT: &'static str = "comment"; 38 pub(crate) const LITERAL_COMMENT: &str = "comment";
39 pub(crate) const LITERAL_STRING: &'static str = "string"; 39 pub(crate) const LITERAL_STRING: &str = "string";
40 pub(crate) const LITERAL_ATTRIBUTE: &'static str = "attribute"; 40 pub(crate) const LITERAL_ATTRIBUTE: &str = "attribute";
41 41
42 pub(crate) const KEYWORD_UNSAFE: &'static str = "keyword.unsafe"; 42 pub(crate) const KEYWORD_UNSAFE: &str = "keyword.unsafe";
43 pub(crate) const KEYWORD_CONTROL: &'static str = "keyword.control"; 43 pub(crate) const KEYWORD_CONTROL: &str = "keyword.control";
44 pub(crate) const KEYWORD: &'static str = "keyword"; 44 pub(crate) const KEYWORD: &str = "keyword";
45} 45}
46 46
47#[derive(Debug)] 47#[derive(Debug)]
@@ -258,9 +258,7 @@ fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
258 SelfType(_) => tags::TYPE_SELF, 258 SelfType(_) => tags::TYPE_SELF,
259 TypeParam(_) => tags::TYPE_PARAM, 259 TypeParam(_) => tags::TYPE_PARAM,
260 Local(local) => { 260 Local(local) => {
261 if local.is_mut(db) { 261 if local.is_mut(db) || local.ty(db).is_mutable_reference() {
262 tags::VARIABLE_MUT
263 } else if local.ty(db).is_mutable_reference() {
264 tags::VARIABLE_MUT 262 tags::VARIABLE_MUT
265 } else { 263 } else {
266 tags::VARIABLE 264 tags::VARIABLE
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 965e7c53c..9e207415e 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -131,7 +131,7 @@ pub fn main_loop(
131 let feature_flags = { 131 let feature_flags = {
132 let mut ff = FeatureFlags::default(); 132 let mut ff = FeatureFlags::default();
133 for (flag, value) in config.feature_flags { 133 for (flag, value) in config.feature_flags {
134 if let Err(_) = ff.set(flag.as_str(), value) { 134 if ff.set(flag.as_str(), value).is_err() {
135 log::error!("unknown feature flag: {:?}", flag); 135 log::error!("unknown feature flag: {:?}", flag);
136 show_message( 136 show_message(
137 req::MessageType::Error, 137 req::MessageType::Error,
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 5b64b27cd..5e3b1a73f 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -164,7 +164,7 @@ pub fn handle_on_type_formatting(
164 164
165 // in `ra_ide`, the `on_type` invariant is that 165 // in `ra_ide`, the `on_type` invariant is that
166 // `text.char_at(position) == typed_char`. 166 // `text.char_at(position) == typed_char`.
167 position.offset = position.offset - TextUnit::of_char('.'); 167 position.offset -= TextUnit::of_char('.');
168 let char_typed = params.ch.chars().next().unwrap_or('\0'); 168 let char_typed = params.ch.chars().next().unwrap_or('\0');
169 169
170 // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, 170 // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`,
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs
index 16cc11e8c..f89b23089 100644
--- a/crates/ra_lsp_server/src/world.rs
+++ b/crates/ra_lsp_server/src/world.rs
@@ -287,19 +287,15 @@ impl WorldSnapshot {
287/// 287///
288/// When processing non-windows path, this is essentially the same as `Url::from_file_path`. 288/// When processing non-windows path, this is essentially the same as `Url::from_file_path`.
289fn url_from_path_with_drive_lowercasing(path: impl AsRef<Path>) -> Result<Url> { 289fn url_from_path_with_drive_lowercasing(path: impl AsRef<Path>) -> Result<Url> {
290 let component_has_windows_drive = path 290 let component_has_windows_drive = path.as_ref().components().any(|comp| {
291 .as_ref() 291 if let Component::Prefix(c) = comp {
292 .components() 292 match c.kind() {
293 .find(|comp| { 293 Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true,
294 if let Component::Prefix(c) = comp { 294 _ => return false,
295 match c.kind() {
296 Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true,
297 _ => return false,
298 }
299 } 295 }
300 false 296 }
301 }) 297 false
302 .is_some(); 298 });
303 299
304 // VSCode expects drive letters to be lowercased, where rust will uppercase the drive letters. 300 // VSCode expects drive letters to be lowercased, where rust will uppercase the drive letters.
305 if component_has_windows_drive { 301 if component_has_windows_drive {
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index 45dad2d10..2c6ae5658 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -97,7 +97,9 @@ impl Shift {
97 tt::Leaf::Literal(lit) => lit.id = self.shift(lit.id), 97 tt::Leaf::Literal(lit) => lit.id = self.shift(lit.id),
98 }, 98 },
99 tt::TokenTree::Subtree(tt) => { 99 tt::TokenTree::Subtree(tt) => {
100 tt.delimiter.as_mut().map(|it: &mut Delimiter| it.id = self.shift(it.id)); 100 if let Some(it) = tt.delimiter.as_mut() {
101 it.id = self.shift(it.id);
102 };
101 self.shift_all(tt) 103 self.shift_all(tt)
102 } 104 }
103 } 105 }
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 40db570da..04a5408fe 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -168,8 +168,7 @@ pub fn let_stmt(pattern: ast::Pat, initializer: Option<ast::Expr>) -> ast::LetSt
168 168
169fn ast_from_text<N: AstNode>(text: &str) -> N { 169fn ast_from_text<N: AstNode>(text: &str) -> N {
170 let parse = SourceFile::parse(text); 170 let parse = SourceFile::parse(text);
171 let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); 171 parse.tree().syntax().descendants().find_map(N::cast).unwrap()
172 res
173} 172}
174 173
175pub mod tokens { 174pub mod tokens {