Repository: rust-analyzer/rust-analyzer
Pull request #1339 (2019-05-29 07:19:15)

flip Into to From

matklad: bors r+
🤖
bors[bot]: # Build failed
  * [continuous-integration/travis-ci/push](https://travis-ci.org/rust-analyzer/rust-analyzer/builds/538603327?utm_source=github_status&utm_medium=notification)

Patch:
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 930a643b74..8c0ba6f2d3 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -76,7 +76,7 @@ impl Parse {
     pub fn debug_dump(&self) -> String {
         let mut buf = self.tree.syntax().debug_dump();
         for err in self.errors.iter() {
-            writeln!(buf, "err: `{}`", err).unwrap();
+            writeln!(buf, "error {:?}: {}", err.location(), err.kind()).unwrap();
         }
         buf
     }
diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/ra_syntax/src/syntax_error.rs
index 27e12293be..d29c0cf6c7 100644
--- a/crates/ra_syntax/src/syntax_error.rs
+++ b/crates/ra_syntax/src/syntax_error.rs
@@ -13,21 +13,30 @@ pub struct SyntaxError {
     location: Location,
 }
 
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash)]
 pub enum Location {
     Offset(TextUnit),
     Range(TextRange),
 }
 
-impl Into<Location> for TextUnit {
-    fn into(self) -> Location {
-        Location::Offset(self)
+impl From<TextUnit> for Location {
+    fn from(offset: TextUnit) -> Location {
+        Location::Offset(offset)
+    }
+}
+
+impl From<TextRange> for Location {
+    fn from(range: TextRange) -> Location {
+        Location::Range(range)
     }
 }
 
-impl Into<Location> for TextRange {
-    fn into(self) -> Location {
-        Location::Range(self)
+impl fmt::Debug for Location {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match self {
+            Location::Offset(it) => fmt::Debug::fmt(it, f),
+            Location::Range(it) => fmt::Debug::fmt(it, f),
+        }
     }
 }
 


Test patch:
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs
index f61048aaf0..40d825893e 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/main.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs
@@ -18,7 +18,8 @@ use tempfile::TempDir;
 use crate::support::{project, Project};
 
 const LOG: &'static str = "";
-const PROFILE: &'static str = "*@3>100";
+const PROFILE: &'static str = "";
+// const PROFILE: &'static str = "*@3>100";
 
 #[test]
 fn completes_items_from_standard_library() {
diff --git a/crates/ra_syntax/tests/data/parser/err/0000_struct_field_missing_comma.txt b/crates/ra_syntax/tests/data/parser/err/0000_struct_field_missing_comma.txt
index 0662052c5a..0dbbfe8534 100644
--- a/crates/ra_syntax/tests/data/parser/err/0000_struct_field_missing_comma.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0000_struct_field_missing_comma.txt
@@ -31,4 +31,4 @@ SOURCE_FILE@[0; 34)
                 IDENT@[29; 32) "u32"
       WHITESPACE@[32; 33) "\n"
       R_CURLY@[33; 34) "}"
-err: `expected COMMA`
+error 21: expected COMMA
diff --git a/crates/ra_syntax/tests/data/parser/err/0001_item_recovery_in_file.txt b/crates/ra_syntax/tests/data/parser/err/0001_item_recovery_in_file.txt
index 45044fe0af..7cfb54ef87 100644
--- a/crates/ra_syntax/tests/data/parser/err/0001_item_recovery_in_file.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0001_item_recovery_in_file.txt
@@ -14,5 +14,5 @@ SOURCE_FILE@[0; 21)
     NAMED_FIELD_DEF_LIST@[19; 21)
       L_CURLY@[19; 20) "{"
       R_CURLY@[20; 21) "}"
-err: `expected an item`
-err: `expected an item`
+error 0: expected an item
+error 3: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/err/0002_duplicate_shebang.txt b/crates/ra_syntax/tests/data/parser/err/0002_duplicate_shebang.txt
index 1506acdfd7..76d186a3ce 100644
--- a/crates/ra_syntax/tests/data/parser/err/0002_duplicate_shebang.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0002_duplicate_shebang.txt
@@ -4,4 +4,4 @@ SOURCE_FILE@[0; 42)
   ERROR@[21; 41)
     SHEBANG@[21; 41) "#!/use/bin/env rusti"
   WHITESPACE@[41; 42) "\n"
-err: `expected an item`
+error 21: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/err/0003_C++_semicolon.txt b/crates/ra_syntax/tests/data/parser/err/0003_C++_semicolon.txt
index 586baf1bbd..8578260378 100644
--- a/crates/ra_syntax/tests/data/parser/err/0003_C++_semicolon.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0003_C++_semicolon.txt
@@ -35,5 +35,5 @@ SOURCE_FILE@[0; 40)
       R_CURLY@[38; 39) "}"
   ERROR@[39; 40)
     SEMI@[39; 40) ";"
-err: `expected item, found `;`
-consider removing this semicolon`
+error 39: expected item, found `;`
+consider removing this semicolon
diff --git a/crates/ra_syntax/tests/data/parser/err/0004_use_path_bad_segment.txt b/crates/ra_syntax/tests/data/parser/err/0004_use_path_bad_segment.txt
index a702239120..5210a884d9 100644
--- a/crates/ra_syntax/tests/data/parser/err/0004_use_path_bad_segment.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0004_use_path_bad_segment.txt
@@ -13,4 +13,4 @@ SOURCE_FILE@[0; 12)
           ERROR@[9; 11)
             INT_NUMBER@[9; 11) "92"
     SEMI@[11; 12) ";"
-err: `expected identifier`
+error 9: expected identifier
diff --git a/crates/ra_syntax/tests/data/parser/err/0005_attribute_recover.txt b/crates/ra_syntax/tests/data/parser/err/0005_attribute_recover.txt
index 9a6da88feb..6d5199a56b 100644
--- a/crates/ra_syntax/tests/data/parser/err/0005_attribute_recover.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0005_attribute_recover.txt
@@ -50,6 +50,6 @@ SOURCE_FILE@[0; 54)
           WHITESPACE@[51; 52) "\n"
           R_CURLY@[52; 53) "}"
   WHITESPACE@[53; 54) "\n"
-err: `expected R_PAREN`
-err: `expected R_BRACK`
-err: `expected an item`
+error 53: expected R_PAREN
+error 53: expected R_BRACK
+error 53: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/err/0006_named_field_recovery.txt b/crates/ra_syntax/tests/data/parser/err/0006_named_field_recovery.txt
index 5effbb60f4..6143e68f13 100644
--- a/crates/ra_syntax/tests/data/parser/err/0006_named_field_recovery.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0006_named_field_recovery.txt
@@ -64,11 +64,11 @@ SOURCE_FILE@[0; 74)
       WHITESPACE@[71; 72) "\n"
       R_CURLY@[72; 73) "}"
   WHITESPACE@[73; 74) "\n"
-err: `expected field declaration`
-err: `expected COMMA`
-err: `expected field declaration`
-err: `expected COMMA`
-err: `expected field declaration`
-err: `expected COMMA`
-err: `expected field declaration`
-err: `expected COMMA`
+error 31: expected field declaration
+error 33: expected COMMA
+error 38: expected field declaration
+error 39: expected COMMA
+error 40: expected field declaration
+error 41: expected COMMA
+error 42: expected field declaration
+error 43: expected COMMA
diff --git a/crates/ra_syntax/tests/data/parser/err/0007_stray_curly_in_file.txt b/crates/ra_syntax/tests/data/parser/err/0007_stray_curly_in_file.txt
index ff59f5d712..b79e01238f 100644
--- a/crates/ra_syntax/tests/data/parser/err/0007_stray_curly_in_file.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0007_stray_curly_in_file.txt
@@ -27,6 +27,6 @@ SOURCE_FILE@[0; 31)
   ERROR@[29; 30)
     R_CURLY@[29; 30) "}"
   WHITESPACE@[30; 31) "\n"
-err: `unmatched `}``
-err: `unmatched `}``
-err: `unmatched `}``
+error 0: unmatched `}`
+error 14: unmatched `}`
+error 29: unmatched `}`
diff --git a/crates/ra_syntax/tests/data/parser/err/0008_item_block_recovery.txt b/crates/ra_syntax/tests/data/parser/err/0008_item_block_recovery.txt
index 75f6b3b9c6..9a8871579b 100644
--- a/crates/ra_syntax/tests/data/parser/err/0008_item_block_recovery.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0008_item_block_recovery.txt
@@ -72,6 +72,6 @@ SOURCE_FILE@[0; 95)
       WHITESPACE@[92; 93) "\n"
       R_CURLY@[93; 94) "}"
   WHITESPACE@[94; 95) "\n"
-err: `expected EXCL`
-err: `expected SEMI`
-err: `expected an item`
+error 17: expected EXCL
+error 19: expected SEMI
+error 20: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/err/0009_broken_struct_type_parameter.txt b/crates/ra_syntax/tests/data/parser/err/0009_broken_struct_type_parameter.txt
index 8aa8c3ef42..e147d6424b 100644
--- a/crates/ra_syntax/tests/data/parser/err/0009_broken_struct_type_parameter.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0009_broken_struct_type_parameter.txt
@@ -45,14 +45,14 @@ SOURCE_FILE@[0; 43)
       IDENT@[40; 41) "T"
     SEMI@[41; 42) ";"
   WHITESPACE@[42; 43) "\n"
-err: `expected type parameter`
-err: `expected COMMA`
-err: `expected R_ANGLE`
-err: `expected `;`, `{`, or `(``
-err: `expected an item`
-err: `expected an item`
-err: `expected an item`
-err: `expected an item`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
+error 9: expected type parameter
+error 11: expected COMMA
+error 11: expected R_ANGLE
+error 11: expected `;`, `{`, or `(`
+error 12: expected an item
+error 14: expected an item
+error 15: expected an item
+error 17: expected an item
+error 24: expected SEMI
+error 24: expected expression
+error 25: expected SEMI
diff --git a/crates/ra_syntax/tests/data/parser/err/0010_unsafe_lambda_block.txt b/crates/ra_syntax/tests/data/parser/err/0010_unsafe_lambda_block.txt
index 22a1727f08..c46809f81f 100644
--- a/crates/ra_syntax/tests/data/parser/err/0010_unsafe_lambda_block.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0010_unsafe_lambda_block.txt
@@ -39,4 +39,4 @@ SOURCE_FILE@[0; 42)
       WHITESPACE@[39; 40) "\n"
       R_CURLY@[40; 41) "}"
   WHITESPACE@[41; 42) "\n"
-err: `expected `{``
+error 24: expected `{`
diff --git a/crates/ra_syntax/tests/data/parser/err/0011_extern_struct.txt b/crates/ra_syntax/tests/data/parser/err/0011_extern_struct.txt
index ee2a29d9f3..033dac2aa9 100644
--- a/crates/ra_syntax/tests/data/parser/err/0011_extern_struct.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0011_extern_struct.txt
@@ -10,4 +10,4 @@ SOURCE_FILE@[0; 19)
       IDENT@[14; 17) "Foo"
     SEMI@[17; 18) ";"
   WHITESPACE@[18; 19) "\n"
-err: `expected fn, trait or impl`
+error 6: expected fn, trait or impl
diff --git a/crates/ra_syntax/tests/data/parser/err/0013_invalid_type.txt b/crates/ra_syntax/tests/data/parser/err/0013_invalid_type.txt
index 1f5cc55c0e..bef286b372 100644
--- a/crates/ra_syntax/tests/data/parser/err/0013_invalid_type.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0013_invalid_type.txt
@@ -69,21 +69,21 @@ SOURCE_FILE@[0; 86)
   ERROR@[83; 84)
     SEMI@[83; 84) ";"
   WHITESPACE@[84; 86) "\n\n"
-err: `expected type`
-err: `expected COMMA`
-err: `expected R_ANGLE`
-err: `expected COMMA`
-err: `expected R_ANGLE`
-err: `expected COMMA`
-err: `expected R_ANGLE`
-err: `expected COMMA`
-err: `expected COMMA`
-err: `expected a type`
-err: `expected R_PAREN`
-err: `expected SEMI`
-err: `expected an item`
-err: `expected an item`
-err: `expected an item`
-err: `expected an item`
-err: `expected an item`
-err: `expected an item`
+error 67: expected type
+error 68: expected COMMA
+error 68: expected R_ANGLE
+error 68: expected COMMA
+error 68: expected R_ANGLE
+error 68: expected COMMA
+error 68: expected R_ANGLE
+error 68: expected COMMA
+error 72: expected COMMA
+error 72: expected a type
+error 72: expected R_PAREN
+error 72: expected SEMI
+error 72: expected an item
+error 73: expected an item
+error 79: expected an item
+error 80: expected an item
+error 82: expected an item
+error 83: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/err/0014_where_no_bounds.txt b/crates/ra_syntax/tests/data/parser/err/0014_where_no_bounds.txt
index 276a58b696..2f08785722 100644
--- a/crates/ra_syntax/tests/data/parser/err/0014_where_no_bounds.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0014_where_no_bounds.txt
@@ -28,4 +28,4 @@ SOURCE_FILE@[0; 23)
       L_CURLY@[20; 21) "{"
       R_CURLY@[21; 22) "}"
   WHITESPACE@[22; 23) "\n"
-err: `expected colon`
+error 19: expected colon
diff --git a/crates/ra_syntax/tests/data/parser/err/0015_curly_in_params.txt b/crates/ra_syntax/tests/data/parser/err/0015_curly_in_params.txt
index 8f93b832d3..23ca0c4467 100644
--- a/crates/ra_syntax/tests/data/parser/err/0015_curly_in_params.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0015_curly_in_params.txt
@@ -16,9 +16,9 @@ SOURCE_FILE@[0; 14)
     WHITESPACE@[11; 12) "\n"
     R_CURLY@[12; 13) "}"
   WHITESPACE@[13; 14) "\n"
-err: `expected value parameter`
-err: `expected R_PAREN`
-err: `expected a block`
-err: `unmatched `}``
-err: `expected an item`
-err: `expected an item`
+error 7: expected value parameter
+error 7: expected R_PAREN
+error 7: expected a block
+error 7: unmatched `}`
+error 8: expected an item
+error 10: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/err/0016_missing_semi.txt b/crates/ra_syntax/tests/data/parser/err/0016_missing_semi.txt
index 105e45a35c..97e64dea94 100644
--- a/crates/ra_syntax/tests/data/parser/err/0016_missing_semi.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0016_missing_semi.txt
@@ -40,4 +40,4 @@ SOURCE_FILE@[0; 56)
       WHITESPACE@[53; 54) "\n"
       R_CURLY@[54; 55) "}"
   WHITESPACE@[55; 56) "\n"
-err: `expected SEMI`
+error 38: expected SEMI
diff --git a/crates/ra_syntax/tests/data/parser/err/0017_incomplete_binexpr.txt b/crates/ra_syntax/tests/data/parser/err/0017_incomplete_binexpr.txt
index 7517406200..c18e209002 100644
--- a/crates/ra_syntax/tests/data/parser/err/0017_incomplete_binexpr.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0017_incomplete_binexpr.txt
@@ -43,4 +43,4 @@ SOURCE_FILE@[0; 47)
       WHITESPACE@[44; 45) "\n"
       R_CURLY@[45; 46) "}"
   WHITESPACE@[46; 47) "\n"
-err: `expected expression`
+error 44: expected expression
diff --git a/crates/ra_syntax/tests/data/parser/err/0018_incomplete_fn.txt b/crates/ra_syntax/tests/data/parser/err/0018_incomplete_fn.txt
index 82908b8f24..51def2d8fc 100644
--- a/crates/ra_syntax/tests/data/parser/err/0018_incomplete_fn.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0018_incomplete_fn.txt
@@ -124,8 +124,8 @@ SOURCE_FILE@[0; 183)
       WHITESPACE@[180; 181) "\n"
       R_CURLY@[181; 182) "}"
   WHITESPACE@[182; 183) "\n"
-err: `expected pattern`
-err: `expected COLON`
-err: `expected type`
-err: `expected function arguments`
-err: `expected a block`
+error 34: expected pattern
+error 34: expected COLON
+error 34: expected type
+error 180: expected function arguments
+error 180: expected a block
diff --git a/crates/ra_syntax/tests/data/parser/err/0019_let_recover.txt b/crates/ra_syntax/tests/data/parser/err/0019_let_recover.txt
index 4a1b84ee50..b6710241e9 100644
--- a/crates/ra_syntax/tests/data/parser/err/0019_let_recover.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0019_let_recover.txt
@@ -91,13 +91,13 @@ SOURCE_FILE@[0; 139)
       WHITESPACE@[136; 137) "\n"
       R_CURLY@[137; 138) "}"
   WHITESPACE@[138; 139) "\n"
-err: `expected expression`
-err: `expected SEMI`
-err: `expected pattern`
-err: `expected SEMI`
-err: `expected pattern`
-err: `expected SEMI`
-err: `expected pattern`
-err: `expected SEMI`
-err: `expected pattern`
-err: `expected SEMI`
+error 24: expected expression
+error 24: expected SEMI
+error 49: expected pattern
+error 49: expected SEMI
+error 75: expected pattern
+error 75: expected SEMI
+error 98: expected pattern
+error 98: expected SEMI
+error 124: expected pattern
+error 124: expected SEMI
diff --git a/crates/ra_syntax/tests/data/parser/err/0020_fn_recover.txt b/crates/ra_syntax/tests/data/parser/err/0020_fn_recover.txt
index d7ac73afa1..71c014028f 100644
--- a/crates/ra_syntax/tests/data/parser/err/0020_fn_recover.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0020_fn_recover.txt
@@ -15,6 +15,6 @@ SOURCE_FILE@[0; 16)
       L_CURLY@[13; 14) "{"
       R_CURLY@[14; 15) "}"
   WHITESPACE@[15; 16) "\n"
-err: `expected a name`
-err: `expected function arguments`
-err: `expected a block`
+error 2: expected a name
+error 2: expected function arguments
+error 2: expected a block
diff --git a/crates/ra_syntax/tests/data/parser/err/0021_incomplete_param.txt b/crates/ra_syntax/tests/data/parser/err/0021_incomplete_param.txt
index 086224eeef..c125a0bc99 100644
--- a/crates/ra_syntax/tests/data/parser/err/0021_incomplete_param.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0021_incomplete_param.txt
@@ -30,5 +30,5 @@ SOURCE_FILE@[0; 22)
       WHITESPACE@[19; 20) "\n"
       R_CURLY@[20; 21) "}"
   WHITESPACE@[21; 22) "\n"
-err: `expected COLON`
-err: `expected type`
+error 16: expected COLON
+error 16: expected type
diff --git a/crates/ra_syntax/tests/data/parser/err/0022_bad_exprs.txt b/crates/ra_syntax/tests/data/parser/err/0022_bad_exprs.txt
index d7a5fa1d22..32b53bba71 100644
--- a/crates/ra_syntax/tests/data/parser/err/0022_bad_exprs.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0022_bad_exprs.txt
@@ -148,42 +148,42 @@ SOURCE_FILE@[0; 112)
       WHITESPACE@[109; 110) " "
       R_CURLY@[110; 111) "}"
   WHITESPACE@[111; 112) "\n"
-err: `expected expression`
-err: `expected R_BRACK`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected a name`
-err: `expected `;`, `{`, or `(``
-err: `expected pattern`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected type`
-err: `expected `{``
-err: `expected expression`
-err: `expected SEMI`
-err: `expected pattern`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected a name`
-err: `expected `{``
-err: `expected pattern`
-err: `expected SEMI`
-err: `expected expression`
+error 15: expected expression
+error 15: expected R_BRACK
+error 15: expected SEMI
+error 16: expected expression
+error 17: expected SEMI
+error 17: expected expression
+error 18: expected SEMI
+error 25: expected a name
+error 26: expected `;`, `{`, or `(`
+error 30: expected pattern
+error 31: expected SEMI
+error 52: expected expression
+error 52: expected SEMI
+error 53: expected expression
+error 54: expected SEMI
+error 54: expected expression
+error 55: expected SEMI
+error 60: expected type
+error 60: expected `{`
+error 60: expected expression
+error 61: expected SEMI
+error 65: expected pattern
+error 65: expected SEMI
+error 65: expected expression
+error 91: expected expression
+error 91: expected SEMI
+error 92: expected expression
+error 93: expected SEMI
+error 93: expected expression
+error 94: expected SEMI
+error 95: expected expression
+error 96: expected SEMI
+error 96: expected expression
+error 97: expected SEMI
+error 103: expected a name
+error 104: expected `{`
+error 108: expected pattern
+error 108: expected SEMI
+error 108: expected expression
diff --git a/crates/ra_syntax/tests/data/parser/err/0023_mismatched_paren.txt b/crates/ra_syntax/tests/data/parser/err/0023_mismatched_paren.txt
index 143600e670..f2515faa70 100644
--- a/crates/ra_syntax/tests/data/parser/err/0023_mismatched_paren.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0023_mismatched_paren.txt
@@ -39,5 +39,5 @@ SOURCE_FILE@[0; 94)
   ERROR@[92; 93)
     R_CURLY@[92; 93) "}"
   WHITESPACE@[93; 94) "\n"
-err: `unmatched `}``
-err: `unmatched `}``
+error 49: unmatched `}`
+error 92: unmatched `}`
diff --git a/crates/ra_syntax/tests/data/parser/err/0024_many_type_parens.txt b/crates/ra_syntax/tests/data/parser/err/0024_many_type_parens.txt
index 4f505fa76c..faf0fe462a 100644
--- a/crates/ra_syntax/tests/data/parser/err/0024_many_type_parens.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0024_many_type_parens.txt
@@ -291,34 +291,34 @@ SOURCE_FILE@[0; 240)
       WHITESPACE@[237; 238) "\n"
       R_CURLY@[238; 239) "}"
   WHITESPACE@[239; 240) "\n"
-err: `expected COMMA`
-err: `expected R_ANGLE`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected type`
-err: `expected R_PAREN`
-err: `expected COMMA`
-err: `expected R_ANGLE`
-err: `expected SEMI`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected R_PAREN`
-err: `expected SEMI`
-err: `expected pattern`
-err: `expected IN_KW`
-err: `expected expression`
-err: `expected a block`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected expression`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected COMMA`
-err: `expected R_ANGLE`
-err: `expected SEMI`
-err: `expected expression`
+error 88: expected COMMA
+error 88: expected R_ANGLE
+error 121: expected SEMI
+error 121: expected expression
+error 140: expected type
+error 141: expected R_PAREN
+error 141: expected COMMA
+error 141: expected R_ANGLE
+error 141: expected SEMI
+error 146: expected SEMI
+error 146: expected expression
+error 147: expected SEMI
+error 148: expected expression
+error 149: expected SEMI
+error 151: expected expression
+error 151: expected R_PAREN
+error 151: expected SEMI
+error 154: expected pattern
+error 155: expected IN_KW
+error 155: expected expression
+error 157: expected a block
+error 157: expected expression
+error 158: expected SEMI
+error 165: expected expression
+error 168: expected expression
+error 179: expected expression
+error 180: expected SEMI
+error 215: expected COMMA
+error 215: expected R_ANGLE
+error 235: expected SEMI
+error 235: expected expression
diff --git a/crates/ra_syntax/tests/data/parser/err/0025_nope.txt b/crates/ra_syntax/tests/data/parser/err/0025_nope.txt
index a1bd8647aa..0a3952dc96 100644
--- a/crates/ra_syntax/tests/data/parser/err/0025_nope.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0025_nope.txt
@@ -190,14 +190,14 @@ SOURCE_FILE@[0; 575)
       WHITESPACE@[572; 573) "\n"
       R_CURLY@[573; 574) "}"
   WHITESPACE@[574; 575) "\n"
-err: `expected type`
-err: `expected COMMA`
-err: `expected field`
-err: `expected field declaration`
-err: `expected COMMA`
-err: `expected a type`
-err: `expected R_PAREN`
-err: `expected COMMA`
-err: `expected enum variant`
-err: `expected enum variant`
-err: `expected expression`
+error 95: expected type
+error 95: expected COMMA
+error 96: expected field
+error 98: expected field declaration
+error 371: expected COMMA
+error 372: expected a type
+error 372: expected R_PAREN
+error 372: expected COMMA
+error 372: expected enum variant
+error 374: expected enum variant
+error 508: expected expression
diff --git a/crates/ra_syntax/tests/data/parser/err/0026_imp_recovery.txt b/crates/ra_syntax/tests/data/parser/err/0026_imp_recovery.txt
index f473718dc5..d3da2f54f7 100644
--- a/crates/ra_syntax/tests/data/parser/err/0026_imp_recovery.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0026_imp_recovery.txt
@@ -45,5 +45,5 @@ SOURCE_FILE@[0; 38)
       L_CURLY@[35; 36) "{"
       R_CURLY@[36; 37) "}"
   WHITESPACE@[37; 38) "\n"
-err: `expected trait or type`
-err: `expected `{``
+error 14: expected trait or type
+error 14: expected `{`
diff --git a/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt
index 5a2b52d054..061e6fb31a 100644
--- a/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0027_incomplere_where_for.txt
@@ -24,5 +24,5 @@ SOURCE_FILE@[0; 30)
       L_CURLY@[27; 28) "{"
       R_CURLY@[28; 29) "}"
   WHITESPACE@[29; 30) "\n"
-err: `expected a path`
-err: `expected colon`
+error 26: expected a path
+error 26: expected colon
diff --git a/crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt b/crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt
index 8a59a5ac35..98bc562a3b 100644
--- a/crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0028_macro_2.0.txt
@@ -256,70 +256,70 @@ SOURCE_FILE@[0; 349)
       WHITESPACE@[346; 347) "\n"
       R_CURLY@[347; 348) "}"
   WHITESPACE@[348; 349) "\n"
-err: `expected EXCL`
-err: `expected SEMI`
-err: `expected an item`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected COMMA`
-err: `expected expression`
-err: `expected R_PAREN`
-err: `expected COMMA`
-err: `expected expression`
-err: `expected R_BRACK`
-err: `expected COMMA`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected R_PAREN`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected COMMA`
-err: `expected expression`
-err: `expected R_PAREN`
-err: `expected COMMA`
-err: `expected expression`
-err: `expected R_BRACK`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected R_PAREN`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
-err: `expected expression`
-err: `expected SEMI`
+error 5: expected EXCL
+error 41: expected SEMI
+error 42: expected an item
+error 139: expected SEMI
+error 152: expected expression
+error 153: expected COMMA
+error 154: expected expression
+error 154: expected R_PAREN
+error 154: expected COMMA
+error 154: expected expression
+error 154: expected R_BRACK
+error 154: expected COMMA
+error 154: expected SEMI
+error 154: expected expression
+error 155: expected SEMI
+error 160: expected SEMI
+error 160: expected expression
+error 161: expected SEMI
+error 165: expected SEMI
+error 165: expected expression
+error 166: expected SEMI
+error 166: expected expression
+error 167: expected SEMI
+error 169: expected expression
+error 170: expected SEMI
+error 171: expected expression
+error 171: expected R_PAREN
+error 171: expected SEMI
+error 171: expected expression
+error 172: expected SEMI
+error 172: expected expression
+error 173: expected SEMI
+error 174: expected expression
+error 175: expected SEMI
+error 175: expected expression
+error 176: expected SEMI
+error 178: expected expression
+error 179: expected COMMA
+error 180: expected expression
+error 180: expected R_PAREN
+error 180: expected COMMA
+error 180: expected expression
+error 180: expected R_BRACK
+error 180: expected SEMI
+error 180: expected expression
+error 181: expected SEMI
+error 187: expected SEMI
+error 187: expected expression
+error 188: expected SEMI
+error 192: expected SEMI
+error 192: expected expression
+error 193: expected SEMI
+error 193: expected expression
+error 194: expected SEMI
+error 196: expected expression
+error 197: expected SEMI
+error 198: expected expression
+error 198: expected R_PAREN
+error 198: expected SEMI
+error 198: expected expression
+error 199: expected SEMI
+error 199: expected expression
+error 200: expected SEMI
+error 201: expected expression
+error 202: expected SEMI
+error 202: expected expression
+error 203: expected SEMI
diff --git a/crates/ra_syntax/tests/data/parser/err/0029_field_completion.txt b/crates/ra_syntax/tests/data/parser/err/0029_field_completion.txt
index fa92f08452..fb50a12fc3 100644
--- a/crates/ra_syntax/tests/data/parser/err/0029_field_completion.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0029_field_completion.txt
@@ -32,4 +32,4 @@ SOURCE_FILE@[0; 24)
       WHITESPACE@[21; 22) "\n"
       R_CURLY@[22; 23) "}"
   WHITESPACE@[23; 24) "\n"
-err: `expected field name or number`
+error 21: expected field name or number
diff --git a/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt b/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt
index fb6d3c9c7b..b0acfa5d25 100644
--- a/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0030_string_suffixes.txt
@@ -67,4 +67,4 @@ SOURCE_FILE@[0; 112)
       WHITESPACE@[109; 110) "\n"
       R_CURLY@[110; 111) "}"
   WHITESPACE@[111; 112) "\n"
-err: `expected SEMI`
+error 27: expected SEMI
diff --git a/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.txt b/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.txt
index b4ec999b19..c205cf147e 100644
--- a/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0031_block_inner_attrs.txt
@@ -108,7 +108,7 @@ SOURCE_FILE@[0; 350)
       WHITESPACE@[347; 348) "\n"
       R_CURLY@[348; 349) "}"
   WHITESPACE@[349; 350) "\n"
-err: `A block in this position cannot accept inner attributes`
-err: `A block in this position cannot accept inner attributes`
-err: `A block in this position cannot accept inner attributes`
-err: `A block in this position cannot accept inner attributes`
+error [39; 83): A block in this position cannot accept inner attributes
+error [152; 171): A block in this position cannot accept inner attributes
+error [180; 212): A block in this position cannot accept inner attributes
+error [283; 302): A block in this position cannot accept inner attributes
diff --git a/crates/ra_syntax/tests/data/parser/err/0032_match_arms_inner_attrs.txt b/crates/ra_syntax/tests/data/parser/err/0032_match_arms_inner_attrs.txt
index a3c53f353e..4e8c4143b9 100644
--- a/crates/ra_syntax/tests/data/parser/err/0032_match_arms_inner_attrs.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0032_match_arms_inner_attrs.txt
@@ -188,14 +188,14 @@ SOURCE_FILE@[0; 293)
       WHITESPACE@[290; 291) "\n"
       R_CURLY@[291; 292) "}"
   WHITESPACE@[292; 293) "\n"
-err: `expected `[``
-err: `expected pattern`
-err: `expected FAT_ARROW`
-err: `expected COMMA`
-err: `expected `[``
-err: `expected pattern`
-err: `expected FAT_ARROW`
-err: `expected `[``
-err: `expected pattern`
-err: `expected FAT_ARROW`
-err: `expected COMMA`
+error 52: expected `[`
+error 52: expected pattern
+error 53: expected FAT_ARROW
+error 78: expected COMMA
+error 161: expected `[`
+error 161: expected pattern
+error 162: expected FAT_ARROW
+error 232: expected `[`
+error 232: expected pattern
+error 233: expected FAT_ARROW
+error 250: expected COMMA
diff --git a/crates/ra_syntax/tests/data/parser/err/0033_match_arms_outer_attrs.txt b/crates/ra_syntax/tests/data/parser/err/0033_match_arms_outer_attrs.txt
index 7bcf5ec811..e4f1f63373 100644
--- a/crates/ra_syntax/tests/data/parser/err/0033_match_arms_outer_attrs.txt
+++ b/crates/ra_syntax/tests/data/parser/err/0033_match_arms_outer_attrs.txt
@@ -59,6 +59,6 @@ SOURCE_FILE@[0; 89)
       WHITESPACE@[86; 87) "\n"
       R_CURLY@[87; 88) "}"
   WHITESPACE@[88; 89) "\n"
-err: `expected pattern`
-err: `expected FAT_ARROW`
-err: `expected expression`
+error 80: expected pattern
+error 80: expected FAT_ARROW
+error 80: expected expression
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0001_array_type_missing_semi.txt b/crates/ra_syntax/tests/data/parser/inline/err/0001_array_type_missing_semi.txt
index eb6d98fcd9..3f0f1b4805 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0001_array_type_missing_semi.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0001_array_type_missing_semi.txt
@@ -20,8 +20,8 @@ SOURCE_FILE@[0; 18)
   ERROR@[16; 17)
     SEMI@[16; 17) ";"
   WHITESPACE@[17; 18) "\n"
-err: `expected `;` or `]``
-err: `expected SEMI`
-err: `expected an item`
-err: `expected an item`
-err: `expected an item`
+error 12: expected `;` or `]`
+error 12: expected SEMI
+error 13: expected an item
+error 15: expected an item
+error 16: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0002_misplaced_label_err.txt b/crates/ra_syntax/tests/data/parser/inline/err/0002_misplaced_label_err.txt
index b1d104bd41..7abc49d5ea 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0002_misplaced_label_err.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0002_misplaced_label_err.txt
@@ -22,7 +22,7 @@ SOURCE_FILE@[0; 30)
       WHITESPACE@[27; 28) "\n"
       R_CURLY@[28; 29) "}"
   WHITESPACE@[29; 30) "\n"
-err: `expected a loop`
-err: `expected SEMI`
-err: `expected type`
-err: `expected `{``
+error 22: expected a loop
+error 22: expected SEMI
+error 27: expected type
+error 27: expected `{`
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0003_pointer_type_no_mutability.txt b/crates/ra_syntax/tests/data/parser/inline/err/0003_pointer_type_no_mutability.txt
index b470d9ad11..b97e339bb4 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0003_pointer_type_no_mutability.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0003_pointer_type_no_mutability.txt
@@ -14,4 +14,4 @@ SOURCE_FILE@[0; 14)
         R_PAREN@[11; 12) ")"
     SEMI@[12; 13) ";"
   WHITESPACE@[13; 14) "\n"
-err: `expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)`
+error 10: expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0004_impl_type.txt b/crates/ra_syntax/tests/data/parser/inline/err/0004_impl_type.txt
index ef4e0d5dd1..43321b1ed8 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0004_impl_type.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0004_impl_type.txt
@@ -73,7 +73,7 @@ SOURCE_FILE@[0; 87)
       L_CURLY@[84; 85) "{"
       R_CURLY@[85; 86) "}"
   WHITESPACE@[86; 87) "\n"
-err: `expected trait or type`
-err: `expected `{``
-err: `expected trait or type`
-err: `expected `{``
+error 38: expected trait or type
+error 38: expected `{`
+error 70: expected trait or type
+error 70: expected `{`
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0005_fn_pointer_type_missing_fn.txt b/crates/ra_syntax/tests/data/parser/inline/err/0005_fn_pointer_type_missing_fn.txt
index 41e623b412..451f29d398 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0005_fn_pointer_type_missing_fn.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0005_fn_pointer_type_missing_fn.txt
@@ -16,8 +16,8 @@ SOURCE_FILE@[0; 20)
   ERROR@[18; 19)
     SEMI@[18; 19) ";"
   WHITESPACE@[19; 20) "\n"
-err: `expected `fn``
-err: `expected SEMI`
-err: `expected an item`
-err: `expected an item`
-err: `expected an item`
+error 15: expected `fn`
+error 15: expected SEMI
+error 16: expected an item
+error 17: expected an item
+error 18: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0006_unsafe_block_in_mod.txt b/crates/ra_syntax/tests/data/parser/inline/err/0006_unsafe_block_in_mod.txt
index f1d0dd5c67..a1871ec082 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0006_unsafe_block_in_mod.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0006_unsafe_block_in_mod.txt
@@ -31,5 +31,5 @@ SOURCE_FILE@[0; 33)
       L_CURLY@[30; 31) "{"
       R_CURLY@[31; 32) "}"
   WHITESPACE@[32; 33) "\n"
-err: `expected an item`
-err: `expected an item`
+error 11: expected an item
+error 18: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0007_async_without_semicolon.txt b/crates/ra_syntax/tests/data/parser/inline/err/0007_async_without_semicolon.txt
index 1a8fa029cc..f70adc25da 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0007_async_without_semicolon.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0007_async_without_semicolon.txt
@@ -28,4 +28,4 @@ SOURCE_FILE@[0; 30)
       WHITESPACE@[27; 28) " "
       R_CURLY@[28; 29) "}"
   WHITESPACE@[29; 30) "\n"
-err: `expected SEMI`
+error 27: expected SEMI
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.txt b/crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.txt
index cadbbc078d..1dbfca698a 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0008_pub_expr.txt
@@ -22,4 +22,4 @@ SOURCE_FILE@[0; 21)
       WHITESPACE@[18; 19) " "
       R_CURLY@[19; 20) "}"
   WHITESPACE@[20; 21) "\n"
-err: `expected an item`
+error 14: expected an item
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0009_attr_on_expr_not_allowed.txt b/crates/ra_syntax/tests/data/parser/inline/err/0009_attr_on_expr_not_allowed.txt
index 8e7d7d2419..338776a72b 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0009_attr_on_expr_not_allowed.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0009_attr_on_expr_not_allowed.txt
@@ -51,5 +51,5 @@ SOURCE_FILE@[0; 48)
       WHITESPACE@[45; 46) "\n"
       R_CURLY@[46; 47) "}"
   WHITESPACE@[47; 48) "\n"
-err: `attributes are not allowed on BIN_EXPR`
-err: `attributes are not allowed on IF_EXPR`
+error 24: attributes are not allowed on BIN_EXPR
+error 44: attributes are not allowed on IF_EXPR
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0010_bad_tuple_index_expr.txt b/crates/ra_syntax/tests/data/parser/inline/err/0010_bad_tuple_index_expr.txt
index 36717439ec..a21b29c80a 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0010_bad_tuple_index_expr.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0010_bad_tuple_index_expr.txt
@@ -46,6 +46,6 @@ SOURCE_FILE@[0; 47)
       WHITESPACE@[44; 45) "\n"
       R_CURLY@[45; 46) "}"
   WHITESPACE@[46; 47) "\n"
-err: `Tuple (struct) field access is only allowed through decimal integers with no underscores or suffix`
-err: `Tuple (struct) field access is only allowed through decimal integers with no underscores or suffix`
-err: `Tuple (struct) field access is only allowed through decimal integers with no underscores or suffix`
+error [17; 19): Tuple (struct) field access is only allowed through decimal integers with no underscores or suffix
+error [27; 31): Tuple (struct) field access is only allowed through decimal integers with no underscores or suffix
+error [39; 43): Tuple (struct) field access is only allowed through decimal integers with no underscores or suffix
diff --git a/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.txt b/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.txt
index 5f39e72382..9eb4c9b36b 100644
--- a/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/err/0010_wrong_order_fns.txt
@@ -35,5 +35,5 @@ SOURCE_FILE@[0; 50)
       L_CURLY@[47; 48) "{"
       R_CURLY@[48; 49) "}"
   WHITESPACE@[49; 50) "\n"
-err: `expected fn, trait or impl`
-err: `expected fn, trait or impl`
+error 5: expected fn, trait or impl
+error 31: expected fn, trait or impl