diff --git a/crates/mun_codegen/src/test.rs b/crates/mun_codegen/src/test.rs index b2ecb0fe5..000612cdb 100644 --- a/crates/mun_codegen/src/test.rs +++ b/crates/mun_codegen/src/test.rs @@ -969,7 +969,7 @@ fn test_snapshot_with_optimization(text: &str, opt: OptimizationLevel) { messages.borrow_mut().push(format!( "error {}:{}: {}", line_col.line + 1, - line_col.col + 1, + line_col.col_utf16 + 1, diag.message() )); }); diff --git a/crates/mun_compiler/src/diagnostics_snippets.rs b/crates/mun_compiler/src/diagnostics_snippets.rs index 574e4567d..1144239fb 100644 --- a/crates/mun_compiler/src/diagnostics_snippets.rs +++ b/crates/mun_compiler/src/diagnostics_snippets.rs @@ -36,8 +36,8 @@ pub(crate) fn emit_syntax_error( origin: Some(relative_file_path), annotations: vec![SourceAnnotation { range: ( - location.offset().to_usize() - line_offset, - location.end_offset().to_usize() - line_offset + 1, + usize::from(location.offset()) - line_offset, + usize::from(location.end_offset()) - line_offset + 1, ), label: &syntax_error_text, annotation_type: AnnotationType::Error, @@ -167,8 +167,8 @@ fn emit_diagnostic( .iter() .map(|annotation| SourceAnnotation { range: ( - annotation.range.start().to_usize() - line_offset, - annotation.range.end().to_usize() - line_offset, + usize::from(annotation.range.start()) - line_offset, + usize::from(annotation.range.end()) - line_offset, ), label: annotation.message.as_str(), annotation_type: AnnotationType::Error, diff --git a/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__free_type_alias_without_type_ref.snap b/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__free_type_alias_without_type_ref.snap index 344b52be4..a92fd5072 100644 --- a/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__free_type_alias_without_type_ref.snap +++ b/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__free_type_alias_without_type_ref.snap @@ -2,5 +2,5 @@ source: crates/mun_hir/src/expr/validator/tests.rs expression: "type Foo; // `Foo` must have a target type" --- -[0; 9): free type alias without type ref +0..9: free type alias without type ref diff --git a/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access.snap b/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access.snap index 498da9907..bbb3243d7 100644 --- a/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access.snap +++ b/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access.snap @@ -2,5 +2,5 @@ source: crates/mun_hir/src/expr/validator/tests.rs expression: "fn foo() {\n let a:int;\n let b = a + 3;\n}" --- -[38; 39): use of possibly-uninitialized variable +38..39: use of possibly-uninitialized variable diff --git a/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access_if.snap b/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access_if.snap index 45e724988..2bf0bb68b 100644 --- a/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access_if.snap +++ b/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access_if.snap @@ -2,5 +2,5 @@ source: crates/mun_hir/src/expr/validator/tests.rs expression: "fn foo() {\n let a:int;\n if true { a = 3; } else { a = 4; }\n let b = a + 4; // correct, `a` is initialized either way\n}\n\nfn bar() {\n let a:int;\n if true { a = 3; }\n let b = a + 4; // `a` is possibly-unitialized\n}\n\nfn baz() {\n let a:int;\n if true { return } else { a = 4 };\n let b = a + 4; // correct, `a` is initialized either way\n}\n\nfn foz() {\n let a:int;\n if true { a = 4 } else { return };\n let b = a + 4; // correct, `a` is initialized either way\n}\n\nfn boz() {\n let a:int;\n return;\n let b = a + 4; // `a` is not initialized but this is dead code anyway\n}" --- -[191; 192): use of possibly-uninitialized variable +191..192: use of possibly-uninitialized variable diff --git a/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access_while.snap b/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access_while.snap index 7256b8aca..06a7bf67b 100644 --- a/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access_while.snap +++ b/crates/mun_hir/src/expr/validator/snapshots/mun_hir__expr__validator__tests__uninitialized_access_while.snap @@ -2,5 +2,5 @@ source: crates/mun_hir/src/expr/validator/tests.rs expression: "fn foo(b:int) {\n let a:int;\n while b < 4 { b += 1; a = b; a += 1; }\n let c = a + 4; // `a` is possibly-unitialized\n}" --- -[86; 87): use of possibly-uninitialized variable +86..87: use of possibly-uninitialized variable diff --git a/crates/mun_hir/src/expr/validator/tests.rs b/crates/mun_hir/src/expr/validator/tests.rs index ddadae891..1da8ecb4f 100644 --- a/crates/mun_hir/src/expr/validator/tests.rs +++ b/crates/mun_hir/src/expr/validator/tests.rs @@ -84,7 +84,7 @@ fn diagnostics(content: &str) -> String { let mut diags = String::new(); let mut diag_sink = DiagnosticSink::new(|diag| { - write!(diags, "{}: {}\n", diag.highlight_range(), diag.message()).unwrap(); + write!(diags, "{:?}: {}\n", diag.highlight_range(), diag.message()).unwrap(); }); for item in Package::all(&db) diff --git a/crates/mun_hir/src/in_file.rs b/crates/mun_hir/src/in_file.rs index 8eeba9126..8adb15e00 100644 --- a/crates/mun_hir/src/in_file.rs +++ b/crates/mun_hir/src/in_file.rs @@ -7,7 +7,7 @@ use mun_syntax::SyntaxNode; /// /// * `InFile` -- syntax node in a file /// * `InFile` -- ast node in a file -/// * `InFile` -- offset in a file +/// * `InFile` -- offset in a file #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] pub struct InFile { pub file_id: FileId, diff --git a/crates/mun_hir/src/line_index.rs b/crates/mun_hir/src/line_index.rs index a4c67d5fd..09d210e4a 100644 --- a/crates/mun_hir/src/line_index.rs +++ b/crates/mun_hir/src/line_index.rs @@ -1,43 +1,128 @@ -use mun_syntax::TextUnit; +use mun_syntax::TextSize; -use superslice::Ext; +use rustc_hash::FxHashMap; #[derive(Clone, Debug, PartialEq, Eq)] pub struct LineIndex { - newlines: Vec, + /// Offsets from the beginning of each line + newlines: Vec, + + /// List of non-ASCII characters on each line + pub(crate) utf16_lines: FxHashMap>, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct LineCol { + /// The line index (zero-based) pub line: u32, - pub col: u32, + + /// The column index when the text is represented as UTF16 text (zero-based) + pub col_utf16: u32, +} + +#[derive(Clone, Debug, Hash, PartialEq, Eq)] +pub(crate) struct Utf16Char { + /// Start offset of a character inside a line, zero-based + pub(crate) start: TextSize, + + /// End offset of a character inside a line, zero-based + pub(crate) end: TextSize, +} + +impl Utf16Char { + /// Returns the length in 8-bit UTF-8 code units. + fn len(&self) -> TextSize { + self.end - self.start + } + + /// Returns the length in 16-bit UTF-16 code units. + fn len_utf16(&self) -> usize { + if self.len() == TextSize::from(4) { + 2 + } else { + 1 + } + } } impl LineIndex { pub fn new(text: &str) -> LineIndex { + let mut utf16_lines = FxHashMap::default(); + let mut utf16_chars = Vec::new(); + + // Iterate over all the characters in the text and record all the newlines and UTF16 + // characters. let mut newlines = vec![0.into()]; let mut curr_row = 0.into(); + let mut curr_col = 0.into(); + let mut line = 0; for c in text.chars() { - curr_row += TextUnit::of_char(c); + let c_len = TextSize::of(c); + curr_row += c_len; if c == '\n' { newlines.push(curr_row); + + // Save any utf-16 characters seen in the previous line + if !utf16_chars.is_empty() { + utf16_lines.insert(line, utf16_chars); + utf16_chars = Vec::new(); + } + + // Prepare for processing the next line + curr_col = 0.into(); + line += 1; + continue; } + + if !c.is_ascii() { + utf16_chars.push(Utf16Char { + start: curr_col, + end: curr_col + c_len, + }); + } + + curr_col += c_len; } - LineIndex { newlines } + // Save any utf-16 characters seen in the last line + if !utf16_chars.is_empty() { + utf16_lines.insert(line, utf16_chars); + } + + LineIndex { + newlines, + utf16_lines, + } } - pub fn line_col(&self, offset: TextUnit) -> LineCol { - let line = self.newlines.upper_bound(&offset) - 1; + /// Returns the line and column index at the given offset in the text + pub fn line_col(&self, offset: TextSize) -> LineCol { + let line = self + .newlines + .binary_search_by(|x| { + if x <= &offset { + std::cmp::Ordering::Less + } else { + std::cmp::Ordering::Greater + } + }) + .unwrap_or_else(|i| i) + - 1; let line_start_offset = self.newlines[line]; let col = offset - line_start_offset; LineCol { line: line as u32, - col: col.to_usize() as u32, + col_utf16: self.utf8_to_utf16_col(line as u32, col) as u32, } } + /// Returns the offset in the text for the given line and column index + pub fn offset(&self, line_col: LineCol) -> TextSize { + let col = self.utf16_to_utf8_col(line_col.line, line_col.col_utf16); + self.newlines[line_col.line as usize] + col + } + /// Retrieves the text between `first_line` and `last_line`, if any. pub fn text_part<'a>( &self, @@ -46,11 +131,11 @@ impl LineIndex { text: &'a str, text_len: usize, ) -> Option<&'a str> { - let start_of_part = self.newlines.get(first_line as usize)?.to_usize(); + let start_of_part = (*self.newlines.get(first_line as usize)?).into(); let end_of_part = self .newlines .get(last_line as usize + 1) - .map(|u| u.to_usize() - 1) + .map(|u| usize::from(*u) - 1usize) .unwrap_or(text_len); Some(&text[start_of_part..end_of_part]) } @@ -58,7 +143,41 @@ impl LineIndex { /// Retrieves the offset to the line corresponding to `line_index`. #[inline] pub fn line_offset(&self, line_index: u32) -> usize { - self.newlines[line_index as usize].to_usize() + self.newlines[line_index as usize].into() + } + + /// Given a line and column number for utf16 text convert it to the offset in utf8 text. + fn utf16_to_utf8_col(&self, line: u32, mut col: u32) -> TextSize { + if let Some(utf16_chars) = self.utf16_lines.get(&line) { + for c in utf16_chars { + if col > u32::from(c.start) { + col += u32::from(c.len()) - c.len_utf16() as u32; + } else { + // From here on, all utf16 characters come *after* the character we are mapping, + // so we don't need to take them into account + break; + } + } + } + + col.into() + } + + /// Given a line and column number for utf8 text, convert it to the offset in utf16 text. + fn utf8_to_utf16_col(&self, line: u32, col: TextSize) -> usize { + let mut res: usize = col.into(); + if let Some(utf16_chars) = self.utf16_lines.get(&line) { + for c in utf16_chars { + if c.end <= col { + res -= usize::from(c.len()) - c.len_utf16(); + } else { + // From here on, all utf16 characters come *after* the character we are mapping, + // so we don't need to take them into account + break; + } + } + } + res } } #[cfg(test)] @@ -69,11 +188,41 @@ mod tests { fn test_line_index() { let text = "hello\nworld"; let index = LineIndex::new(text); - assert_eq!(index.line_col(0.into()), LineCol { line: 0, col: 0 }); - assert_eq!(index.line_col(1.into()), LineCol { line: 0, col: 1 }); - assert_eq!(index.line_col(5.into()), LineCol { line: 0, col: 5 }); - assert_eq!(index.line_col(6.into()), LineCol { line: 1, col: 0 }); - assert_eq!(index.line_col(7.into()), LineCol { line: 1, col: 1 }); + assert_eq!( + index.line_col(0.into()), + LineCol { + line: 0, + col_utf16: 0 + } + ); + assert_eq!( + index.line_col(1.into()), + LineCol { + line: 0, + col_utf16: 1 + } + ); + assert_eq!( + index.line_col(5.into()), + LineCol { + line: 0, + col_utf16: 5 + } + ); + assert_eq!( + index.line_col(6.into()), + LineCol { + line: 1, + col_utf16: 0 + } + ); + assert_eq!( + index.line_col(7.into()), + LineCol { + line: 1, + col_utf16: 1 + } + ); } #[test] fn test_text_part() { @@ -88,6 +237,24 @@ mod tests { ); assert_eq!(index.text_part(0, 2, &text, text_len), Some(text)); } + #[test] + fn test_text_part_utf16() { + let text = "a\n❤️\nb"; + let index = LineIndex::new(text); + let start = index.offset(LineCol { + line: 1, + col_utf16: 0, + }); + let end = index.offset(LineCol { + line: 1, + col_utf16: 1, + }); + assert_eq!( + index.text_part(1, 1, &text, (end - start).into()), + Some("❤️") + ); + } + #[test] fn test_line_offset() { let text = "for\ntest\npurpose"; diff --git a/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_cyclic.snap b/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_cyclic.snap index 91999dc4f..6559ba942 100644 --- a/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_cyclic.snap +++ b/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_cyclic.snap @@ -4,11 +4,11 @@ expression: "//- /foo.mun\nuse super::baz::Cyclic;\n\npub struct Ok;\n\n//- /bar --- mod mod +-- mod bar -| +-- ERROR: [17; 23): unresolved import +| +-- ERROR: 17..23: unresolved import | '-- use struct package::foo::Ok +-- mod baz -| +-- ERROR: [17; 23): unresolved import +| +-- ERROR: 17..23: unresolved import | '-- use struct package::foo::Ok '-- mod foo - +-- ERROR: [4; 22): unresolved import + +-- ERROR: 4..22: unresolved import '-- struct Ok diff --git a/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_duplicate_name.snap b/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_duplicate_name.snap index f4fee7f1e..68209a36c 100644 --- a/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_duplicate_name.snap +++ b/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_duplicate_name.snap @@ -4,7 +4,7 @@ expression: "//- /foo.mun\npub struct Ok;\n\n//- /bar.mun\nuse package::foo::Ok; --- mod mod +-- mod bar -| +-- ERROR: [4; 20): a second item with the same name imported. Try to use an alias. +| +-- ERROR: 4..20: a second item with the same name imported. Try to use an alias. | '-- struct Ok '-- mod foo '-- struct Ok diff --git a/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_unresolved.snap b/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_unresolved.snap index 61f6ac0e7..2fb73df29 100644 --- a/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_unresolved.snap +++ b/crates/mun_hir/src/package_defs/snapshots/mun_hir__package_defs__tests__use_unresolved.snap @@ -3,8 +3,8 @@ source: crates/mun_hir/src/package_defs/tests.rs expression: "//- /foo.mun\npub struct Foo;\n\n//- /mod.mun\nuse foo::Foo; // works\nuse foo::Bar; // doesnt work (Bar does not exist)\nuse baz::Baz; // doesnt work (baz does not exist)" --- mod mod -+-- ERROR: [29; 37): unresolved import -+-- ERROR: [81; 89): unresolved import ++-- ERROR: 29..37: unresolved import ++-- ERROR: 81..89: unresolved import +-- use struct package::foo::Foo '-- mod foo '-- struct Foo diff --git a/crates/mun_hir/src/package_defs/tests.rs b/crates/mun_hir/src/package_defs/tests.rs index 11453d332..6a31840fb 100644 --- a/crates/mun_hir/src/package_defs/tests.rs +++ b/crates/mun_hir/src/package_defs/tests.rs @@ -181,7 +181,7 @@ fn tree_for_module( // Add module level diagnostics let mut diag_sink = DiagnosticSink::new(|diag| { node.push(format!( - "ERROR: {}: {}", + "ERROR: {:?}: {}", diag.highlight_range(), diag.message() )); diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__comparison_not_implemented_for_struct.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__comparison_not_implemented_for_struct.snap index d659955fe..2c1987b05 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__comparison_not_implemented_for_struct.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__comparison_not_implemented_for_struct.snap @@ -2,8 +2,8 @@ source: crates/mun_hir/src/ty/tests.rs expression: "struct Foo;\n\nfn main() -> bool {\n Foo == Foo\n}" --- -[37; 47): cannot apply binary operator -[31; 49) '{ ... Foo }': bool -[37; 40) 'Foo': Foo -[37; 47) 'Foo == Foo': bool -[44; 47) 'Foo': Foo +37..47: cannot apply binary operator +31..49 '{ ... Foo }': bool +37..40 'Foo': Foo +37..47 'Foo == Foo': bool +44..47 'Foo': Foo diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__extern_fn.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__extern_fn.snap index d4dc98fb9..d14e2d612 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__extern_fn.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__extern_fn.snap @@ -2,15 +2,15 @@ source: crates/mun_hir/src/ty/tests.rs expression: "extern fn foo(a:i32, b:i32) -> i32;\nfn main() {\n foo(3,4);\n}\n\nextern fn with_body() {} // extern functions cannot have bodies\n\nstruct S;\nextern fn with_non_primitive(s:S); // extern functions can only have primitives as parameters\nextern fn with_non_primitive_return() -> S; // extern functions can only have primitives as parameters" --- -[65; 89): extern functions cannot have bodies -[174; 175): extern functions can only have primitives as parameter- and return types -[279; 280): extern functions can only have primitives as parameter- and return types -[14; 15) 'a': i32 -[21; 22) 'b': i32 -[46; 63) '{ ...,4); }': nothing -[52; 55) 'foo': function foo(i32, i32) -> i32 -[52; 60) 'foo(3,4)': i32 -[56; 57) '3': i32 -[58; 59) '4': i32 -[87; 89) '{}': nothing -[172; 173) 's': S +65..89: extern functions cannot have bodies +174..175: extern functions can only have primitives as parameter- and return types +279..280: extern functions can only have primitives as parameter- and return types +14..15 'a': i32 +21..22 'b': i32 +46..63 '{ ...,4); }': nothing +52..55 'foo': function foo(i32, i32) -> i32 +52..60 'foo(3,4)': i32 +56..57 '3': i32 +58..59 '4': i32 +87..89 '{}': nothing +172..173 's': S diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_basics.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_basics.snap index b5a769991..2b932a321 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_basics.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_basics.snap @@ -2,12 +2,12 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn test(a:i32, b:f64, c:never, d:bool) -> bool {\n a;\n b;\n c;\n d\n}" --- -[8; 9) 'a': i32 -[15; 16) 'b': f64 -[22; 23) 'c': never -[31; 32) 'd': bool -[47; 77) '{ ... d }': never -[53; 54) 'a': i32 -[60; 61) 'b': f64 -[67; 68) 'c': never -[74; 75) 'd': bool +8..9 'a': i32 +15..16 'b': f64 +22..23 'c': never +31..32 'd': bool +47..77 '{ ... d }': never +53..54 'a': i32 +60..61 'b': f64 +67..68 'c': never +74..75 'd': bool diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_branching.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_branching.snap index dcbe7a28b..8125b232f 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_branching.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_branching.snap @@ -2,41 +2,41 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn test() {\n let a = if true { 3 } else { 4 }\n let b = if true { 3 } // Missing else branch\n let c = if true { 3; }\n let d = if true { 5 } else if false { 3 } else { 4 }\n let e = if true { 5.0 } else { 5 } // Mismatched branches\n}" --- -[61; 74): missing else branch -[208; 234): mismatched branches -[10; 260) '{ ...ches }': nothing -[20; 21) 'a': i32 -[24; 48) 'if tru... { 4 }': i32 -[27; 31) 'true': bool -[32; 37) '{ 3 }': i32 -[34; 35) '3': i32 -[43; 48) '{ 4 }': i32 -[45; 46) '4': i32 -[57; 58) 'b': nothing -[61; 74) 'if true { 3 }': nothing -[64; 68) 'true': bool -[69; 74) '{ 3 }': i32 -[71; 72) '3': i32 -[120; 121) 'c': nothing -[124; 138) 'if true { 3; }': nothing -[127; 131) 'true': bool -[132; 138) '{ 3; }': nothing -[134; 135) '3': i32 -[147; 148) 'd': i32 -[151; 195) 'if tru... { 4 }': i32 -[154; 158) 'true': bool -[159; 164) '{ 5 }': i32 -[161; 162) '5': i32 -[170; 195) 'if fal... { 4 }': i32 -[173; 178) 'false': bool -[179; 184) '{ 3 }': i32 -[181; 182) '3': i32 -[190; 195) '{ 4 }': i32 -[192; 193) '4': i32 -[204; 205) 'e': f64 -[208; 234) 'if tru... { 5 }': f64 -[211; 215) 'true': bool -[216; 223) '{ 5.0 }': f64 -[218; 221) '5.0': f64 -[229; 234) '{ 5 }': i32 -[231; 232) '5': i32 +61..74: missing else branch +208..234: mismatched branches +10..260 '{ ...ches }': nothing +20..21 'a': i32 +24..48 'if tru... { 4 }': i32 +27..31 'true': bool +32..37 '{ 3 }': i32 +34..35 '3': i32 +43..48 '{ 4 }': i32 +45..46 '4': i32 +57..58 'b': nothing +61..74 'if true { 3 }': nothing +64..68 'true': bool +69..74 '{ 3 }': i32 +71..72 '3': i32 +120..121 'c': nothing +124..138 'if true { 3; }': nothing +127..131 'true': bool +132..138 '{ 3; }': nothing +134..135 '3': i32 +147..148 'd': i32 +151..195 'if tru... { 4 }': i32 +154..158 'true': bool +159..164 '{ 5 }': i32 +161..162 '5': i32 +170..195 'if fal... { 4 }': i32 +173..178 'false': bool +179..184 '{ 3 }': i32 +181..182 '3': i32 +190..195 '{ 4 }': i32 +192..193 '4': i32 +204..205 'e': f64 +208..234 'if tru... { 5 }': f64 +211..215 'true': bool +216..223 '{ 5.0 }': f64 +218..221 '5.0': f64 +229..234 '{ 5 }': i32 +231..232 '5': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_break.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_break.snap index 7084bb254..18f538176 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_break.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_break.snap @@ -2,39 +2,39 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn foo()->i32 {\n break; // error: not in a loop\n loop { break 3; break 3.0; } // error: mismatched type\n let a:i32 = loop { break 3.0; } // error: mismatched type\n loop { break 3; }\n let a:i32 = loop { break loop { break 3; } }\n loop { break loop { break 3.0; } } // error: mismatched type\n}" --- -[20; 25): `break` outside of a loop -[71; 80): mismatched type -[133; 142): mismatched type -[267; 276): mismatched type -[14; 309) '{ ...type }': never -[20; 25) 'break': never -[55; 83) 'loop {...3.0; }': i32 -[60; 83) '{ brea...3.0; }': never -[62; 69) 'break 3': never -[68; 69) '3': i32 -[71; 80) 'break 3.0': never -[77; 80) '3.0': f64 -[118; 119) 'a': i32 -[126; 145) 'loop {...3.0; }': i32 -[131; 145) '{ break 3.0; }': never -[133; 142) 'break 3.0': never -[139; 142) '3.0': f64 -[176; 193) 'loop {...k 3; }': i32 -[181; 193) '{ break 3; }': never -[183; 190) 'break 3': never -[189; 190) '3': i32 -[202; 203) 'a': i32 -[210; 242) 'loop {...3; } }': i32 -[215; 242) '{ brea...3; } }': never -[217; 240) 'break ...k 3; }': never -[223; 240) 'loop {...k 3; }': i32 -[228; 240) '{ break 3; }': never -[230; 237) 'break 3': never -[236; 237) '3': i32 -[247; 281) 'loop {...0; } }': i32 -[252; 281) '{ brea...0; } }': never -[254; 279) 'break ...3.0; }': never -[260; 279) 'loop {...3.0; }': i32 -[265; 279) '{ break 3.0; }': never -[267; 276) 'break 3.0': never -[273; 276) '3.0': f64 +20..25: `break` outside of a loop +71..80: mismatched type +133..142: mismatched type +267..276: mismatched type +14..309 '{ ...type }': never +20..25 'break': never +55..83 'loop {...3.0; }': i32 +60..83 '{ brea...3.0; }': never +62..69 'break 3': never +68..69 '3': i32 +71..80 'break 3.0': never +77..80 '3.0': f64 +118..119 'a': i32 +126..145 'loop {...3.0; }': i32 +131..145 '{ break 3.0; }': never +133..142 'break 3.0': never +139..142 '3.0': f64 +176..193 'loop {...k 3; }': i32 +181..193 '{ break 3; }': never +183..190 'break 3': never +189..190 '3': i32 +202..203 'a': i32 +210..242 'loop {...3; } }': i32 +215..242 '{ brea...3; } }': never +217..240 'break ...k 3; }': never +223..240 'loop {...k 3; }': i32 +228..240 '{ break 3; }': never +230..237 'break 3': never +236..237 '3': i32 +247..281 'loop {...0; } }': i32 +252..281 '{ brea...0; } }': never +254..279 'break ...3.0; }': never +260..279 'loop {...3.0; }': i32 +265..279 '{ break 3.0; }': never +267..276 'break 3.0': never +273..276 '3.0': f64 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_conditional_return.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_conditional_return.snap index 62737f87c..ac506ee01 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_conditional_return.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_conditional_return.snap @@ -2,26 +2,26 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn foo(a:int)->i32 {\n if a > 4 {\n return 4;\n }\n a\n}\n\nfn bar(a:i32)->i32 {\n if a > 4 {\n return 4;\n } else {\n return 1;\n }\n}" --- -[9; 12): undefined type -[7; 8) 'a': {unknown} -[19; 67) '{ ... a }': i32 -[25; 59) 'if a >... }': nothing -[28; 29) 'a': {unknown} -[28; 33) 'a > 4': bool -[32; 33) '4': i32 -[34; 59) '{ ... }': never -[44; 52) 'return 4': never -[51; 52) '4': i32 -[64; 65) 'a': {unknown} -[76; 77) 'a': i32 -[88; 161) '{ ... } }': i32 -[94; 159) 'if a >... }': i32 -[97; 98) 'a': i32 -[97; 102) 'a > 4': bool -[101; 102) '4': i32 -[103; 128) '{ ... }': never -[113; 121) 'return 4': never -[120; 121) '4': i32 -[134; 159) '{ ... }': never -[144; 152) 'return 1': never -[151; 152) '1': i32 +9..12: undefined type +7..8 'a': {unknown} +19..67 '{ ... a }': i32 +25..59 'if a >... }': nothing +28..29 'a': {unknown} +28..33 'a > 4': bool +32..33 '4': i32 +34..59 '{ ... }': never +44..52 'return 4': never +51..52 '4': i32 +64..65 'a': {unknown} +76..77 'a': i32 +88..161 '{ ... } }': i32 +94..159 'if a >... }': i32 +97..98 'a': i32 +97..102 'a > 4': bool +101..102 '4': i32 +103..128 '{ ... }': never +113..121 'return 4': never +120..121 '4': i32 +134..159 '{ ... }': never +144..152 'return 1': never +151..152 '1': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_invalid_struct_type.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_invalid_struct_type.snap index 8c6973742..a34ccfd7c 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_invalid_struct_type.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_invalid_struct_type.snap @@ -2,8 +2,8 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn main(){\n let a = Foo {b: 3};\n}" --- -[23; 26): undefined type -[9; 36) '{ ... 3}; }': nothing -[19; 20) 'a': {unknown} -[23; 33) 'Foo {b: 3}': {unknown} -[31; 32) '3': i32 +23..26: undefined type +9..36 '{ ... 3}; }': nothing +19..20 'a': {unknown} +23..33 'Foo {b: 3}': {unknown} +31..32 '3': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_literals.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_literals.snap index 4005ea975..257563ee9 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_literals.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_literals.snap @@ -2,13 +2,13 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn integer() -> i32 {\n 0\n }\n\n fn large_unsigned_integer() -> u128 {\n 0\n }\n\n fn with_let() -> u16 {\n let b = 4;\n let a = 4;\n a\n }" --- -[20; 37) '{ ... }': i32 -[30; 31) '0': i32 -[79; 96) '{ ... }': u128 -[89; 90) '0': u128 -[123; 178) '{ ... }': u16 -[137; 138) 'b': i32 -[141; 142) '4': i32 -[156; 157) 'a': u16 -[160; 161) '4': u16 -[171; 172) 'a': u16 +20..37 '{ ... }': i32 +30..31 '0': i32 +79..96 '{ ... }': u128 +89..90 '0': u128 +123..178 '{ ... }': u16 +137..138 'b': i32 +141..142 '4': i32 +156..157 'a': u16 +160..161 '4': u16 +171..172 'a': u16 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_loop.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_loop.snap index 2c602626c..5ff144dc2 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_loop.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_loop.snap @@ -2,6 +2,6 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn foo() {\n loop {}\n}" --- -[9; 24) '{ loop {} }': never -[15; 22) 'loop {}': never -[20; 22) '{}': nothing +9..24 '{ loop {} }': never +15..22 'loop {}': never +20..22 '{}': nothing diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_return.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_return.snap index b88feb93b..3f771e72f 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_return.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_return.snap @@ -2,8 +2,8 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn test()->i32 {\n return; // error: mismatched type\n return 5;\n}" --- -[21; 27): `return;` in a function whose return type is not `()` -[15; 70) '{ ...n 5; }': never -[21; 27) 'return': never -[59; 67) 'return 5': never -[66; 67) '5': i32 +21..27: `return;` in a function whose return type is not `()` +15..70 '{ ...n 5; }': never +21..27 'return': never +59..67 'return 5': never +66..67 '5': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_suffix_literals.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_suffix_literals.snap index fedb3fe66..7c63d43d1 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_suffix_literals.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_suffix_literals.snap @@ -2,47 +2,47 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn main(){\n 123;\n 123u8;\n 123u16;\n 123u32;\n 123u64;\n 123u128;\n 1_000_000_u32;\n 123i8;\n 123i16;\n 123i32;\n 123i64;\n 123i128;\n 1_000_000_i32;\n 1_000_123.0e-2;\n 1_000_123.0e-2f32;\n 1_000_123.0e-2f64;\n 9999999999999999999999999999999999999999999_f64;\n}\n\nfn add(a:u32) -> u32 {\n a + 12u32\n}\n\nfn errors() {\n 0b22222; // invalid literal\n 0b00010_f32; // non-10 base f64\n 0o71234_f32; // non-10 base f64\n 1234_foo; // invalid suffix\n 1234.0_bar; // invalid suffix\n 9999999999999999999999999999999999999999999; // too large\n 256_u8; // literal out of range for `u8`\n 128_i8; // literal out of range for `i8`\n 12712371237123_u32; // literal out of range `u32`\n 9999999999999999999999999; // literal out of range `i32`\n}" --- -[358; 365): invalid literal value -[390; 401): binary float literal is not supported -[426; 437): octal float literal is not supported -[462; 470): invalid suffix `foo` -[494; 504): invalid suffix `bar` -[528; 571): int literal is too large -[590; 596): literal out of range for `u8` -[635; 641): literal out of range for `i8` -[680; 698): literal out of range for `u32` -[734; 759): literal out of range for `i32` -[9; 298) '{ ...f64; }': nothing -[15; 18) '123': i32 -[24; 29) '123u8': u8 -[35; 41) '123u16': u16 -[47; 53) '123u32': u32 -[59; 65) '123u64': u64 -[71; 78) '123u128': u128 -[84; 97) '1_000_000_u32': u32 -[103; 108) '123i8': i8 -[114; 120) '123i16': i16 -[126; 132) '123i32': i32 -[138; 144) '123i64': i64 -[150; 157) '123i128': i128 -[163; 176) '1_000_000_i32': i32 -[182; 196) '1_000_123.0e-2': f64 -[202; 219) '1_000_...e-2f32': f32 -[225; 242) '1_000_...e-2f64': f64 -[248; 295) '999999...99_f64': f64 -[307; 308) 'a': u32 -[321; 338) '{ ...2u32 }': u32 -[327; 328) 'a': u32 -[327; 336) 'a + 12u32': u32 -[331; 336) '12u32': u32 -[352; 792) '{ ...i32` }': nothing -[358; 365) '0b22222': i32 -[390; 401) '0b00010_f32': f32 -[426; 437) '0o71234_f32': f32 -[462; 470) '1234_foo': i32 -[494; 504) '1234.0_bar': f64 -[528; 571) '999999...999999': i32 -[590; 596) '256_u8': u8 -[635; 641) '128_i8': i8 -[680; 698) '127123...23_u32': u32 -[734; 759) '999999...999999': i32 +358..365: invalid literal value +390..401: binary float literal is not supported +426..437: octal float literal is not supported +462..470: invalid suffix `foo` +494..504: invalid suffix `bar` +528..571: int literal is too large +590..596: literal out of range for `u8` +635..641: literal out of range for `i8` +680..698: literal out of range for `u32` +734..759: literal out of range for `i32` +9..298 '{ ...f64; }': nothing +15..18 '123': i32 +24..29 '123u8': u8 +35..41 '123u16': u16 +47..53 '123u32': u32 +59..65 '123u64': u64 +71..78 '123u128': u128 +84..97 '1_000_000_u32': u32 +103..108 '123i8': i8 +114..120 '123i16': i16 +126..132 '123i32': i32 +138..144 '123i64': i64 +150..157 '123i128': i128 +163..176 '1_000_000_i32': i32 +182..196 '1_000_123.0e-2': f64 +202..219 '1_000_...e-2f32': f32 +225..242 '1_000_...e-2f64': f64 +248..295 '999999...99_f64': f64 +307..308 'a': u32 +321..338 '{ ...2u32 }': u32 +327..328 'a': u32 +327..336 'a + 12u32': u32 +331..336 '12u32': u32 +352..792 '{ ...i32` }': nothing +358..365 '0b22222': i32 +390..401 '0b00010_f32': f32 +426..437 '0o71234_f32': f32 +462..470 '1234_foo': i32 +494..504 '1234.0_bar': f64 +528..571 '999999...999999': i32 +590..596 '256_u8': u8 +635..641 '128_i8': i8 +680..698 '127123...23_u32': u32 +734..759 '999999...999999': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_type_alias.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_type_alias.snap index 38fb10555..48463ac95 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_type_alias.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_type_alias.snap @@ -2,8 +2,8 @@ source: crates/mun_hir/src/ty/tests.rs expression: "type Foo = i32;\ntype Bar = Foo;\ntype Baz = UnknownType; // error: undefined type\n\nfn main(a: Foo) {\n let b: Bar = a;\n}" --- -[43; 54): undefined type -[91; 92) 'a': i32 -[99; 122) '{ ...= a; }': nothing -[109; 110) 'b': i32 -[118; 119) 'a': i32 +43..54: undefined type +91..92 'a': i32 +99..122 '{ ...= a; }': nothing +109..110 'b': i32 +118..119 'a': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_unary_ops.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_unary_ops.snap index 2657e3716..80a172c51 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_unary_ops.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_unary_ops.snap @@ -2,14 +2,14 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn foo(a: i32, b: bool) {\n a = -a;\n b = !b;\n}" --- -[7; 8) 'a': i32 -[15; 16) 'b': bool -[24; 51) '{ ... !b; }': nothing -[30; 31) 'a': i32 -[30; 36) 'a = -a': nothing -[34; 36) '-a': i32 -[35; 36) 'a': i32 -[42; 43) 'b': bool -[42; 48) 'b = !b': nothing -[46; 48) '!b': bool -[47; 48) 'b': bool +7..8 'a': i32 +15..16 'b': bool +24..51 '{ ... !b; }': nothing +30..31 'a': i32 +30..36 'a = -a': nothing +34..36 '-a': i32 +35..36 'a': i32 +42..43 'b': bool +42..48 'b = !b': nothing +46..48 '!b': bool +47..48 'b': bool diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_while.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_while.snap index cb33bdc96..a321d3064 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_while.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__infer_while.snap @@ -2,39 +2,39 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn foo() {\n let n = 0;\n while n < 3 { n += 1; };\n while n < 3 { n += 1; break; };\n while n < 3 { break 3; }; // error: break with value can only appear in a loop\n while n < 3 { loop { break 3; }; };\n}" --- -[109; 116): `break` with value can only appear in a `loop` -[9; 217) '{ ...; }; }': nothing -[19; 20) 'n': i32 -[23; 24) '0': i32 -[30; 53) 'while ...= 1; }': nothing -[36; 37) 'n': i32 -[36; 41) 'n < 3': bool -[40; 41) '3': i32 -[42; 53) '{ n += 1; }': nothing -[44; 45) 'n': i32 -[44; 50) 'n += 1': nothing -[49; 50) '1': i32 -[59; 89) 'while ...eak; }': nothing -[65; 66) 'n': i32 -[65; 70) 'n < 3': bool -[69; 70) '3': i32 -[71; 89) '{ n +=...eak; }': never -[73; 74) 'n': i32 -[73; 79) 'n += 1': nothing -[78; 79) '1': i32 -[81; 86) 'break': never -[95; 119) 'while ...k 3; }': nothing -[101; 102) 'n': i32 -[101; 106) 'n < 3': bool -[105; 106) '3': i32 -[107; 119) '{ break 3; }': never -[109; 116) 'break 3': never -[180; 214) 'while ...; }; }': nothing -[186; 187) 'n': i32 -[186; 191) 'n < 3': bool -[190; 191) '3': i32 -[192; 214) '{ loop...; }; }': nothing -[194; 211) 'loop {...k 3; }': i32 -[199; 211) '{ break 3; }': never -[201; 208) 'break 3': never -[207; 208) '3': i32 +109..116: `break` with value can only appear in a `loop` +9..217 '{ ...; }; }': nothing +19..20 'n': i32 +23..24 '0': i32 +30..53 'while ...= 1; }': nothing +36..37 'n': i32 +36..41 'n < 3': bool +40..41 '3': i32 +42..53 '{ n += 1; }': nothing +44..45 'n': i32 +44..50 'n += 1': nothing +49..50 '1': i32 +59..89 'while ...eak; }': nothing +65..66 'n': i32 +65..70 'n < 3': bool +69..70 '3': i32 +71..89 '{ n +=...eak; }': never +73..74 'n': i32 +73..79 'n += 1': nothing +78..79 '1': i32 +81..86 'break': never +95..119 'while ...k 3; }': nothing +101..102 'n': i32 +101..106 'n < 3': bool +105..106 '3': i32 +107..119 '{ break 3; }': never +109..116 'break 3': never +180..214 'while ...; }; }': nothing +186..187 'n': i32 +186..191 'n < 3': bool +190..191 '3': i32 +192..214 '{ loop...; }; }': nothing +194..211 'loop {...k 3; }': i32 +199..211 '{ break 3; }': never +201..208 'break 3': never +207..208 '3': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__invalid_binary_ops.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__invalid_binary_ops.snap index 9773b5091..3577edf3a 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__invalid_binary_ops.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__invalid_binary_ops.snap @@ -2,12 +2,12 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn foo() {\n let b = false;\n let n = 1;\n let _ = b + n; // error: invalid binary operation\n}" --- -[57; 62): cannot apply binary operator -[9; 100) '{ ...tion }': nothing -[19; 20) 'b': bool -[23; 28) 'false': bool -[38; 39) 'n': i32 -[42; 43) '1': i32 -[57; 58) 'b': bool -[57; 62) 'b + n': i32 -[61; 62) 'n': i32 +57..62: cannot apply binary operator +9..100 '{ ...tion }': nothing +19..20 'b': bool +23..28 'false': bool +38..39 'n': i32 +42..43 '1': i32 +57..58 'b': bool +57..62 'b + n': i32 +61..62 'n': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__invalid_unary_ops.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__invalid_unary_ops.snap index 0110362ce..1b5e6de11 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__invalid_unary_ops.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__invalid_unary_ops.snap @@ -2,16 +2,16 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn bar(a: f64, b: bool) {\n a = !a; // mismatched type\n b = -b; // mismatched type\n}" --- -[35; 36): cannot apply unary operator -[66; 67): cannot apply unary operator -[7; 8) 'a': f64 -[15; 16) 'b': bool -[24; 89) '{ ...type }': nothing -[30; 31) 'a': f64 -[30; 36) 'a = !a': nothing -[34; 36) '!a': {unknown} -[35; 36) 'a': f64 -[61; 62) 'b': bool -[61; 67) 'b = -b': nothing -[65; 67) '-b': {unknown} -[66; 67) 'b': bool +35..36: cannot apply unary operator +66..67: cannot apply unary operator +7..8 'a': f64 +15..16 'b': bool +24..89 '{ ...type }': nothing +30..31 'a': f64 +30..36 'a = !a': nothing +34..36 '!a': {unknown} +35..36 'a': f64 +61..62 'b': bool +61..67 'b = -b': nothing +65..67 '-b': {unknown} +66..67 'b': bool diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__place_expressions.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__place_expressions.snap index 59092fb46..e17496e37 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__place_expressions.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__place_expressions.snap @@ -2,12 +2,12 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn foo(a:i32) {\n a += 3;\n 3 = 5; // error: invalid left hand side of expression\n}" --- -[32; 33): invalid left hand side of expression -[7; 8) 'a': i32 -[14; 87) '{ ...sion }': nothing -[20; 21) 'a': i32 -[20; 26) 'a += 3': nothing -[25; 26) '3': i32 -[32; 33) '3': i32 -[32; 37) '3 = 5': nothing -[36; 37) '5': i32 +32..33: invalid left hand side of expression +7..8 'a': i32 +14..87 '{ ...sion }': nothing +20..21 'a': i32 +20..26 'a += 3': nothing +25..26 '3': i32 +32..33 '3': i32 +32..37 '3 = 5': nothing +36..37 '5': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__primitives.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__primitives.snap index 9629ffac8..1ad696124 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__primitives.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__primitives.snap @@ -2,26 +2,26 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn unsigned_primitives(a: u8, b: u16, c: u32, d: u64, e: u128, f: usize, g: u32) -> u8 { a }\nfn signed_primitives(a: i8, b: i16, c: i32, d: i64, e: i128, f: isize, g: i32) -> i8 { a }\nfn float_primitives(a: f32, b: f64, c: f64) -> f32 { a }" --- -[23; 24) 'a': u8 -[30; 31) 'b': u16 -[38; 39) 'c': u32 -[46; 47) 'd': u64 -[54; 55) 'e': u128 -[63; 64) 'f': usize -[73; 74) 'g': u32 -[87; 92) '{ a }': u8 -[89; 90) 'a': u8 -[114; 115) 'a': i8 -[121; 122) 'b': i16 -[129; 130) 'c': i32 -[137; 138) 'd': i64 -[145; 146) 'e': i128 -[154; 155) 'f': isize -[164; 165) 'g': i32 -[178; 183) '{ a }': i8 -[180; 181) 'a': i8 -[204; 205) 'a': f32 -[212; 213) 'b': f64 -[220; 221) 'c': f64 -[235; 240) '{ a }': f32 -[237; 238) 'a': f32 +23..24 'a': u8 +30..31 'b': u16 +38..39 'c': u32 +46..47 'd': u64 +54..55 'e': u128 +63..64 'f': usize +73..74 'g': u32 +87..92 '{ a }': u8 +89..90 'a': u8 +114..115 'a': i8 +121..122 'b': i16 +129..130 'c': i32 +137..138 'd': i64 +145..146 'e': i128 +154..155 'f': isize +164..165 'g': i32 +178..183 '{ a }': i8 +180..181 'a': i8 +204..205 'a': f32 +212..213 'b': f64 +220..221 'c': f64 +235..240 '{ a }': f32 +237..238 'a': f32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__private_access.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__private_access.snap index 23d88e3d4..600293c41 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__private_access.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__private_access.snap @@ -2,106 +2,106 @@ source: crates/mun_hir/src/ty/tests.rs expression: "//- /foo.mun\nstruct Foo {};\nstruct Bar(i64);\nstruct Baz;\nfn foo() {}\ntype FooBar = Foo;\n\npub struct PubFoo {};\npub struct PubBar(i64);\npub struct PubBaz;\npub fn pub_foo() {}\npub type PubFooBar = PubFoo;\n\npub(super) struct PubSupFoo {};\npub(super) struct PubSupBar(i64);\npub(super) struct PubSupBaz;\npub(super) fn pub_sup_foo() {}\npub(super) type PubSupFooBar = PubSupFoo;\n\npub(package) struct PubPackageFoo {};\npub(package) struct PubPackageBar(i64);\npub(package) struct PubPackageBaz;\npub(package) fn pub_package_foo() {}\npub(package) type PubPackageFooBar = PubPackageFoo;\n\n//- /bar.mun\nfn main() {\n let a = package::foo::Foo {}; // private access\n let a = package::foo::Bar(3); // private access\n let a = package::foo::Baz; // private access\n let a = package::foo::FooBar{}}; // private access\n\n let a = super::foo::Foo {}; // private access\n let a = super::foo::Bar(3); // private access\n let a = super::foo::Baz; // private access\n let a = super::foo::FooBar{}; // private access\n\n package::foo::foo(); // private access\n super::foo::foo(); // private access\n\n let a = package::foo::PubFoo {};\n let a = package::foo::PubBar(3);\n let a = package::foo::PubBaz;\n let a = package::foo::PubFooBar{};\n\n let a = super::foo::PubFoo {};\n let a = super::foo::PubBar(3);\n let a = super::foo::PubBaz;\n let a = super::foo::PubFooBar{};\n\n package::foo::pub_foo();\n super::foo::pub_foo();\n\n let a = package::foo::PubSupFoo {};\n let a = package::foo::PubSupBar(3);\n let a = package::foo::PubSupBaz;\n let a = package::foo::PubSupFooBar{};\n\n let a = super::foo::PubSupFoo {};\n let a = super::foo::PubSupBar(3);\n let a = super::foo::PubSupBaz;\n let a = super::foo::PubSupFooBar{};\n\n package::foo::pub_sup_foo();\n super::foo::pub_sup_foo();\n\n let a = package::foo::PubPackageFoo {};\n let a = package::foo::PubPackageBar(3);\n let a = package::foo::PubPackageBaz;\n let a = package::foo::PubPackageFooBar{};\n\n let a = super::foo::PubPackageFoo {};\n let a = super::foo::PubPackageBar(3);\n let a = super::foo::PubPackageBaz;\n let a = super::foo::PubPackageFooBar{};\n\n package::foo::pub_package_foo();\n super::foo::pub_package_foo();\n}\n\n//- /foo/baz.mun\nfn main() {\n let a = package::foo::Foo {};\n let a = package::foo::Bar(3);\n let a = package::foo::Baz;\n let a = package::foo::FooBar{};\n\n let a = super::Foo {};\n let a = super::Bar(3);\n let a = super::Baz;\n let a = super::FooBar{};\n\n package::foo::foo();\n super::foo();\n}\n\n//- /mod.mun\nfn main() {\n let a = package::foo::Foo {}; // private access\n let a = package::foo::Bar(3); // private access\n let a = package::foo::Baz; // private access\n let a = package::foo::FooBar{}; // private access\n\n let a = foo::Foo {}; // private access\n let a = foo::Bar(3); // private access\n let a = foo::Baz; // private access\n let a = foo::FooBar{}; // private access\n\n package::foo::foo(); // private access\n foo::foo(); // private access\n\n let a = package::foo::PubSupFoo {};\n let a = package::foo::PubSupBar(3);\n let a = package::foo::PubSupBaz;\n let a = package::foo::PubSupFooBar{};\n\n let a = foo::PubSupFoo {};\n let a = foo::PubSupBar(3);\n let a = foo::PubSupBaz;\n let a = foo::PubSupFooBar{};\n\n package::foo::pub_sup_foo();\n foo::pub_sup_foo();\n}" --- -[24; 41): access of private type -[76; 93): access of private type -[128; 145): access of private type -[177; 197): access of private type -[232; 240): access of private type -[275; 283): access of private type -[318; 326): access of private type -[358; 369): access of private type -[396; 413): access of private type -[439; 447): access of private type -[24; 41): access of private type -[76; 93): access of private type -[128; 145): access of private type -[177; 197): access of private type -[10; 812) '{ ...o(); }': nothing -[20; 21) 'a': Foo -[24; 44) 'packag...Foo {}': Foo -[72; 73) 'a': Bar -[76; 93) 'packag...o::Bar': ctor Bar(i64) -> Bar -[76; 96) 'packag...Bar(3)': Bar -[94; 95) '3': i64 -[124; 125) 'a': Baz -[128; 145) 'packag...o::Baz': Baz -[173; 174) 'a': Foo -[177; 199) 'packag...oBar{}': Foo -[228; 229) 'a': Foo -[232; 243) 'foo::Foo {}': Foo -[271; 272) 'a': Bar -[275; 283) 'foo::Bar': ctor Bar(i64) -> Bar -[275; 286) 'foo::Bar(3)': Bar -[284; 285) '3': i64 -[314; 315) 'a': Baz -[318; 326) 'foo::Baz': Baz -[354; 355) 'a': Foo -[358; 371) 'foo::FooBar{}': Foo -[396; 413) 'packag...o::foo': function foo() -> nothing -[396; 415) 'packag...:foo()': nothing -[439; 447) 'foo::foo': function foo() -> nothing -[439; 449) 'foo::foo()': nothing -[478; 479) 'a': PubSupFoo -[482; 508) 'packag...Foo {}': PubSupFoo -[518; 519) 'a': PubSupBar -[522; 545) 'packag...SupBar': ctor PubSupBar(i64) -> PubSupBar -[522; 548) 'packag...Bar(3)': PubSupBar -[546; 547) '3': i64 -[558; 559) 'a': PubSupBaz -[562; 585) 'packag...SupBaz': PubSupBaz -[595; 596) 'a': PubSupFoo -[599; 627) 'packag...oBar{}': PubSupFoo -[638; 639) 'a': PubSupFoo -[642; 659) 'foo::P...Foo {}': PubSupFoo -[669; 670) 'a': PubSupBar -[673; 687) 'foo::PubSupBar': ctor PubSupBar(i64) -> PubSupBar -[673; 690) 'foo::P...Bar(3)': PubSupBar -[688; 689) '3': i64 -[700; 701) 'a': PubSupBaz -[704; 718) 'foo::PubSupBaz': PubSupBaz -[728; 729) 'a': PubSupFoo -[732; 751) 'foo::P...oBar{}': PubSupFoo -[758; 783) 'packag...up_foo': function pub_sup_foo() -> nothing -[758; 785) 'packag..._foo()': nothing -[791; 807) 'foo::p...up_foo': function pub_sup_foo() -> nothing -[791; 809) 'foo::p..._foo()': nothing -[10; 200) '{ ...Bar{}}': nothing -[20; 21) 'a': Foo -[24; 44) 'packag...Foo {}': Foo -[72; 73) 'a': Bar -[76; 93) 'packag...o::Bar': ctor Bar(i64) -> Bar -[76; 96) 'packag...Bar(3)': Bar -[94; 95) '3': i64 -[124; 125) 'a': Baz -[128; 145) 'packag...o::Baz': Baz -[173; 174) 'a': Foo -[177; 199) 'packag...oBar{}': Foo -[53; 55) '{}': nothing -[158; 160) '{}': nothing -[314; 316) '{}': nothing -[507; 509) '{}': nothing -[10; 300) '{ ...o(); }': nothing -[20; 21) 'a': Foo -[24; 44) 'packag...Foo {}': Foo -[54; 55) 'a': Bar -[58; 75) 'packag...o::Bar': ctor Bar(i64) -> Bar -[58; 78) 'packag...Bar(3)': Bar -[76; 77) '3': i64 -[88; 89) 'a': Baz -[92; 109) 'packag...o::Baz': Baz -[119; 120) 'a': Foo -[123; 145) 'packag...oBar{}': Foo -[156; 157) 'a': Foo -[160; 173) 'super::Foo {}': Foo -[183; 184) 'a': Bar -[187; 197) 'super::Bar': ctor Bar(i64) -> Bar -[187; 200) 'super::Bar(3)': Bar -[198; 199) '3': i64 -[210; 211) 'a': Baz -[214; 224) 'super::Baz': Baz -[234; 235) 'a': Foo -[238; 253) 'super::FooBar{}': Foo -[260; 277) 'packag...o::foo': function foo() -> nothing -[260; 279) 'packag...:foo()': nothing -[285; 295) 'super::foo': function foo() -> nothing -[285; 297) 'super::foo()': nothing +24..41: access of private type +76..93: access of private type +128..145: access of private type +177..197: access of private type +232..240: access of private type +275..283: access of private type +318..326: access of private type +358..369: access of private type +396..413: access of private type +439..447: access of private type +24..41: access of private type +76..93: access of private type +128..145: access of private type +177..197: access of private type +10..812 '{ ...o(); }': nothing +20..21 'a': Foo +24..44 'packag...Foo {}': Foo +72..73 'a': Bar +76..93 'packag...o::Bar': ctor Bar(i64) -> Bar +76..96 'packag...Bar(3)': Bar +94..95 '3': i64 +124..125 'a': Baz +128..145 'packag...o::Baz': Baz +173..174 'a': Foo +177..199 'packag...oBar{}': Foo +228..229 'a': Foo +232..243 'foo::Foo {}': Foo +271..272 'a': Bar +275..283 'foo::Bar': ctor Bar(i64) -> Bar +275..286 'foo::Bar(3)': Bar +284..285 '3': i64 +314..315 'a': Baz +318..326 'foo::Baz': Baz +354..355 'a': Foo +358..371 'foo::FooBar{}': Foo +396..413 'packag...o::foo': function foo() -> nothing +396..415 'packag...:foo()': nothing +439..447 'foo::foo': function foo() -> nothing +439..449 'foo::foo()': nothing +478..479 'a': PubSupFoo +482..508 'packag...Foo {}': PubSupFoo +518..519 'a': PubSupBar +522..545 'packag...SupBar': ctor PubSupBar(i64) -> PubSupBar +522..548 'packag...Bar(3)': PubSupBar +546..547 '3': i64 +558..559 'a': PubSupBaz +562..585 'packag...SupBaz': PubSupBaz +595..596 'a': PubSupFoo +599..627 'packag...oBar{}': PubSupFoo +638..639 'a': PubSupFoo +642..659 'foo::P...Foo {}': PubSupFoo +669..670 'a': PubSupBar +673..687 'foo::PubSupBar': ctor PubSupBar(i64) -> PubSupBar +673..690 'foo::P...Bar(3)': PubSupBar +688..689 '3': i64 +700..701 'a': PubSupBaz +704..718 'foo::PubSupBaz': PubSupBaz +728..729 'a': PubSupFoo +732..751 'foo::P...oBar{}': PubSupFoo +758..783 'packag...up_foo': function pub_sup_foo() -> nothing +758..785 'packag..._foo()': nothing +791..807 'foo::p...up_foo': function pub_sup_foo() -> nothing +791..809 'foo::p..._foo()': nothing +10..200 '{ ...Bar{}}': nothing +20..21 'a': Foo +24..44 'packag...Foo {}': Foo +72..73 'a': Bar +76..93 'packag...o::Bar': ctor Bar(i64) -> Bar +76..96 'packag...Bar(3)': Bar +94..95 '3': i64 +124..125 'a': Baz +128..145 'packag...o::Baz': Baz +173..174 'a': Foo +177..199 'packag...oBar{}': Foo +53..55 '{}': nothing +158..160 '{}': nothing +314..316 '{}': nothing +507..509 '{}': nothing +10..300 '{ ...o(); }': nothing +20..21 'a': Foo +24..44 'packag...Foo {}': Foo +54..55 'a': Bar +58..75 'packag...o::Bar': ctor Bar(i64) -> Bar +58..78 'packag...Bar(3)': Bar +76..77 '3': i64 +88..89 'a': Baz +92..109 'packag...o::Baz': Baz +119..120 'a': Foo +123..145 'packag...oBar{}': Foo +156..157 'a': Foo +160..173 'super::Foo {}': Foo +183..184 'a': Bar +187..197 'super::Bar': ctor Bar(i64) -> Bar +187..200 'super::Bar(3)': Bar +198..199 '3': i64 +210..211 'a': Baz +214..224 'super::Baz': Baz +234..235 'a': Foo +238..253 'super::FooBar{}': Foo +260..277 'packag...o::foo': function foo() -> nothing +260..279 'packag...:foo()': nothing +285..295 'super::foo': function foo() -> nothing +285..297 'super::foo()': nothing diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__recursive_alias.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__recursive_alias.snap index a14bdb02b..15af1173f 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__recursive_alias.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__recursive_alias.snap @@ -2,12 +2,12 @@ source: crates/mun_hir/src/ty/tests.rs expression: "struct Foo {}\ntype Foo = Foo;\n\ntype A = B;\ntype B = A;\n\nfn main() {\n let a: Foo; // error: unknown type\n let b: A; // error: unknown type\n let c: B; // error: unknown type\n}" --- -[14; 29): the name `Foo` is defined multiple times -[40; 41): cyclic type -[52; 53): cyclic type -[119; 120): cyclic type -[159; 160): cyclic type -[66; 189) '{ ...type }': nothing -[76; 77) 'a': Foo -[116; 117) 'b': {unknown} -[156; 157) 'c': {unknown} +14..29: the name `Foo` is defined multiple times +40..41: cyclic type +52..53: cyclic type +119..120: cyclic type +159..160: cyclic type +66..189 '{ ...type }': nothing +76..77 'a': Foo +116..117 'b': {unknown} +156..157 'c': {unknown} diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__scoped_path.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__scoped_path.snap index 372f6f478..b6f862b27 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__scoped_path.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__scoped_path.snap @@ -2,18 +2,18 @@ source: crates/mun_hir/src/ty/tests.rs expression: "//- /mod.mun\nstruct Foo;\n\nfn main() -> self::Foo {\n Foo\n}\n\nfn bar() -> Foo {\n super::Foo // undefined value\n}\n\nfn baz() -> Foo {\n package::Foo\n}\n\n//- /foo.mun\nstruct Foo;\n\nfn bar() -> Foo {\n super::Foo // mismatched type\n}\n\nfn baz() -> package::Foo {\n super::Foo\n}\n\nfn nested() -> self::Foo {\n package::foo::Foo\n}" --- -[71; 81): undefined value -[35; 45): mismatched type -[29; 67): mismatched type -[36; 47) '{ Foo }': Foo -[42; 45) 'Foo': Foo -[65; 103) '{ ...alue }': Foo -[71; 81) 'super::Foo': {unknown} -[121; 141) '{ ...:Foo }': Foo -[127; 139) 'package::Foo': Foo -[29; 67) '{ ...type }': Foo -[35; 45) 'super::Foo': Foo -[94; 112) '{ ...:Foo }': Foo -[100; 110) 'super::Foo': Foo -[139; 164) '{ ...:Foo }': Foo -[145; 162) 'packag...o::Foo': Foo +71..81: undefined value +35..45: mismatched type +29..67: mismatched type +36..47 '{ Foo }': Foo +42..45 'Foo': Foo +65..103 '{ ...alue }': Foo +71..81 'super::Foo': {unknown} +121..141 '{ ...:Foo }': Foo +127..139 'package::Foo': Foo +29..67 '{ ...type }': Foo +35..45 'super::Foo': Foo +94..112 '{ ...:Foo }': Foo +100..110 'super::Foo': Foo +139..164 '{ ...:Foo }': Foo +145..162 'packag...o::Foo': Foo diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_decl.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_decl.snap index 515f2a677..4cdaa12bb 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_decl.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_decl.snap @@ -2,7 +2,7 @@ source: crates/mun_hir/src/ty/tests.rs expression: "struct Foo;\nstruct(gc) Bar {\n f: f64,\n i: i32,\n}\nstruct(value) Baz(f64, i32);\n\n\nfn main() {\n let foo: Foo;\n let bar: Bar;\n let baz: Baz;\n}" --- -[96; 153) '{ ...Baz; }': nothing -[106; 109) 'foo': Foo -[124; 127) 'bar': Bar -[142; 145) 'baz': Baz +96..153 '{ ...Baz; }': nothing +106..109 'foo': Foo +124..127 'bar': Bar +142..145 'baz': Baz diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_field_index.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_field_index.snap index 306ad03c7..8b3c92e04 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_field_index.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_field_index.snap @@ -2,37 +2,37 @@ source: crates/mun_hir/src/ty/tests.rs expression: "struct Foo {\n a: f64,\n b: i32,\n}\nstruct Bar(f64, i32)\nstruct Baz;\n\nfn main() {\n let foo = Foo { a: 1.23, b: 4 };\n foo.a\n foo.b\n foo.c // error: attempted to access a non-existent field in a struct.\n let bar = Bar(1.23, 4);\n bar.0\n bar.1\n bar.2 // error: attempted to access a non-existent field in a struct.\n let baz = Baz;\n baz.a // error: attempted to access a non-existent field in a struct.\n let f = 1.0\n f.0; // error: attempted to access a field on a primitive type.\n}" --- -[146; 151): attempted to access a non-existent field in a struct. -[268; 273): attempted to access a non-existent field in a struct. -[361; 366): attempted to access a non-existent field in a struct. -[451; 452): attempted to access a field on a primitive type. -[83; 516) '{ ...ype. }': nothing -[93; 96) 'foo': Foo -[99; 120) 'Foo { ...b: 4 }': Foo -[108; 112) '1.23': f64 -[117; 118) '4': i32 -[126; 129) 'foo': Foo -[126; 131) 'foo.a': f64 -[136; 139) 'foo': Foo -[136; 141) 'foo.b': i32 -[146; 149) 'foo': Foo -[146; 151) 'foo.c': {unknown} -[224; 227) 'bar': Bar -[230; 233) 'Bar': ctor Bar(f64, i32) -> Bar -[230; 242) 'Bar(1.23, 4)': Bar -[234; 238) '1.23': f64 -[240; 241) '4': i32 -[248; 251) 'bar': Bar -[248; 253) 'bar.0': f64 -[258; 261) 'bar': Bar -[258; 263) 'bar.1': i32 -[268; 271) 'bar': Bar -[268; 273) 'bar.2': {unknown} -[346; 349) 'baz': Baz -[352; 355) 'Baz': Baz -[361; 364) 'baz': Baz -[361; 366) 'baz.a': {unknown} -[439; 440) 'f': f64 -[443; 446) '1.0': f64 -[451; 452) 'f': f64 -[451; 454) 'f.0': {unknown} +146..151: attempted to access a non-existent field in a struct. +268..273: attempted to access a non-existent field in a struct. +361..366: attempted to access a non-existent field in a struct. +451..452: attempted to access a field on a primitive type. +83..516 '{ ...ype. }': nothing +93..96 'foo': Foo +99..120 'Foo { ...b: 4 }': Foo +108..112 '1.23': f64 +117..118 '4': i32 +126..129 'foo': Foo +126..131 'foo.a': f64 +136..139 'foo': Foo +136..141 'foo.b': i32 +146..149 'foo': Foo +146..151 'foo.c': {unknown} +224..227 'bar': Bar +230..233 'Bar': ctor Bar(f64, i32) -> Bar +230..242 'Bar(1.23, 4)': Bar +234..238 '1.23': f64 +240..241 '4': i32 +248..251 'bar': Bar +248..253 'bar.0': f64 +258..261 'bar': Bar +258..263 'bar.1': i32 +268..271 'bar': Bar +268..273 'bar.2': {unknown} +346..349 'baz': Baz +352..355 'Baz': Baz +361..364 'baz': Baz +361..366 'baz.a': {unknown} +439..440 'f': f64 +443..446 '1.0': f64 +451..452 'f': f64 +451..454 'f.0': {unknown} diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_lit.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_lit.snap index 971c7dd45..03099c377 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_lit.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__struct_lit.snap @@ -2,43 +2,43 @@ source: crates/mun_hir/src/ty/tests.rs expression: "struct Foo;\nstruct Bar {\n a: f64,\n}\nstruct Baz(f64, i32);\n\nfn main() {\n let a: Foo = Foo;\n let b: Bar = Bar { a: 1.23, };\n let c = Baz(1.23, 1);\n\n let a = Foo{}; // error: mismatched struct literal kind. expected `unit struct`, found `record`\n let a = Foo(); // error: mismatched struct literal kind. expected `unit struct`, found `tuple`\n let b = Bar; // error: mismatched struct literal kind. expected `record`, found `unit struct`\n let b = Bar(); // error: mismatched struct literal kind. expected `record`, found `tuple`\n let b = Bar{}; // error: missing record fields: a\n let c = Baz; // error: mismatched struct literal kind. expected `tuple`, found `unit struct`\n let c = Baz{}; // error: mismatched struct literal kind. expected `tuple`, found `record`\n let c = Baz(); // error: this tuple struct literal has 2 fields but 0 fields were supplied\n}" --- -[170; 175): mismatched struct literal kind. expected `unit struct`, found `record` -[270; 275): mismatched struct literal kind. expected `unit struct`, found `tuple` -[369; 372): mismatched struct literal kind. expected `record`, found `unit struct` -[467; 470): mismatched struct literal kind. expected `record`, found `tuple` -[561; 566): missing record fields: +170..175: mismatched struct literal kind. expected `unit struct`, found `record` +270..275: mismatched struct literal kind. expected `unit struct`, found `tuple` +369..372: mismatched struct literal kind. expected `record`, found `unit struct` +467..470: mismatched struct literal kind. expected `record`, found `tuple` +561..566: missing record fields: - a -[615; 618): mismatched struct literal kind. expected `tuple`, found `unit struct` -[712; 717): mismatched struct literal kind. expected `tuple`, found `record` -[806; 811): this tuple struct literal has 2 fields but 0 fields were supplied -[72; 890) '{ ...lied }': nothing -[82; 83) 'a': Foo -[91; 94) 'Foo': Foo -[104; 105) 'b': Bar -[113; 129) 'Bar { ....23, }': Bar -[122; 126) '1.23': f64 -[139; 140) 'c': Baz -[143; 146) 'Baz': ctor Baz(f64, i32) -> Baz -[143; 155) 'Baz(1.23, 1)': Baz -[147; 151) '1.23': f64 -[153; 154) '1': i32 -[166; 167) 'a': Foo -[170; 175) 'Foo{}': Foo -[266; 267) 'a': Foo -[270; 273) 'Foo': Foo -[270; 275) 'Foo()': Foo -[365; 366) 'b': Bar -[369; 372) 'Bar': Bar -[463; 464) 'b': Bar -[467; 470) 'Bar': Bar -[467; 472) 'Bar()': Bar -[557; 558) 'b': Bar -[561; 566) 'Bar{}': Bar -[611; 612) 'c': ctor Baz(f64, i32) -> Baz -[615; 618) 'Baz': ctor Baz(f64, i32) -> Baz -[708; 709) 'c': Baz -[712; 717) 'Baz{}': Baz -[802; 803) 'c': Baz -[806; 809) 'Baz': ctor Baz(f64, i32) -> Baz -[806; 811) 'Baz()': Baz +615..618: mismatched struct literal kind. expected `tuple`, found `unit struct` +712..717: mismatched struct literal kind. expected `tuple`, found `record` +806..811: this tuple struct literal has 2 fields but 0 fields were supplied +72..890 '{ ...lied }': nothing +82..83 'a': Foo +91..94 'Foo': Foo +104..105 'b': Bar +113..129 'Bar { ....23, }': Bar +122..126 '1.23': f64 +139..140 'c': Baz +143..146 'Baz': ctor Baz(f64, i32) -> Baz +143..155 'Baz(1.23, 1)': Baz +147..151 '1.23': f64 +153..154 '1': i32 +166..167 'a': Foo +170..175 'Foo{}': Foo +266..267 'a': Foo +270..273 'Foo': Foo +270..275 'Foo()': Foo +365..366 'b': Bar +369..372 'Bar': Bar +463..464 'b': Bar +467..470 'Bar': Bar +467..472 'Bar()': Bar +557..558 'b': Bar +561..566 'Bar{}': Bar +611..612 'c': ctor Baz(f64, i32) -> Baz +615..618 'Baz': ctor Baz(f64, i32) -> Baz +708..709 'c': Baz +712..717 'Baz{}': Baz +802..803 'c': Baz +806..809 'Baz': ctor Baz(f64, i32) -> Baz +806..811 'Baz()': Baz diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__update_operators.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__update_operators.snap index 8e4dd0789..e92217f5d 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__update_operators.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__update_operators.snap @@ -2,44 +2,44 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn foo(a:i32, b:f64) {\n a += 3;\n a -= 3;\n a *= 3;\n a /= 3;\n a %= 3;\n b += 3.0;\n b -= 3.0;\n b *= 3.0;\n b /= 3.0;\n b %= 3.0;\n a *= 3.0; // mismatched type\n b *= 3; // mismatched type\n}" --- -[162; 165): mismatched type -[195; 196): mismatched type -[7; 8) 'a': i32 -[14; 15) 'b': f64 -[21; 218) '{ ...type }': nothing -[27; 28) 'a': i32 -[27; 33) 'a += 3': nothing -[32; 33) '3': i32 -[39; 40) 'a': i32 -[39; 45) 'a -= 3': nothing -[44; 45) '3': i32 -[51; 52) 'a': i32 -[51; 57) 'a *= 3': nothing -[56; 57) '3': i32 -[63; 64) 'a': i32 -[63; 69) 'a /= 3': nothing -[68; 69) '3': i32 -[75; 76) 'a': i32 -[75; 81) 'a %= 3': nothing -[80; 81) '3': i32 -[87; 88) 'b': f64 -[87; 95) 'b += 3.0': nothing -[92; 95) '3.0': f64 -[101; 102) 'b': f64 -[101; 109) 'b -= 3.0': nothing -[106; 109) '3.0': f64 -[115; 116) 'b': f64 -[115; 123) 'b *= 3.0': nothing -[120; 123) '3.0': f64 -[129; 130) 'b': f64 -[129; 137) 'b /= 3.0': nothing -[134; 137) '3.0': f64 -[143; 144) 'b': f64 -[143; 151) 'b %= 3.0': nothing -[148; 151) '3.0': f64 -[157; 158) 'a': i32 -[157; 165) 'a *= 3.0': nothing -[162; 165) '3.0': f64 -[190; 191) 'b': f64 -[190; 196) 'b *= 3': nothing -[195; 196) '3': i32 +162..165: mismatched type +195..196: mismatched type +7..8 'a': i32 +14..15 'b': f64 +21..218 '{ ...type }': nothing +27..28 'a': i32 +27..33 'a += 3': nothing +32..33 '3': i32 +39..40 'a': i32 +39..45 'a -= 3': nothing +44..45 '3': i32 +51..52 'a': i32 +51..57 'a *= 3': nothing +56..57 '3': i32 +63..64 'a': i32 +63..69 'a /= 3': nothing +68..69 '3': i32 +75..76 'a': i32 +75..81 'a %= 3': nothing +80..81 '3': i32 +87..88 'b': f64 +87..95 'b += 3.0': nothing +92..95 '3.0': f64 +101..102 'b': f64 +101..109 'b -= 3.0': nothing +106..109 '3.0': f64 +115..116 'b': f64 +115..123 'b *= 3.0': nothing +120..123 '3.0': f64 +129..130 'b': f64 +129..137 'b /= 3.0': nothing +134..137 '3.0': f64 +143..144 'b': f64 +143..151 'b %= 3.0': nothing +148..151 '3.0': f64 +157..158 'a': i32 +157..165 'a *= 3.0': nothing +162..165 '3.0': f64 +190..191 'b': f64 +190..196 'b *= 3': nothing +195..196 '3': i32 diff --git a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__void_return.snap b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__void_return.snap index 326f96747..b356bcdab 100644 --- a/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__void_return.snap +++ b/crates/mun_hir/src/ty/snapshots/mun_hir__ty__tests__void_return.snap @@ -2,11 +2,11 @@ source: crates/mun_hir/src/ty/tests.rs expression: "fn bar() {\n let a = 3;\n}\nfn foo(a:i32) {\n let c = bar()\n}" --- -[9; 27) '{ ...= 3; }': nothing -[19; 20) 'a': i32 -[23; 24) '3': i32 -[35; 36) 'a': i32 -[42; 63) '{ ...ar() }': nothing -[52; 53) 'c': nothing -[56; 59) 'bar': function bar() -> nothing -[56; 61) 'bar()': nothing +9..27 '{ ...= 3; }': nothing +19..20 'a': i32 +23..24 '3': i32 +35..36 'a': i32 +42..63 '{ ...ar() }': nothing +52..53 'c': nothing +56..59 'bar': function bar() -> nothing +56..61 'bar()': nothing diff --git a/crates/mun_hir/src/ty/tests.rs b/crates/mun_hir/src/ty/tests.rs index 06222e6da..8dce0b6c5 100644 --- a/crates/mun_hir/src/ty/tests.rs +++ b/crates/mun_hir/src/ty/tests.rs @@ -637,7 +637,7 @@ fn infer(content: &str) -> String { ); write!( acc, - "{} '{}': {}\n", + "{:?} '{}': {}\n", range, ellipsize(text, 15), ty.display(&db) @@ -649,7 +649,7 @@ fn infer(content: &str) -> String { let mut diags = String::new(); let mut diag_sink = DiagnosticSink::new(|diag| { - write!(diags, "{}: {}\n", diag.highlight_range(), diag.message()).unwrap(); + write!(diags, "{:?}: {}\n", diag.highlight_range(), diag.message()).unwrap(); }); for package in Package::all(&db).iter() { diff --git a/crates/mun_language_server/src/capabilities.rs b/crates/mun_language_server/src/capabilities.rs index 4afbe5997..2dcc86119 100644 --- a/crates/mun_language_server/src/capabilities.rs +++ b/crates/mun_language_server/src/capabilities.rs @@ -5,7 +5,9 @@ use lsp_types::{ /// Returns the capabilities of this LSP server implementation given the capabilities of the client. pub fn server_capabilities(_client_caps: &ClientCapabilities) -> ServerCapabilities { ServerCapabilities { - text_document_sync: Some(TextDocumentSyncCapability::Kind(TextDocumentSyncKind::Full)), + text_document_sync: Some(TextDocumentSyncCapability::Kind( + TextDocumentSyncKind::Incremental, + )), document_symbol_provider: Some(OneOf::Left(true)), ..Default::default() } diff --git a/crates/mun_language_server/src/diagnostics.rs b/crates/mun_language_server/src/diagnostics.rs index a7c88f460..9b4b5886e 100644 --- a/crates/mun_language_server/src/diagnostics.rs +++ b/crates/mun_language_server/src/diagnostics.rs @@ -22,7 +22,7 @@ pub struct Diagnostic { /// Converts a location to a a range for use in diagnostics fn location_to_range(location: Location) -> TextRange { match location { - Location::Offset(offset) => TextRange::offset_len(offset, 1.into()), + Location::Offset(offset) => TextRange::at(offset, 1.into()), Location::Range(range) => range, } } diff --git a/crates/mun_language_server/src/from_lsp.rs b/crates/mun_language_server/src/from_lsp.rs new file mode 100644 index 000000000..27b1cf6bc --- /dev/null +++ b/crates/mun_language_server/src/from_lsp.rs @@ -0,0 +1,50 @@ +//! This modules contains several helper functions to convert from types defined in the Language +//! Server Protocol to our own datatypes. + +use crate::state::LanguageServerSnapshot; +use hir::line_index::LineIndex; +use lsp_types::Url; +use mun_syntax::{TextRange, TextSize}; +use paths::AbsPathBuf; +use std::convert::TryFrom; + +/// Converts the specified `uri` to an absolute path. Returns an error if the url could not be +/// converted to an absolute path. +pub(crate) fn abs_path(uri: &Url) -> anyhow::Result { + uri.to_file_path() + .ok() + .and_then(|path| AbsPathBuf::try_from(path).ok()) + .ok_or_else(|| anyhow::anyhow!("invalid uri: {}", uri)) +} + +/// Returns the `hir::FileId` associated with the given `Url`. +pub(crate) fn file_id( + snapshot: &LanguageServerSnapshot, + url: &lsp_types::Url, +) -> anyhow::Result { + abs_path(url).and_then(|path| { + snapshot + .vfs + .read() + .file_id(&path) + .ok_or_else(|| anyhow::anyhow!("url does not refer to a file: {}", url)) + .map(|id| hir::FileId(id.0)) + }) +} + +/// Converts the specified offset to our own `TextSize` structure +pub(crate) fn offset(line_index: &LineIndex, position: lsp_types::Position) -> TextSize { + let line_col = hir::line_index::LineCol { + line: position.line as u32, + col_utf16: position.character as u32, + }; + line_index.offset(line_col) +} + +/// Converts the given lsp range to a `TextRange`. This requires a `LineIndex` to convert lines to +/// offsets. +pub(crate) fn text_range(line_index: &LineIndex, range: lsp_types::Range) -> TextRange { + let start = offset(line_index, range.start); + let end = offset(line_index, range.end); + TextRange::new(start, end) +} diff --git a/crates/mun_language_server/src/handlers.rs b/crates/mun_language_server/src/handlers.rs index ad00dc740..1af37799c 100644 --- a/crates/mun_language_server/src/handlers.rs +++ b/crates/mun_language_server/src/handlers.rs @@ -1,7 +1,4 @@ -use crate::{ - conversion::{convert_range, convert_symbol_kind}, - state::LanguageServerSnapshot, -}; +use crate::{from_lsp, state::LanguageServerSnapshot, to_lsp}; use lsp_types::DocumentSymbol; /// Computes the document symbols for a specific document. Converts the LSP types to internal @@ -11,7 +8,7 @@ pub(crate) fn handle_document_symbol( snapshot: LanguageServerSnapshot, params: lsp_types::DocumentSymbolParams, ) -> anyhow::Result> { - let file_id = snapshot.uri_to_file_id(¶ms.text_document.uri)?; + let file_id = from_lsp::file_id(&snapshot, ¶ms.text_document.uri)?; let line_index = snapshot.analysis.file_line_index(file_id)?; let mut parents: Vec<(DocumentSymbol, Option)> = Vec::new(); @@ -21,11 +18,11 @@ pub(crate) fn handle_document_symbol( let doc_symbol = DocumentSymbol { name: symbol.label, detail: symbol.detail, - kind: convert_symbol_kind(symbol.kind), + kind: to_lsp::symbol_kind(symbol.kind), tags: None, deprecated: None, - range: convert_range(symbol.node_range, &line_index), - selection_range: convert_range(symbol.navigation_range, &line_index), + range: to_lsp::range(symbol.node_range, &line_index), + selection_range: to_lsp::range(symbol.navigation_range, &line_index), children: None, }; diff --git a/crates/mun_language_server/src/lib.rs b/crates/mun_language_server/src/lib.rs index 6d2027430..8973dbe1a 100644 --- a/crates/mun_language_server/src/lib.rs +++ b/crates/mun_language_server/src/lib.rs @@ -14,14 +14,16 @@ mod cancelation; mod capabilities; mod change; mod config; -mod conversion; mod db; mod diagnostics; mod file_structure; +mod from_lsp; mod handlers; +mod lsp_utils; mod main_loop; mod state; mod symbol_kind; +mod to_lsp; /// Deserializes a `T` from a json value. pub fn from_json( diff --git a/crates/mun_language_server/src/lsp_utils.rs b/crates/mun_language_server/src/lsp_utils.rs new file mode 100644 index 000000000..1b9873908 --- /dev/null +++ b/crates/mun_language_server/src/lsp_utils.rs @@ -0,0 +1,127 @@ +use crate::from_lsp; +use hir::line_index::LineIndex; + +/// Given a set of text document changes apply them to the given string. +pub(crate) fn apply_document_changes( + old_text: &mut String, + content_changes: Vec, +) { + // The changes are specified with ranges where they apply. These ranges are given as line-column + // pairs. We can compute the offset in the text using a `LineIndex` however, changes to the text + // may invalidate this too. + // As a simple optimization we keep track of the lines that are possibly invalid in the + // LineIndex based on where we insert new text. If a changes is within the invalid range we + // recompute the LineIndex. Some clients (e.g. Code) sort the ranges in reverse which should + // ensure that we almost never invalidate the LineIndex. + + let mut line_index = LineIndex::new(old_text); + + enum IndexValid { + All, + UpToLineExclusive(u32), + } + + impl IndexValid { + fn covers(&self, line: u32) -> bool { + match *self { + IndexValid::UpToLineExclusive(to) => to > line, + _ => true, + } + } + } + + let mut index_valid = IndexValid::All; + for change in content_changes { + match change.range { + Some(range) => { + if !index_valid.covers(range.end.line) { + line_index = LineIndex::new(&old_text); + } + index_valid = IndexValid::UpToLineExclusive(range.start.line); + let range = from_lsp::text_range(&line_index, range); + old_text.replace_range(std::ops::Range::::from(range), &change.text); + } + None => { + *old_text = change.text; + index_valid = IndexValid::UpToLineExclusive(0) + } + } + } +} + +#[cfg(test)] +mod tests { + use crate::lsp_utils::apply_document_changes; + use lsp_types::{Position, Range, TextDocumentContentChangeEvent}; + + #[test] + fn test_apply_document_changes() { + macro_rules! change { + [$($sl:expr, $sc:expr; $el:expr, $ec:expr => $text:expr),+] => { + vec![$(TextDocumentContentChangeEvent { + range: Some(Range { + start: Position { line: $sl, character: $sc }, + end: Position { line: $el, character: $ec }, + }), + range_length: None, + text: String::from($text), + }),+] + }; + } + + let mut text = String::new(); + apply_document_changes(&mut text, vec![]); + assert_eq!(text, ""); + + // Test if full updates work (without a range) + apply_document_changes( + &mut text, + vec![TextDocumentContentChangeEvent { + range: None, + range_length: None, + text: String::from("the"), + }], + ); + assert_eq!(text, "the"); + apply_document_changes(&mut text, change![0, 3; 0, 3 => " quick"]); + assert_eq!(text, "the quick"); + apply_document_changes(&mut text, change![0, 0; 0, 4 => "", 0, 5; 0, 5 => " foxes"]); + assert_eq!(text, "quick foxes"); + apply_document_changes(&mut text, change![0, 11; 0, 11 => "\ndream"]); + assert_eq!(text, "quick foxes\ndream"); + apply_document_changes(&mut text, change![1, 0; 1, 0 => "have "]); + assert_eq!(text, "quick foxes\nhave dream"); + apply_document_changes( + &mut text, + change![0, 0; 0, 0 => "the ", 1, 4; 1, 4 => " quiet", 1, 16; 1, 16 => "s\n"], + ); + assert_eq!(text, "the quick foxes\nhave quiet dreams\n"); + apply_document_changes( + &mut text, + change![0, 15; 0, 15 => "\n", 2, 17; 2, 17 => "\n"], + ); + assert_eq!(text, "the quick foxes\n\nhave quiet dreams\n\n"); + apply_document_changes( + &mut text, + change![1, 0; 1, 0 => "DREAM", 2, 0; 2, 0 => "they ", 3, 0; 3, 0 => "DON'T THEY?"], + ); + assert_eq!( + text, + "the quick foxes\nDREAM\nthey have quiet dreams\nDON'T THEY?\n" + ); + apply_document_changes(&mut text, change![0, 10; 1, 5 => "", 2, 0; 2, 12 => ""]); + assert_eq!(text, "the quick \nthey have quiet dreams\n"); + + text = String::from("❤️"); + apply_document_changes(&mut text, change![0, 0; 0, 0 => "a"]); + assert_eq!(text, "a❤️"); + + text = String::from("a\nb"); + apply_document_changes(&mut text, change![0, 1; 1, 0 => "\nțc", 0, 1; 1, 1 => "d"]); + assert_eq!(text, "adcb"); + + text = String::from("a\nb"); + apply_document_changes(&mut text, change![0, 1; 1, 0 => "ț\nc", 0, 2; 0, 2 => "c"]); + assert_eq!(text, "ațc\ncb"); + } +} diff --git a/crates/mun_language_server/src/state.rs b/crates/mun_language_server/src/state.rs index 75bfa4be5..5a6ff863f 100644 --- a/crates/mun_language_server/src/state.rs +++ b/crates/mun_language_server/src/state.rs @@ -2,19 +2,18 @@ use crate::{ analysis::{Analysis, AnalysisSnapshot}, change::AnalysisChange, config::Config, - conversion::{convert_range, url_from_path_with_drive_lowercasing}, state::utils::Progress, - to_json, + to_json, to_lsp, }; use crossbeam_channel::{select, unbounded, Receiver, Sender}; use lsp_server::{ReqQueue, Response}; use lsp_types::{ - notification::Notification, notification::PublishDiagnostics, PublishDiagnosticsParams, Url, + notification::Notification, notification::PublishDiagnostics, PublishDiagnosticsParams, }; use parking_lot::RwLock; use paths::AbsPathBuf; use rustc_hash::FxHashSet; -use std::{convert::TryFrom, ops::Deref, sync::Arc, time::Instant}; +use std::{ops::Deref, sync::Arc, time::Instant}; use vfs::VirtualFileSystem; mod protocol; @@ -247,14 +246,14 @@ fn handle_diagnostics(state: LanguageServerSnapshot, sender: Sender) -> an // Publish all diagnostics for file in files { let line_index = state.analysis.file_line_index(file)?; - let uri = state.file_id_to_uri(file).unwrap(); + let uri = to_lsp::url(&state, file)?; let diagnostics = state.analysis.diagnostics(file)?; let diagnostics = { let mut lsp_diagnostics = Vec::with_capacity(diagnostics.len()); for d in diagnostics { lsp_diagnostics.push(lsp_types::Diagnostic { - range: convert_range(d.range, &line_index), + range: to_lsp::range(d.range, &line_index), severity: Some(lsp_types::DiagnosticSeverity::Error), code: None, code_description: None, @@ -266,10 +265,8 @@ fn handle_diagnostics(state: LanguageServerSnapshot, sender: Sender) -> an for annotation in d.additional_annotations { annotations.push(lsp_types::DiagnosticRelatedInformation { location: lsp_types::Location { - uri: state - .file_id_to_uri(annotation.range.file_id) - .unwrap(), - range: convert_range( + uri: to_lsp::url(&state, annotation.range.file_id)?, + range: to_lsp::range( annotation.range.value, state .analysis @@ -368,34 +365,6 @@ impl LanguageServerState { } } -impl LanguageServerSnapshot { - /// Converts the specified `hir::FileId` to a `Url` - pub fn file_id_to_uri(&self, id: hir::FileId) -> anyhow::Result { - let vfs = self.vfs.read(); - let path = vfs.file_path(vfs::FileId(id.0)); - let url = url_from_path_with_drive_lowercasing(path)?; - - Ok(url) - } - - /// Converts the specified `Url` to a `hir::FileId` - pub fn uri_to_file_id(&self, url: &Url) -> anyhow::Result { - url.to_file_path() - .map_err(|_| anyhow::anyhow!("invalid uri: {}", url)) - .and_then(|path| { - AbsPathBuf::try_from(path) - .map_err(|_| anyhow::anyhow!("url does not refer to absolute path: {}", url)) - }) - .and_then(|path| { - self.vfs - .read() - .file_id(&path) - .ok_or_else(|| anyhow::anyhow!("url does not refer to a file: {}", url)) - .map(|id| hir::FileId(id.0)) - }) - } -} - impl Drop for LanguageServerState { fn drop(&mut self) { self.analysis.request_cancelation(); diff --git a/crates/mun_language_server/src/state/protocol.rs b/crates/mun_language_server/src/state/protocol.rs index 65bc55678..d3666764d 100644 --- a/crates/mun_language_server/src/state/protocol.rs +++ b/crates/mun_language_server/src/state/protocol.rs @@ -1,6 +1,5 @@ use super::LanguageServerState; -use crate::{conversion::convert_uri, handlers, state::RequestHandler}; -use anyhow::Result; +use crate::{from_lsp, handlers, lsp_utils::apply_document_changes, state::RequestHandler}; use dispatcher::{NotificationDispatcher, RequestDispatcher}; use lsp_types::notification::{ DidChangeTextDocument, DidChangeWatchedFiles, DidCloseTextDocument, DidOpenTextDocument, @@ -15,7 +14,7 @@ impl LanguageServerState { &mut self, params: lsp_types::DidOpenTextDocumentParams, ) -> anyhow::Result<()> { - if let Ok(path) = convert_uri(¶ms.text_document.uri) { + if let Ok(path) = from_lsp::abs_path(¶ms.text_document.uri) { self.open_docs.insert(path.clone()); self.vfs .write() @@ -33,11 +32,17 @@ impl LanguageServerState { text_document, content_changes, } = params; - if let Ok(path) = convert_uri(&text_document.uri) { - let new_content = content_changes.get(0).unwrap().text.clone(); - self.vfs - .write() - .set_file_contents(&path, Some(new_content.into_bytes())); + if let Ok(path) = from_lsp::abs_path(&text_document.uri) { + let vfs = &mut *self.vfs.write(); + let file_id = vfs + .file_id(&path) + .expect("we already checked that the file_id exists!"); + let mut text = vfs + .file_contents(file_id) + .and_then(|contents| String::from_utf8(contents.to_vec()).ok()) + .expect("if the file_id exists it must be valid utf8"); + apply_document_changes(&mut text, content_changes); + vfs.set_file_contents(&path, Some(text.into_bytes())); } Ok(()) } @@ -47,7 +52,7 @@ impl LanguageServerState { &mut self, params: lsp_types::DidCloseTextDocumentParams, ) -> anyhow::Result<()> { - if let Ok(path) = convert_uri(¶ms.text_document.uri) { + if let Ok(path) = from_lsp::abs_path(¶ms.text_document.uri) { self.open_docs.remove(&path); self.vfs_monitor.reload(&path); } @@ -60,7 +65,7 @@ impl LanguageServerState { params: lsp_types::DidChangeWatchedFilesParams, ) -> anyhow::Result<()> { for change in params.changes { - if let Ok(path) = convert_uri(&change.uri) { + if let Ok(path) = from_lsp::abs_path(&change.uri) { self.vfs_monitor.reload(&path); } } @@ -72,7 +77,7 @@ impl LanguageServerState { &mut self, request: lsp_server::Request, request_received: Instant, - ) -> Result<()> { + ) -> anyhow::Result<()> { self.register_request(&request, request_received); // If a shutdown was requested earlier, immediately respond with an error @@ -98,7 +103,10 @@ impl LanguageServerState { } /// Handles a notification from the language server client - pub(super) fn on_notification(&mut self, notification: lsp_server::Notification) -> Result<()> { + pub(super) fn on_notification( + &mut self, + notification: lsp_server::Notification, + ) -> anyhow::Result<()> { NotificationDispatcher::new(self, notification) .on::(LanguageServerState::on_did_open_text_document)? .on::(LanguageServerState::on_did_change_text_document)? diff --git a/crates/mun_language_server/src/conversion.rs b/crates/mun_language_server/src/to_lsp.rs similarity index 71% rename from crates/mun_language_server/src/conversion.rs rename to crates/mun_language_server/src/to_lsp.rs index e3bece615..db73a573c 100644 --- a/crates/mun_language_server/src/conversion.rs +++ b/crates/mun_language_server/src/to_lsp.rs @@ -1,9 +1,8 @@ +use crate::state::LanguageServerSnapshot; use crate::symbol_kind::SymbolKind; use lsp_types::Url; -use mun_syntax::{TextRange, TextUnit}; -use paths::AbsPathBuf; +use mun_syntax::{TextRange, TextSize}; use std::{ - convert::TryFrom, path::{Component, Path, Prefix}, str::FromStr, }; @@ -12,7 +11,7 @@ use std::{ /// This will only happen when processing Windows paths. /// /// When processing non-windows path, this is essentially do the same as `Url::from_file_path`. -pub fn url_from_path_with_drive_lowercasing(path: impl AsRef) -> anyhow::Result { +fn url_from_path_with_drive_lowercasing(path: impl AsRef) -> anyhow::Result { let component_has_windows_drive = path.as_ref().components().any(|comp| { if let Component::Prefix(c) = comp { match c.kind() { @@ -48,39 +47,37 @@ pub fn url_from_path_with_drive_lowercasing(path: impl AsRef) -> anyhow::R } } -pub fn convert_range( - range: TextRange, - line_index: &hir::line_index::LineIndex, -) -> lsp_types::Range { +pub(crate) fn range(range: TextRange, line_index: &hir::line_index::LineIndex) -> lsp_types::Range { lsp_types::Range { - start: convert_unit(range.start(), line_index), - end: convert_unit(range.end(), line_index), + start: position(range.start(), line_index), + end: position(range.end(), line_index), } } -pub fn convert_unit( - range: TextUnit, +pub(crate) fn position( + range: TextSize, line_index: &hir::line_index::LineIndex, ) -> lsp_types::Position { let line_col = line_index.line_col(range); lsp_types::Position { line: line_col.line, - character: line_col.col, + character: line_col.col_utf16, } } -pub fn convert_uri(uri: &Url) -> anyhow::Result { - uri.to_file_path() - .ok() - .and_then(|path| AbsPathBuf::try_from(path).ok()) - .ok_or_else(|| anyhow::anyhow!("invalid uri: {}", uri)) -} - /// Converts a symbol kind from this crate to one for the LSP protocol. -pub fn convert_symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind { +pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind { match symbol_kind { SymbolKind::Function => lsp_types::SymbolKind::Function, SymbolKind::Struct => lsp_types::SymbolKind::Struct, SymbolKind::TypeAlias => lsp_types::SymbolKind::TypeParameter, } } + +/// Returns the `Url` associated with the specified `FileId`. +pub(crate) fn url(snapshot: &LanguageServerSnapshot, file_id: hir::FileId) -> anyhow::Result { + let vfs = snapshot.vfs.read(); + let path = vfs.file_path(vfs::FileId(file_id.0)); + let url = url_from_path_with_drive_lowercasing(path)?; + Ok(url) +} diff --git a/crates/mun_syntax/Cargo.toml b/crates/mun_syntax/Cargo.toml index 83c18bd9d..f1da575ba 100644 --- a/crates/mun_syntax/Cargo.toml +++ b/crates/mun_syntax/Cargo.toml @@ -14,8 +14,8 @@ categories = ["game-development", "mun"] [dependencies] abi = { version = "=0.2.0", path = "../mun_abi", package = "mun_abi" } -rowan = "0.6.1" -text_unit = { version = "0.1.6", features = ["serde"] } +rowan = "0.10.0" +text-size = { version = "1.1.0", features = ["serde"] } smol_str = { version = "0.1.17", features = ["serde"] } unicode-xid = "0.1.0" drop_bomb = "0.1.4" diff --git a/crates/mun_syntax/src/ast/expr_extensions.rs b/crates/mun_syntax/src/ast/expr_extensions.rs index fa3404bd1..9db683a7c 100644 --- a/crates/mun_syntax/src/ast/expr_extensions.rs +++ b/crates/mun_syntax/src/ast/expr_extensions.rs @@ -3,9 +3,10 @@ use crate::ast::{child_opt, AstChildren, Literal}; use crate::{ ast, AstNode, SmolStr, SyntaxKind::{self, *}, - SyntaxToken, TextRange, TextUnit, + SyntaxToken, TextRange, TextSize, }; use std::iter::Peekable; +use std::ops::Add; use std::str::CharIndices; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] @@ -189,7 +190,7 @@ impl ast::FieldExpr { let start = field_name .map(|f| f.start()) - .or_else(|| field_index.map(|i| TextUnit::from_usize(i.start().to_usize() + 1))) + .or_else(|| field_index.map(|i| i.start().add(TextSize::from(1u32)))) .unwrap_or_else(|| self.syntax().text_range().start()); let end = field_name @@ -197,7 +198,7 @@ impl ast::FieldExpr { .or_else(|| field_index.map(|f| f.end())) .unwrap_or_else(|| self.syntax().text_range().end()); - TextRange::from_to(start, end) + TextRange::new(start, end) } } diff --git a/crates/mun_syntax/src/ast/extensions.rs b/crates/mun_syntax/src/ast/extensions.rs index 6aea3929f..706fcdcf3 100644 --- a/crates/mun_syntax/src/ast/extensions.rs +++ b/crates/mun_syntax/src/ast/extensions.rs @@ -4,7 +4,7 @@ use crate::{ }; use crate::{SmolStr, SyntaxNode}; use abi::StructMemoryKind; -use text_unit::TextRange; +use text_size::TextRange; impl ast::Name { pub fn text(&self) -> &SmolStr { @@ -51,15 +51,15 @@ impl ast::FunctionDef { .or_else(|| fn_kw.map(|kw| kw.end())) .unwrap_or_else(|| self.syntax().text_range().end()); - TextRange::from_to(start, end) + TextRange::new(start, end) } } fn text_of_first_token(node: &SyntaxNode) -> &SmolStr { node.green() .children() - .first() - .and_then(|it| it.as_token()) + .next() + .and_then(|it| it.into_token()) .unwrap() .text() } @@ -166,7 +166,7 @@ impl ast::StructDef { .or_else(|| struct_kw.map(|kw| kw.end())) .unwrap_or_else(|| self.syntax().text_range().end()); - TextRange::from_to(start, end) + TextRange::new(start, end) } } diff --git a/crates/mun_syntax/src/lib.rs b/crates/mun_syntax/src/lib.rs index cb26985ea..13676484a 100644 --- a/crates/mun_syntax/src/lib.rs +++ b/crates/mun_syntax/src/lib.rs @@ -31,7 +31,7 @@ pub use crate::{ syntax_kind::SyntaxKind, syntax_node::{Direction, SyntaxElement, SyntaxNode, SyntaxToken, SyntaxTreeBuilder}, }; -pub use rowan::{SmolStr, TextRange, TextUnit, WalkEvent}; +pub use rowan::{SmolStr, TextRange, TextSize, WalkEvent}; use rowan::GreenNode; diff --git a/crates/mun_syntax/src/parsing/lexer.rs b/crates/mun_syntax/src/parsing/lexer.rs index 7610e9c4b..f02340515 100644 --- a/crates/mun_syntax/src/parsing/lexer.rs +++ b/crates/mun_syntax/src/parsing/lexer.rs @@ -9,7 +9,7 @@ use self::{ }; use crate::{ SyntaxKind::{self, *}, - TextUnit, + TextSize, }; /// A token of Mun source @@ -19,7 +19,7 @@ pub struct Token { pub kind: SyntaxKind, /// The length of the token - pub len: TextUnit, + pub len: TextSize, } /// Break a string up into its component tokens diff --git a/crates/mun_syntax/src/parsing/lexer/cursor.rs b/crates/mun_syntax/src/parsing/lexer/cursor.rs index 0eecb0cd3..95e59ef02 100644 --- a/crates/mun_syntax/src/parsing/lexer/cursor.rs +++ b/crates/mun_syntax/src/parsing/lexer/cursor.rs @@ -1,11 +1,11 @@ -use crate::TextUnit; +use crate::TextSize; use std::str::Chars; /// A simple view into the characters of a string. pub(crate) struct Cursor<'s> { text: &'s str, - len: TextUnit, + len: TextSize, } impl<'s> Cursor<'s> { @@ -18,7 +18,7 @@ impl<'s> Cursor<'s> { } /// Gets the length of the remaining string. - pub fn into_len(self) -> TextUnit { + pub fn into_len(self) -> TextSize { self.len } @@ -57,7 +57,7 @@ impl<'s> Cursor<'s> { /// Move to the next character pub fn bump(&mut self) -> Option { let ch = self.chars().next()?; - self.len += TextUnit::of_char(ch); + self.len += TextSize::of(ch); Some(ch) } diff --git a/crates/mun_syntax/src/parsing/text_token_source.rs b/crates/mun_syntax/src/parsing/text_token_source.rs index 447639f2a..a66858c5e 100644 --- a/crates/mun_syntax/src/parsing/text_token_source.rs +++ b/crates/mun_syntax/src/parsing/text_token_source.rs @@ -1,9 +1,8 @@ use crate::{ parsing::{lexer::Token, Token as PToken, TokenSource}, SyntaxKind::*, - TextUnit, + TextRange, TextSize, }; -use text_unit::TextRange; /// An implementation of `TokenSource` for text. pub(crate) struct TextTokenSource<'t> { @@ -16,7 +15,7 @@ pub(crate) struct TextTokenSource<'t> { /// 0 7 10 /// ``` /// (token, start_offset): `[(struct, 0), (Foo, 7), (;, 10)]` - start_offsets: Vec, + start_offsets: Vec, /// non-whitespace/comment tokens /// ```non-rust /// struct Foo {} @@ -52,12 +51,12 @@ impl<'t> TokenSource for TextTokenSource<'t> { if pos >= self.tokens.len() { return false; } - let range = TextRange::offset_len(self.start_offsets[pos], self.tokens[pos].len); + let range = TextRange::at(self.start_offsets[pos], self.tokens[pos].len); self.text[range] == *kw } } -fn mk_token(pos: usize, start_offsets: &[TextUnit], tokens: &[Token]) -> PToken { +fn mk_token(pos: usize, start_offsets: &[TextSize], tokens: &[Token]) -> PToken { let kind = tokens.get(pos).map(|t| t.kind).unwrap_or(EOF); let is_jointed_to_next = if pos + 1 < start_offsets.len() { start_offsets[pos] + tokens[pos].len == start_offsets[pos + 1] diff --git a/crates/mun_syntax/src/parsing/text_tree_sink.rs b/crates/mun_syntax/src/parsing/text_tree_sink.rs index 970605f80..8f5cc962e 100644 --- a/crates/mun_syntax/src/parsing/text_tree_sink.rs +++ b/crates/mun_syntax/src/parsing/text_tree_sink.rs @@ -5,13 +5,13 @@ use crate::{ syntax_node::GreenNode, SmolStr, SyntaxError, SyntaxKind::{self, *}, - SyntaxTreeBuilder, TextRange, TextUnit, + SyntaxTreeBuilder, TextRange, TextSize, }; pub(crate) struct TextTreeSink<'a> { text: &'a str, tokens: &'a [Token], - text_pos: TextUnit, + text_pos: TextSize, token_pos: usize, state: State, inner: SyntaxTreeBuilder, @@ -35,7 +35,7 @@ impl<'a> TreeSink for TextTreeSink<'a> { let len = self.tokens[self.token_pos..self.token_pos + n_tokens] .iter() .map(|it| it.len) - .sum::(); + .sum::(); self.do_token(kind, len, n_tokens); } @@ -56,12 +56,12 @@ impl<'a> TreeSink for TextTreeSink<'a> { .count(); let leading_trivias = &self.tokens[self.token_pos..self.token_pos + n_trivias]; let mut trivia_end = - self.text_pos + leading_trivias.iter().map(|it| it.len).sum::(); + self.text_pos + leading_trivias.iter().map(|it| it.len).sum::(); let n_attached_trivias = { let leading_trivias = leading_trivias.iter().rev().map(|it| { let next_end = trivia_end - it.len; - let range = TextRange::from_to(next_end, trivia_end); + let range = TextRange::new(next_end, trivia_end); trivia_end = next_end; (it.kind, &self.text[range]) }); @@ -126,8 +126,8 @@ impl<'a> TextTreeSink<'a> { } } - fn do_token(&mut self, kind: SyntaxKind, len: TextUnit, n_tokens: usize) { - let range = TextRange::offset_len(self.text_pos, len); + fn do_token(&mut self, kind: SyntaxKind, len: TextSize, n_tokens: usize) { + let range = TextRange::at(self.text_pos, len); let text: SmolStr = self.text[range].into(); self.text_pos += len; self.token_pos += n_tokens; diff --git a/crates/mun_syntax/src/ptr.rs b/crates/mun_syntax/src/ptr.rs index c32b66744..8e14223e5 100644 --- a/crates/mun_syntax/src/ptr.rs +++ b/crates/mun_syntax/src/ptr.rs @@ -22,7 +22,7 @@ impl SyntaxNodePtr { assert!(root.parent().is_none()); successors(Some(root.clone()), |node| { node.children() - .find(|it| self.range.is_subrange(&it.text_range())) + .find(|it| it.text_range().contains_range(self.range)) }) .find(|it| it.text_range() == self.range && it.kind() == self.kind) .unwrap_or_else(|| panic!("can't resolve local ptr to SyntaxNode: {:?}", self)) diff --git a/crates/mun_syntax/src/syntax_error.rs b/crates/mun_syntax/src/syntax_error.rs index e3ace2a27..2e23c738b 100644 --- a/crates/mun_syntax/src/syntax_error.rs +++ b/crates/mun_syntax/src/syntax_error.rs @@ -1,15 +1,15 @@ use crate::parsing::ParseError; use std::fmt; -use text_unit::{TextRange, TextUnit}; +use text_size::{TextRange, TextSize}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Location { - Offset(TextUnit), + Offset(TextSize), Range(TextRange), } -impl Into for TextUnit { +impl Into for TextSize { fn into(self) -> Location { Location::Offset(self) } @@ -22,21 +22,21 @@ impl Into for TextRange { } impl Location { - pub fn offset(&self) -> TextUnit { + pub fn offset(&self) -> TextSize { match &self { Location::Offset(offset) => *offset, Location::Range(range) => range.start(), } } - pub fn end_offset(&self) -> TextUnit { + pub fn end_offset(&self) -> TextSize { match &self { Location::Offset(offset) => *offset, Location::Range(range) => range.end(), } } - pub fn add_offset(&self, plus_offset: TextUnit, minus_offset: TextUnit) -> Location { + pub fn add_offset(&self, plus_offset: TextSize, minus_offset: TextSize) -> Location { match &self { Location::Range(range) => Location::Range(range + plus_offset - minus_offset), Location::Offset(offset) => Location::Offset(offset + plus_offset - minus_offset), diff --git a/crates/mun_syntax/src/syntax_node.rs b/crates/mun_syntax/src/syntax_node.rs index ef3f1008f..5f3e9cdb9 100644 --- a/crates/mun_syntax/src/syntax_node.rs +++ b/crates/mun_syntax/src/syntax_node.rs @@ -9,7 +9,7 @@ use crate::{ parsing::ParseError, syntax_error::{SyntaxError, SyntaxErrorKind}, - Parse, SmolStr, SyntaxKind, TextUnit, + Parse, SmolStr, SyntaxKind, TextSize, }; use rowan::{GreenNodeBuilder, Language}; @@ -20,12 +20,12 @@ pub enum MunLanguage {} impl Language for MunLanguage { type Kind = SyntaxKind; - fn kind_from_raw(raw: rowan::cursor::SyntaxKind) -> SyntaxKind { + fn kind_from_raw(raw: rowan::SyntaxKind) -> SyntaxKind { SyntaxKind::from(raw.0) } - fn kind_to_raw(kind: SyntaxKind) -> rowan::cursor::SyntaxKind { - rowan::cursor::SyntaxKind(kind.into()) + fn kind_to_raw(kind: SyntaxKind) -> rowan::SyntaxKind { + rowan::SyntaxKind(kind.into()) } } @@ -39,7 +39,7 @@ pub use rowan::{Direction, NodeOrToken}; pub struct SyntaxTreeBuilder { errors: Vec, - inner: GreenNodeBuilder, + inner: GreenNodeBuilder<'static>, } impl Default for SyntaxTreeBuilder { @@ -80,7 +80,7 @@ impl SyntaxTreeBuilder { self.inner.finish_node() } - pub fn error(&mut self, error: ParseError, text_pos: TextUnit) { + pub fn error(&mut self, error: ParseError, text_pos: TextSize) { let error = SyntaxError::new(SyntaxErrorKind::ParseError(error), text_pos); self.errors.push(error) } diff --git a/crates/mun_syntax/src/tests/lexer.rs b/crates/mun_syntax/src/tests/lexer.rs index 4116a882d..d5fae8d54 100644 --- a/crates/mun_syntax/src/tests/lexer.rs +++ b/crates/mun_syntax/src/tests/lexer.rs @@ -8,7 +8,7 @@ fn dump_tokens(tokens: &[crate::Token], text: &str) -> String { let len = len as usize; let token_text = &text[offset..offset + len]; offset += len; - write!(acc, "{:?} {} {:?}\n", token.kind, token.len, token_text).unwrap() + write!(acc, "{:?} {} {:?}\n", token.kind, len, token_text).unwrap() } acc } diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__arithmetic_operands.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__arithmetic_operands.snap index 6399a41aa..0bcaf00c7 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__arithmetic_operands.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__arithmetic_operands.snap @@ -2,258 +2,258 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn main() {\n let _ = a + b;\n let _ = a - b;\n let _ = a * b;\n let _ = a / b;\n let _ = a % b;\n let _ = a << b;\n let _ = a >> b;\n let _ = a & b;\n let _ = a | b;\n let _ = a ^ b;\n}" --- -SOURCE_FILE@[0; 205) - FUNCTION_DEF@[0; 205) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 7) - IDENT@[3; 7) "main" - PARAM_LIST@[7; 9) - L_PAREN@[7; 8) "(" - R_PAREN@[8; 9) ")" - WHITESPACE@[9; 10) " " - BLOCK_EXPR@[10; 205) - L_CURLY@[10; 11) "{" - WHITESPACE@[11; 16) "\n " - LET_STMT@[16; 30) - LET_KW@[16; 19) "let" - WHITESPACE@[19; 20) " " - PLACEHOLDER_PAT@[20; 21) - UNDERSCORE@[20; 21) "_" - WHITESPACE@[21; 22) " " - EQ@[22; 23) "=" - WHITESPACE@[23; 24) " " - BIN_EXPR@[24; 29) - PATH_EXPR@[24; 25) - PATH@[24; 25) - PATH_SEGMENT@[24; 25) - NAME_REF@[24; 25) - IDENT@[24; 25) "a" - WHITESPACE@[25; 26) " " - PLUS@[26; 27) "+" - WHITESPACE@[27; 28) " " - PATH_EXPR@[28; 29) - PATH@[28; 29) - PATH_SEGMENT@[28; 29) - NAME_REF@[28; 29) - IDENT@[28; 29) "b" - SEMI@[29; 30) ";" - WHITESPACE@[30; 35) "\n " - LET_STMT@[35; 49) - LET_KW@[35; 38) "let" - WHITESPACE@[38; 39) " " - PLACEHOLDER_PAT@[39; 40) - UNDERSCORE@[39; 40) "_" - WHITESPACE@[40; 41) " " - EQ@[41; 42) "=" - WHITESPACE@[42; 43) " " - BIN_EXPR@[43; 48) - PATH_EXPR@[43; 44) - PATH@[43; 44) - PATH_SEGMENT@[43; 44) - NAME_REF@[43; 44) - IDENT@[43; 44) "a" - WHITESPACE@[44; 45) " " - MINUS@[45; 46) "-" - WHITESPACE@[46; 47) " " - PATH_EXPR@[47; 48) - PATH@[47; 48) - PATH_SEGMENT@[47; 48) - NAME_REF@[47; 48) - IDENT@[47; 48) "b" - SEMI@[48; 49) ";" - WHITESPACE@[49; 54) "\n " - LET_STMT@[54; 68) - LET_KW@[54; 57) "let" - WHITESPACE@[57; 58) " " - PLACEHOLDER_PAT@[58; 59) - UNDERSCORE@[58; 59) "_" - WHITESPACE@[59; 60) " " - EQ@[60; 61) "=" - WHITESPACE@[61; 62) " " - BIN_EXPR@[62; 67) - PATH_EXPR@[62; 63) - PATH@[62; 63) - PATH_SEGMENT@[62; 63) - NAME_REF@[62; 63) - IDENT@[62; 63) "a" - WHITESPACE@[63; 64) " " - STAR@[64; 65) "*" - WHITESPACE@[65; 66) " " - PATH_EXPR@[66; 67) - PATH@[66; 67) - PATH_SEGMENT@[66; 67) - NAME_REF@[66; 67) - IDENT@[66; 67) "b" - SEMI@[67; 68) ";" - WHITESPACE@[68; 73) "\n " - LET_STMT@[73; 87) - LET_KW@[73; 76) "let" - WHITESPACE@[76; 77) " " - PLACEHOLDER_PAT@[77; 78) - UNDERSCORE@[77; 78) "_" - WHITESPACE@[78; 79) " " - EQ@[79; 80) "=" - WHITESPACE@[80; 81) " " - BIN_EXPR@[81; 86) - PATH_EXPR@[81; 82) - PATH@[81; 82) - PATH_SEGMENT@[81; 82) - NAME_REF@[81; 82) - IDENT@[81; 82) "a" - WHITESPACE@[82; 83) " " - SLASH@[83; 84) "/" - WHITESPACE@[84; 85) " " - PATH_EXPR@[85; 86) - PATH@[85; 86) - PATH_SEGMENT@[85; 86) - NAME_REF@[85; 86) - IDENT@[85; 86) "b" - SEMI@[86; 87) ";" - WHITESPACE@[87; 92) "\n " - LET_STMT@[92; 106) - LET_KW@[92; 95) "let" - WHITESPACE@[95; 96) " " - PLACEHOLDER_PAT@[96; 97) - UNDERSCORE@[96; 97) "_" - WHITESPACE@[97; 98) " " - EQ@[98; 99) "=" - WHITESPACE@[99; 100) " " - BIN_EXPR@[100; 105) - PATH_EXPR@[100; 101) - PATH@[100; 101) - PATH_SEGMENT@[100; 101) - NAME_REF@[100; 101) - IDENT@[100; 101) "a" - WHITESPACE@[101; 102) " " - PERCENT@[102; 103) "%" - WHITESPACE@[103; 104) " " - PATH_EXPR@[104; 105) - PATH@[104; 105) - PATH_SEGMENT@[104; 105) - NAME_REF@[104; 105) - IDENT@[104; 105) "b" - SEMI@[105; 106) ";" - WHITESPACE@[106; 111) "\n " - LET_STMT@[111; 126) - LET_KW@[111; 114) "let" - WHITESPACE@[114; 115) " " - PLACEHOLDER_PAT@[115; 116) - UNDERSCORE@[115; 116) "_" - WHITESPACE@[116; 117) " " - EQ@[117; 118) "=" - WHITESPACE@[118; 119) " " - BIN_EXPR@[119; 125) - PATH_EXPR@[119; 120) - PATH@[119; 120) - PATH_SEGMENT@[119; 120) - NAME_REF@[119; 120) - IDENT@[119; 120) "a" - WHITESPACE@[120; 121) " " - SHL@[121; 123) "<<" - WHITESPACE@[123; 124) " " - PATH_EXPR@[124; 125) - PATH@[124; 125) - PATH_SEGMENT@[124; 125) - NAME_REF@[124; 125) - IDENT@[124; 125) "b" - SEMI@[125; 126) ";" - WHITESPACE@[126; 131) "\n " - LET_STMT@[131; 146) - LET_KW@[131; 134) "let" - WHITESPACE@[134; 135) " " - PLACEHOLDER_PAT@[135; 136) - UNDERSCORE@[135; 136) "_" - WHITESPACE@[136; 137) " " - EQ@[137; 138) "=" - WHITESPACE@[138; 139) " " - BIN_EXPR@[139; 145) - PATH_EXPR@[139; 140) - PATH@[139; 140) - PATH_SEGMENT@[139; 140) - NAME_REF@[139; 140) - IDENT@[139; 140) "a" - WHITESPACE@[140; 141) " " - SHR@[141; 143) ">>" - WHITESPACE@[143; 144) " " - PATH_EXPR@[144; 145) - PATH@[144; 145) - PATH_SEGMENT@[144; 145) - NAME_REF@[144; 145) - IDENT@[144; 145) "b" - SEMI@[145; 146) ";" - WHITESPACE@[146; 151) "\n " - LET_STMT@[151; 165) - LET_KW@[151; 154) "let" - WHITESPACE@[154; 155) " " - PLACEHOLDER_PAT@[155; 156) - UNDERSCORE@[155; 156) "_" - WHITESPACE@[156; 157) " " - EQ@[157; 158) "=" - WHITESPACE@[158; 159) " " - BIN_EXPR@[159; 164) - PATH_EXPR@[159; 160) - PATH@[159; 160) - PATH_SEGMENT@[159; 160) - NAME_REF@[159; 160) - IDENT@[159; 160) "a" - WHITESPACE@[160; 161) " " - AMP@[161; 162) "&" - WHITESPACE@[162; 163) " " - PATH_EXPR@[163; 164) - PATH@[163; 164) - PATH_SEGMENT@[163; 164) - NAME_REF@[163; 164) - IDENT@[163; 164) "b" - SEMI@[164; 165) ";" - WHITESPACE@[165; 170) "\n " - LET_STMT@[170; 184) - LET_KW@[170; 173) "let" - WHITESPACE@[173; 174) " " - PLACEHOLDER_PAT@[174; 175) - UNDERSCORE@[174; 175) "_" - WHITESPACE@[175; 176) " " - EQ@[176; 177) "=" - WHITESPACE@[177; 178) " " - BIN_EXPR@[178; 183) - PATH_EXPR@[178; 179) - PATH@[178; 179) - PATH_SEGMENT@[178; 179) - NAME_REF@[178; 179) - IDENT@[178; 179) "a" - WHITESPACE@[179; 180) " " - PIPE@[180; 181) "|" - WHITESPACE@[181; 182) " " - PATH_EXPR@[182; 183) - PATH@[182; 183) - PATH_SEGMENT@[182; 183) - NAME_REF@[182; 183) - IDENT@[182; 183) "b" - SEMI@[183; 184) ";" - WHITESPACE@[184; 189) "\n " - LET_STMT@[189; 203) - LET_KW@[189; 192) "let" - WHITESPACE@[192; 193) " " - PLACEHOLDER_PAT@[193; 194) - UNDERSCORE@[193; 194) "_" - WHITESPACE@[194; 195) " " - EQ@[195; 196) "=" - WHITESPACE@[196; 197) " " - BIN_EXPR@[197; 202) - PATH_EXPR@[197; 198) - PATH@[197; 198) - PATH_SEGMENT@[197; 198) - NAME_REF@[197; 198) - IDENT@[197; 198) "a" - WHITESPACE@[198; 199) " " - CARET@[199; 200) "^" - WHITESPACE@[200; 201) " " - PATH_EXPR@[201; 202) - PATH@[201; 202) - PATH_SEGMENT@[201; 202) - NAME_REF@[201; 202) - IDENT@[201; 202) "b" - SEMI@[202; 203) ";" - WHITESPACE@[203; 204) "\n" - R_CURLY@[204; 205) "}" +SOURCE_FILE@0..205 + FUNCTION_DEF@0..205 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..7 + IDENT@3..7 "main" + PARAM_LIST@7..9 + L_PAREN@7..8 "(" + R_PAREN@8..9 ")" + WHITESPACE@9..10 " " + BLOCK_EXPR@10..205 + L_CURLY@10..11 "{" + WHITESPACE@11..16 "\n " + LET_STMT@16..30 + LET_KW@16..19 "let" + WHITESPACE@19..20 " " + PLACEHOLDER_PAT@20..21 + UNDERSCORE@20..21 "_" + WHITESPACE@21..22 " " + EQ@22..23 "=" + WHITESPACE@23..24 " " + BIN_EXPR@24..29 + PATH_EXPR@24..25 + PATH@24..25 + PATH_SEGMENT@24..25 + NAME_REF@24..25 + IDENT@24..25 "a" + WHITESPACE@25..26 " " + PLUS@26..27 "+" + WHITESPACE@27..28 " " + PATH_EXPR@28..29 + PATH@28..29 + PATH_SEGMENT@28..29 + NAME_REF@28..29 + IDENT@28..29 "b" + SEMI@29..30 ";" + WHITESPACE@30..35 "\n " + LET_STMT@35..49 + LET_KW@35..38 "let" + WHITESPACE@38..39 " " + PLACEHOLDER_PAT@39..40 + UNDERSCORE@39..40 "_" + WHITESPACE@40..41 " " + EQ@41..42 "=" + WHITESPACE@42..43 " " + BIN_EXPR@43..48 + PATH_EXPR@43..44 + PATH@43..44 + PATH_SEGMENT@43..44 + NAME_REF@43..44 + IDENT@43..44 "a" + WHITESPACE@44..45 " " + MINUS@45..46 "-" + WHITESPACE@46..47 " " + PATH_EXPR@47..48 + PATH@47..48 + PATH_SEGMENT@47..48 + NAME_REF@47..48 + IDENT@47..48 "b" + SEMI@48..49 ";" + WHITESPACE@49..54 "\n " + LET_STMT@54..68 + LET_KW@54..57 "let" + WHITESPACE@57..58 " " + PLACEHOLDER_PAT@58..59 + UNDERSCORE@58..59 "_" + WHITESPACE@59..60 " " + EQ@60..61 "=" + WHITESPACE@61..62 " " + BIN_EXPR@62..67 + PATH_EXPR@62..63 + PATH@62..63 + PATH_SEGMENT@62..63 + NAME_REF@62..63 + IDENT@62..63 "a" + WHITESPACE@63..64 " " + STAR@64..65 "*" + WHITESPACE@65..66 " " + PATH_EXPR@66..67 + PATH@66..67 + PATH_SEGMENT@66..67 + NAME_REF@66..67 + IDENT@66..67 "b" + SEMI@67..68 ";" + WHITESPACE@68..73 "\n " + LET_STMT@73..87 + LET_KW@73..76 "let" + WHITESPACE@76..77 " " + PLACEHOLDER_PAT@77..78 + UNDERSCORE@77..78 "_" + WHITESPACE@78..79 " " + EQ@79..80 "=" + WHITESPACE@80..81 " " + BIN_EXPR@81..86 + PATH_EXPR@81..82 + PATH@81..82 + PATH_SEGMENT@81..82 + NAME_REF@81..82 + IDENT@81..82 "a" + WHITESPACE@82..83 " " + SLASH@83..84 "/" + WHITESPACE@84..85 " " + PATH_EXPR@85..86 + PATH@85..86 + PATH_SEGMENT@85..86 + NAME_REF@85..86 + IDENT@85..86 "b" + SEMI@86..87 ";" + WHITESPACE@87..92 "\n " + LET_STMT@92..106 + LET_KW@92..95 "let" + WHITESPACE@95..96 " " + PLACEHOLDER_PAT@96..97 + UNDERSCORE@96..97 "_" + WHITESPACE@97..98 " " + EQ@98..99 "=" + WHITESPACE@99..100 " " + BIN_EXPR@100..105 + PATH_EXPR@100..101 + PATH@100..101 + PATH_SEGMENT@100..101 + NAME_REF@100..101 + IDENT@100..101 "a" + WHITESPACE@101..102 " " + PERCENT@102..103 "%" + WHITESPACE@103..104 " " + PATH_EXPR@104..105 + PATH@104..105 + PATH_SEGMENT@104..105 + NAME_REF@104..105 + IDENT@104..105 "b" + SEMI@105..106 ";" + WHITESPACE@106..111 "\n " + LET_STMT@111..126 + LET_KW@111..114 "let" + WHITESPACE@114..115 " " + PLACEHOLDER_PAT@115..116 + UNDERSCORE@115..116 "_" + WHITESPACE@116..117 " " + EQ@117..118 "=" + WHITESPACE@118..119 " " + BIN_EXPR@119..125 + PATH_EXPR@119..120 + PATH@119..120 + PATH_SEGMENT@119..120 + NAME_REF@119..120 + IDENT@119..120 "a" + WHITESPACE@120..121 " " + SHL@121..123 "<<" + WHITESPACE@123..124 " " + PATH_EXPR@124..125 + PATH@124..125 + PATH_SEGMENT@124..125 + NAME_REF@124..125 + IDENT@124..125 "b" + SEMI@125..126 ";" + WHITESPACE@126..131 "\n " + LET_STMT@131..146 + LET_KW@131..134 "let" + WHITESPACE@134..135 " " + PLACEHOLDER_PAT@135..136 + UNDERSCORE@135..136 "_" + WHITESPACE@136..137 " " + EQ@137..138 "=" + WHITESPACE@138..139 " " + BIN_EXPR@139..145 + PATH_EXPR@139..140 + PATH@139..140 + PATH_SEGMENT@139..140 + NAME_REF@139..140 + IDENT@139..140 "a" + WHITESPACE@140..141 " " + SHR@141..143 ">>" + WHITESPACE@143..144 " " + PATH_EXPR@144..145 + PATH@144..145 + PATH_SEGMENT@144..145 + NAME_REF@144..145 + IDENT@144..145 "b" + SEMI@145..146 ";" + WHITESPACE@146..151 "\n " + LET_STMT@151..165 + LET_KW@151..154 "let" + WHITESPACE@154..155 " " + PLACEHOLDER_PAT@155..156 + UNDERSCORE@155..156 "_" + WHITESPACE@156..157 " " + EQ@157..158 "=" + WHITESPACE@158..159 " " + BIN_EXPR@159..164 + PATH_EXPR@159..160 + PATH@159..160 + PATH_SEGMENT@159..160 + NAME_REF@159..160 + IDENT@159..160 "a" + WHITESPACE@160..161 " " + AMP@161..162 "&" + WHITESPACE@162..163 " " + PATH_EXPR@163..164 + PATH@163..164 + PATH_SEGMENT@163..164 + NAME_REF@163..164 + IDENT@163..164 "b" + SEMI@164..165 ";" + WHITESPACE@165..170 "\n " + LET_STMT@170..184 + LET_KW@170..173 "let" + WHITESPACE@173..174 " " + PLACEHOLDER_PAT@174..175 + UNDERSCORE@174..175 "_" + WHITESPACE@175..176 " " + EQ@176..177 "=" + WHITESPACE@177..178 " " + BIN_EXPR@178..183 + PATH_EXPR@178..179 + PATH@178..179 + PATH_SEGMENT@178..179 + NAME_REF@178..179 + IDENT@178..179 "a" + WHITESPACE@179..180 " " + PIPE@180..181 "|" + WHITESPACE@181..182 " " + PATH_EXPR@182..183 + PATH@182..183 + PATH_SEGMENT@182..183 + NAME_REF@182..183 + IDENT@182..183 "b" + SEMI@183..184 ";" + WHITESPACE@184..189 "\n " + LET_STMT@189..203 + LET_KW@189..192 "let" + WHITESPACE@192..193 " " + PLACEHOLDER_PAT@193..194 + UNDERSCORE@193..194 "_" + WHITESPACE@194..195 " " + EQ@195..196 "=" + WHITESPACE@196..197 " " + BIN_EXPR@197..202 + PATH_EXPR@197..198 + PATH@197..198 + PATH_SEGMENT@197..198 + NAME_REF@197..198 + IDENT@197..198 "a" + WHITESPACE@198..199 " " + CARET@199..200 "^" + WHITESPACE@200..201 " " + PATH_EXPR@201..202 + PATH@201..202 + PATH_SEGMENT@201..202 + NAME_REF@201..202 + IDENT@201..202 "b" + SEMI@202..203 ";" + WHITESPACE@203..204 "\n" + R_CURLY@204..205 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__assignment_operands.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__assignment_operands.snap index 562c7dc71..d9ad8939b 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__assignment_operands.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__assignment_operands.snap @@ -2,204 +2,204 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn main() {\n let a = b;\n a += b;\n a -= b;\n a *= b;\n a /= b;\n a %= b;\n a <<= b;\n a >>= b;\n a &= b;\n a |= b;\n a ^= b;\n}" --- -SOURCE_FILE@[0; 150) - FUNCTION_DEF@[0; 150) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 7) - IDENT@[3; 7) "main" - PARAM_LIST@[7; 9) - L_PAREN@[7; 8) "(" - R_PAREN@[8; 9) ")" - WHITESPACE@[9; 10) " " - BLOCK_EXPR@[10; 150) - L_CURLY@[10; 11) "{" - WHITESPACE@[11; 16) "\n " - LET_STMT@[16; 26) - LET_KW@[16; 19) "let" - WHITESPACE@[19; 20) " " - BIND_PAT@[20; 21) - NAME@[20; 21) - IDENT@[20; 21) "a" - WHITESPACE@[21; 22) " " - EQ@[22; 23) "=" - WHITESPACE@[23; 24) " " - PATH_EXPR@[24; 25) - PATH@[24; 25) - PATH_SEGMENT@[24; 25) - NAME_REF@[24; 25) - IDENT@[24; 25) "b" - SEMI@[25; 26) ";" - WHITESPACE@[26; 31) "\n " - EXPR_STMT@[31; 38) - BIN_EXPR@[31; 37) - PATH_EXPR@[31; 32) - PATH@[31; 32) - PATH_SEGMENT@[31; 32) - NAME_REF@[31; 32) - IDENT@[31; 32) "a" - WHITESPACE@[32; 33) " " - PLUSEQ@[33; 35) "+=" - WHITESPACE@[35; 36) " " - PATH_EXPR@[36; 37) - PATH@[36; 37) - PATH_SEGMENT@[36; 37) - NAME_REF@[36; 37) - IDENT@[36; 37) "b" - SEMI@[37; 38) ";" - WHITESPACE@[38; 43) "\n " - EXPR_STMT@[43; 50) - BIN_EXPR@[43; 49) - PATH_EXPR@[43; 44) - PATH@[43; 44) - PATH_SEGMENT@[43; 44) - NAME_REF@[43; 44) - IDENT@[43; 44) "a" - WHITESPACE@[44; 45) " " - MINUSEQ@[45; 47) "-=" - WHITESPACE@[47; 48) " " - PATH_EXPR@[48; 49) - PATH@[48; 49) - PATH_SEGMENT@[48; 49) - NAME_REF@[48; 49) - IDENT@[48; 49) "b" - SEMI@[49; 50) ";" - WHITESPACE@[50; 55) "\n " - EXPR_STMT@[55; 62) - BIN_EXPR@[55; 61) - PATH_EXPR@[55; 56) - PATH@[55; 56) - PATH_SEGMENT@[55; 56) - NAME_REF@[55; 56) - IDENT@[55; 56) "a" - WHITESPACE@[56; 57) " " - STAREQ@[57; 59) "*=" - WHITESPACE@[59; 60) " " - PATH_EXPR@[60; 61) - PATH@[60; 61) - PATH_SEGMENT@[60; 61) - NAME_REF@[60; 61) - IDENT@[60; 61) "b" - SEMI@[61; 62) ";" - WHITESPACE@[62; 67) "\n " - EXPR_STMT@[67; 74) - BIN_EXPR@[67; 73) - PATH_EXPR@[67; 68) - PATH@[67; 68) - PATH_SEGMENT@[67; 68) - NAME_REF@[67; 68) - IDENT@[67; 68) "a" - WHITESPACE@[68; 69) " " - SLASHEQ@[69; 71) "/=" - WHITESPACE@[71; 72) " " - PATH_EXPR@[72; 73) - PATH@[72; 73) - PATH_SEGMENT@[72; 73) - NAME_REF@[72; 73) - IDENT@[72; 73) "b" - SEMI@[73; 74) ";" - WHITESPACE@[74; 79) "\n " - EXPR_STMT@[79; 86) - BIN_EXPR@[79; 85) - PATH_EXPR@[79; 80) - PATH@[79; 80) - PATH_SEGMENT@[79; 80) - NAME_REF@[79; 80) - IDENT@[79; 80) "a" - WHITESPACE@[80; 81) " " - PERCENTEQ@[81; 83) "%=" - WHITESPACE@[83; 84) " " - PATH_EXPR@[84; 85) - PATH@[84; 85) - PATH_SEGMENT@[84; 85) - NAME_REF@[84; 85) - IDENT@[84; 85) "b" - SEMI@[85; 86) ";" - WHITESPACE@[86; 91) "\n " - EXPR_STMT@[91; 99) - BIN_EXPR@[91; 98) - PATH_EXPR@[91; 92) - PATH@[91; 92) - PATH_SEGMENT@[91; 92) - NAME_REF@[91; 92) - IDENT@[91; 92) "a" - WHITESPACE@[92; 93) " " - SHLEQ@[93; 96) "<<=" - WHITESPACE@[96; 97) " " - PATH_EXPR@[97; 98) - PATH@[97; 98) - PATH_SEGMENT@[97; 98) - NAME_REF@[97; 98) - IDENT@[97; 98) "b" - SEMI@[98; 99) ";" - WHITESPACE@[99; 104) "\n " - EXPR_STMT@[104; 112) - BIN_EXPR@[104; 111) - PATH_EXPR@[104; 105) - PATH@[104; 105) - PATH_SEGMENT@[104; 105) - NAME_REF@[104; 105) - IDENT@[104; 105) "a" - WHITESPACE@[105; 106) " " - SHREQ@[106; 109) ">>=" - WHITESPACE@[109; 110) " " - PATH_EXPR@[110; 111) - PATH@[110; 111) - PATH_SEGMENT@[110; 111) - NAME_REF@[110; 111) - IDENT@[110; 111) "b" - SEMI@[111; 112) ";" - WHITESPACE@[112; 117) "\n " - EXPR_STMT@[117; 124) - BIN_EXPR@[117; 123) - PATH_EXPR@[117; 118) - PATH@[117; 118) - PATH_SEGMENT@[117; 118) - NAME_REF@[117; 118) - IDENT@[117; 118) "a" - WHITESPACE@[118; 119) " " - AMPEQ@[119; 121) "&=" - WHITESPACE@[121; 122) " " - PATH_EXPR@[122; 123) - PATH@[122; 123) - PATH_SEGMENT@[122; 123) - NAME_REF@[122; 123) - IDENT@[122; 123) "b" - SEMI@[123; 124) ";" - WHITESPACE@[124; 129) "\n " - EXPR_STMT@[129; 136) - BIN_EXPR@[129; 135) - PATH_EXPR@[129; 130) - PATH@[129; 130) - PATH_SEGMENT@[129; 130) - NAME_REF@[129; 130) - IDENT@[129; 130) "a" - WHITESPACE@[130; 131) " " - PIPEEQ@[131; 133) "|=" - WHITESPACE@[133; 134) " " - PATH_EXPR@[134; 135) - PATH@[134; 135) - PATH_SEGMENT@[134; 135) - NAME_REF@[134; 135) - IDENT@[134; 135) "b" - SEMI@[135; 136) ";" - WHITESPACE@[136; 141) "\n " - EXPR_STMT@[141; 148) - BIN_EXPR@[141; 147) - PATH_EXPR@[141; 142) - PATH@[141; 142) - PATH_SEGMENT@[141; 142) - NAME_REF@[141; 142) - IDENT@[141; 142) "a" - WHITESPACE@[142; 143) " " - CARETEQ@[143; 145) "^=" - WHITESPACE@[145; 146) " " - PATH_EXPR@[146; 147) - PATH@[146; 147) - PATH_SEGMENT@[146; 147) - NAME_REF@[146; 147) - IDENT@[146; 147) "b" - SEMI@[147; 148) ";" - WHITESPACE@[148; 149) "\n" - R_CURLY@[149; 150) "}" +SOURCE_FILE@0..150 + FUNCTION_DEF@0..150 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..7 + IDENT@3..7 "main" + PARAM_LIST@7..9 + L_PAREN@7..8 "(" + R_PAREN@8..9 ")" + WHITESPACE@9..10 " " + BLOCK_EXPR@10..150 + L_CURLY@10..11 "{" + WHITESPACE@11..16 "\n " + LET_STMT@16..26 + LET_KW@16..19 "let" + WHITESPACE@19..20 " " + BIND_PAT@20..21 + NAME@20..21 + IDENT@20..21 "a" + WHITESPACE@21..22 " " + EQ@22..23 "=" + WHITESPACE@23..24 " " + PATH_EXPR@24..25 + PATH@24..25 + PATH_SEGMENT@24..25 + NAME_REF@24..25 + IDENT@24..25 "b" + SEMI@25..26 ";" + WHITESPACE@26..31 "\n " + EXPR_STMT@31..38 + BIN_EXPR@31..37 + PATH_EXPR@31..32 + PATH@31..32 + PATH_SEGMENT@31..32 + NAME_REF@31..32 + IDENT@31..32 "a" + WHITESPACE@32..33 " " + PLUSEQ@33..35 "+=" + WHITESPACE@35..36 " " + PATH_EXPR@36..37 + PATH@36..37 + PATH_SEGMENT@36..37 + NAME_REF@36..37 + IDENT@36..37 "b" + SEMI@37..38 ";" + WHITESPACE@38..43 "\n " + EXPR_STMT@43..50 + BIN_EXPR@43..49 + PATH_EXPR@43..44 + PATH@43..44 + PATH_SEGMENT@43..44 + NAME_REF@43..44 + IDENT@43..44 "a" + WHITESPACE@44..45 " " + MINUSEQ@45..47 "-=" + WHITESPACE@47..48 " " + PATH_EXPR@48..49 + PATH@48..49 + PATH_SEGMENT@48..49 + NAME_REF@48..49 + IDENT@48..49 "b" + SEMI@49..50 ";" + WHITESPACE@50..55 "\n " + EXPR_STMT@55..62 + BIN_EXPR@55..61 + PATH_EXPR@55..56 + PATH@55..56 + PATH_SEGMENT@55..56 + NAME_REF@55..56 + IDENT@55..56 "a" + WHITESPACE@56..57 " " + STAREQ@57..59 "*=" + WHITESPACE@59..60 " " + PATH_EXPR@60..61 + PATH@60..61 + PATH_SEGMENT@60..61 + NAME_REF@60..61 + IDENT@60..61 "b" + SEMI@61..62 ";" + WHITESPACE@62..67 "\n " + EXPR_STMT@67..74 + BIN_EXPR@67..73 + PATH_EXPR@67..68 + PATH@67..68 + PATH_SEGMENT@67..68 + NAME_REF@67..68 + IDENT@67..68 "a" + WHITESPACE@68..69 " " + SLASHEQ@69..71 "/=" + WHITESPACE@71..72 " " + PATH_EXPR@72..73 + PATH@72..73 + PATH_SEGMENT@72..73 + NAME_REF@72..73 + IDENT@72..73 "b" + SEMI@73..74 ";" + WHITESPACE@74..79 "\n " + EXPR_STMT@79..86 + BIN_EXPR@79..85 + PATH_EXPR@79..80 + PATH@79..80 + PATH_SEGMENT@79..80 + NAME_REF@79..80 + IDENT@79..80 "a" + WHITESPACE@80..81 " " + PERCENTEQ@81..83 "%=" + WHITESPACE@83..84 " " + PATH_EXPR@84..85 + PATH@84..85 + PATH_SEGMENT@84..85 + NAME_REF@84..85 + IDENT@84..85 "b" + SEMI@85..86 ";" + WHITESPACE@86..91 "\n " + EXPR_STMT@91..99 + BIN_EXPR@91..98 + PATH_EXPR@91..92 + PATH@91..92 + PATH_SEGMENT@91..92 + NAME_REF@91..92 + IDENT@91..92 "a" + WHITESPACE@92..93 " " + SHLEQ@93..96 "<<=" + WHITESPACE@96..97 " " + PATH_EXPR@97..98 + PATH@97..98 + PATH_SEGMENT@97..98 + NAME_REF@97..98 + IDENT@97..98 "b" + SEMI@98..99 ";" + WHITESPACE@99..104 "\n " + EXPR_STMT@104..112 + BIN_EXPR@104..111 + PATH_EXPR@104..105 + PATH@104..105 + PATH_SEGMENT@104..105 + NAME_REF@104..105 + IDENT@104..105 "a" + WHITESPACE@105..106 " " + SHREQ@106..109 ">>=" + WHITESPACE@109..110 " " + PATH_EXPR@110..111 + PATH@110..111 + PATH_SEGMENT@110..111 + NAME_REF@110..111 + IDENT@110..111 "b" + SEMI@111..112 ";" + WHITESPACE@112..117 "\n " + EXPR_STMT@117..124 + BIN_EXPR@117..123 + PATH_EXPR@117..118 + PATH@117..118 + PATH_SEGMENT@117..118 + NAME_REF@117..118 + IDENT@117..118 "a" + WHITESPACE@118..119 " " + AMPEQ@119..121 "&=" + WHITESPACE@121..122 " " + PATH_EXPR@122..123 + PATH@122..123 + PATH_SEGMENT@122..123 + NAME_REF@122..123 + IDENT@122..123 "b" + SEMI@123..124 ";" + WHITESPACE@124..129 "\n " + EXPR_STMT@129..136 + BIN_EXPR@129..135 + PATH_EXPR@129..130 + PATH@129..130 + PATH_SEGMENT@129..130 + NAME_REF@129..130 + IDENT@129..130 "a" + WHITESPACE@130..131 " " + PIPEEQ@131..133 "|=" + WHITESPACE@133..134 " " + PATH_EXPR@134..135 + PATH@134..135 + PATH_SEGMENT@134..135 + NAME_REF@134..135 + IDENT@134..135 "b" + SEMI@135..136 ";" + WHITESPACE@136..141 "\n " + EXPR_STMT@141..148 + BIN_EXPR@141..147 + PATH_EXPR@141..142 + PATH@141..142 + PATH_SEGMENT@141..142 + NAME_REF@141..142 + IDENT@141..142 "a" + WHITESPACE@142..143 " " + CARETEQ@143..145 "^=" + WHITESPACE@145..146 " " + PATH_EXPR@146..147 + PATH@146..147 + PATH_SEGMENT@146..147 + NAME_REF@146..147 + IDENT@146..147 "b" + SEMI@147..148 ";" + WHITESPACE@148..149 "\n" + R_CURLY@149..150 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__binary_expr.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__binary_expr.snap index ccf685af7..60ca501fc 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__binary_expr.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__binary_expr.snap @@ -2,62 +2,62 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n let a = 3+4*5\n let b = 3*4+10/2\n}" --- -SOURCE_FILE@[0; 51) - FUNCTION_DEF@[0; 51) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 51) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - LET_STMT@[15; 28) - LET_KW@[15; 18) "let" - WHITESPACE@[18; 19) " " - BIND_PAT@[19; 20) - NAME@[19; 20) - IDENT@[19; 20) "a" - WHITESPACE@[20; 21) " " - EQ@[21; 22) "=" - WHITESPACE@[22; 23) " " - BIN_EXPR@[23; 28) - LITERAL@[23; 24) - INT_NUMBER@[23; 24) "3" - PLUS@[24; 25) "+" - BIN_EXPR@[25; 28) - LITERAL@[25; 26) - INT_NUMBER@[25; 26) "4" - STAR@[26; 27) "*" - LITERAL@[27; 28) - INT_NUMBER@[27; 28) "5" - WHITESPACE@[28; 33) "\n " - LET_STMT@[33; 49) - LET_KW@[33; 36) "let" - WHITESPACE@[36; 37) " " - BIND_PAT@[37; 38) - NAME@[37; 38) - IDENT@[37; 38) "b" - WHITESPACE@[38; 39) " " - EQ@[39; 40) "=" - WHITESPACE@[40; 41) " " - BIN_EXPR@[41; 49) - BIN_EXPR@[41; 44) - LITERAL@[41; 42) - INT_NUMBER@[41; 42) "3" - STAR@[42; 43) "*" - LITERAL@[43; 44) - INT_NUMBER@[43; 44) "4" - PLUS@[44; 45) "+" - BIN_EXPR@[45; 49) - LITERAL@[45; 47) - INT_NUMBER@[45; 47) "10" - SLASH@[47; 48) "/" - LITERAL@[48; 49) - INT_NUMBER@[48; 49) "2" - WHITESPACE@[49; 50) "\n" - R_CURLY@[50; 51) "}" +SOURCE_FILE@0..51 + FUNCTION_DEF@0..51 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..51 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + LET_STMT@15..28 + LET_KW@15..18 "let" + WHITESPACE@18..19 " " + BIND_PAT@19..20 + NAME@19..20 + IDENT@19..20 "a" + WHITESPACE@20..21 " " + EQ@21..22 "=" + WHITESPACE@22..23 " " + BIN_EXPR@23..28 + LITERAL@23..24 + INT_NUMBER@23..24 "3" + PLUS@24..25 "+" + BIN_EXPR@25..28 + LITERAL@25..26 + INT_NUMBER@25..26 "4" + STAR@26..27 "*" + LITERAL@27..28 + INT_NUMBER@27..28 "5" + WHITESPACE@28..33 "\n " + LET_STMT@33..49 + LET_KW@33..36 "let" + WHITESPACE@36..37 " " + BIND_PAT@37..38 + NAME@37..38 + IDENT@37..38 "b" + WHITESPACE@38..39 " " + EQ@39..40 "=" + WHITESPACE@40..41 " " + BIN_EXPR@41..49 + BIN_EXPR@41..44 + LITERAL@41..42 + INT_NUMBER@41..42 "3" + STAR@42..43 "*" + LITERAL@43..44 + INT_NUMBER@43..44 "4" + PLUS@44..45 "+" + BIN_EXPR@45..49 + LITERAL@45..47 + INT_NUMBER@45..47 "10" + SLASH@47..48 "/" + LITERAL@48..49 + INT_NUMBER@48..49 "2" + WHITESPACE@49..50 "\n" + R_CURLY@50..51 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__block.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__block.snap index d49a9ca5c..167338ae4 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__block.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__block.snap @@ -2,54 +2,54 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n let a;\n let b:i32;\n let c:string;\n}" --- -SOURCE_FILE@[0; 56) - FUNCTION_DEF@[0; 56) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 56) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - LET_STMT@[15; 21) - LET_KW@[15; 18) "let" - WHITESPACE@[18; 19) " " - BIND_PAT@[19; 20) - NAME@[19; 20) - IDENT@[19; 20) "a" - SEMI@[20; 21) ";" - WHITESPACE@[21; 26) "\n " - LET_STMT@[26; 36) - LET_KW@[26; 29) "let" - WHITESPACE@[29; 30) " " - BIND_PAT@[30; 31) - NAME@[30; 31) - IDENT@[30; 31) "b" - COLON@[31; 32) ":" - PATH_TYPE@[32; 35) - PATH@[32; 35) - PATH_SEGMENT@[32; 35) - NAME_REF@[32; 35) - IDENT@[32; 35) "i32" - SEMI@[35; 36) ";" - WHITESPACE@[36; 41) "\n " - LET_STMT@[41; 54) - LET_KW@[41; 44) "let" - WHITESPACE@[44; 45) " " - BIND_PAT@[45; 46) - NAME@[45; 46) - IDENT@[45; 46) "c" - COLON@[46; 47) ":" - PATH_TYPE@[47; 53) - PATH@[47; 53) - PATH_SEGMENT@[47; 53) - NAME_REF@[47; 53) - IDENT@[47; 53) "string" - SEMI@[53; 54) ";" - WHITESPACE@[54; 55) "\n" - R_CURLY@[55; 56) "}" +SOURCE_FILE@0..56 + FUNCTION_DEF@0..56 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..56 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + LET_STMT@15..21 + LET_KW@15..18 "let" + WHITESPACE@18..19 " " + BIND_PAT@19..20 + NAME@19..20 + IDENT@19..20 "a" + SEMI@20..21 ";" + WHITESPACE@21..26 "\n " + LET_STMT@26..36 + LET_KW@26..29 "let" + WHITESPACE@29..30 " " + BIND_PAT@30..31 + NAME@30..31 + IDENT@30..31 "b" + COLON@31..32 ":" + PATH_TYPE@32..35 + PATH@32..35 + PATH_SEGMENT@32..35 + NAME_REF@32..35 + IDENT@32..35 "i32" + SEMI@35..36 ";" + WHITESPACE@36..41 "\n " + LET_STMT@41..54 + LET_KW@41..44 "let" + WHITESPACE@44..45 " " + BIND_PAT@45..46 + NAME@45..46 + IDENT@45..46 "c" + COLON@46..47 ":" + PATH_TYPE@47..53 + PATH@47..53 + PATH_SEGMENT@47..53 + NAME_REF@47..53 + IDENT@47..53 "string" + SEMI@53..54 ";" + WHITESPACE@54..55 "\n" + R_CURLY@55..56 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__block_expr.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__block_expr.snap index f9ac48873..240824db9 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__block_expr.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__block_expr.snap @@ -2,24 +2,24 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn bar() {\n {3}\n}" --- -SOURCE_FILE@[0; 20) - FUNCTION_DEF@[0; 20) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "bar" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 20) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - BLOCK_EXPR@[15; 18) - L_CURLY@[15; 16) "{" - LITERAL@[16; 17) - INT_NUMBER@[16; 17) "3" - R_CURLY@[17; 18) "}" - WHITESPACE@[18; 19) "\n" - R_CURLY@[19; 20) "}" +SOURCE_FILE@0..20 + FUNCTION_DEF@0..20 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "bar" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..20 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + BLOCK_EXPR@15..18 + L_CURLY@15..16 "{" + LITERAL@16..17 + INT_NUMBER@16..17 "3" + R_CURLY@17..18 "}" + WHITESPACE@18..19 "\n" + R_CURLY@19..20 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__break_expr.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__break_expr.snap index ea8474ff3..1bae325c4 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__break_expr.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__break_expr.snap @@ -2,61 +2,61 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n break;\n if break { 3; }\n if break 4 { 3; }\n}" --- -SOURCE_FILE@[0; 65) - FUNCTION_DEF@[0; 65) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 65) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - EXPR_STMT@[15; 21) - BREAK_EXPR@[15; 20) - BREAK_KW@[15; 20) "break" - SEMI@[20; 21) ";" - WHITESPACE@[21; 26) "\n " - EXPR_STMT@[26; 41) - IF_EXPR@[26; 41) - IF_KW@[26; 28) "if" - WHITESPACE@[28; 29) " " - CONDITION@[29; 34) - BREAK_EXPR@[29; 34) - BREAK_KW@[29; 34) "break" - WHITESPACE@[34; 35) " " - BLOCK_EXPR@[35; 41) - L_CURLY@[35; 36) "{" - WHITESPACE@[36; 37) " " - EXPR_STMT@[37; 39) - LITERAL@[37; 38) - INT_NUMBER@[37; 38) "3" - SEMI@[38; 39) ";" - WHITESPACE@[39; 40) " " - R_CURLY@[40; 41) "}" - WHITESPACE@[41; 46) "\n " - IF_EXPR@[46; 63) - IF_KW@[46; 48) "if" - WHITESPACE@[48; 49) " " - CONDITION@[49; 56) - BREAK_EXPR@[49; 56) - BREAK_KW@[49; 54) "break" - WHITESPACE@[54; 55) " " - LITERAL@[55; 56) - INT_NUMBER@[55; 56) "4" - WHITESPACE@[56; 57) " " - BLOCK_EXPR@[57; 63) - L_CURLY@[57; 58) "{" - WHITESPACE@[58; 59) " " - EXPR_STMT@[59; 61) - LITERAL@[59; 60) - INT_NUMBER@[59; 60) "3" - SEMI@[60; 61) ";" - WHITESPACE@[61; 62) " " - R_CURLY@[62; 63) "}" - WHITESPACE@[63; 64) "\n" - R_CURLY@[64; 65) "}" +SOURCE_FILE@0..65 + FUNCTION_DEF@0..65 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..65 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + EXPR_STMT@15..21 + BREAK_EXPR@15..20 + BREAK_KW@15..20 "break" + SEMI@20..21 ";" + WHITESPACE@21..26 "\n " + EXPR_STMT@26..41 + IF_EXPR@26..41 + IF_KW@26..28 "if" + WHITESPACE@28..29 " " + CONDITION@29..34 + BREAK_EXPR@29..34 + BREAK_KW@29..34 "break" + WHITESPACE@34..35 " " + BLOCK_EXPR@35..41 + L_CURLY@35..36 "{" + WHITESPACE@36..37 " " + EXPR_STMT@37..39 + LITERAL@37..38 + INT_NUMBER@37..38 "3" + SEMI@38..39 ";" + WHITESPACE@39..40 " " + R_CURLY@40..41 "}" + WHITESPACE@41..46 "\n " + IF_EXPR@46..63 + IF_KW@46..48 "if" + WHITESPACE@48..49 " " + CONDITION@49..56 + BREAK_EXPR@49..56 + BREAK_KW@49..54 "break" + WHITESPACE@54..55 " " + LITERAL@55..56 + INT_NUMBER@55..56 "4" + WHITESPACE@56..57 " " + BLOCK_EXPR@57..63 + L_CURLY@57..58 "{" + WHITESPACE@58..59 " " + EXPR_STMT@59..61 + LITERAL@59..60 + INT_NUMBER@59..60 "3" + SEMI@60..61 ";" + WHITESPACE@61..62 " " + R_CURLY@62..63 "}" + WHITESPACE@63..64 "\n" + R_CURLY@64..65 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__compare_operands.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__compare_operands.snap index 6489ff172..e196e1d0a 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__compare_operands.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__compare_operands.snap @@ -2,186 +2,186 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn main() {\n let _ = a == b;\n let _ = a == b;\n let _ = a != b;\n let _ = a < b;\n let _ = a > b;\n let _ = a <= b;\n let _ = a >= b;\n}" --- -SOURCE_FILE@[0; 151) - FUNCTION_DEF@[0; 151) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 7) - IDENT@[3; 7) "main" - PARAM_LIST@[7; 9) - L_PAREN@[7; 8) "(" - R_PAREN@[8; 9) ")" - WHITESPACE@[9; 10) " " - BLOCK_EXPR@[10; 151) - L_CURLY@[10; 11) "{" - WHITESPACE@[11; 16) "\n " - LET_STMT@[16; 31) - LET_KW@[16; 19) "let" - WHITESPACE@[19; 20) " " - PLACEHOLDER_PAT@[20; 21) - UNDERSCORE@[20; 21) "_" - WHITESPACE@[21; 22) " " - EQ@[22; 23) "=" - WHITESPACE@[23; 24) " " - BIN_EXPR@[24; 30) - PATH_EXPR@[24; 25) - PATH@[24; 25) - PATH_SEGMENT@[24; 25) - NAME_REF@[24; 25) - IDENT@[24; 25) "a" - WHITESPACE@[25; 26) " " - EQEQ@[26; 28) "==" - WHITESPACE@[28; 29) " " - PATH_EXPR@[29; 30) - PATH@[29; 30) - PATH_SEGMENT@[29; 30) - NAME_REF@[29; 30) - IDENT@[29; 30) "b" - SEMI@[30; 31) ";" - WHITESPACE@[31; 36) "\n " - LET_STMT@[36; 51) - LET_KW@[36; 39) "let" - WHITESPACE@[39; 40) " " - PLACEHOLDER_PAT@[40; 41) - UNDERSCORE@[40; 41) "_" - WHITESPACE@[41; 42) " " - EQ@[42; 43) "=" - WHITESPACE@[43; 44) " " - BIN_EXPR@[44; 50) - PATH_EXPR@[44; 45) - PATH@[44; 45) - PATH_SEGMENT@[44; 45) - NAME_REF@[44; 45) - IDENT@[44; 45) "a" - WHITESPACE@[45; 46) " " - EQEQ@[46; 48) "==" - WHITESPACE@[48; 49) " " - PATH_EXPR@[49; 50) - PATH@[49; 50) - PATH_SEGMENT@[49; 50) - NAME_REF@[49; 50) - IDENT@[49; 50) "b" - SEMI@[50; 51) ";" - WHITESPACE@[51; 56) "\n " - LET_STMT@[56; 71) - LET_KW@[56; 59) "let" - WHITESPACE@[59; 60) " " - PLACEHOLDER_PAT@[60; 61) - UNDERSCORE@[60; 61) "_" - WHITESPACE@[61; 62) " " - EQ@[62; 63) "=" - WHITESPACE@[63; 64) " " - BIN_EXPR@[64; 70) - PATH_EXPR@[64; 65) - PATH@[64; 65) - PATH_SEGMENT@[64; 65) - NAME_REF@[64; 65) - IDENT@[64; 65) "a" - WHITESPACE@[65; 66) " " - NEQ@[66; 68) "!=" - WHITESPACE@[68; 69) " " - PATH_EXPR@[69; 70) - PATH@[69; 70) - PATH_SEGMENT@[69; 70) - NAME_REF@[69; 70) - IDENT@[69; 70) "b" - SEMI@[70; 71) ";" - WHITESPACE@[71; 76) "\n " - LET_STMT@[76; 90) - LET_KW@[76; 79) "let" - WHITESPACE@[79; 80) " " - PLACEHOLDER_PAT@[80; 81) - UNDERSCORE@[80; 81) "_" - WHITESPACE@[81; 82) " " - EQ@[82; 83) "=" - WHITESPACE@[83; 84) " " - BIN_EXPR@[84; 89) - PATH_EXPR@[84; 85) - PATH@[84; 85) - PATH_SEGMENT@[84; 85) - NAME_REF@[84; 85) - IDENT@[84; 85) "a" - WHITESPACE@[85; 86) " " - LT@[86; 87) "<" - WHITESPACE@[87; 88) " " - PATH_EXPR@[88; 89) - PATH@[88; 89) - PATH_SEGMENT@[88; 89) - NAME_REF@[88; 89) - IDENT@[88; 89) "b" - SEMI@[89; 90) ";" - WHITESPACE@[90; 95) "\n " - LET_STMT@[95; 109) - LET_KW@[95; 98) "let" - WHITESPACE@[98; 99) " " - PLACEHOLDER_PAT@[99; 100) - UNDERSCORE@[99; 100) "_" - WHITESPACE@[100; 101) " " - EQ@[101; 102) "=" - WHITESPACE@[102; 103) " " - BIN_EXPR@[103; 108) - PATH_EXPR@[103; 104) - PATH@[103; 104) - PATH_SEGMENT@[103; 104) - NAME_REF@[103; 104) - IDENT@[103; 104) "a" - WHITESPACE@[104; 105) " " - GT@[105; 106) ">" - WHITESPACE@[106; 107) " " - PATH_EXPR@[107; 108) - PATH@[107; 108) - PATH_SEGMENT@[107; 108) - NAME_REF@[107; 108) - IDENT@[107; 108) "b" - SEMI@[108; 109) ";" - WHITESPACE@[109; 114) "\n " - LET_STMT@[114; 129) - LET_KW@[114; 117) "let" - WHITESPACE@[117; 118) " " - PLACEHOLDER_PAT@[118; 119) - UNDERSCORE@[118; 119) "_" - WHITESPACE@[119; 120) " " - EQ@[120; 121) "=" - WHITESPACE@[121; 122) " " - BIN_EXPR@[122; 128) - PATH_EXPR@[122; 123) - PATH@[122; 123) - PATH_SEGMENT@[122; 123) - NAME_REF@[122; 123) - IDENT@[122; 123) "a" - WHITESPACE@[123; 124) " " - LTEQ@[124; 126) "<=" - WHITESPACE@[126; 127) " " - PATH_EXPR@[127; 128) - PATH@[127; 128) - PATH_SEGMENT@[127; 128) - NAME_REF@[127; 128) - IDENT@[127; 128) "b" - SEMI@[128; 129) ";" - WHITESPACE@[129; 134) "\n " - LET_STMT@[134; 149) - LET_KW@[134; 137) "let" - WHITESPACE@[137; 138) " " - PLACEHOLDER_PAT@[138; 139) - UNDERSCORE@[138; 139) "_" - WHITESPACE@[139; 140) " " - EQ@[140; 141) "=" - WHITESPACE@[141; 142) " " - BIN_EXPR@[142; 148) - PATH_EXPR@[142; 143) - PATH@[142; 143) - PATH_SEGMENT@[142; 143) - NAME_REF@[142; 143) - IDENT@[142; 143) "a" - WHITESPACE@[143; 144) " " - GTEQ@[144; 146) ">=" - WHITESPACE@[146; 147) " " - PATH_EXPR@[147; 148) - PATH@[147; 148) - PATH_SEGMENT@[147; 148) - NAME_REF@[147; 148) - IDENT@[147; 148) "b" - SEMI@[148; 149) ";" - WHITESPACE@[149; 150) "\n" - R_CURLY@[150; 151) "}" +SOURCE_FILE@0..151 + FUNCTION_DEF@0..151 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..7 + IDENT@3..7 "main" + PARAM_LIST@7..9 + L_PAREN@7..8 "(" + R_PAREN@8..9 ")" + WHITESPACE@9..10 " " + BLOCK_EXPR@10..151 + L_CURLY@10..11 "{" + WHITESPACE@11..16 "\n " + LET_STMT@16..31 + LET_KW@16..19 "let" + WHITESPACE@19..20 " " + PLACEHOLDER_PAT@20..21 + UNDERSCORE@20..21 "_" + WHITESPACE@21..22 " " + EQ@22..23 "=" + WHITESPACE@23..24 " " + BIN_EXPR@24..30 + PATH_EXPR@24..25 + PATH@24..25 + PATH_SEGMENT@24..25 + NAME_REF@24..25 + IDENT@24..25 "a" + WHITESPACE@25..26 " " + EQEQ@26..28 "==" + WHITESPACE@28..29 " " + PATH_EXPR@29..30 + PATH@29..30 + PATH_SEGMENT@29..30 + NAME_REF@29..30 + IDENT@29..30 "b" + SEMI@30..31 ";" + WHITESPACE@31..36 "\n " + LET_STMT@36..51 + LET_KW@36..39 "let" + WHITESPACE@39..40 " " + PLACEHOLDER_PAT@40..41 + UNDERSCORE@40..41 "_" + WHITESPACE@41..42 " " + EQ@42..43 "=" + WHITESPACE@43..44 " " + BIN_EXPR@44..50 + PATH_EXPR@44..45 + PATH@44..45 + PATH_SEGMENT@44..45 + NAME_REF@44..45 + IDENT@44..45 "a" + WHITESPACE@45..46 " " + EQEQ@46..48 "==" + WHITESPACE@48..49 " " + PATH_EXPR@49..50 + PATH@49..50 + PATH_SEGMENT@49..50 + NAME_REF@49..50 + IDENT@49..50 "b" + SEMI@50..51 ";" + WHITESPACE@51..56 "\n " + LET_STMT@56..71 + LET_KW@56..59 "let" + WHITESPACE@59..60 " " + PLACEHOLDER_PAT@60..61 + UNDERSCORE@60..61 "_" + WHITESPACE@61..62 " " + EQ@62..63 "=" + WHITESPACE@63..64 " " + BIN_EXPR@64..70 + PATH_EXPR@64..65 + PATH@64..65 + PATH_SEGMENT@64..65 + NAME_REF@64..65 + IDENT@64..65 "a" + WHITESPACE@65..66 " " + NEQ@66..68 "!=" + WHITESPACE@68..69 " " + PATH_EXPR@69..70 + PATH@69..70 + PATH_SEGMENT@69..70 + NAME_REF@69..70 + IDENT@69..70 "b" + SEMI@70..71 ";" + WHITESPACE@71..76 "\n " + LET_STMT@76..90 + LET_KW@76..79 "let" + WHITESPACE@79..80 " " + PLACEHOLDER_PAT@80..81 + UNDERSCORE@80..81 "_" + WHITESPACE@81..82 " " + EQ@82..83 "=" + WHITESPACE@83..84 " " + BIN_EXPR@84..89 + PATH_EXPR@84..85 + PATH@84..85 + PATH_SEGMENT@84..85 + NAME_REF@84..85 + IDENT@84..85 "a" + WHITESPACE@85..86 " " + LT@86..87 "<" + WHITESPACE@87..88 " " + PATH_EXPR@88..89 + PATH@88..89 + PATH_SEGMENT@88..89 + NAME_REF@88..89 + IDENT@88..89 "b" + SEMI@89..90 ";" + WHITESPACE@90..95 "\n " + LET_STMT@95..109 + LET_KW@95..98 "let" + WHITESPACE@98..99 " " + PLACEHOLDER_PAT@99..100 + UNDERSCORE@99..100 "_" + WHITESPACE@100..101 " " + EQ@101..102 "=" + WHITESPACE@102..103 " " + BIN_EXPR@103..108 + PATH_EXPR@103..104 + PATH@103..104 + PATH_SEGMENT@103..104 + NAME_REF@103..104 + IDENT@103..104 "a" + WHITESPACE@104..105 " " + GT@105..106 ">" + WHITESPACE@106..107 " " + PATH_EXPR@107..108 + PATH@107..108 + PATH_SEGMENT@107..108 + NAME_REF@107..108 + IDENT@107..108 "b" + SEMI@108..109 ";" + WHITESPACE@109..114 "\n " + LET_STMT@114..129 + LET_KW@114..117 "let" + WHITESPACE@117..118 " " + PLACEHOLDER_PAT@118..119 + UNDERSCORE@118..119 "_" + WHITESPACE@119..120 " " + EQ@120..121 "=" + WHITESPACE@121..122 " " + BIN_EXPR@122..128 + PATH_EXPR@122..123 + PATH@122..123 + PATH_SEGMENT@122..123 + NAME_REF@122..123 + IDENT@122..123 "a" + WHITESPACE@123..124 " " + LTEQ@124..126 "<=" + WHITESPACE@126..127 " " + PATH_EXPR@127..128 + PATH@127..128 + PATH_SEGMENT@127..128 + NAME_REF@127..128 + IDENT@127..128 "b" + SEMI@128..129 ";" + WHITESPACE@129..134 "\n " + LET_STMT@134..149 + LET_KW@134..137 "let" + WHITESPACE@137..138 " " + PLACEHOLDER_PAT@138..139 + UNDERSCORE@138..139 "_" + WHITESPACE@139..140 " " + EQ@140..141 "=" + WHITESPACE@141..142 " " + BIN_EXPR@142..148 + PATH_EXPR@142..143 + PATH@142..143 + PATH_SEGMENT@142..143 + NAME_REF@142..143 + IDENT@142..143 "a" + WHITESPACE@143..144 " " + GTEQ@144..146 ">=" + WHITESPACE@146..147 " " + PATH_EXPR@147..148 + PATH@147..148 + PATH_SEGMENT@147..148 + NAME_REF@147..148 + IDENT@147..148 "b" + SEMI@148..149 ";" + WHITESPACE@149..150 "\n" + R_CURLY@150..151 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__empty.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__empty.snap index 304328aac..bba39ffb2 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__empty.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__empty.snap @@ -2,5 +2,5 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "" --- -SOURCE_FILE@[0; 0) +SOURCE_FILE@0..0 diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__expression_statement.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__expression_statement.snap index 9fc56467f..495274804 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__expression_statement.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__expression_statement.snap @@ -2,97 +2,97 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n let a = \"hello\"\n let b = \"world\"\n let c\n b = \"Hello, world!\"\n !-5+2*(a+b);\n -3\n}" --- -SOURCE_FILE@[0; 110) - FUNCTION_DEF@[0; 110) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 110) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - LET_STMT@[15; 30) - LET_KW@[15; 18) "let" - WHITESPACE@[18; 19) " " - BIND_PAT@[19; 20) - NAME@[19; 20) - IDENT@[19; 20) "a" - WHITESPACE@[20; 21) " " - EQ@[21; 22) "=" - WHITESPACE@[22; 23) " " - LITERAL@[23; 30) - STRING@[23; 30) "\"hello\"" - WHITESPACE@[30; 35) "\n " - LET_STMT@[35; 50) - LET_KW@[35; 38) "let" - WHITESPACE@[38; 39) " " - BIND_PAT@[39; 40) - NAME@[39; 40) - IDENT@[39; 40) "b" - WHITESPACE@[40; 41) " " - EQ@[41; 42) "=" - WHITESPACE@[42; 43) " " - LITERAL@[43; 50) - STRING@[43; 50) "\"world\"" - WHITESPACE@[50; 55) "\n " - LET_STMT@[55; 60) - LET_KW@[55; 58) "let" - WHITESPACE@[58; 59) " " - BIND_PAT@[59; 60) - NAME@[59; 60) - IDENT@[59; 60) "c" - WHITESPACE@[60; 65) "\n " - EXPR_STMT@[65; 84) - BIN_EXPR@[65; 84) - PATH_EXPR@[65; 66) - PATH@[65; 66) - PATH_SEGMENT@[65; 66) - NAME_REF@[65; 66) - IDENT@[65; 66) "b" - WHITESPACE@[66; 67) " " - EQ@[67; 68) "=" - WHITESPACE@[68; 69) " " - LITERAL@[69; 84) - STRING@[69; 84) "\"Hello, world!\"" - WHITESPACE@[84; 89) "\n " - EXPR_STMT@[89; 101) - BIN_EXPR@[89; 100) - PREFIX_EXPR@[89; 92) - EXCLAMATION@[89; 90) "!" - PREFIX_EXPR@[90; 92) - MINUS@[90; 91) "-" - LITERAL@[91; 92) - INT_NUMBER@[91; 92) "5" - PLUS@[92; 93) "+" - BIN_EXPR@[93; 100) - LITERAL@[93; 94) - INT_NUMBER@[93; 94) "2" - STAR@[94; 95) "*" - PAREN_EXPR@[95; 100) - L_PAREN@[95; 96) "(" - BIN_EXPR@[96; 99) - PATH_EXPR@[96; 97) - PATH@[96; 97) - PATH_SEGMENT@[96; 97) - NAME_REF@[96; 97) - IDENT@[96; 97) "a" - PLUS@[97; 98) "+" - PATH_EXPR@[98; 99) - PATH@[98; 99) - PATH_SEGMENT@[98; 99) - NAME_REF@[98; 99) - IDENT@[98; 99) "b" - R_PAREN@[99; 100) ")" - SEMI@[100; 101) ";" - WHITESPACE@[101; 106) "\n " - PREFIX_EXPR@[106; 108) - MINUS@[106; 107) "-" - LITERAL@[107; 108) - INT_NUMBER@[107; 108) "3" - WHITESPACE@[108; 109) "\n" - R_CURLY@[109; 110) "}" +SOURCE_FILE@0..110 + FUNCTION_DEF@0..110 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..110 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + LET_STMT@15..30 + LET_KW@15..18 "let" + WHITESPACE@18..19 " " + BIND_PAT@19..20 + NAME@19..20 + IDENT@19..20 "a" + WHITESPACE@20..21 " " + EQ@21..22 "=" + WHITESPACE@22..23 " " + LITERAL@23..30 + STRING@23..30 "\"hello\"" + WHITESPACE@30..35 "\n " + LET_STMT@35..50 + LET_KW@35..38 "let" + WHITESPACE@38..39 " " + BIND_PAT@39..40 + NAME@39..40 + IDENT@39..40 "b" + WHITESPACE@40..41 " " + EQ@41..42 "=" + WHITESPACE@42..43 " " + LITERAL@43..50 + STRING@43..50 "\"world\"" + WHITESPACE@50..55 "\n " + LET_STMT@55..60 + LET_KW@55..58 "let" + WHITESPACE@58..59 " " + BIND_PAT@59..60 + NAME@59..60 + IDENT@59..60 "c" + WHITESPACE@60..65 "\n " + EXPR_STMT@65..84 + BIN_EXPR@65..84 + PATH_EXPR@65..66 + PATH@65..66 + PATH_SEGMENT@65..66 + NAME_REF@65..66 + IDENT@65..66 "b" + WHITESPACE@66..67 " " + EQ@67..68 "=" + WHITESPACE@68..69 " " + LITERAL@69..84 + STRING@69..84 "\"Hello, world!\"" + WHITESPACE@84..89 "\n " + EXPR_STMT@89..101 + BIN_EXPR@89..100 + PREFIX_EXPR@89..92 + EXCLAMATION@89..90 "!" + PREFIX_EXPR@90..92 + MINUS@90..91 "-" + LITERAL@91..92 + INT_NUMBER@91..92 "5" + PLUS@92..93 "+" + BIN_EXPR@93..100 + LITERAL@93..94 + INT_NUMBER@93..94 "2" + STAR@94..95 "*" + PAREN_EXPR@95..100 + L_PAREN@95..96 "(" + BIN_EXPR@96..99 + PATH_EXPR@96..97 + PATH@96..97 + PATH_SEGMENT@96..97 + NAME_REF@96..97 + IDENT@96..97 "a" + PLUS@97..98 "+" + PATH_EXPR@98..99 + PATH@98..99 + PATH_SEGMENT@98..99 + NAME_REF@98..99 + IDENT@98..99 "b" + R_PAREN@99..100 ")" + SEMI@100..101 ";" + WHITESPACE@101..106 "\n " + PREFIX_EXPR@106..108 + MINUS@106..107 "-" + LITERAL@107..108 + INT_NUMBER@107..108 "3" + WHITESPACE@108..109 "\n" + R_CURLY@109..110 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__extern_fn.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__extern_fn.snap index 9b1ff40da..b2627eb31 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__extern_fn.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__extern_fn.snap @@ -2,20 +2,20 @@ source: crates/mun_syntax/src/tests/parser.rs expression: pub extern fn foo(); --- -SOURCE_FILE@[0; 20) - FUNCTION_DEF@[0; 20) - VISIBILITY@[0; 3) - PUB_KW@[0; 3) "pub" - WHITESPACE@[3; 4) " " - EXTERN@[4; 10) - EXTERN_KW@[4; 10) "extern" - WHITESPACE@[10; 11) " " - FN_KW@[11; 13) "fn" - WHITESPACE@[13; 14) " " - NAME@[14; 17) - IDENT@[14; 17) "foo" - PARAM_LIST@[17; 19) - L_PAREN@[17; 18) "(" - R_PAREN@[18; 19) ")" - SEMI@[19; 20) ";" +SOURCE_FILE@0..20 + FUNCTION_DEF@0..20 + VISIBILITY@0..3 + PUB_KW@0..3 "pub" + WHITESPACE@3..4 " " + EXTERN@4..10 + EXTERN_KW@4..10 "extern" + WHITESPACE@10..11 " " + FN_KW@11..13 "fn" + WHITESPACE@13..14 " " + NAME@14..17 + IDENT@14..17 "foo" + PARAM_LIST@17..19 + L_PAREN@17..18 "(" + R_PAREN@18..19 ")" + SEMI@19..20 ";" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function.snap index b7550f942..5baf2547d 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function.snap @@ -2,110 +2,110 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "// Source file comment\n\n// Comment that belongs to the function\nfn a() {}\nfn b(value:number) {}\npub fn d() {}\npub fn c()->never {}\nfn b(value:number)->number {}" --- -SOURCE_FILE@[0; 160) - COMMENT@[0; 22) "// Source file comment" - WHITESPACE@[22; 24) "\n\n" - FUNCTION_DEF@[24; 73) - COMMENT@[24; 63) "// Comment that belon ..." - WHITESPACE@[63; 64) "\n" - FN_KW@[64; 66) "fn" - WHITESPACE@[66; 67) " " - NAME@[67; 68) - IDENT@[67; 68) "a" - PARAM_LIST@[68; 70) - L_PAREN@[68; 69) "(" - R_PAREN@[69; 70) ")" - WHITESPACE@[70; 71) " " - BLOCK_EXPR@[71; 73) - L_CURLY@[71; 72) "{" - R_CURLY@[72; 73) "}" - FUNCTION_DEF@[73; 95) - WHITESPACE@[73; 74) "\n" - FN_KW@[74; 76) "fn" - WHITESPACE@[76; 77) " " - NAME@[77; 78) - IDENT@[77; 78) "b" - PARAM_LIST@[78; 92) - L_PAREN@[78; 79) "(" - PARAM@[79; 91) - BIND_PAT@[79; 84) - NAME@[79; 84) - IDENT@[79; 84) "value" - COLON@[84; 85) ":" - PATH_TYPE@[85; 91) - PATH@[85; 91) - PATH_SEGMENT@[85; 91) - NAME_REF@[85; 91) - IDENT@[85; 91) "number" - R_PAREN@[91; 92) ")" - WHITESPACE@[92; 93) " " - BLOCK_EXPR@[93; 95) - L_CURLY@[93; 94) "{" - R_CURLY@[94; 95) "}" - FUNCTION_DEF@[95; 109) - WHITESPACE@[95; 96) "\n" - VISIBILITY@[96; 99) - PUB_KW@[96; 99) "pub" - WHITESPACE@[99; 100) " " - FN_KW@[100; 102) "fn" - WHITESPACE@[102; 103) " " - NAME@[103; 104) - IDENT@[103; 104) "d" - PARAM_LIST@[104; 106) - L_PAREN@[104; 105) "(" - R_PAREN@[105; 106) ")" - WHITESPACE@[106; 107) " " - BLOCK_EXPR@[107; 109) - L_CURLY@[107; 108) "{" - R_CURLY@[108; 109) "}" - FUNCTION_DEF@[109; 130) - WHITESPACE@[109; 110) "\n" - VISIBILITY@[110; 113) - PUB_KW@[110; 113) "pub" - WHITESPACE@[113; 114) " " - FN_KW@[114; 116) "fn" - WHITESPACE@[116; 117) " " - NAME@[117; 118) - IDENT@[117; 118) "c" - PARAM_LIST@[118; 120) - L_PAREN@[118; 119) "(" - R_PAREN@[119; 120) ")" - RET_TYPE@[120; 127) - THIN_ARROW@[120; 122) "->" - NEVER_TYPE@[122; 127) - NEVER_KW@[122; 127) "never" - WHITESPACE@[127; 128) " " - BLOCK_EXPR@[128; 130) - L_CURLY@[128; 129) "{" - R_CURLY@[129; 130) "}" - FUNCTION_DEF@[130; 160) - WHITESPACE@[130; 131) "\n" - FN_KW@[131; 133) "fn" - WHITESPACE@[133; 134) " " - NAME@[134; 135) - IDENT@[134; 135) "b" - PARAM_LIST@[135; 149) - L_PAREN@[135; 136) "(" - PARAM@[136; 148) - BIND_PAT@[136; 141) - NAME@[136; 141) - IDENT@[136; 141) "value" - COLON@[141; 142) ":" - PATH_TYPE@[142; 148) - PATH@[142; 148) - PATH_SEGMENT@[142; 148) - NAME_REF@[142; 148) - IDENT@[142; 148) "number" - R_PAREN@[148; 149) ")" - RET_TYPE@[149; 157) - THIN_ARROW@[149; 151) "->" - PATH_TYPE@[151; 157) - PATH@[151; 157) - PATH_SEGMENT@[151; 157) - NAME_REF@[151; 157) - IDENT@[151; 157) "number" - WHITESPACE@[157; 158) " " - BLOCK_EXPR@[158; 160) - L_CURLY@[158; 159) "{" - R_CURLY@[159; 160) "}" +SOURCE_FILE@0..160 + COMMENT@0..22 "// Source file comment" + WHITESPACE@22..24 "\n\n" + FUNCTION_DEF@24..73 + COMMENT@24..63 "// Comment that belon ..." + WHITESPACE@63..64 "\n" + FN_KW@64..66 "fn" + WHITESPACE@66..67 " " + NAME@67..68 + IDENT@67..68 "a" + PARAM_LIST@68..70 + L_PAREN@68..69 "(" + R_PAREN@69..70 ")" + WHITESPACE@70..71 " " + BLOCK_EXPR@71..73 + L_CURLY@71..72 "{" + R_CURLY@72..73 "}" + FUNCTION_DEF@73..95 + WHITESPACE@73..74 "\n" + FN_KW@74..76 "fn" + WHITESPACE@76..77 " " + NAME@77..78 + IDENT@77..78 "b" + PARAM_LIST@78..92 + L_PAREN@78..79 "(" + PARAM@79..91 + BIND_PAT@79..84 + NAME@79..84 + IDENT@79..84 "value" + COLON@84..85 ":" + PATH_TYPE@85..91 + PATH@85..91 + PATH_SEGMENT@85..91 + NAME_REF@85..91 + IDENT@85..91 "number" + R_PAREN@91..92 ")" + WHITESPACE@92..93 " " + BLOCK_EXPR@93..95 + L_CURLY@93..94 "{" + R_CURLY@94..95 "}" + FUNCTION_DEF@95..109 + WHITESPACE@95..96 "\n" + VISIBILITY@96..99 + PUB_KW@96..99 "pub" + WHITESPACE@99..100 " " + FN_KW@100..102 "fn" + WHITESPACE@102..103 " " + NAME@103..104 + IDENT@103..104 "d" + PARAM_LIST@104..106 + L_PAREN@104..105 "(" + R_PAREN@105..106 ")" + WHITESPACE@106..107 " " + BLOCK_EXPR@107..109 + L_CURLY@107..108 "{" + R_CURLY@108..109 "}" + FUNCTION_DEF@109..130 + WHITESPACE@109..110 "\n" + VISIBILITY@110..113 + PUB_KW@110..113 "pub" + WHITESPACE@113..114 " " + FN_KW@114..116 "fn" + WHITESPACE@116..117 " " + NAME@117..118 + IDENT@117..118 "c" + PARAM_LIST@118..120 + L_PAREN@118..119 "(" + R_PAREN@119..120 ")" + RET_TYPE@120..127 + THIN_ARROW@120..122 "->" + NEVER_TYPE@122..127 + NEVER_KW@122..127 "never" + WHITESPACE@127..128 " " + BLOCK_EXPR@128..130 + L_CURLY@128..129 "{" + R_CURLY@129..130 "}" + FUNCTION_DEF@130..160 + WHITESPACE@130..131 "\n" + FN_KW@131..133 "fn" + WHITESPACE@133..134 " " + NAME@134..135 + IDENT@134..135 "b" + PARAM_LIST@135..149 + L_PAREN@135..136 "(" + PARAM@136..148 + BIND_PAT@136..141 + NAME@136..141 + IDENT@136..141 "value" + COLON@141..142 ":" + PATH_TYPE@142..148 + PATH@142..148 + PATH_SEGMENT@142..148 + NAME_REF@142..148 + IDENT@142..148 "number" + R_PAREN@148..149 ")" + RET_TYPE@149..157 + THIN_ARROW@149..151 "->" + PATH_TYPE@151..157 + PATH@151..157 + PATH_SEGMENT@151..157 + NAME_REF@151..157 + IDENT@151..157 "number" + WHITESPACE@157..158 " " + BLOCK_EXPR@158..160 + L_CURLY@158..159 "{" + R_CURLY@159..160 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function_calls.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function_calls.snap index 8e9d7e94e..412745ff8 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function_calls.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function_calls.snap @@ -2,71 +2,71 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn bar(i:number) { }\nfn foo(i:number) {\n bar(i+1)\n}" --- -SOURCE_FILE@[0; 52) - FUNCTION_DEF@[0; 20) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "bar" - PARAM_LIST@[6; 16) - L_PAREN@[6; 7) "(" - PARAM@[7; 15) - BIND_PAT@[7; 8) - NAME@[7; 8) - IDENT@[7; 8) "i" - COLON@[8; 9) ":" - PATH_TYPE@[9; 15) - PATH@[9; 15) - PATH_SEGMENT@[9; 15) - NAME_REF@[9; 15) - IDENT@[9; 15) "number" - R_PAREN@[15; 16) ")" - WHITESPACE@[16; 17) " " - BLOCK_EXPR@[17; 20) - L_CURLY@[17; 18) "{" - WHITESPACE@[18; 19) " " - R_CURLY@[19; 20) "}" - FUNCTION_DEF@[20; 52) - WHITESPACE@[20; 21) "\n" - FN_KW@[21; 23) "fn" - WHITESPACE@[23; 24) " " - NAME@[24; 27) - IDENT@[24; 27) "foo" - PARAM_LIST@[27; 37) - L_PAREN@[27; 28) "(" - PARAM@[28; 36) - BIND_PAT@[28; 29) - NAME@[28; 29) - IDENT@[28; 29) "i" - COLON@[29; 30) ":" - PATH_TYPE@[30; 36) - PATH@[30; 36) - PATH_SEGMENT@[30; 36) - NAME_REF@[30; 36) - IDENT@[30; 36) "number" - R_PAREN@[36; 37) ")" - WHITESPACE@[37; 38) " " - BLOCK_EXPR@[38; 52) - L_CURLY@[38; 39) "{" - WHITESPACE@[39; 42) "\n " - CALL_EXPR@[42; 50) - PATH_EXPR@[42; 45) - PATH@[42; 45) - PATH_SEGMENT@[42; 45) - NAME_REF@[42; 45) - IDENT@[42; 45) "bar" - ARG_LIST@[45; 50) - L_PAREN@[45; 46) "(" - BIN_EXPR@[46; 49) - PATH_EXPR@[46; 47) - PATH@[46; 47) - PATH_SEGMENT@[46; 47) - NAME_REF@[46; 47) - IDENT@[46; 47) "i" - PLUS@[47; 48) "+" - LITERAL@[48; 49) - INT_NUMBER@[48; 49) "1" - R_PAREN@[49; 50) ")" - WHITESPACE@[50; 51) "\n" - R_CURLY@[51; 52) "}" +SOURCE_FILE@0..52 + FUNCTION_DEF@0..20 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "bar" + PARAM_LIST@6..16 + L_PAREN@6..7 "(" + PARAM@7..15 + BIND_PAT@7..8 + NAME@7..8 + IDENT@7..8 "i" + COLON@8..9 ":" + PATH_TYPE@9..15 + PATH@9..15 + PATH_SEGMENT@9..15 + NAME_REF@9..15 + IDENT@9..15 "number" + R_PAREN@15..16 ")" + WHITESPACE@16..17 " " + BLOCK_EXPR@17..20 + L_CURLY@17..18 "{" + WHITESPACE@18..19 " " + R_CURLY@19..20 "}" + FUNCTION_DEF@20..52 + WHITESPACE@20..21 "\n" + FN_KW@21..23 "fn" + WHITESPACE@23..24 " " + NAME@24..27 + IDENT@24..27 "foo" + PARAM_LIST@27..37 + L_PAREN@27..28 "(" + PARAM@28..36 + BIND_PAT@28..29 + NAME@28..29 + IDENT@28..29 "i" + COLON@29..30 ":" + PATH_TYPE@30..36 + PATH@30..36 + PATH_SEGMENT@30..36 + NAME_REF@30..36 + IDENT@30..36 "number" + R_PAREN@36..37 ")" + WHITESPACE@37..38 " " + BLOCK_EXPR@38..52 + L_CURLY@38..39 "{" + WHITESPACE@39..42 "\n " + CALL_EXPR@42..50 + PATH_EXPR@42..45 + PATH@42..45 + PATH_SEGMENT@42..45 + NAME_REF@42..45 + IDENT@42..45 "bar" + ARG_LIST@45..50 + L_PAREN@45..46 "(" + BIN_EXPR@46..49 + PATH_EXPR@46..47 + PATH@46..47 + PATH_SEGMENT@46..47 + NAME_REF@46..47 + IDENT@46..47 "i" + PLUS@47..48 "+" + LITERAL@48..49 + INT_NUMBER@48..49 "1" + R_PAREN@49..50 ")" + WHITESPACE@50..51 "\n" + R_CURLY@51..52 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function_return_path.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function_return_path.snap index 70e13f730..ae229a0b0 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function_return_path.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__function_return_path.snap @@ -2,113 +2,113 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn main() -> self::Foo {}\n fn main1() -> super::Foo {}\n fn main2() -> package::Foo {}\n fn main3() -> package::foo::Foo {}" --- -SOURCE_FILE@[0; 130) - FUNCTION_DEF@[0; 25) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 7) - IDENT@[3; 7) "main" - PARAM_LIST@[7; 9) - L_PAREN@[7; 8) "(" - R_PAREN@[8; 9) ")" - WHITESPACE@[9; 10) " " - RET_TYPE@[10; 22) - THIN_ARROW@[10; 12) "->" - WHITESPACE@[12; 13) " " - PATH_TYPE@[13; 22) - PATH@[13; 22) - PATH@[13; 17) - PATH_SEGMENT@[13; 17) - SELF_KW@[13; 17) "self" - COLONCOLON@[17; 19) "::" - PATH_SEGMENT@[19; 22) - NAME_REF@[19; 22) - IDENT@[19; 22) "Foo" - WHITESPACE@[22; 23) " " - BLOCK_EXPR@[23; 25) - L_CURLY@[23; 24) "{" - R_CURLY@[24; 25) "}" - FUNCTION_DEF@[25; 57) - WHITESPACE@[25; 30) "\n " - FN_KW@[30; 32) "fn" - WHITESPACE@[32; 33) " " - NAME@[33; 38) - IDENT@[33; 38) "main1" - PARAM_LIST@[38; 40) - L_PAREN@[38; 39) "(" - R_PAREN@[39; 40) ")" - WHITESPACE@[40; 41) " " - RET_TYPE@[41; 54) - THIN_ARROW@[41; 43) "->" - WHITESPACE@[43; 44) " " - PATH_TYPE@[44; 54) - PATH@[44; 54) - PATH@[44; 49) - PATH_SEGMENT@[44; 49) - SUPER_KW@[44; 49) "super" - COLONCOLON@[49; 51) "::" - PATH_SEGMENT@[51; 54) - NAME_REF@[51; 54) - IDENT@[51; 54) "Foo" - WHITESPACE@[54; 55) " " - BLOCK_EXPR@[55; 57) - L_CURLY@[55; 56) "{" - R_CURLY@[56; 57) "}" - FUNCTION_DEF@[57; 91) - WHITESPACE@[57; 62) "\n " - FN_KW@[62; 64) "fn" - WHITESPACE@[64; 65) " " - NAME@[65; 70) - IDENT@[65; 70) "main2" - PARAM_LIST@[70; 72) - L_PAREN@[70; 71) "(" - R_PAREN@[71; 72) ")" - WHITESPACE@[72; 73) " " - RET_TYPE@[73; 88) - THIN_ARROW@[73; 75) "->" - WHITESPACE@[75; 76) " " - PATH_TYPE@[76; 88) - PATH@[76; 88) - PATH@[76; 83) - PATH_SEGMENT@[76; 83) - PACKAGE_KW@[76; 83) "package" - COLONCOLON@[83; 85) "::" - PATH_SEGMENT@[85; 88) - NAME_REF@[85; 88) - IDENT@[85; 88) "Foo" - WHITESPACE@[88; 89) " " - BLOCK_EXPR@[89; 91) - L_CURLY@[89; 90) "{" - R_CURLY@[90; 91) "}" - FUNCTION_DEF@[91; 130) - WHITESPACE@[91; 96) "\n " - FN_KW@[96; 98) "fn" - WHITESPACE@[98; 99) " " - NAME@[99; 104) - IDENT@[99; 104) "main3" - PARAM_LIST@[104; 106) - L_PAREN@[104; 105) "(" - R_PAREN@[105; 106) ")" - WHITESPACE@[106; 107) " " - RET_TYPE@[107; 127) - THIN_ARROW@[107; 109) "->" - WHITESPACE@[109; 110) " " - PATH_TYPE@[110; 127) - PATH@[110; 127) - PATH@[110; 122) - PATH@[110; 117) - PATH_SEGMENT@[110; 117) - PACKAGE_KW@[110; 117) "package" - COLONCOLON@[117; 119) "::" - PATH_SEGMENT@[119; 122) - NAME_REF@[119; 122) - IDENT@[119; 122) "foo" - COLONCOLON@[122; 124) "::" - PATH_SEGMENT@[124; 127) - NAME_REF@[124; 127) - IDENT@[124; 127) "Foo" - WHITESPACE@[127; 128) " " - BLOCK_EXPR@[128; 130) - L_CURLY@[128; 129) "{" - R_CURLY@[129; 130) "}" +SOURCE_FILE@0..130 + FUNCTION_DEF@0..25 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..7 + IDENT@3..7 "main" + PARAM_LIST@7..9 + L_PAREN@7..8 "(" + R_PAREN@8..9 ")" + WHITESPACE@9..10 " " + RET_TYPE@10..22 + THIN_ARROW@10..12 "->" + WHITESPACE@12..13 " " + PATH_TYPE@13..22 + PATH@13..22 + PATH@13..17 + PATH_SEGMENT@13..17 + SELF_KW@13..17 "self" + COLONCOLON@17..19 "::" + PATH_SEGMENT@19..22 + NAME_REF@19..22 + IDENT@19..22 "Foo" + WHITESPACE@22..23 " " + BLOCK_EXPR@23..25 + L_CURLY@23..24 "{" + R_CURLY@24..25 "}" + FUNCTION_DEF@25..57 + WHITESPACE@25..30 "\n " + FN_KW@30..32 "fn" + WHITESPACE@32..33 " " + NAME@33..38 + IDENT@33..38 "main1" + PARAM_LIST@38..40 + L_PAREN@38..39 "(" + R_PAREN@39..40 ")" + WHITESPACE@40..41 " " + RET_TYPE@41..54 + THIN_ARROW@41..43 "->" + WHITESPACE@43..44 " " + PATH_TYPE@44..54 + PATH@44..54 + PATH@44..49 + PATH_SEGMENT@44..49 + SUPER_KW@44..49 "super" + COLONCOLON@49..51 "::" + PATH_SEGMENT@51..54 + NAME_REF@51..54 + IDENT@51..54 "Foo" + WHITESPACE@54..55 " " + BLOCK_EXPR@55..57 + L_CURLY@55..56 "{" + R_CURLY@56..57 "}" + FUNCTION_DEF@57..91 + WHITESPACE@57..62 "\n " + FN_KW@62..64 "fn" + WHITESPACE@64..65 " " + NAME@65..70 + IDENT@65..70 "main2" + PARAM_LIST@70..72 + L_PAREN@70..71 "(" + R_PAREN@71..72 ")" + WHITESPACE@72..73 " " + RET_TYPE@73..88 + THIN_ARROW@73..75 "->" + WHITESPACE@75..76 " " + PATH_TYPE@76..88 + PATH@76..88 + PATH@76..83 + PATH_SEGMENT@76..83 + PACKAGE_KW@76..83 "package" + COLONCOLON@83..85 "::" + PATH_SEGMENT@85..88 + NAME_REF@85..88 + IDENT@85..88 "Foo" + WHITESPACE@88..89 " " + BLOCK_EXPR@89..91 + L_CURLY@89..90 "{" + R_CURLY@90..91 "}" + FUNCTION_DEF@91..130 + WHITESPACE@91..96 "\n " + FN_KW@96..98 "fn" + WHITESPACE@98..99 " " + NAME@99..104 + IDENT@99..104 "main3" + PARAM_LIST@104..106 + L_PAREN@104..105 "(" + R_PAREN@105..106 ")" + WHITESPACE@106..107 " " + RET_TYPE@107..127 + THIN_ARROW@107..109 "->" + WHITESPACE@109..110 " " + PATH_TYPE@110..127 + PATH@110..127 + PATH@110..122 + PATH@110..117 + PATH_SEGMENT@110..117 + PACKAGE_KW@110..117 "package" + COLONCOLON@117..119 "::" + PATH_SEGMENT@119..122 + NAME_REF@119..122 + IDENT@119..122 "foo" + COLONCOLON@122..124 "::" + PATH_SEGMENT@124..127 + NAME_REF@124..127 + IDENT@124..127 "Foo" + WHITESPACE@127..128 " " + BLOCK_EXPR@128..130 + L_CURLY@128..129 "{" + R_CURLY@129..130 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__if_expr.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__if_expr.snap index accca1415..dd3d6d71d 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__if_expr.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__if_expr.snap @@ -2,102 +2,102 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn bar() {\n if true {};\n if true {} else {};\n if true {} else if false {} else {};\n if {true} {} else {}\n}" --- -SOURCE_FILE@[0; 118) - FUNCTION_DEF@[0; 118) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "bar" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 118) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - EXPR_STMT@[15; 26) - IF_EXPR@[15; 25) - IF_KW@[15; 17) "if" - WHITESPACE@[17; 18) " " - CONDITION@[18; 22) - LITERAL@[18; 22) - TRUE_KW@[18; 22) "true" - WHITESPACE@[22; 23) " " - BLOCK_EXPR@[23; 25) - L_CURLY@[23; 24) "{" - R_CURLY@[24; 25) "}" - SEMI@[25; 26) ";" - WHITESPACE@[26; 31) "\n " - EXPR_STMT@[31; 50) - IF_EXPR@[31; 49) - IF_KW@[31; 33) "if" - WHITESPACE@[33; 34) " " - CONDITION@[34; 38) - LITERAL@[34; 38) - TRUE_KW@[34; 38) "true" - WHITESPACE@[38; 39) " " - BLOCK_EXPR@[39; 41) - L_CURLY@[39; 40) "{" - R_CURLY@[40; 41) "}" - WHITESPACE@[41; 42) " " - ELSE_KW@[42; 46) "else" - WHITESPACE@[46; 47) " " - BLOCK_EXPR@[47; 49) - L_CURLY@[47; 48) "{" - R_CURLY@[48; 49) "}" - SEMI@[49; 50) ";" - WHITESPACE@[50; 55) "\n " - EXPR_STMT@[55; 91) - IF_EXPR@[55; 90) - IF_KW@[55; 57) "if" - WHITESPACE@[57; 58) " " - CONDITION@[58; 62) - LITERAL@[58; 62) - TRUE_KW@[58; 62) "true" - WHITESPACE@[62; 63) " " - BLOCK_EXPR@[63; 65) - L_CURLY@[63; 64) "{" - R_CURLY@[64; 65) "}" - WHITESPACE@[65; 66) " " - ELSE_KW@[66; 70) "else" - WHITESPACE@[70; 71) " " - IF_EXPR@[71; 90) - IF_KW@[71; 73) "if" - WHITESPACE@[73; 74) " " - CONDITION@[74; 79) - LITERAL@[74; 79) - FALSE_KW@[74; 79) "false" - WHITESPACE@[79; 80) " " - BLOCK_EXPR@[80; 82) - L_CURLY@[80; 81) "{" - R_CURLY@[81; 82) "}" - WHITESPACE@[82; 83) " " - ELSE_KW@[83; 87) "else" - WHITESPACE@[87; 88) " " - BLOCK_EXPR@[88; 90) - L_CURLY@[88; 89) "{" - R_CURLY@[89; 90) "}" - SEMI@[90; 91) ";" - WHITESPACE@[91; 96) "\n " - IF_EXPR@[96; 116) - IF_KW@[96; 98) "if" - WHITESPACE@[98; 99) " " - CONDITION@[99; 105) - BLOCK_EXPR@[99; 105) - L_CURLY@[99; 100) "{" - LITERAL@[100; 104) - TRUE_KW@[100; 104) "true" - R_CURLY@[104; 105) "}" - WHITESPACE@[105; 106) " " - BLOCK_EXPR@[106; 108) - L_CURLY@[106; 107) "{" - R_CURLY@[107; 108) "}" - WHITESPACE@[108; 109) " " - ELSE_KW@[109; 113) "else" - WHITESPACE@[113; 114) " " - BLOCK_EXPR@[114; 116) - L_CURLY@[114; 115) "{" - R_CURLY@[115; 116) "}" - WHITESPACE@[116; 117) "\n" - R_CURLY@[117; 118) "}" +SOURCE_FILE@0..118 + FUNCTION_DEF@0..118 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "bar" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..118 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + EXPR_STMT@15..26 + IF_EXPR@15..25 + IF_KW@15..17 "if" + WHITESPACE@17..18 " " + CONDITION@18..22 + LITERAL@18..22 + TRUE_KW@18..22 "true" + WHITESPACE@22..23 " " + BLOCK_EXPR@23..25 + L_CURLY@23..24 "{" + R_CURLY@24..25 "}" + SEMI@25..26 ";" + WHITESPACE@26..31 "\n " + EXPR_STMT@31..50 + IF_EXPR@31..49 + IF_KW@31..33 "if" + WHITESPACE@33..34 " " + CONDITION@34..38 + LITERAL@34..38 + TRUE_KW@34..38 "true" + WHITESPACE@38..39 " " + BLOCK_EXPR@39..41 + L_CURLY@39..40 "{" + R_CURLY@40..41 "}" + WHITESPACE@41..42 " " + ELSE_KW@42..46 "else" + WHITESPACE@46..47 " " + BLOCK_EXPR@47..49 + L_CURLY@47..48 "{" + R_CURLY@48..49 "}" + SEMI@49..50 ";" + WHITESPACE@50..55 "\n " + EXPR_STMT@55..91 + IF_EXPR@55..90 + IF_KW@55..57 "if" + WHITESPACE@57..58 " " + CONDITION@58..62 + LITERAL@58..62 + TRUE_KW@58..62 "true" + WHITESPACE@62..63 " " + BLOCK_EXPR@63..65 + L_CURLY@63..64 "{" + R_CURLY@64..65 "}" + WHITESPACE@65..66 " " + ELSE_KW@66..70 "else" + WHITESPACE@70..71 " " + IF_EXPR@71..90 + IF_KW@71..73 "if" + WHITESPACE@73..74 " " + CONDITION@74..79 + LITERAL@74..79 + FALSE_KW@74..79 "false" + WHITESPACE@79..80 " " + BLOCK_EXPR@80..82 + L_CURLY@80..81 "{" + R_CURLY@81..82 "}" + WHITESPACE@82..83 " " + ELSE_KW@83..87 "else" + WHITESPACE@87..88 " " + BLOCK_EXPR@88..90 + L_CURLY@88..89 "{" + R_CURLY@89..90 "}" + SEMI@90..91 ";" + WHITESPACE@91..96 "\n " + IF_EXPR@96..116 + IF_KW@96..98 "if" + WHITESPACE@98..99 " " + CONDITION@99..105 + BLOCK_EXPR@99..105 + L_CURLY@99..100 "{" + LITERAL@100..104 + TRUE_KW@100..104 "true" + R_CURLY@104..105 "}" + WHITESPACE@105..106 " " + BLOCK_EXPR@106..108 + L_CURLY@106..107 "{" + R_CURLY@107..108 "}" + WHITESPACE@108..109 " " + ELSE_KW@109..113 "else" + WHITESPACE@113..114 " " + BLOCK_EXPR@114..116 + L_CURLY@114..115 "{" + R_CURLY@115..116 "}" + WHITESPACE@116..117 "\n" + R_CURLY@117..118 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__literals.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__literals.snap index 2f8d223a7..586af60e5 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__literals.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__literals.snap @@ -2,82 +2,82 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n let a = true;\n let b = false;\n let c = 1;\n let d = 1.12;\n let e = \"Hello, world!\"\n}" --- -SOURCE_FILE@[0; 110) - FUNCTION_DEF@[0; 110) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 110) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - LET_STMT@[15; 28) - LET_KW@[15; 18) "let" - WHITESPACE@[18; 19) " " - BIND_PAT@[19; 20) - NAME@[19; 20) - IDENT@[19; 20) "a" - WHITESPACE@[20; 21) " " - EQ@[21; 22) "=" - WHITESPACE@[22; 23) " " - LITERAL@[23; 27) - TRUE_KW@[23; 27) "true" - SEMI@[27; 28) ";" - WHITESPACE@[28; 33) "\n " - LET_STMT@[33; 47) - LET_KW@[33; 36) "let" - WHITESPACE@[36; 37) " " - BIND_PAT@[37; 38) - NAME@[37; 38) - IDENT@[37; 38) "b" - WHITESPACE@[38; 39) " " - EQ@[39; 40) "=" - WHITESPACE@[40; 41) " " - LITERAL@[41; 46) - FALSE_KW@[41; 46) "false" - SEMI@[46; 47) ";" - WHITESPACE@[47; 52) "\n " - LET_STMT@[52; 62) - LET_KW@[52; 55) "let" - WHITESPACE@[55; 56) " " - BIND_PAT@[56; 57) - NAME@[56; 57) - IDENT@[56; 57) "c" - WHITESPACE@[57; 58) " " - EQ@[58; 59) "=" - WHITESPACE@[59; 60) " " - LITERAL@[60; 61) - INT_NUMBER@[60; 61) "1" - SEMI@[61; 62) ";" - WHITESPACE@[62; 67) "\n " - LET_STMT@[67; 80) - LET_KW@[67; 70) "let" - WHITESPACE@[70; 71) " " - BIND_PAT@[71; 72) - NAME@[71; 72) - IDENT@[71; 72) "d" - WHITESPACE@[72; 73) " " - EQ@[73; 74) "=" - WHITESPACE@[74; 75) " " - LITERAL@[75; 79) - FLOAT_NUMBER@[75; 79) "1.12" - SEMI@[79; 80) ";" - WHITESPACE@[80; 85) "\n " - LET_STMT@[85; 108) - LET_KW@[85; 88) "let" - WHITESPACE@[88; 89) " " - BIND_PAT@[89; 90) - NAME@[89; 90) - IDENT@[89; 90) "e" - WHITESPACE@[90; 91) " " - EQ@[91; 92) "=" - WHITESPACE@[92; 93) " " - LITERAL@[93; 108) - STRING@[93; 108) "\"Hello, world!\"" - WHITESPACE@[108; 109) "\n" - R_CURLY@[109; 110) "}" +SOURCE_FILE@0..110 + FUNCTION_DEF@0..110 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..110 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + LET_STMT@15..28 + LET_KW@15..18 "let" + WHITESPACE@18..19 " " + BIND_PAT@19..20 + NAME@19..20 + IDENT@19..20 "a" + WHITESPACE@20..21 " " + EQ@21..22 "=" + WHITESPACE@22..23 " " + LITERAL@23..27 + TRUE_KW@23..27 "true" + SEMI@27..28 ";" + WHITESPACE@28..33 "\n " + LET_STMT@33..47 + LET_KW@33..36 "let" + WHITESPACE@36..37 " " + BIND_PAT@37..38 + NAME@37..38 + IDENT@37..38 "b" + WHITESPACE@38..39 " " + EQ@39..40 "=" + WHITESPACE@40..41 " " + LITERAL@41..46 + FALSE_KW@41..46 "false" + SEMI@46..47 ";" + WHITESPACE@47..52 "\n " + LET_STMT@52..62 + LET_KW@52..55 "let" + WHITESPACE@55..56 " " + BIND_PAT@56..57 + NAME@56..57 + IDENT@56..57 "c" + WHITESPACE@57..58 " " + EQ@58..59 "=" + WHITESPACE@59..60 " " + LITERAL@60..61 + INT_NUMBER@60..61 "1" + SEMI@61..62 ";" + WHITESPACE@62..67 "\n " + LET_STMT@67..80 + LET_KW@67..70 "let" + WHITESPACE@70..71 " " + BIND_PAT@71..72 + NAME@71..72 + IDENT@71..72 "d" + WHITESPACE@72..73 " " + EQ@73..74 "=" + WHITESPACE@74..75 " " + LITERAL@75..79 + FLOAT_NUMBER@75..79 "1.12" + SEMI@79..80 ";" + WHITESPACE@80..85 "\n " + LET_STMT@85..108 + LET_KW@85..88 "let" + WHITESPACE@88..89 " " + BIND_PAT@89..90 + NAME@89..90 + IDENT@89..90 "e" + WHITESPACE@90..91 " " + EQ@91..92 "=" + WHITESPACE@92..93 " " + LITERAL@93..108 + STRING@93..108 "\"Hello, world!\"" + WHITESPACE@108..109 "\n" + R_CURLY@109..110 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__logic_operands.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__logic_operands.snap index 45c23a370..905e79c8c 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__logic_operands.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__logic_operands.snap @@ -2,66 +2,66 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn main() {\n let _ = a || b;\n let _ = a && b;\n}" --- -SOURCE_FILE@[0; 53) - FUNCTION_DEF@[0; 53) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 7) - IDENT@[3; 7) "main" - PARAM_LIST@[7; 9) - L_PAREN@[7; 8) "(" - R_PAREN@[8; 9) ")" - WHITESPACE@[9; 10) " " - BLOCK_EXPR@[10; 53) - L_CURLY@[10; 11) "{" - WHITESPACE@[11; 16) "\n " - LET_STMT@[16; 31) - LET_KW@[16; 19) "let" - WHITESPACE@[19; 20) " " - PLACEHOLDER_PAT@[20; 21) - UNDERSCORE@[20; 21) "_" - WHITESPACE@[21; 22) " " - EQ@[22; 23) "=" - WHITESPACE@[23; 24) " " - BIN_EXPR@[24; 30) - PATH_EXPR@[24; 25) - PATH@[24; 25) - PATH_SEGMENT@[24; 25) - NAME_REF@[24; 25) - IDENT@[24; 25) "a" - WHITESPACE@[25; 26) " " - PIPEPIPE@[26; 28) "||" - WHITESPACE@[28; 29) " " - PATH_EXPR@[29; 30) - PATH@[29; 30) - PATH_SEGMENT@[29; 30) - NAME_REF@[29; 30) - IDENT@[29; 30) "b" - SEMI@[30; 31) ";" - WHITESPACE@[31; 36) "\n " - LET_STMT@[36; 51) - LET_KW@[36; 39) "let" - WHITESPACE@[39; 40) " " - PLACEHOLDER_PAT@[40; 41) - UNDERSCORE@[40; 41) "_" - WHITESPACE@[41; 42) " " - EQ@[42; 43) "=" - WHITESPACE@[43; 44) " " - BIN_EXPR@[44; 50) - PATH_EXPR@[44; 45) - PATH@[44; 45) - PATH_SEGMENT@[44; 45) - NAME_REF@[44; 45) - IDENT@[44; 45) "a" - WHITESPACE@[45; 46) " " - AMPAMP@[46; 48) "&&" - WHITESPACE@[48; 49) " " - PATH_EXPR@[49; 50) - PATH@[49; 50) - PATH_SEGMENT@[49; 50) - NAME_REF@[49; 50) - IDENT@[49; 50) "b" - SEMI@[50; 51) ";" - WHITESPACE@[51; 52) "\n" - R_CURLY@[52; 53) "}" +SOURCE_FILE@0..53 + FUNCTION_DEF@0..53 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..7 + IDENT@3..7 "main" + PARAM_LIST@7..9 + L_PAREN@7..8 "(" + R_PAREN@8..9 ")" + WHITESPACE@9..10 " " + BLOCK_EXPR@10..53 + L_CURLY@10..11 "{" + WHITESPACE@11..16 "\n " + LET_STMT@16..31 + LET_KW@16..19 "let" + WHITESPACE@19..20 " " + PLACEHOLDER_PAT@20..21 + UNDERSCORE@20..21 "_" + WHITESPACE@21..22 " " + EQ@22..23 "=" + WHITESPACE@23..24 " " + BIN_EXPR@24..30 + PATH_EXPR@24..25 + PATH@24..25 + PATH_SEGMENT@24..25 + NAME_REF@24..25 + IDENT@24..25 "a" + WHITESPACE@25..26 " " + PIPEPIPE@26..28 "||" + WHITESPACE@28..29 " " + PATH_EXPR@29..30 + PATH@29..30 + PATH_SEGMENT@29..30 + NAME_REF@29..30 + IDENT@29..30 "b" + SEMI@30..31 ";" + WHITESPACE@31..36 "\n " + LET_STMT@36..51 + LET_KW@36..39 "let" + WHITESPACE@39..40 " " + PLACEHOLDER_PAT@40..41 + UNDERSCORE@40..41 "_" + WHITESPACE@41..42 " " + EQ@42..43 "=" + WHITESPACE@43..44 " " + BIN_EXPR@44..50 + PATH_EXPR@44..45 + PATH@44..45 + PATH_SEGMENT@44..45 + NAME_REF@44..45 + IDENT@44..45 "a" + WHITESPACE@45..46 " " + AMPAMP@46..48 "&&" + WHITESPACE@48..49 " " + PATH_EXPR@49..50 + PATH@49..50 + PATH_SEGMENT@49..50 + NAME_REF@49..50 + IDENT@49..50 "b" + SEMI@50..51 ";" + WHITESPACE@51..52 "\n" + R_CURLY@52..53 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__loop_expr.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__loop_expr.snap index dcbc940ad..227f81e7f 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__loop_expr.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__loop_expr.snap @@ -2,25 +2,25 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n loop {}\n}" --- -SOURCE_FILE@[0; 24) - FUNCTION_DEF@[0; 24) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 24) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - LOOP_EXPR@[15; 22) - LOOP_KW@[15; 19) "loop" - WHITESPACE@[19; 20) " " - BLOCK_EXPR@[20; 22) - L_CURLY@[20; 21) "{" - R_CURLY@[21; 22) "}" - WHITESPACE@[22; 23) "\n" - R_CURLY@[23; 24) "}" +SOURCE_FILE@0..24 + FUNCTION_DEF@0..24 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..24 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + LOOP_EXPR@15..22 + LOOP_KW@15..19 "loop" + WHITESPACE@19..20 " " + BLOCK_EXPR@20..22 + L_CURLY@20..21 "{" + R_CURLY@21..22 "}" + WHITESPACE@22..23 "\n" + R_CURLY@23..24 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__memory_type_specifier.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__memory_type_specifier.snap index 893f9a227..b751bdaa0 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__memory_type_specifier.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__memory_type_specifier.snap @@ -2,81 +2,81 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "struct Foo {};\nstruct(gc) Baz {};\nstruct(value) Baz {};\nstruct() Err1 {}; // error: expected memory type specifier\nstruct(foo) Err2 {}; // error: expected memory type specifier" --- -SOURCE_FILE@[0; 179) - STRUCT_DEF@[0; 14) - STRUCT_KW@[0; 6) "struct" - WHITESPACE@[6; 7) " " - NAME@[7; 10) - IDENT@[7; 10) "Foo" - WHITESPACE@[10; 11) " " - RECORD_FIELD_DEF_LIST@[11; 14) - L_CURLY@[11; 12) "{" - R_CURLY@[12; 13) "}" - SEMI@[13; 14) ";" - WHITESPACE@[14; 15) "\n" - STRUCT_DEF@[15; 33) - STRUCT_KW@[15; 21) "struct" - MEMORY_TYPE_SPECIFIER@[21; 25) - L_PAREN@[21; 22) "(" - GC_KW@[22; 24) "gc" - R_PAREN@[24; 25) ")" - WHITESPACE@[25; 26) " " - NAME@[26; 29) - IDENT@[26; 29) "Baz" - WHITESPACE@[29; 30) " " - RECORD_FIELD_DEF_LIST@[30; 33) - L_CURLY@[30; 31) "{" - R_CURLY@[31; 32) "}" - SEMI@[32; 33) ";" - WHITESPACE@[33; 34) "\n" - STRUCT_DEF@[34; 55) - STRUCT_KW@[34; 40) "struct" - MEMORY_TYPE_SPECIFIER@[40; 47) - L_PAREN@[40; 41) "(" - VALUE_KW@[41; 46) "value" - R_PAREN@[46; 47) ")" - WHITESPACE@[47; 48) " " - NAME@[48; 51) - IDENT@[48; 51) "Baz" - WHITESPACE@[51; 52) " " - RECORD_FIELD_DEF_LIST@[52; 55) - L_CURLY@[52; 53) "{" - R_CURLY@[53; 54) "}" - SEMI@[54; 55) ";" - WHITESPACE@[55; 56) "\n" - STRUCT_DEF@[56; 73) - STRUCT_KW@[56; 62) "struct" - MEMORY_TYPE_SPECIFIER@[62; 64) - L_PAREN@[62; 63) "(" - R_PAREN@[63; 64) ")" - WHITESPACE@[64; 65) " " - NAME@[65; 69) - IDENT@[65; 69) "Err1" - WHITESPACE@[69; 70) " " - RECORD_FIELD_DEF_LIST@[70; 73) - L_CURLY@[70; 71) "{" - R_CURLY@[71; 72) "}" - SEMI@[72; 73) ";" - WHITESPACE@[73; 77) " " - COMMENT@[77; 117) "// error: expected me ..." - WHITESPACE@[117; 118) "\n" - STRUCT_DEF@[118; 138) - STRUCT_KW@[118; 124) "struct" - MEMORY_TYPE_SPECIFIER@[124; 129) - L_PAREN@[124; 125) "(" - ERROR@[125; 128) - IDENT@[125; 128) "foo" - R_PAREN@[128; 129) ")" - WHITESPACE@[129; 130) " " - NAME@[130; 134) - IDENT@[130; 134) "Err2" - WHITESPACE@[134; 135) " " - RECORD_FIELD_DEF_LIST@[135; 138) - L_CURLY@[135; 136) "{" - R_CURLY@[136; 137) "}" - SEMI@[137; 138) ";" - WHITESPACE@[138; 139) " " - COMMENT@[139; 179) "// error: expected me ..." +SOURCE_FILE@0..179 + STRUCT_DEF@0..14 + STRUCT_KW@0..6 "struct" + WHITESPACE@6..7 " " + NAME@7..10 + IDENT@7..10 "Foo" + WHITESPACE@10..11 " " + RECORD_FIELD_DEF_LIST@11..14 + L_CURLY@11..12 "{" + R_CURLY@12..13 "}" + SEMI@13..14 ";" + WHITESPACE@14..15 "\n" + STRUCT_DEF@15..33 + STRUCT_KW@15..21 "struct" + MEMORY_TYPE_SPECIFIER@21..25 + L_PAREN@21..22 "(" + GC_KW@22..24 "gc" + R_PAREN@24..25 ")" + WHITESPACE@25..26 " " + NAME@26..29 + IDENT@26..29 "Baz" + WHITESPACE@29..30 " " + RECORD_FIELD_DEF_LIST@30..33 + L_CURLY@30..31 "{" + R_CURLY@31..32 "}" + SEMI@32..33 ";" + WHITESPACE@33..34 "\n" + STRUCT_DEF@34..55 + STRUCT_KW@34..40 "struct" + MEMORY_TYPE_SPECIFIER@40..47 + L_PAREN@40..41 "(" + VALUE_KW@41..46 "value" + R_PAREN@46..47 ")" + WHITESPACE@47..48 " " + NAME@48..51 + IDENT@48..51 "Baz" + WHITESPACE@51..52 " " + RECORD_FIELD_DEF_LIST@52..55 + L_CURLY@52..53 "{" + R_CURLY@53..54 "}" + SEMI@54..55 ";" + WHITESPACE@55..56 "\n" + STRUCT_DEF@56..73 + STRUCT_KW@56..62 "struct" + MEMORY_TYPE_SPECIFIER@62..64 + L_PAREN@62..63 "(" + R_PAREN@63..64 ")" + WHITESPACE@64..65 " " + NAME@65..69 + IDENT@65..69 "Err1" + WHITESPACE@69..70 " " + RECORD_FIELD_DEF_LIST@70..73 + L_CURLY@70..71 "{" + R_CURLY@71..72 "}" + SEMI@72..73 ";" + WHITESPACE@73..77 " " + COMMENT@77..117 "// error: expected me ..." + WHITESPACE@117..118 "\n" + STRUCT_DEF@118..138 + STRUCT_KW@118..124 "struct" + MEMORY_TYPE_SPECIFIER@124..129 + L_PAREN@124..125 "(" + ERROR@125..128 + IDENT@125..128 "foo" + R_PAREN@128..129 ")" + WHITESPACE@129..130 " " + NAME@130..134 + IDENT@130..134 "Err2" + WHITESPACE@134..135 " " + RECORD_FIELD_DEF_LIST@135..138 + L_CURLY@135..136 "{" + R_CURLY@136..137 "}" + SEMI@137..138 ";" + WHITESPACE@138..139 " " + COMMENT@139..179 "// error: expected me ..." error Offset(63): expected memory type specifier error Offset(125): expected memory type specifier diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__patterns.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__patterns.snap index d6763b552..379405b4a 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__patterns.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__patterns.snap @@ -2,55 +2,55 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn main(_:number) {\n let a = 0;\n let _ = a;\n}" --- -SOURCE_FILE@[0; 49) - FUNCTION_DEF@[0; 49) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 7) - IDENT@[3; 7) "main" - PARAM_LIST@[7; 17) - L_PAREN@[7; 8) "(" - PARAM@[8; 16) - PLACEHOLDER_PAT@[8; 9) - UNDERSCORE@[8; 9) "_" - COLON@[9; 10) ":" - PATH_TYPE@[10; 16) - PATH@[10; 16) - PATH_SEGMENT@[10; 16) - NAME_REF@[10; 16) - IDENT@[10; 16) "number" - R_PAREN@[16; 17) ")" - WHITESPACE@[17; 18) " " - BLOCK_EXPR@[18; 49) - L_CURLY@[18; 19) "{" - WHITESPACE@[19; 23) "\n " - LET_STMT@[23; 33) - LET_KW@[23; 26) "let" - WHITESPACE@[26; 27) " " - BIND_PAT@[27; 28) - NAME@[27; 28) - IDENT@[27; 28) "a" - WHITESPACE@[28; 29) " " - EQ@[29; 30) "=" - WHITESPACE@[30; 31) " " - LITERAL@[31; 32) - INT_NUMBER@[31; 32) "0" - SEMI@[32; 33) ";" - WHITESPACE@[33; 37) "\n " - LET_STMT@[37; 47) - LET_KW@[37; 40) "let" - WHITESPACE@[40; 41) " " - PLACEHOLDER_PAT@[41; 42) - UNDERSCORE@[41; 42) "_" - WHITESPACE@[42; 43) " " - EQ@[43; 44) "=" - WHITESPACE@[44; 45) " " - PATH_EXPR@[45; 46) - PATH@[45; 46) - PATH_SEGMENT@[45; 46) - NAME_REF@[45; 46) - IDENT@[45; 46) "a" - SEMI@[46; 47) ";" - WHITESPACE@[47; 48) "\n" - R_CURLY@[48; 49) "}" +SOURCE_FILE@0..49 + FUNCTION_DEF@0..49 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..7 + IDENT@3..7 "main" + PARAM_LIST@7..17 + L_PAREN@7..8 "(" + PARAM@8..16 + PLACEHOLDER_PAT@8..9 + UNDERSCORE@8..9 "_" + COLON@9..10 ":" + PATH_TYPE@10..16 + PATH@10..16 + PATH_SEGMENT@10..16 + NAME_REF@10..16 + IDENT@10..16 "number" + R_PAREN@16..17 ")" + WHITESPACE@17..18 " " + BLOCK_EXPR@18..49 + L_CURLY@18..19 "{" + WHITESPACE@19..23 "\n " + LET_STMT@23..33 + LET_KW@23..26 "let" + WHITESPACE@26..27 " " + BIND_PAT@27..28 + NAME@27..28 + IDENT@27..28 "a" + WHITESPACE@28..29 " " + EQ@29..30 "=" + WHITESPACE@30..31 " " + LITERAL@31..32 + INT_NUMBER@31..32 "0" + SEMI@32..33 ";" + WHITESPACE@33..37 "\n " + LET_STMT@37..47 + LET_KW@37..40 "let" + WHITESPACE@40..41 " " + PLACEHOLDER_PAT@41..42 + UNDERSCORE@41..42 "_" + WHITESPACE@42..43 " " + EQ@43..44 "=" + WHITESPACE@44..45 " " + PATH_EXPR@45..46 + PATH@45..46 + PATH_SEGMENT@45..46 + NAME_REF@45..46 + IDENT@45..46 "a" + SEMI@46..47 ";" + WHITESPACE@47..48 "\n" + R_CURLY@48..49 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__return_expr.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__return_expr.snap index a933ad13c..76d5c9722 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__return_expr.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__return_expr.snap @@ -2,31 +2,31 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n return;\n return 50;\n}" --- -SOURCE_FILE@[0; 39) - FUNCTION_DEF@[0; 39) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 39) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - EXPR_STMT@[15; 22) - RETURN_EXPR@[15; 21) - RETURN_KW@[15; 21) "return" - SEMI@[21; 22) ";" - WHITESPACE@[22; 27) "\n " - EXPR_STMT@[27; 37) - RETURN_EXPR@[27; 36) - RETURN_KW@[27; 33) "return" - WHITESPACE@[33; 34) " " - LITERAL@[34; 36) - INT_NUMBER@[34; 36) "50" - SEMI@[36; 37) ";" - WHITESPACE@[37; 38) "\n" - R_CURLY@[38; 39) "}" +SOURCE_FILE@0..39 + FUNCTION_DEF@0..39 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..39 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + EXPR_STMT@15..22 + RETURN_EXPR@15..21 + RETURN_KW@15..21 "return" + SEMI@21..22 ";" + WHITESPACE@22..27 "\n " + EXPR_STMT@27..37 + RETURN_EXPR@27..36 + RETURN_KW@27..33 "return" + WHITESPACE@33..34 " " + LITERAL@34..36 + INT_NUMBER@34..36 "50" + SEMI@36..37 ";" + WHITESPACE@37..38 "\n" + R_CURLY@38..39 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_def.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_def.snap index 5b52aac9d..fbcb79975 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_def.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_def.snap @@ -2,215 +2,215 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "struct Foo // error: expected a ';', or a '{'\nstruct Foo;\nstruct Foo;; // error: expected a declaration\nstruct Foo {}\nstruct Foo {};\nstruct Foo {,}; // error: expected a field declaration\nstruct Foo {\n a: f64,\n}\nstruct Foo {\n a: f64,\n b: i32,\n};\nstruct Foo()\nstruct Foo();\nstruct Foo(,); // error: expected a type\nstruct Foo(f64)\nstruct Foo(f64,);\nstruct Foo(f64, i32)" --- -SOURCE_FILE@[0; 386) - STRUCT_DEF@[0; 10) - STRUCT_KW@[0; 6) "struct" - WHITESPACE@[6; 7) " " - NAME@[7; 10) - IDENT@[7; 10) "Foo" - WHITESPACE@[10; 16) " " - COMMENT@[16; 50) "// error: expected a ..." - WHITESPACE@[50; 51) "\n" - STRUCT_DEF@[51; 62) - STRUCT_KW@[51; 57) "struct" - WHITESPACE@[57; 58) " " - NAME@[58; 61) - IDENT@[58; 61) "Foo" - SEMI@[61; 62) ";" - WHITESPACE@[62; 63) "\n" - STRUCT_DEF@[63; 74) - STRUCT_KW@[63; 69) "struct" - WHITESPACE@[69; 70) " " - NAME@[70; 73) - IDENT@[70; 73) "Foo" - SEMI@[73; 74) ";" - ERROR@[74; 75) - SEMI@[74; 75) ";" - WHITESPACE@[75; 79) " " - COMMENT@[79; 111) "// error: expected a ..." - WHITESPACE@[111; 112) "\n" - STRUCT_DEF@[112; 125) - STRUCT_KW@[112; 118) "struct" - WHITESPACE@[118; 119) " " - NAME@[119; 122) - IDENT@[119; 122) "Foo" - WHITESPACE@[122; 123) " " - RECORD_FIELD_DEF_LIST@[123; 125) - L_CURLY@[123; 124) "{" - R_CURLY@[124; 125) "}" - WHITESPACE@[125; 126) "\n" - STRUCT_DEF@[126; 140) - STRUCT_KW@[126; 132) "struct" - WHITESPACE@[132; 133) " " - NAME@[133; 136) - IDENT@[133; 136) "Foo" - WHITESPACE@[136; 137) " " - RECORD_FIELD_DEF_LIST@[137; 140) - L_CURLY@[137; 138) "{" - R_CURLY@[138; 139) "}" - SEMI@[139; 140) ";" - WHITESPACE@[140; 141) "\n" - STRUCT_DEF@[141; 156) - STRUCT_KW@[141; 147) "struct" - WHITESPACE@[147; 148) " " - NAME@[148; 151) - IDENT@[148; 151) "Foo" - WHITESPACE@[151; 152) " " - RECORD_FIELD_DEF_LIST@[152; 156) - L_CURLY@[152; 153) "{" - ERROR@[153; 154) - COMMA@[153; 154) "," - R_CURLY@[154; 155) "}" - SEMI@[155; 156) ";" - WHITESPACE@[156; 157) " " - COMMENT@[157; 195) "// error: expected a ..." - WHITESPACE@[195; 196) "\n" - STRUCT_DEF@[196; 222) - STRUCT_KW@[196; 202) "struct" - WHITESPACE@[202; 203) " " - NAME@[203; 206) - IDENT@[203; 206) "Foo" - WHITESPACE@[206; 207) " " - RECORD_FIELD_DEF_LIST@[207; 222) - L_CURLY@[207; 208) "{" - WHITESPACE@[208; 213) "\n " - RECORD_FIELD_DEF@[213; 219) - NAME@[213; 214) - IDENT@[213; 214) "a" - COLON@[214; 215) ":" - WHITESPACE@[215; 216) " " - PATH_TYPE@[216; 219) - PATH@[216; 219) - PATH_SEGMENT@[216; 219) - NAME_REF@[216; 219) - IDENT@[216; 219) "f64" - COMMA@[219; 220) "," - WHITESPACE@[220; 221) "\n" - R_CURLY@[221; 222) "}" - WHITESPACE@[222; 223) "\n" - STRUCT_DEF@[223; 262) - STRUCT_KW@[223; 229) "struct" - WHITESPACE@[229; 230) " " - NAME@[230; 233) - IDENT@[230; 233) "Foo" - WHITESPACE@[233; 234) " " - RECORD_FIELD_DEF_LIST@[234; 262) - L_CURLY@[234; 235) "{" - WHITESPACE@[235; 240) "\n " - RECORD_FIELD_DEF@[240; 246) - NAME@[240; 241) - IDENT@[240; 241) "a" - COLON@[241; 242) ":" - WHITESPACE@[242; 243) " " - PATH_TYPE@[243; 246) - PATH@[243; 246) - PATH_SEGMENT@[243; 246) - NAME_REF@[243; 246) - IDENT@[243; 246) "f64" - COMMA@[246; 247) "," - WHITESPACE@[247; 252) "\n " - RECORD_FIELD_DEF@[252; 258) - NAME@[252; 253) - IDENT@[252; 253) "b" - COLON@[253; 254) ":" - WHITESPACE@[254; 255) " " - PATH_TYPE@[255; 258) - PATH@[255; 258) - PATH_SEGMENT@[255; 258) - NAME_REF@[255; 258) - IDENT@[255; 258) "i32" - COMMA@[258; 259) "," - WHITESPACE@[259; 260) "\n" - R_CURLY@[260; 261) "}" - SEMI@[261; 262) ";" - WHITESPACE@[262; 263) "\n" - STRUCT_DEF@[263; 275) - STRUCT_KW@[263; 269) "struct" - WHITESPACE@[269; 270) " " - NAME@[270; 273) - IDENT@[270; 273) "Foo" - TUPLE_FIELD_DEF_LIST@[273; 275) - L_PAREN@[273; 274) "(" - R_PAREN@[274; 275) ")" - WHITESPACE@[275; 276) "\n" - STRUCT_DEF@[276; 289) - STRUCT_KW@[276; 282) "struct" - WHITESPACE@[282; 283) " " - NAME@[283; 286) - IDENT@[283; 286) "Foo" - TUPLE_FIELD_DEF_LIST@[286; 289) - L_PAREN@[286; 287) "(" - R_PAREN@[287; 288) ")" - SEMI@[288; 289) ";" - WHITESPACE@[289; 290) "\n" - STRUCT_DEF@[290; 304) - STRUCT_KW@[290; 296) "struct" - WHITESPACE@[296; 297) " " - NAME@[297; 300) - IDENT@[297; 300) "Foo" - TUPLE_FIELD_DEF_LIST@[300; 304) - L_PAREN@[300; 301) "(" - ERROR@[301; 302) - COMMA@[301; 302) "," - R_PAREN@[302; 303) ")" - SEMI@[303; 304) ";" - WHITESPACE@[304; 306) " " - COMMENT@[306; 331) "// error: expected a ..." - WHITESPACE@[331; 332) "\n" - STRUCT_DEF@[332; 347) - STRUCT_KW@[332; 338) "struct" - WHITESPACE@[338; 339) " " - NAME@[339; 342) - IDENT@[339; 342) "Foo" - TUPLE_FIELD_DEF_LIST@[342; 347) - L_PAREN@[342; 343) "(" - TUPLE_FIELD_DEF@[343; 346) - PATH_TYPE@[343; 346) - PATH@[343; 346) - PATH_SEGMENT@[343; 346) - NAME_REF@[343; 346) - IDENT@[343; 346) "f64" - R_PAREN@[346; 347) ")" - WHITESPACE@[347; 348) "\n" - STRUCT_DEF@[348; 365) - STRUCT_KW@[348; 354) "struct" - WHITESPACE@[354; 355) " " - NAME@[355; 358) - IDENT@[355; 358) "Foo" - TUPLE_FIELD_DEF_LIST@[358; 365) - L_PAREN@[358; 359) "(" - TUPLE_FIELD_DEF@[359; 362) - PATH_TYPE@[359; 362) - PATH@[359; 362) - PATH_SEGMENT@[359; 362) - NAME_REF@[359; 362) - IDENT@[359; 362) "f64" - COMMA@[362; 363) "," - R_PAREN@[363; 364) ")" - SEMI@[364; 365) ";" - WHITESPACE@[365; 366) "\n" - STRUCT_DEF@[366; 386) - STRUCT_KW@[366; 372) "struct" - WHITESPACE@[372; 373) " " - NAME@[373; 376) - IDENT@[373; 376) "Foo" - TUPLE_FIELD_DEF_LIST@[376; 386) - L_PAREN@[376; 377) "(" - TUPLE_FIELD_DEF@[377; 380) - PATH_TYPE@[377; 380) - PATH@[377; 380) - PATH_SEGMENT@[377; 380) - NAME_REF@[377; 380) - IDENT@[377; 380) "f64" - COMMA@[380; 381) "," - WHITESPACE@[381; 382) " " - TUPLE_FIELD_DEF@[382; 385) - PATH_TYPE@[382; 385) - PATH@[382; 385) - PATH_SEGMENT@[382; 385) - NAME_REF@[382; 385) - IDENT@[382; 385) "i32" - R_PAREN@[385; 386) ")" +SOURCE_FILE@0..386 + STRUCT_DEF@0..10 + STRUCT_KW@0..6 "struct" + WHITESPACE@6..7 " " + NAME@7..10 + IDENT@7..10 "Foo" + WHITESPACE@10..16 " " + COMMENT@16..50 "// error: expected a ..." + WHITESPACE@50..51 "\n" + STRUCT_DEF@51..62 + STRUCT_KW@51..57 "struct" + WHITESPACE@57..58 " " + NAME@58..61 + IDENT@58..61 "Foo" + SEMI@61..62 ";" + WHITESPACE@62..63 "\n" + STRUCT_DEF@63..74 + STRUCT_KW@63..69 "struct" + WHITESPACE@69..70 " " + NAME@70..73 + IDENT@70..73 "Foo" + SEMI@73..74 ";" + ERROR@74..75 + SEMI@74..75 ";" + WHITESPACE@75..79 " " + COMMENT@79..111 "// error: expected a ..." + WHITESPACE@111..112 "\n" + STRUCT_DEF@112..125 + STRUCT_KW@112..118 "struct" + WHITESPACE@118..119 " " + NAME@119..122 + IDENT@119..122 "Foo" + WHITESPACE@122..123 " " + RECORD_FIELD_DEF_LIST@123..125 + L_CURLY@123..124 "{" + R_CURLY@124..125 "}" + WHITESPACE@125..126 "\n" + STRUCT_DEF@126..140 + STRUCT_KW@126..132 "struct" + WHITESPACE@132..133 " " + NAME@133..136 + IDENT@133..136 "Foo" + WHITESPACE@136..137 " " + RECORD_FIELD_DEF_LIST@137..140 + L_CURLY@137..138 "{" + R_CURLY@138..139 "}" + SEMI@139..140 ";" + WHITESPACE@140..141 "\n" + STRUCT_DEF@141..156 + STRUCT_KW@141..147 "struct" + WHITESPACE@147..148 " " + NAME@148..151 + IDENT@148..151 "Foo" + WHITESPACE@151..152 " " + RECORD_FIELD_DEF_LIST@152..156 + L_CURLY@152..153 "{" + ERROR@153..154 + COMMA@153..154 "," + R_CURLY@154..155 "}" + SEMI@155..156 ";" + WHITESPACE@156..157 " " + COMMENT@157..195 "// error: expected a ..." + WHITESPACE@195..196 "\n" + STRUCT_DEF@196..222 + STRUCT_KW@196..202 "struct" + WHITESPACE@202..203 " " + NAME@203..206 + IDENT@203..206 "Foo" + WHITESPACE@206..207 " " + RECORD_FIELD_DEF_LIST@207..222 + L_CURLY@207..208 "{" + WHITESPACE@208..213 "\n " + RECORD_FIELD_DEF@213..219 + NAME@213..214 + IDENT@213..214 "a" + COLON@214..215 ":" + WHITESPACE@215..216 " " + PATH_TYPE@216..219 + PATH@216..219 + PATH_SEGMENT@216..219 + NAME_REF@216..219 + IDENT@216..219 "f64" + COMMA@219..220 "," + WHITESPACE@220..221 "\n" + R_CURLY@221..222 "}" + WHITESPACE@222..223 "\n" + STRUCT_DEF@223..262 + STRUCT_KW@223..229 "struct" + WHITESPACE@229..230 " " + NAME@230..233 + IDENT@230..233 "Foo" + WHITESPACE@233..234 " " + RECORD_FIELD_DEF_LIST@234..262 + L_CURLY@234..235 "{" + WHITESPACE@235..240 "\n " + RECORD_FIELD_DEF@240..246 + NAME@240..241 + IDENT@240..241 "a" + COLON@241..242 ":" + WHITESPACE@242..243 " " + PATH_TYPE@243..246 + PATH@243..246 + PATH_SEGMENT@243..246 + NAME_REF@243..246 + IDENT@243..246 "f64" + COMMA@246..247 "," + WHITESPACE@247..252 "\n " + RECORD_FIELD_DEF@252..258 + NAME@252..253 + IDENT@252..253 "b" + COLON@253..254 ":" + WHITESPACE@254..255 " " + PATH_TYPE@255..258 + PATH@255..258 + PATH_SEGMENT@255..258 + NAME_REF@255..258 + IDENT@255..258 "i32" + COMMA@258..259 "," + WHITESPACE@259..260 "\n" + R_CURLY@260..261 "}" + SEMI@261..262 ";" + WHITESPACE@262..263 "\n" + STRUCT_DEF@263..275 + STRUCT_KW@263..269 "struct" + WHITESPACE@269..270 " " + NAME@270..273 + IDENT@270..273 "Foo" + TUPLE_FIELD_DEF_LIST@273..275 + L_PAREN@273..274 "(" + R_PAREN@274..275 ")" + WHITESPACE@275..276 "\n" + STRUCT_DEF@276..289 + STRUCT_KW@276..282 "struct" + WHITESPACE@282..283 " " + NAME@283..286 + IDENT@283..286 "Foo" + TUPLE_FIELD_DEF_LIST@286..289 + L_PAREN@286..287 "(" + R_PAREN@287..288 ")" + SEMI@288..289 ";" + WHITESPACE@289..290 "\n" + STRUCT_DEF@290..304 + STRUCT_KW@290..296 "struct" + WHITESPACE@296..297 " " + NAME@297..300 + IDENT@297..300 "Foo" + TUPLE_FIELD_DEF_LIST@300..304 + L_PAREN@300..301 "(" + ERROR@301..302 + COMMA@301..302 "," + R_PAREN@302..303 ")" + SEMI@303..304 ";" + WHITESPACE@304..306 " " + COMMENT@306..331 "// error: expected a ..." + WHITESPACE@331..332 "\n" + STRUCT_DEF@332..347 + STRUCT_KW@332..338 "struct" + WHITESPACE@338..339 " " + NAME@339..342 + IDENT@339..342 "Foo" + TUPLE_FIELD_DEF_LIST@342..347 + L_PAREN@342..343 "(" + TUPLE_FIELD_DEF@343..346 + PATH_TYPE@343..346 + PATH@343..346 + PATH_SEGMENT@343..346 + NAME_REF@343..346 + IDENT@343..346 "f64" + R_PAREN@346..347 ")" + WHITESPACE@347..348 "\n" + STRUCT_DEF@348..365 + STRUCT_KW@348..354 "struct" + WHITESPACE@354..355 " " + NAME@355..358 + IDENT@355..358 "Foo" + TUPLE_FIELD_DEF_LIST@358..365 + L_PAREN@358..359 "(" + TUPLE_FIELD_DEF@359..362 + PATH_TYPE@359..362 + PATH@359..362 + PATH_SEGMENT@359..362 + NAME_REF@359..362 + IDENT@359..362 "f64" + COMMA@362..363 "," + R_PAREN@363..364 ")" + SEMI@364..365 ";" + WHITESPACE@365..366 "\n" + STRUCT_DEF@366..386 + STRUCT_KW@366..372 "struct" + WHITESPACE@372..373 " " + NAME@373..376 + IDENT@373..376 "Foo" + TUPLE_FIELD_DEF_LIST@376..386 + L_PAREN@376..377 "(" + TUPLE_FIELD_DEF@377..380 + PATH_TYPE@377..380 + PATH@377..380 + PATH_SEGMENT@377..380 + NAME_REF@377..380 + IDENT@377..380 "f64" + COMMA@380..381 "," + WHITESPACE@381..382 " " + TUPLE_FIELD_DEF@382..385 + PATH_TYPE@382..385 + PATH@382..385 + PATH_SEGMENT@382..385 + NAME_REF@382..385 + IDENT@382..385 "i32" + R_PAREN@385..386 ")" error Offset(10): expected a ';', '{', or '(' error Offset(74): expected a declaration error Offset(153): expected a field declaration diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_field_index.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_field_index.snap index aabaf31a3..0e2bc762d 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_field_index.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_field_index.snap @@ -2,114 +2,114 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn main() {\n foo.a\n foo.a.b\n foo.0\n foo.0.1\n foo.10\n foo.01 // index: .0\n foo.0 1 // index: .0 \n foo.a.0\n}" --- -SOURCE_FILE@[0; 131) - FUNCTION_DEF@[0; 131) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 7) - IDENT@[3; 7) "main" - PARAM_LIST@[7; 9) - L_PAREN@[7; 8) "(" - R_PAREN@[8; 9) ")" - WHITESPACE@[9; 10) " " - BLOCK_EXPR@[10; 131) - L_CURLY@[10; 11) "{" - WHITESPACE@[11; 16) "\n " - EXPR_STMT@[16; 21) - FIELD_EXPR@[16; 21) - PATH_EXPR@[16; 19) - PATH@[16; 19) - PATH_SEGMENT@[16; 19) - NAME_REF@[16; 19) - IDENT@[16; 19) "foo" - DOT@[19; 20) "." - NAME_REF@[20; 21) - IDENT@[20; 21) "a" - WHITESPACE@[21; 26) "\n " - EXPR_STMT@[26; 33) - FIELD_EXPR@[26; 33) - FIELD_EXPR@[26; 31) - PATH_EXPR@[26; 29) - PATH@[26; 29) - PATH_SEGMENT@[26; 29) - NAME_REF@[26; 29) - IDENT@[26; 29) "foo" - DOT@[29; 30) "." - NAME_REF@[30; 31) - IDENT@[30; 31) "a" - DOT@[31; 32) "." - NAME_REF@[32; 33) - IDENT@[32; 33) "b" - WHITESPACE@[33; 38) "\n " - EXPR_STMT@[38; 43) - FIELD_EXPR@[38; 43) - PATH_EXPR@[38; 41) - PATH@[38; 41) - PATH_SEGMENT@[38; 41) - NAME_REF@[38; 41) - IDENT@[38; 41) "foo" - INDEX@[41; 43) ".0" - WHITESPACE@[43; 48) "\n " - EXPR_STMT@[48; 55) - FIELD_EXPR@[48; 55) - FIELD_EXPR@[48; 53) - PATH_EXPR@[48; 51) - PATH@[48; 51) - PATH_SEGMENT@[48; 51) - NAME_REF@[48; 51) - IDENT@[48; 51) "foo" - INDEX@[51; 53) ".0" - INDEX@[53; 55) ".1" - WHITESPACE@[55; 60) "\n " - EXPR_STMT@[60; 66) - FIELD_EXPR@[60; 66) - PATH_EXPR@[60; 63) - PATH@[60; 63) - PATH_SEGMENT@[60; 63) - NAME_REF@[60; 63) - IDENT@[60; 63) "foo" - INDEX@[63; 66) ".10" - WHITESPACE@[66; 71) "\n " - EXPR_STMT@[71; 76) - FIELD_EXPR@[71; 76) - PATH_EXPR@[71; 74) - PATH@[71; 74) - PATH_SEGMENT@[71; 74) - NAME_REF@[71; 74) - IDENT@[71; 74) "foo" - INDEX@[74; 76) ".0" - EXPR_STMT@[76; 77) - LITERAL@[76; 77) - INT_NUMBER@[76; 77) "1" - WHITESPACE@[77; 79) " " - COMMENT@[79; 91) "// index: .0" - WHITESPACE@[91; 96) "\n " - EXPR_STMT@[96; 101) - FIELD_EXPR@[96; 101) - PATH_EXPR@[96; 99) - PATH@[96; 99) - PATH_SEGMENT@[96; 99) - NAME_REF@[96; 99) - IDENT@[96; 99) "foo" - INDEX@[99; 101) ".0" - WHITESPACE@[101; 102) " " - EXPR_STMT@[102; 103) - LITERAL@[102; 103) - INT_NUMBER@[102; 103) "1" - WHITESPACE@[103; 104) " " - COMMENT@[104; 117) "// index: .0 " - WHITESPACE@[117; 122) "\n " - FIELD_EXPR@[122; 129) - FIELD_EXPR@[122; 127) - PATH_EXPR@[122; 125) - PATH@[122; 125) - PATH_SEGMENT@[122; 125) - NAME_REF@[122; 125) - IDENT@[122; 125) "foo" - DOT@[125; 126) "." - NAME_REF@[126; 127) - IDENT@[126; 127) "a" - INDEX@[127; 129) ".0" - WHITESPACE@[129; 130) "\n" - R_CURLY@[130; 131) "}" +SOURCE_FILE@0..131 + FUNCTION_DEF@0..131 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..7 + IDENT@3..7 "main" + PARAM_LIST@7..9 + L_PAREN@7..8 "(" + R_PAREN@8..9 ")" + WHITESPACE@9..10 " " + BLOCK_EXPR@10..131 + L_CURLY@10..11 "{" + WHITESPACE@11..16 "\n " + EXPR_STMT@16..21 + FIELD_EXPR@16..21 + PATH_EXPR@16..19 + PATH@16..19 + PATH_SEGMENT@16..19 + NAME_REF@16..19 + IDENT@16..19 "foo" + DOT@19..20 "." + NAME_REF@20..21 + IDENT@20..21 "a" + WHITESPACE@21..26 "\n " + EXPR_STMT@26..33 + FIELD_EXPR@26..33 + FIELD_EXPR@26..31 + PATH_EXPR@26..29 + PATH@26..29 + PATH_SEGMENT@26..29 + NAME_REF@26..29 + IDENT@26..29 "foo" + DOT@29..30 "." + NAME_REF@30..31 + IDENT@30..31 "a" + DOT@31..32 "." + NAME_REF@32..33 + IDENT@32..33 "b" + WHITESPACE@33..38 "\n " + EXPR_STMT@38..43 + FIELD_EXPR@38..43 + PATH_EXPR@38..41 + PATH@38..41 + PATH_SEGMENT@38..41 + NAME_REF@38..41 + IDENT@38..41 "foo" + INDEX@41..43 ".0" + WHITESPACE@43..48 "\n " + EXPR_STMT@48..55 + FIELD_EXPR@48..55 + FIELD_EXPR@48..53 + PATH_EXPR@48..51 + PATH@48..51 + PATH_SEGMENT@48..51 + NAME_REF@48..51 + IDENT@48..51 "foo" + INDEX@51..53 ".0" + INDEX@53..55 ".1" + WHITESPACE@55..60 "\n " + EXPR_STMT@60..66 + FIELD_EXPR@60..66 + PATH_EXPR@60..63 + PATH@60..63 + PATH_SEGMENT@60..63 + NAME_REF@60..63 + IDENT@60..63 "foo" + INDEX@63..66 ".10" + WHITESPACE@66..71 "\n " + EXPR_STMT@71..76 + FIELD_EXPR@71..76 + PATH_EXPR@71..74 + PATH@71..74 + PATH_SEGMENT@71..74 + NAME_REF@71..74 + IDENT@71..74 "foo" + INDEX@74..76 ".0" + EXPR_STMT@76..77 + LITERAL@76..77 + INT_NUMBER@76..77 "1" + WHITESPACE@77..79 " " + COMMENT@79..91 "// index: .0" + WHITESPACE@91..96 "\n " + EXPR_STMT@96..101 + FIELD_EXPR@96..101 + PATH_EXPR@96..99 + PATH@96..99 + PATH_SEGMENT@96..99 + NAME_REF@96..99 + IDENT@96..99 "foo" + INDEX@99..101 ".0" + WHITESPACE@101..102 " " + EXPR_STMT@102..103 + LITERAL@102..103 + INT_NUMBER@102..103 "1" + WHITESPACE@103..104 " " + COMMENT@104..117 "// index: .0 " + WHITESPACE@117..122 "\n " + FIELD_EXPR@122..129 + FIELD_EXPR@122..127 + PATH_EXPR@122..125 + PATH@122..125 + PATH_SEGMENT@122..125 + NAME_REF@122..125 + IDENT@122..125 "foo" + DOT@125..126 "." + NAME_REF@126..127 + IDENT@126..127 "a" + INDEX@127..129 ".0" + WHITESPACE@129..130 "\n" + R_CURLY@130..131 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_lit.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_lit.snap index 109983a5e..11817e2c7 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_lit.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__struct_lit.snap @@ -2,151 +2,151 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n U;\n S {};\n S { x, y: 32, };\n S { x: 32, y: 64 };\n TupleStruct { 0: 1 };\n T(1.23);\n T(1.23, 4,)\n}" --- -SOURCE_FILE@[0; 129) - FUNCTION_DEF@[0; 129) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 129) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - EXPR_STMT@[15; 17) - PATH_EXPR@[15; 16) - PATH@[15; 16) - PATH_SEGMENT@[15; 16) - NAME_REF@[15; 16) - IDENT@[15; 16) "U" - SEMI@[16; 17) ";" - WHITESPACE@[17; 22) "\n " - EXPR_STMT@[22; 27) - RECORD_LIT@[22; 26) - PATH_TYPE@[22; 23) - PATH@[22; 23) - PATH_SEGMENT@[22; 23) - NAME_REF@[22; 23) - IDENT@[22; 23) "S" - WHITESPACE@[23; 24) " " - RECORD_FIELD_LIST@[24; 26) - L_CURLY@[24; 25) "{" - R_CURLY@[25; 26) "}" - SEMI@[26; 27) ";" - WHITESPACE@[27; 32) "\n " - EXPR_STMT@[32; 48) - RECORD_LIT@[32; 47) - PATH_TYPE@[32; 33) - PATH@[32; 33) - PATH_SEGMENT@[32; 33) - NAME_REF@[32; 33) - IDENT@[32; 33) "S" - WHITESPACE@[33; 34) " " - RECORD_FIELD_LIST@[34; 47) - L_CURLY@[34; 35) "{" - WHITESPACE@[35; 36) " " - RECORD_FIELD@[36; 37) - NAME_REF@[36; 37) - IDENT@[36; 37) "x" - COMMA@[37; 38) "," - WHITESPACE@[38; 39) " " - RECORD_FIELD@[39; 44) - NAME_REF@[39; 40) - IDENT@[39; 40) "y" - COLON@[40; 41) ":" - WHITESPACE@[41; 42) " " - LITERAL@[42; 44) - INT_NUMBER@[42; 44) "32" - COMMA@[44; 45) "," - WHITESPACE@[45; 46) " " - R_CURLY@[46; 47) "}" - SEMI@[47; 48) ";" - WHITESPACE@[48; 53) "\n " - EXPR_STMT@[53; 72) - RECORD_LIT@[53; 71) - PATH_TYPE@[53; 54) - PATH@[53; 54) - PATH_SEGMENT@[53; 54) - NAME_REF@[53; 54) - IDENT@[53; 54) "S" - WHITESPACE@[54; 55) " " - RECORD_FIELD_LIST@[55; 71) - L_CURLY@[55; 56) "{" - WHITESPACE@[56; 57) " " - RECORD_FIELD@[57; 62) - NAME_REF@[57; 58) - IDENT@[57; 58) "x" - COLON@[58; 59) ":" - WHITESPACE@[59; 60) " " - LITERAL@[60; 62) - INT_NUMBER@[60; 62) "32" - COMMA@[62; 63) "," - WHITESPACE@[63; 64) " " - RECORD_FIELD@[64; 69) - NAME_REF@[64; 65) - IDENT@[64; 65) "y" - COLON@[65; 66) ":" - WHITESPACE@[66; 67) " " - LITERAL@[67; 69) - INT_NUMBER@[67; 69) "64" - WHITESPACE@[69; 70) " " - R_CURLY@[70; 71) "}" - SEMI@[71; 72) ";" - WHITESPACE@[72; 77) "\n " - EXPR_STMT@[77; 98) - RECORD_LIT@[77; 97) - PATH_TYPE@[77; 88) - PATH@[77; 88) - PATH_SEGMENT@[77; 88) - NAME_REF@[77; 88) - IDENT@[77; 88) "TupleStruct" - WHITESPACE@[88; 89) " " - RECORD_FIELD_LIST@[89; 97) - L_CURLY@[89; 90) "{" - WHITESPACE@[90; 91) " " - RECORD_FIELD@[91; 95) - NAME_REF@[91; 92) - INT_NUMBER@[91; 92) "0" - COLON@[92; 93) ":" - WHITESPACE@[93; 94) " " - LITERAL@[94; 95) - INT_NUMBER@[94; 95) "1" - WHITESPACE@[95; 96) " " - R_CURLY@[96; 97) "}" - SEMI@[97; 98) ";" - WHITESPACE@[98; 103) "\n " - EXPR_STMT@[103; 111) - CALL_EXPR@[103; 110) - PATH_EXPR@[103; 104) - PATH@[103; 104) - PATH_SEGMENT@[103; 104) - NAME_REF@[103; 104) - IDENT@[103; 104) "T" - ARG_LIST@[104; 110) - L_PAREN@[104; 105) "(" - LITERAL@[105; 109) - FLOAT_NUMBER@[105; 109) "1.23" - R_PAREN@[109; 110) ")" - SEMI@[110; 111) ";" - WHITESPACE@[111; 116) "\n " - CALL_EXPR@[116; 127) - PATH_EXPR@[116; 117) - PATH@[116; 117) - PATH_SEGMENT@[116; 117) - NAME_REF@[116; 117) - IDENT@[116; 117) "T" - ARG_LIST@[117; 127) - L_PAREN@[117; 118) "(" - LITERAL@[118; 122) - FLOAT_NUMBER@[118; 122) "1.23" - COMMA@[122; 123) "," - WHITESPACE@[123; 124) " " - LITERAL@[124; 125) - INT_NUMBER@[124; 125) "4" - COMMA@[125; 126) "," - R_PAREN@[126; 127) ")" - WHITESPACE@[127; 128) "\n" - R_CURLY@[128; 129) "}" +SOURCE_FILE@0..129 + FUNCTION_DEF@0..129 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..129 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + EXPR_STMT@15..17 + PATH_EXPR@15..16 + PATH@15..16 + PATH_SEGMENT@15..16 + NAME_REF@15..16 + IDENT@15..16 "U" + SEMI@16..17 ";" + WHITESPACE@17..22 "\n " + EXPR_STMT@22..27 + RECORD_LIT@22..26 + PATH_TYPE@22..23 + PATH@22..23 + PATH_SEGMENT@22..23 + NAME_REF@22..23 + IDENT@22..23 "S" + WHITESPACE@23..24 " " + RECORD_FIELD_LIST@24..26 + L_CURLY@24..25 "{" + R_CURLY@25..26 "}" + SEMI@26..27 ";" + WHITESPACE@27..32 "\n " + EXPR_STMT@32..48 + RECORD_LIT@32..47 + PATH_TYPE@32..33 + PATH@32..33 + PATH_SEGMENT@32..33 + NAME_REF@32..33 + IDENT@32..33 "S" + WHITESPACE@33..34 " " + RECORD_FIELD_LIST@34..47 + L_CURLY@34..35 "{" + WHITESPACE@35..36 " " + RECORD_FIELD@36..37 + NAME_REF@36..37 + IDENT@36..37 "x" + COMMA@37..38 "," + WHITESPACE@38..39 " " + RECORD_FIELD@39..44 + NAME_REF@39..40 + IDENT@39..40 "y" + COLON@40..41 ":" + WHITESPACE@41..42 " " + LITERAL@42..44 + INT_NUMBER@42..44 "32" + COMMA@44..45 "," + WHITESPACE@45..46 " " + R_CURLY@46..47 "}" + SEMI@47..48 ";" + WHITESPACE@48..53 "\n " + EXPR_STMT@53..72 + RECORD_LIT@53..71 + PATH_TYPE@53..54 + PATH@53..54 + PATH_SEGMENT@53..54 + NAME_REF@53..54 + IDENT@53..54 "S" + WHITESPACE@54..55 " " + RECORD_FIELD_LIST@55..71 + L_CURLY@55..56 "{" + WHITESPACE@56..57 " " + RECORD_FIELD@57..62 + NAME_REF@57..58 + IDENT@57..58 "x" + COLON@58..59 ":" + WHITESPACE@59..60 " " + LITERAL@60..62 + INT_NUMBER@60..62 "32" + COMMA@62..63 "," + WHITESPACE@63..64 " " + RECORD_FIELD@64..69 + NAME_REF@64..65 + IDENT@64..65 "y" + COLON@65..66 ":" + WHITESPACE@66..67 " " + LITERAL@67..69 + INT_NUMBER@67..69 "64" + WHITESPACE@69..70 " " + R_CURLY@70..71 "}" + SEMI@71..72 ";" + WHITESPACE@72..77 "\n " + EXPR_STMT@77..98 + RECORD_LIT@77..97 + PATH_TYPE@77..88 + PATH@77..88 + PATH_SEGMENT@77..88 + NAME_REF@77..88 + IDENT@77..88 "TupleStruct" + WHITESPACE@88..89 " " + RECORD_FIELD_LIST@89..97 + L_CURLY@89..90 "{" + WHITESPACE@90..91 " " + RECORD_FIELD@91..95 + NAME_REF@91..92 + INT_NUMBER@91..92 "0" + COLON@92..93 ":" + WHITESPACE@93..94 " " + LITERAL@94..95 + INT_NUMBER@94..95 "1" + WHITESPACE@95..96 " " + R_CURLY@96..97 "}" + SEMI@97..98 ";" + WHITESPACE@98..103 "\n " + EXPR_STMT@103..111 + CALL_EXPR@103..110 + PATH_EXPR@103..104 + PATH@103..104 + PATH_SEGMENT@103..104 + NAME_REF@103..104 + IDENT@103..104 "T" + ARG_LIST@104..110 + L_PAREN@104..105 "(" + LITERAL@105..109 + FLOAT_NUMBER@105..109 "1.23" + R_PAREN@109..110 ")" + SEMI@110..111 ";" + WHITESPACE@111..116 "\n " + CALL_EXPR@116..127 + PATH_EXPR@116..117 + PATH@116..117 + PATH_SEGMENT@116..117 + NAME_REF@116..117 + IDENT@116..117 "T" + ARG_LIST@117..127 + L_PAREN@117..118 "(" + LITERAL@118..122 + FLOAT_NUMBER@118..122 "1.23" + COMMA@122..123 "," + WHITESPACE@123..124 " " + LITERAL@124..125 + INT_NUMBER@124..125 "4" + COMMA@125..126 "," + R_PAREN@126..127 ")" + WHITESPACE@127..128 "\n" + R_CURLY@128..129 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__type_alias_def.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__type_alias_def.snap index a17cb47c7..f8190e411 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__type_alias_def.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__type_alias_def.snap @@ -2,34 +2,34 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "type Foo = i32;\ntype Bar = Foo;" --- -SOURCE_FILE@[0; 31) - TYPE_ALIAS_DEF@[0; 15) - TYPE_KW@[0; 4) "type" - WHITESPACE@[4; 5) " " - NAME@[5; 8) - IDENT@[5; 8) "Foo" - WHITESPACE@[8; 9) " " - EQ@[9; 10) "=" - WHITESPACE@[10; 11) " " - PATH_TYPE@[11; 14) - PATH@[11; 14) - PATH_SEGMENT@[11; 14) - NAME_REF@[11; 14) - IDENT@[11; 14) "i32" - SEMI@[14; 15) ";" - WHITESPACE@[15; 16) "\n" - TYPE_ALIAS_DEF@[16; 31) - TYPE_KW@[16; 20) "type" - WHITESPACE@[20; 21) " " - NAME@[21; 24) - IDENT@[21; 24) "Bar" - WHITESPACE@[24; 25) " " - EQ@[25; 26) "=" - WHITESPACE@[26; 27) " " - PATH_TYPE@[27; 30) - PATH@[27; 30) - PATH_SEGMENT@[27; 30) - NAME_REF@[27; 30) - IDENT@[27; 30) "Foo" - SEMI@[30; 31) ";" +SOURCE_FILE@0..31 + TYPE_ALIAS_DEF@0..15 + TYPE_KW@0..4 "type" + WHITESPACE@4..5 " " + NAME@5..8 + IDENT@5..8 "Foo" + WHITESPACE@8..9 " " + EQ@9..10 "=" + WHITESPACE@10..11 " " + PATH_TYPE@11..14 + PATH@11..14 + PATH_SEGMENT@11..14 + NAME_REF@11..14 + IDENT@11..14 "i32" + SEMI@14..15 ";" + WHITESPACE@15..16 "\n" + TYPE_ALIAS_DEF@16..31 + TYPE_KW@16..20 "type" + WHITESPACE@20..21 " " + NAME@21..24 + IDENT@21..24 "Bar" + WHITESPACE@24..25 " " + EQ@25..26 "=" + WHITESPACE@26..27 " " + PATH_TYPE@27..30 + PATH@27..30 + PATH_SEGMENT@27..30 + NAME_REF@27..30 + IDENT@27..30 "Foo" + SEMI@30..31 ";" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__unary_expr.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__unary_expr.snap index 3976ed5f6..a823815e6 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__unary_expr.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__unary_expr.snap @@ -2,52 +2,52 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n let a = --3;\n let b = !!true;\n}" --- -SOURCE_FILE@[0; 49) - FUNCTION_DEF@[0; 49) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 49) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - LET_STMT@[15; 27) - LET_KW@[15; 18) "let" - WHITESPACE@[18; 19) " " - BIND_PAT@[19; 20) - NAME@[19; 20) - IDENT@[19; 20) "a" - WHITESPACE@[20; 21) " " - EQ@[21; 22) "=" - WHITESPACE@[22; 23) " " - PREFIX_EXPR@[23; 26) - MINUS@[23; 24) "-" - PREFIX_EXPR@[24; 26) - MINUS@[24; 25) "-" - LITERAL@[25; 26) - INT_NUMBER@[25; 26) "3" - SEMI@[26; 27) ";" - WHITESPACE@[27; 32) "\n " - LET_STMT@[32; 47) - LET_KW@[32; 35) "let" - WHITESPACE@[35; 36) " " - BIND_PAT@[36; 37) - NAME@[36; 37) - IDENT@[36; 37) "b" - WHITESPACE@[37; 38) " " - EQ@[38; 39) "=" - WHITESPACE@[39; 40) " " - PREFIX_EXPR@[40; 46) - EXCLAMATION@[40; 41) "!" - PREFIX_EXPR@[41; 46) - EXCLAMATION@[41; 42) "!" - LITERAL@[42; 46) - TRUE_KW@[42; 46) "true" - SEMI@[46; 47) ";" - WHITESPACE@[47; 48) "\n" - R_CURLY@[48; 49) "}" +SOURCE_FILE@0..49 + FUNCTION_DEF@0..49 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..49 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + LET_STMT@15..27 + LET_KW@15..18 "let" + WHITESPACE@18..19 " " + BIND_PAT@19..20 + NAME@19..20 + IDENT@19..20 "a" + WHITESPACE@20..21 " " + EQ@21..22 "=" + WHITESPACE@22..23 " " + PREFIX_EXPR@23..26 + MINUS@23..24 "-" + PREFIX_EXPR@24..26 + MINUS@24..25 "-" + LITERAL@25..26 + INT_NUMBER@25..26 "3" + SEMI@26..27 ";" + WHITESPACE@27..32 "\n " + LET_STMT@32..47 + LET_KW@32..35 "let" + WHITESPACE@35..36 " " + BIND_PAT@36..37 + NAME@36..37 + IDENT@36..37 "b" + WHITESPACE@37..38 " " + EQ@38..39 "=" + WHITESPACE@39..40 " " + PREFIX_EXPR@40..46 + EXCLAMATION@40..41 "!" + PREFIX_EXPR@41..46 + EXCLAMATION@41..42 "!" + LITERAL@42..46 + TRUE_KW@42..46 "true" + SEMI@46..47 ";" + WHITESPACE@47..48 "\n" + R_CURLY@48..49 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__use_.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__use_.snap index 0c6cfe388..5d9807ee9 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__use_.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__use_.snap @@ -2,329 +2,329 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "// Simple paths\n use package_name;\n use self::item_in_scope_or_package_name;\n use self::module::Item;\n use package::Item;\n use self::some::Struct;\n use package::some_item;\n\n // Use tree list\n use crate::{Item};\n use self::{Item};\n\n // Wildcard import\n use *; // Error\n use ::*; // Error\n use crate::*;\n use crate::{*};\n\n // Renames\n use some::path as some_name;\n use some::{\n other::path as some_other_name,\n different::path as different_name,\n yet::another::path,\n running::out::of::synonyms::for_::different::*\n };\n use Foo as _;" --- -SOURCE_FILE@[0; 616) - COMMENT@[0; 15) "// Simple paths" - WHITESPACE@[15; 20) "\n " - USE@[20; 37) - USE_KW@[20; 23) "use" - WHITESPACE@[23; 24) " " - USE_TREE@[24; 36) - PATH@[24; 36) - PATH_SEGMENT@[24; 36) - NAME_REF@[24; 36) - IDENT@[24; 36) "package_name" - SEMI@[36; 37) ";" - WHITESPACE@[37; 42) "\n " - USE@[42; 82) - USE_KW@[42; 45) "use" - WHITESPACE@[45; 46) " " - USE_TREE@[46; 81) - PATH@[46; 81) - PATH@[46; 50) - PATH_SEGMENT@[46; 50) - SELF_KW@[46; 50) "self" - COLONCOLON@[50; 52) "::" - PATH_SEGMENT@[52; 81) - NAME_REF@[52; 81) - IDENT@[52; 81) "item_in_scope_or_pack ..." - SEMI@[81; 82) ";" - WHITESPACE@[82; 87) "\n " - USE@[87; 110) - USE_KW@[87; 90) "use" - WHITESPACE@[90; 91) " " - USE_TREE@[91; 109) - PATH@[91; 109) - PATH@[91; 103) - PATH@[91; 95) - PATH_SEGMENT@[91; 95) - SELF_KW@[91; 95) "self" - COLONCOLON@[95; 97) "::" - PATH_SEGMENT@[97; 103) - NAME_REF@[97; 103) - IDENT@[97; 103) "module" - COLONCOLON@[103; 105) "::" - PATH_SEGMENT@[105; 109) - NAME_REF@[105; 109) - IDENT@[105; 109) "Item" - SEMI@[109; 110) ";" - WHITESPACE@[110; 115) "\n " - USE@[115; 133) - USE_KW@[115; 118) "use" - WHITESPACE@[118; 119) " " - USE_TREE@[119; 132) - PATH@[119; 132) - PATH@[119; 126) - PATH_SEGMENT@[119; 126) - PACKAGE_KW@[119; 126) "package" - COLONCOLON@[126; 128) "::" - PATH_SEGMENT@[128; 132) - NAME_REF@[128; 132) - IDENT@[128; 132) "Item" - SEMI@[132; 133) ";" - WHITESPACE@[133; 138) "\n " - USE@[138; 161) - USE_KW@[138; 141) "use" - WHITESPACE@[141; 142) " " - USE_TREE@[142; 160) - PATH@[142; 160) - PATH@[142; 152) - PATH@[142; 146) - PATH_SEGMENT@[142; 146) - SELF_KW@[142; 146) "self" - COLONCOLON@[146; 148) "::" - PATH_SEGMENT@[148; 152) - NAME_REF@[148; 152) - IDENT@[148; 152) "some" - COLONCOLON@[152; 154) "::" - PATH_SEGMENT@[154; 160) - NAME_REF@[154; 160) - IDENT@[154; 160) "Struct" - SEMI@[160; 161) ";" - WHITESPACE@[161; 166) "\n " - USE@[166; 189) - USE_KW@[166; 169) "use" - WHITESPACE@[169; 170) " " - USE_TREE@[170; 188) - PATH@[170; 188) - PATH@[170; 177) - PATH_SEGMENT@[170; 177) - PACKAGE_KW@[170; 177) "package" - COLONCOLON@[177; 179) "::" - PATH_SEGMENT@[179; 188) - NAME_REF@[179; 188) - IDENT@[179; 188) "some_item" - SEMI@[188; 189) ";" - WHITESPACE@[189; 195) "\n\n " - COMMENT@[195; 211) "// Use tree list" - WHITESPACE@[211; 216) "\n " - USE@[216; 234) - USE_KW@[216; 219) "use" - WHITESPACE@[219; 220) " " - USE_TREE@[220; 233) - PATH@[220; 225) - PATH_SEGMENT@[220; 225) - NAME_REF@[220; 225) - IDENT@[220; 225) "crate" - COLONCOLON@[225; 227) "::" - USE_TREE_LIST@[227; 233) - L_CURLY@[227; 228) "{" - USE_TREE@[228; 232) - PATH@[228; 232) - PATH_SEGMENT@[228; 232) - NAME_REF@[228; 232) - IDENT@[228; 232) "Item" - R_CURLY@[232; 233) "}" - SEMI@[233; 234) ";" - WHITESPACE@[234; 239) "\n " - USE@[239; 256) - USE_KW@[239; 242) "use" - WHITESPACE@[242; 243) " " - USE_TREE@[243; 255) - PATH@[243; 247) - PATH_SEGMENT@[243; 247) - SELF_KW@[243; 247) "self" - COLONCOLON@[247; 249) "::" - USE_TREE_LIST@[249; 255) - L_CURLY@[249; 250) "{" - USE_TREE@[250; 254) - PATH@[250; 254) - PATH_SEGMENT@[250; 254) - NAME_REF@[250; 254) - IDENT@[250; 254) "Item" - R_CURLY@[254; 255) "}" - SEMI@[255; 256) ";" - WHITESPACE@[256; 262) "\n\n " - COMMENT@[262; 280) "// Wildcard import" - WHITESPACE@[280; 285) "\n " - USE@[285; 291) - USE_KW@[285; 288) "use" - WHITESPACE@[288; 289) " " - ERROR@[289; 290) - STAR@[289; 290) "*" - SEMI@[290; 291) ";" - WHITESPACE@[291; 292) " " - COMMENT@[292; 300) "// Error" - WHITESPACE@[300; 305) "\n " - USE@[305; 310) - USE_KW@[305; 308) "use" - WHITESPACE@[308; 309) " " - ERROR@[309; 310) - COLON@[309; 310) ":" - ERROR@[310; 311) - COLON@[310; 311) ":" - ERROR@[311; 312) - STAR@[311; 312) "*" - ERROR@[312; 313) - SEMI@[312; 313) ";" - WHITESPACE@[313; 314) " " - COMMENT@[314; 322) "// Error" - WHITESPACE@[322; 327) "\n " - USE@[327; 340) - USE_KW@[327; 330) "use" - WHITESPACE@[330; 331) " " - USE_TREE@[331; 339) - PATH@[331; 336) - PATH_SEGMENT@[331; 336) - NAME_REF@[331; 336) - IDENT@[331; 336) "crate" - COLONCOLON@[336; 338) "::" - STAR@[338; 339) "*" - SEMI@[339; 340) ";" - WHITESPACE@[340; 345) "\n " - USE@[345; 360) - USE_KW@[345; 348) "use" - WHITESPACE@[348; 349) " " - USE_TREE@[349; 359) - PATH@[349; 354) - PATH_SEGMENT@[349; 354) - NAME_REF@[349; 354) - IDENT@[349; 354) "crate" - COLONCOLON@[354; 356) "::" - USE_TREE_LIST@[356; 359) - L_CURLY@[356; 357) "{" - USE_TREE@[357; 358) - STAR@[357; 358) "*" - R_CURLY@[358; 359) "}" - SEMI@[359; 360) ";" - WHITESPACE@[360; 366) "\n\n " - COMMENT@[366; 376) "// Renames" - WHITESPACE@[376; 381) "\n " - USE@[381; 409) - USE_KW@[381; 384) "use" - WHITESPACE@[384; 385) " " - USE_TREE@[385; 408) - PATH@[385; 395) - PATH@[385; 389) - PATH_SEGMENT@[385; 389) - NAME_REF@[385; 389) - IDENT@[385; 389) "some" - COLONCOLON@[389; 391) "::" - PATH_SEGMENT@[391; 395) - NAME_REF@[391; 395) - IDENT@[391; 395) "path" - WHITESPACE@[395; 396) " " - RENAME@[396; 408) - AS_KW@[396; 398) "as" - WHITESPACE@[398; 399) " " - NAME@[399; 408) - IDENT@[399; 408) "some_name" - SEMI@[408; 409) ";" - WHITESPACE@[409; 414) "\n " - USE@[414; 598) - USE_KW@[414; 417) "use" - WHITESPACE@[417; 418) " " - USE_TREE@[418; 597) - PATH@[418; 422) - PATH_SEGMENT@[418; 422) - NAME_REF@[418; 422) - IDENT@[418; 422) "some" - COLONCOLON@[422; 424) "::" - USE_TREE_LIST@[424; 597) - L_CURLY@[424; 425) "{" - WHITESPACE@[425; 434) "\n " - USE_TREE@[434; 464) - PATH@[434; 445) - PATH@[434; 439) - PATH_SEGMENT@[434; 439) - NAME_REF@[434; 439) - IDENT@[434; 439) "other" - COLONCOLON@[439; 441) "::" - PATH_SEGMENT@[441; 445) - NAME_REF@[441; 445) - IDENT@[441; 445) "path" - WHITESPACE@[445; 446) " " - RENAME@[446; 464) - AS_KW@[446; 448) "as" - WHITESPACE@[448; 449) " " - NAME@[449; 464) - IDENT@[449; 464) "some_other_name" - COMMA@[464; 465) "," - WHITESPACE@[465; 474) "\n " - USE_TREE@[474; 507) - PATH@[474; 489) - PATH@[474; 483) - PATH_SEGMENT@[474; 483) - NAME_REF@[474; 483) - IDENT@[474; 483) "different" - COLONCOLON@[483; 485) "::" - PATH_SEGMENT@[485; 489) - NAME_REF@[485; 489) - IDENT@[485; 489) "path" - WHITESPACE@[489; 490) " " - RENAME@[490; 507) - AS_KW@[490; 492) "as" - WHITESPACE@[492; 493) " " - NAME@[493; 507) - IDENT@[493; 507) "different_name" - COMMA@[507; 508) "," - WHITESPACE@[508; 517) "\n " - USE_TREE@[517; 535) - PATH@[517; 535) - PATH@[517; 529) - PATH@[517; 520) - PATH_SEGMENT@[517; 520) - NAME_REF@[517; 520) - IDENT@[517; 520) "yet" - COLONCOLON@[520; 522) "::" - PATH_SEGMENT@[522; 529) - NAME_REF@[522; 529) - IDENT@[522; 529) "another" - COLONCOLON@[529; 531) "::" - PATH_SEGMENT@[531; 535) - NAME_REF@[531; 535) - IDENT@[531; 535) "path" - COMMA@[535; 536) "," - WHITESPACE@[536; 545) "\n " - USE_TREE@[545; 591) - PATH@[545; 588) - PATH@[545; 577) - PATH@[545; 571) - PATH@[545; 561) - PATH@[545; 557) - PATH@[545; 552) - PATH_SEGMENT@[545; 552) - NAME_REF@[545; 552) - IDENT@[545; 552) "running" - COLONCOLON@[552; 554) "::" - PATH_SEGMENT@[554; 557) - NAME_REF@[554; 557) - IDENT@[554; 557) "out" - COLONCOLON@[557; 559) "::" - PATH_SEGMENT@[559; 561) - NAME_REF@[559; 561) - IDENT@[559; 561) "of" - COLONCOLON@[561; 563) "::" - PATH_SEGMENT@[563; 571) - NAME_REF@[563; 571) - IDENT@[563; 571) "synonyms" - COLONCOLON@[571; 573) "::" - PATH_SEGMENT@[573; 577) - NAME_REF@[573; 577) - IDENT@[573; 577) "for_" - COLONCOLON@[577; 579) "::" - PATH_SEGMENT@[579; 588) - NAME_REF@[579; 588) - IDENT@[579; 588) "different" - COLONCOLON@[588; 590) "::" - STAR@[590; 591) "*" - WHITESPACE@[591; 596) "\n " - R_CURLY@[596; 597) "}" - SEMI@[597; 598) ";" - WHITESPACE@[598; 603) "\n " - USE@[603; 616) - USE_KW@[603; 606) "use" - WHITESPACE@[606; 607) " " - USE_TREE@[607; 615) - PATH@[607; 610) - PATH_SEGMENT@[607; 610) - NAME_REF@[607; 610) - IDENT@[607; 610) "Foo" - WHITESPACE@[610; 611) " " - RENAME@[611; 615) - AS_KW@[611; 613) "as" - WHITESPACE@[613; 614) " " - UNDERSCORE@[614; 615) "_" - SEMI@[615; 616) ";" +SOURCE_FILE@0..616 + COMMENT@0..15 "// Simple paths" + WHITESPACE@15..20 "\n " + USE@20..37 + USE_KW@20..23 "use" + WHITESPACE@23..24 " " + USE_TREE@24..36 + PATH@24..36 + PATH_SEGMENT@24..36 + NAME_REF@24..36 + IDENT@24..36 "package_name" + SEMI@36..37 ";" + WHITESPACE@37..42 "\n " + USE@42..82 + USE_KW@42..45 "use" + WHITESPACE@45..46 " " + USE_TREE@46..81 + PATH@46..81 + PATH@46..50 + PATH_SEGMENT@46..50 + SELF_KW@46..50 "self" + COLONCOLON@50..52 "::" + PATH_SEGMENT@52..81 + NAME_REF@52..81 + IDENT@52..81 "item_in_scope_or_pack ..." + SEMI@81..82 ";" + WHITESPACE@82..87 "\n " + USE@87..110 + USE_KW@87..90 "use" + WHITESPACE@90..91 " " + USE_TREE@91..109 + PATH@91..109 + PATH@91..103 + PATH@91..95 + PATH_SEGMENT@91..95 + SELF_KW@91..95 "self" + COLONCOLON@95..97 "::" + PATH_SEGMENT@97..103 + NAME_REF@97..103 + IDENT@97..103 "module" + COLONCOLON@103..105 "::" + PATH_SEGMENT@105..109 + NAME_REF@105..109 + IDENT@105..109 "Item" + SEMI@109..110 ";" + WHITESPACE@110..115 "\n " + USE@115..133 + USE_KW@115..118 "use" + WHITESPACE@118..119 " " + USE_TREE@119..132 + PATH@119..132 + PATH@119..126 + PATH_SEGMENT@119..126 + PACKAGE_KW@119..126 "package" + COLONCOLON@126..128 "::" + PATH_SEGMENT@128..132 + NAME_REF@128..132 + IDENT@128..132 "Item" + SEMI@132..133 ";" + WHITESPACE@133..138 "\n " + USE@138..161 + USE_KW@138..141 "use" + WHITESPACE@141..142 " " + USE_TREE@142..160 + PATH@142..160 + PATH@142..152 + PATH@142..146 + PATH_SEGMENT@142..146 + SELF_KW@142..146 "self" + COLONCOLON@146..148 "::" + PATH_SEGMENT@148..152 + NAME_REF@148..152 + IDENT@148..152 "some" + COLONCOLON@152..154 "::" + PATH_SEGMENT@154..160 + NAME_REF@154..160 + IDENT@154..160 "Struct" + SEMI@160..161 ";" + WHITESPACE@161..166 "\n " + USE@166..189 + USE_KW@166..169 "use" + WHITESPACE@169..170 " " + USE_TREE@170..188 + PATH@170..188 + PATH@170..177 + PATH_SEGMENT@170..177 + PACKAGE_KW@170..177 "package" + COLONCOLON@177..179 "::" + PATH_SEGMENT@179..188 + NAME_REF@179..188 + IDENT@179..188 "some_item" + SEMI@188..189 ";" + WHITESPACE@189..195 "\n\n " + COMMENT@195..211 "// Use tree list" + WHITESPACE@211..216 "\n " + USE@216..234 + USE_KW@216..219 "use" + WHITESPACE@219..220 " " + USE_TREE@220..233 + PATH@220..225 + PATH_SEGMENT@220..225 + NAME_REF@220..225 + IDENT@220..225 "crate" + COLONCOLON@225..227 "::" + USE_TREE_LIST@227..233 + L_CURLY@227..228 "{" + USE_TREE@228..232 + PATH@228..232 + PATH_SEGMENT@228..232 + NAME_REF@228..232 + IDENT@228..232 "Item" + R_CURLY@232..233 "}" + SEMI@233..234 ";" + WHITESPACE@234..239 "\n " + USE@239..256 + USE_KW@239..242 "use" + WHITESPACE@242..243 " " + USE_TREE@243..255 + PATH@243..247 + PATH_SEGMENT@243..247 + SELF_KW@243..247 "self" + COLONCOLON@247..249 "::" + USE_TREE_LIST@249..255 + L_CURLY@249..250 "{" + USE_TREE@250..254 + PATH@250..254 + PATH_SEGMENT@250..254 + NAME_REF@250..254 + IDENT@250..254 "Item" + R_CURLY@254..255 "}" + SEMI@255..256 ";" + WHITESPACE@256..262 "\n\n " + COMMENT@262..280 "// Wildcard import" + WHITESPACE@280..285 "\n " + USE@285..291 + USE_KW@285..288 "use" + WHITESPACE@288..289 " " + ERROR@289..290 + STAR@289..290 "*" + SEMI@290..291 ";" + WHITESPACE@291..292 " " + COMMENT@292..300 "// Error" + WHITESPACE@300..305 "\n " + USE@305..310 + USE_KW@305..308 "use" + WHITESPACE@308..309 " " + ERROR@309..310 + COLON@309..310 ":" + ERROR@310..311 + COLON@310..311 ":" + ERROR@311..312 + STAR@311..312 "*" + ERROR@312..313 + SEMI@312..313 ";" + WHITESPACE@313..314 " " + COMMENT@314..322 "// Error" + WHITESPACE@322..327 "\n " + USE@327..340 + USE_KW@327..330 "use" + WHITESPACE@330..331 " " + USE_TREE@331..339 + PATH@331..336 + PATH_SEGMENT@331..336 + NAME_REF@331..336 + IDENT@331..336 "crate" + COLONCOLON@336..338 "::" + STAR@338..339 "*" + SEMI@339..340 ";" + WHITESPACE@340..345 "\n " + USE@345..360 + USE_KW@345..348 "use" + WHITESPACE@348..349 " " + USE_TREE@349..359 + PATH@349..354 + PATH_SEGMENT@349..354 + NAME_REF@349..354 + IDENT@349..354 "crate" + COLONCOLON@354..356 "::" + USE_TREE_LIST@356..359 + L_CURLY@356..357 "{" + USE_TREE@357..358 + STAR@357..358 "*" + R_CURLY@358..359 "}" + SEMI@359..360 ";" + WHITESPACE@360..366 "\n\n " + COMMENT@366..376 "// Renames" + WHITESPACE@376..381 "\n " + USE@381..409 + USE_KW@381..384 "use" + WHITESPACE@384..385 " " + USE_TREE@385..408 + PATH@385..395 + PATH@385..389 + PATH_SEGMENT@385..389 + NAME_REF@385..389 + IDENT@385..389 "some" + COLONCOLON@389..391 "::" + PATH_SEGMENT@391..395 + NAME_REF@391..395 + IDENT@391..395 "path" + WHITESPACE@395..396 " " + RENAME@396..408 + AS_KW@396..398 "as" + WHITESPACE@398..399 " " + NAME@399..408 + IDENT@399..408 "some_name" + SEMI@408..409 ";" + WHITESPACE@409..414 "\n " + USE@414..598 + USE_KW@414..417 "use" + WHITESPACE@417..418 " " + USE_TREE@418..597 + PATH@418..422 + PATH_SEGMENT@418..422 + NAME_REF@418..422 + IDENT@418..422 "some" + COLONCOLON@422..424 "::" + USE_TREE_LIST@424..597 + L_CURLY@424..425 "{" + WHITESPACE@425..434 "\n " + USE_TREE@434..464 + PATH@434..445 + PATH@434..439 + PATH_SEGMENT@434..439 + NAME_REF@434..439 + IDENT@434..439 "other" + COLONCOLON@439..441 "::" + PATH_SEGMENT@441..445 + NAME_REF@441..445 + IDENT@441..445 "path" + WHITESPACE@445..446 " " + RENAME@446..464 + AS_KW@446..448 "as" + WHITESPACE@448..449 " " + NAME@449..464 + IDENT@449..464 "some_other_name" + COMMA@464..465 "," + WHITESPACE@465..474 "\n " + USE_TREE@474..507 + PATH@474..489 + PATH@474..483 + PATH_SEGMENT@474..483 + NAME_REF@474..483 + IDENT@474..483 "different" + COLONCOLON@483..485 "::" + PATH_SEGMENT@485..489 + NAME_REF@485..489 + IDENT@485..489 "path" + WHITESPACE@489..490 " " + RENAME@490..507 + AS_KW@490..492 "as" + WHITESPACE@492..493 " " + NAME@493..507 + IDENT@493..507 "different_name" + COMMA@507..508 "," + WHITESPACE@508..517 "\n " + USE_TREE@517..535 + PATH@517..535 + PATH@517..529 + PATH@517..520 + PATH_SEGMENT@517..520 + NAME_REF@517..520 + IDENT@517..520 "yet" + COLONCOLON@520..522 "::" + PATH_SEGMENT@522..529 + NAME_REF@522..529 + IDENT@522..529 "another" + COLONCOLON@529..531 "::" + PATH_SEGMENT@531..535 + NAME_REF@531..535 + IDENT@531..535 "path" + COMMA@535..536 "," + WHITESPACE@536..545 "\n " + USE_TREE@545..591 + PATH@545..588 + PATH@545..577 + PATH@545..571 + PATH@545..561 + PATH@545..557 + PATH@545..552 + PATH_SEGMENT@545..552 + NAME_REF@545..552 + IDENT@545..552 "running" + COLONCOLON@552..554 "::" + PATH_SEGMENT@554..557 + NAME_REF@554..557 + IDENT@554..557 "out" + COLONCOLON@557..559 "::" + PATH_SEGMENT@559..561 + NAME_REF@559..561 + IDENT@559..561 "of" + COLONCOLON@561..563 "::" + PATH_SEGMENT@563..571 + NAME_REF@563..571 + IDENT@563..571 "synonyms" + COLONCOLON@571..573 "::" + PATH_SEGMENT@573..577 + NAME_REF@573..577 + IDENT@573..577 "for_" + COLONCOLON@577..579 "::" + PATH_SEGMENT@579..588 + NAME_REF@579..588 + IDENT@579..588 "different" + COLONCOLON@588..590 "::" + STAR@590..591 "*" + WHITESPACE@591..596 "\n " + R_CURLY@596..597 "}" + SEMI@597..598 ";" + WHITESPACE@598..603 "\n " + USE@603..616 + USE_KW@603..606 "use" + WHITESPACE@606..607 " " + USE_TREE@607..615 + PATH@607..610 + PATH_SEGMENT@607..610 + NAME_REF@607..610 + IDENT@607..610 "Foo" + WHITESPACE@610..611 " " + RENAME@611..615 + AS_KW@611..613 "as" + WHITESPACE@613..614 " " + UNDERSCORE@614..615 "_" + SEMI@615..616 ";" error Offset(289): expected one of `self`, `super`, `package` or an identifier error Offset(309): expected one of `self`, `super`, `package` or an identifier error Offset(310): expected SEMI diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__visibility.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__visibility.snap index 835ccdcb6..3e1b77cd4 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__visibility.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__visibility.snap @@ -2,93 +2,93 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "pub struct Foo {};\npub(package) struct(gc) Baz {};\npub(super) fn foo() {}\npub(package) fn bar() {}\npub fn baz() {}" --- -SOURCE_FILE@[0; 114) - STRUCT_DEF@[0; 18) - VISIBILITY@[0; 3) - PUB_KW@[0; 3) "pub" - WHITESPACE@[3; 4) " " - STRUCT_KW@[4; 10) "struct" - WHITESPACE@[10; 11) " " - NAME@[11; 14) - IDENT@[11; 14) "Foo" - WHITESPACE@[14; 15) " " - RECORD_FIELD_DEF_LIST@[15; 18) - L_CURLY@[15; 16) "{" - R_CURLY@[16; 17) "}" - SEMI@[17; 18) ";" - WHITESPACE@[18; 19) "\n" - STRUCT_DEF@[19; 50) - VISIBILITY@[19; 31) - PUB_KW@[19; 22) "pub" - L_PAREN@[22; 23) "(" - PACKAGE_KW@[23; 30) "package" - R_PAREN@[30; 31) ")" - WHITESPACE@[31; 32) " " - STRUCT_KW@[32; 38) "struct" - MEMORY_TYPE_SPECIFIER@[38; 42) - L_PAREN@[38; 39) "(" - GC_KW@[39; 41) "gc" - R_PAREN@[41; 42) ")" - WHITESPACE@[42; 43) " " - NAME@[43; 46) - IDENT@[43; 46) "Baz" - WHITESPACE@[46; 47) " " - RECORD_FIELD_DEF_LIST@[47; 50) - L_CURLY@[47; 48) "{" - R_CURLY@[48; 49) "}" - SEMI@[49; 50) ";" - FUNCTION_DEF@[50; 73) - WHITESPACE@[50; 51) "\n" - VISIBILITY@[51; 61) - PUB_KW@[51; 54) "pub" - L_PAREN@[54; 55) "(" - SUPER_KW@[55; 60) "super" - R_PAREN@[60; 61) ")" - WHITESPACE@[61; 62) " " - FN_KW@[62; 64) "fn" - WHITESPACE@[64; 65) " " - NAME@[65; 68) - IDENT@[65; 68) "foo" - PARAM_LIST@[68; 70) - L_PAREN@[68; 69) "(" - R_PAREN@[69; 70) ")" - WHITESPACE@[70; 71) " " - BLOCK_EXPR@[71; 73) - L_CURLY@[71; 72) "{" - R_CURLY@[72; 73) "}" - FUNCTION_DEF@[73; 98) - WHITESPACE@[73; 74) "\n" - VISIBILITY@[74; 86) - PUB_KW@[74; 77) "pub" - L_PAREN@[77; 78) "(" - PACKAGE_KW@[78; 85) "package" - R_PAREN@[85; 86) ")" - WHITESPACE@[86; 87) " " - FN_KW@[87; 89) "fn" - WHITESPACE@[89; 90) " " - NAME@[90; 93) - IDENT@[90; 93) "bar" - PARAM_LIST@[93; 95) - L_PAREN@[93; 94) "(" - R_PAREN@[94; 95) ")" - WHITESPACE@[95; 96) " " - BLOCK_EXPR@[96; 98) - L_CURLY@[96; 97) "{" - R_CURLY@[97; 98) "}" - FUNCTION_DEF@[98; 114) - WHITESPACE@[98; 99) "\n" - VISIBILITY@[99; 102) - PUB_KW@[99; 102) "pub" - WHITESPACE@[102; 103) " " - FN_KW@[103; 105) "fn" - WHITESPACE@[105; 106) " " - NAME@[106; 109) - IDENT@[106; 109) "baz" - PARAM_LIST@[109; 111) - L_PAREN@[109; 110) "(" - R_PAREN@[110; 111) ")" - WHITESPACE@[111; 112) " " - BLOCK_EXPR@[112; 114) - L_CURLY@[112; 113) "{" - R_CURLY@[113; 114) "}" +SOURCE_FILE@0..114 + STRUCT_DEF@0..18 + VISIBILITY@0..3 + PUB_KW@0..3 "pub" + WHITESPACE@3..4 " " + STRUCT_KW@4..10 "struct" + WHITESPACE@10..11 " " + NAME@11..14 + IDENT@11..14 "Foo" + WHITESPACE@14..15 " " + RECORD_FIELD_DEF_LIST@15..18 + L_CURLY@15..16 "{" + R_CURLY@16..17 "}" + SEMI@17..18 ";" + WHITESPACE@18..19 "\n" + STRUCT_DEF@19..50 + VISIBILITY@19..31 + PUB_KW@19..22 "pub" + L_PAREN@22..23 "(" + PACKAGE_KW@23..30 "package" + R_PAREN@30..31 ")" + WHITESPACE@31..32 " " + STRUCT_KW@32..38 "struct" + MEMORY_TYPE_SPECIFIER@38..42 + L_PAREN@38..39 "(" + GC_KW@39..41 "gc" + R_PAREN@41..42 ")" + WHITESPACE@42..43 " " + NAME@43..46 + IDENT@43..46 "Baz" + WHITESPACE@46..47 " " + RECORD_FIELD_DEF_LIST@47..50 + L_CURLY@47..48 "{" + R_CURLY@48..49 "}" + SEMI@49..50 ";" + FUNCTION_DEF@50..73 + WHITESPACE@50..51 "\n" + VISIBILITY@51..61 + PUB_KW@51..54 "pub" + L_PAREN@54..55 "(" + SUPER_KW@55..60 "super" + R_PAREN@60..61 ")" + WHITESPACE@61..62 " " + FN_KW@62..64 "fn" + WHITESPACE@64..65 " " + NAME@65..68 + IDENT@65..68 "foo" + PARAM_LIST@68..70 + L_PAREN@68..69 "(" + R_PAREN@69..70 ")" + WHITESPACE@70..71 " " + BLOCK_EXPR@71..73 + L_CURLY@71..72 "{" + R_CURLY@72..73 "}" + FUNCTION_DEF@73..98 + WHITESPACE@73..74 "\n" + VISIBILITY@74..86 + PUB_KW@74..77 "pub" + L_PAREN@77..78 "(" + PACKAGE_KW@78..85 "package" + R_PAREN@85..86 ")" + WHITESPACE@86..87 " " + FN_KW@87..89 "fn" + WHITESPACE@89..90 " " + NAME@90..93 + IDENT@90..93 "bar" + PARAM_LIST@93..95 + L_PAREN@93..94 "(" + R_PAREN@94..95 ")" + WHITESPACE@95..96 " " + BLOCK_EXPR@96..98 + L_CURLY@96..97 "{" + R_CURLY@97..98 "}" + FUNCTION_DEF@98..114 + WHITESPACE@98..99 "\n" + VISIBILITY@99..102 + PUB_KW@99..102 "pub" + WHITESPACE@102..103 " " + FN_KW@103..105 "fn" + WHITESPACE@105..106 " " + NAME@106..109 + IDENT@106..109 "baz" + PARAM_LIST@109..111 + L_PAREN@109..110 "(" + R_PAREN@110..111 ")" + WHITESPACE@111..112 " " + BLOCK_EXPR@112..114 + L_CURLY@112..113 "{" + R_CURLY@113..114 "}" diff --git a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__while_expr.snap b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__while_expr.snap index 267b037f2..7d37732e2 100644 --- a/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__while_expr.snap +++ b/crates/mun_syntax/src/tests/snapshots/mun_syntax__tests__parser__while_expr.snap @@ -2,49 +2,49 @@ source: crates/mun_syntax/src/tests/parser.rs expression: "fn foo() {\n while true {};\n while { true } {};\n}" --- -SOURCE_FILE@[0; 54) - FUNCTION_DEF@[0; 54) - FN_KW@[0; 2) "fn" - WHITESPACE@[2; 3) " " - NAME@[3; 6) - IDENT@[3; 6) "foo" - PARAM_LIST@[6; 8) - L_PAREN@[6; 7) "(" - R_PAREN@[7; 8) ")" - WHITESPACE@[8; 9) " " - BLOCK_EXPR@[9; 54) - L_CURLY@[9; 10) "{" - WHITESPACE@[10; 15) "\n " - EXPR_STMT@[15; 29) - WHILE_EXPR@[15; 28) - WHILE_KW@[15; 20) "while" - WHITESPACE@[20; 21) " " - CONDITION@[21; 25) - LITERAL@[21; 25) - TRUE_KW@[21; 25) "true" - WHITESPACE@[25; 26) " " - BLOCK_EXPR@[26; 28) - L_CURLY@[26; 27) "{" - R_CURLY@[27; 28) "}" - SEMI@[28; 29) ";" - WHITESPACE@[29; 34) "\n " - EXPR_STMT@[34; 52) - WHILE_EXPR@[34; 51) - WHILE_KW@[34; 39) "while" - WHITESPACE@[39; 40) " " - CONDITION@[40; 48) - BLOCK_EXPR@[40; 48) - L_CURLY@[40; 41) "{" - WHITESPACE@[41; 42) " " - LITERAL@[42; 46) - TRUE_KW@[42; 46) "true" - WHITESPACE@[46; 47) " " - R_CURLY@[47; 48) "}" - WHITESPACE@[48; 49) " " - BLOCK_EXPR@[49; 51) - L_CURLY@[49; 50) "{" - R_CURLY@[50; 51) "}" - SEMI@[51; 52) ";" - WHITESPACE@[52; 53) "\n" - R_CURLY@[53; 54) "}" +SOURCE_FILE@0..54 + FUNCTION_DEF@0..54 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..54 + L_CURLY@9..10 "{" + WHITESPACE@10..15 "\n " + EXPR_STMT@15..29 + WHILE_EXPR@15..28 + WHILE_KW@15..20 "while" + WHITESPACE@20..21 " " + CONDITION@21..25 + LITERAL@21..25 + TRUE_KW@21..25 "true" + WHITESPACE@25..26 " " + BLOCK_EXPR@26..28 + L_CURLY@26..27 "{" + R_CURLY@27..28 "}" + SEMI@28..29 ";" + WHITESPACE@29..34 "\n " + EXPR_STMT@34..52 + WHILE_EXPR@34..51 + WHILE_KW@34..39 "while" + WHITESPACE@39..40 " " + CONDITION@40..48 + BLOCK_EXPR@40..48 + L_CURLY@40..41 "{" + WHITESPACE@41..42 " " + LITERAL@42..46 + TRUE_KW@42..46 "true" + WHITESPACE@46..47 " " + R_CURLY@47..48 "}" + WHITESPACE@48..49 " " + BLOCK_EXPR@49..51 + L_CURLY@49..50 "{" + R_CURLY@50..51 "}" + SEMI@51..52 ";" + WHITESPACE@52..53 "\n" + R_CURLY@53..54 "}"