aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_db/src/lib.rs6
-rw-r--r--crates/ra_hir/src/code_model.rs2
-rw-r--r--crates/ra_hir/src/expr/scope.rs4
-rw-r--r--crates/ra_hir/src/expr/validation.rs2
-rw-r--r--crates/ra_hir/src/ids.rs2
-rw-r--r--crates/ra_hir/src/source_binder.rs2
-rw-r--r--crates/ra_hir/src/ty/tests.rs240
7 files changed, 137 insertions, 121 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index 68b9a7143..7c49c585b 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -4,7 +4,7 @@ mod input;
4 4
5use std::{panic, sync::Arc}; 5use std::{panic, sync::Arc};
6 6
7use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc}; 7use ra_syntax::{TextUnit, TextRange, SourceFile, Parse};
8use relative_path::RelativePathBuf; 8use relative_path::RelativePathBuf;
9use ra_prof::profile; 9use ra_prof::profile;
10 10
@@ -74,7 +74,7 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug {
74 fn file_text(&self, file_id: FileId) -> Arc<String>; 74 fn file_text(&self, file_id: FileId) -> Arc<String>;
75 // Parses the file into the syntax tree. 75 // Parses the file into the syntax tree.
76 #[salsa::invoke(parse_query)] 76 #[salsa::invoke(parse_query)]
77 fn parse(&self, file_id: FileId) -> TreeArc<SourceFile>; 77 fn parse(&self, file_id: FileId) -> Parse;
78 /// Path to a file, relative to the root of its source root. 78 /// Path to a file, relative to the root of its source root.
79 #[salsa::input] 79 #[salsa::input]
80 fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf; 80 fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf;
@@ -98,7 +98,7 @@ fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<Cra
98 Arc::new(res) 98 Arc::new(res)
99} 99}
100 100
101fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> TreeArc<SourceFile> { 101fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> Parse {
102 let _p = profile("parse_query"); 102 let _p = profile("parse_query");
103 let text = db.file_text(file_id); 103 let text = db.file_text(file_id);
104 SourceFile::parse(&*text) 104 SourceFile::parse(&*text)
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index a9ffc8782..69496b624 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -116,7 +116,7 @@ impl ModuleSource {
116 ) -> ModuleSource { 116 ) -> ModuleSource {
117 match (file_id, decl_id) { 117 match (file_id, decl_id) {
118 (Some(file_id), _) => { 118 (Some(file_id), _) => {
119 let source_file = db.parse(file_id); 119 let source_file = db.parse(file_id).tree;
120 ModuleSource::SourceFile(source_file) 120 ModuleSource::SourceFile(source_file)
121 } 121 }
122 (None, Some(item_id)) => { 122 (None, Some(item_id)) => {
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs
index 58f365128..83d226fc1 100644
--- a/crates/ra_hir/src/expr/scope.rs
+++ b/crates/ra_hir/src/expr/scope.rs
@@ -190,7 +190,7 @@ mod tests {
190 }; 190 };
191 191
192 let (db, _source_root, file_id) = MockDatabase::with_single_file(&code); 192 let (db, _source_root, file_id) = MockDatabase::with_single_file(&code);
193 let file = db.parse(file_id); 193 let file = db.parse(file_id).ok().unwrap();
194 let marker: &ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap(); 194 let marker: &ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap();
195 let analyzer = SourceAnalyzer::new(&db, file_id, marker.syntax(), None); 195 let analyzer = SourceAnalyzer::new(&db, file_id, marker.syntax(), None);
196 196
@@ -288,7 +288,7 @@ mod tests {
288 let (off, code) = extract_offset(code); 288 let (off, code) = extract_offset(code);
289 289
290 let (db, _source_root, file_id) = MockDatabase::with_single_file(&code); 290 let (db, _source_root, file_id) = MockDatabase::with_single_file(&code);
291 let file = db.parse(file_id); 291 let file = db.parse(file_id).ok().unwrap();
292 let expected_name = find_node_at_offset::<ast::Name>(file.syntax(), expected_offset.into()) 292 let expected_name = find_node_at_offset::<ast::Name>(file.syntax(), expected_offset.into())
293 .expect("failed to find a name at the target offset"); 293 .expect("failed to find a name at the target offset");
294 let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap(); 294 let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap();
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs
index 3f758f283..2816144a7 100644
--- a/crates/ra_hir/src/expr/validation.rs
+++ b/crates/ra_hir/src/expr/validation.rs
@@ -75,7 +75,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
75 } 75 }
76 let source_map = self.func.body_source_map(db); 76 let source_map = self.func.body_source_map(db);
77 let file_id = self.func.source(db).0; 77 let file_id = self.func.source(db).0;
78 let source_file = db.parse(file_id.original_file(db)); 78 let source_file = db.parse(file_id.original_file(db)).tree;
79 if let Some(field_list_node) = source_map 79 if let Some(field_list_node) = source_map
80 .expr_syntax(id) 80 .expr_syntax(id)
81 .map(|ptr| ptr.to_node(source_file.syntax())) 81 .map(|ptr| ptr.to_node(source_file.syntax()))
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index 5c3799e95..06b6888f4 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -64,7 +64,7 @@ impl HirFileId {
64 db.check_canceled(); 64 db.check_canceled();
65 let _p = profile("parse_or_expand_query"); 65 let _p = profile("parse_or_expand_query");
66 match file_id.0 { 66 match file_id.0 {
67 HirFileIdRepr::File(file_id) => Some(db.parse(file_id).syntax().to_owned()), 67 HirFileIdRepr::File(file_id) => Some(db.parse(file_id).tree.syntax().to_owned()),
68 HirFileIdRepr::Macro(macro_file) => { 68 HirFileIdRepr::Macro(macro_file) => {
69 let macro_call_id = macro_file.macro_call_id; 69 let macro_call_id = macro_file.macro_call_id;
70 let tt = db 70 let tt = db
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 179faebfb..860e10069 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -46,7 +46,7 @@ pub fn module_from_declaration(
46 46
47/// Locates the module by position in the source code. 47/// Locates the module by position in the source code.
48pub fn module_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Module> { 48pub fn module_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Module> {
49 let file = db.parse(position.file_id); 49 let file = db.parse(position.file_id).tree;
50 match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) { 50 match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) {
51 Some(m) if !m.has_semi() => module_from_inline(db, position.file_id.into(), m), 51 Some(m) if !m.has_semi() => module_from_inline(db, position.file_id.into(), m),
52 _ => module_from_file_id(db, position.file_id.into()), 52 _ => module_from_file_id(db, position.file_id.into()),
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index cd24faba5..da9aeec6d 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -59,7 +59,7 @@ fn test() {
59 let b: usize = 1; 59 let b: usize = 1;
60 let c = b; 60 let c = b;
61} 61}
62}"#), 62"#),
63 @r###" 63 @r###"
64[11; 71) '{ ...= b; }': () 64[11; 71) '{ ...= b; }': ()
65[21; 22) 'a': isize 65[21; 22) 'a': isize
@@ -85,7 +85,7 @@ fn test() {
85 a(); 85 a();
86 b::c(); 86 b::c();
87} 87}
88}"#), 88"#),
89 @r###" 89 @r###"
90[15; 20) '{ 1 }': u32 90[15; 20) '{ 1 }': u32
91[17; 18) '1': u32 91[17; 18) '1': u32
@@ -1004,7 +1004,7 @@ fn infer_tuple_struct_generics() {
1004 assert_snapshot_matches!( 1004 assert_snapshot_matches!(
1005 infer(r#" 1005 infer(r#"
1006struct A<T>(T); 1006struct A<T>(T);
1007enum Option<T> { Some(T), None }; 1007enum Option<T> { Some(T), None }
1008use Option::*; 1008use Option::*;
1009 1009
1010fn test() { 1010fn test() {
@@ -1017,22 +1017,24 @@ fn test() {
1017} 1017}
1018"#), 1018"#),
1019 @r###" 1019 @r###"
1020[77; 185) '{ ...one; }': () 1020
1021[83; 84) 'A': A<i32>(T) -> A<T> 1021 ⋮[76; 184) '{ ...one; }': ()
1022[83; 88) 'A(42)': A<i32> 1022 ⋮[82; 83) 'A': A<i32>(T) -> A<T>
1023[85; 87) '42': i32 1023 ⋮[82; 87) 'A(42)': A<i32>
1024[94; 95) 'A': A<u128>(T) -> A<T> 1024 ⋮[84; 86) '42': i32
1025[94; 103) 'A(42u128)': A<u128> 1025 ⋮[93; 94) 'A': A<u128>(T) -> A<T>
1026[96; 102) '42u128': u128 1026 ⋮[93; 102) 'A(42u128)': A<u128>
1027[109; 113) 'Some': Some<&str>(T) -> Option<T> 1027 ⋮[95; 101) '42u128': u128
1028[109; 118) 'Some("x")': Option<&str> 1028 ⋮[108; 112) 'Some': Some<&str>(T) -> Option<T>
1029[114; 117) '"x"': &str 1029 ⋮[108; 117) 'Some("x")': Option<&str>
1030[124; 136) 'Option::Some': Some<&str>(T) -> Option<T> 1030 ⋮[113; 116) '"x"': &str
1031[124; 141) 'Option...e("x")': Option<&str> 1031 ⋮[123; 135) 'Option::Some': Some<&str>(T) -> Option<T>
1032[137; 140) '"x"': &str 1032 ⋮[123; 140) 'Option...e("x")': Option<&str>
1033[147; 151) 'None': Option<{unknown}> 1033 ⋮[136; 139) '"x"': &str
1034[161; 162) 'x': Option<i64> 1034 ⋮[146; 150) 'None': Option<{unknown}>
1035[178; 182) 'None': Option<i64>"### 1035 ⋮[160; 161) 'x': Option<i64>
1036 ⋮[177; 181) 'None': Option<i64>
1037 "###
1036 ); 1038 );
1037} 1039}
1038 1040
@@ -1268,7 +1270,7 @@ impl Struct {
1268 const FOO: u32 = 1; 1270 const FOO: u32 = 1;
1269} 1271}
1270 1272
1271enum Enum; 1273enum Enum {}
1272 1274
1273impl Enum { 1275impl Enum {
1274 const BAR: u32 = 2; 1276 const BAR: u32 = 2;
@@ -1291,16 +1293,18 @@ fn test() {
1291} 1293}
1292"#), 1294"#),
1293 @r###" 1295 @r###"
1294[52; 53) '1': u32 1296
1295[103; 104) '2': u32 1297 ⋮[52; 53) '1': u32
1296[211; 212) '5': u32 1298 ⋮[105; 106) '2': u32
1297[227; 305) '{ ...:ID; }': () 1299 ⋮[213; 214) '5': u32
1298[237; 238) 'x': u32 1300 ⋮[229; 307) '{ ...:ID; }': ()
1299[241; 252) 'Struct::FOO': u32 1301 ⋮[239; 240) 'x': u32
1300[262; 263) 'y': u32 1302 ⋮[243; 254) 'Struct::FOO': u32
1301[266; 275) 'Enum::BAR': u32 1303 ⋮[264; 265) 'y': u32
1302[285; 286) 'z': {unknown} 1304 ⋮[268; 277) 'Enum::BAR': u32
1303[289; 302) 'TraitTest::ID': {unknown}"### 1305 ⋮[287; 288) 'z': {unknown}
1306 ⋮[291; 304) 'TraitTest::ID': {unknown}
1307 "###
1304 ); 1308 );
1305} 1309}
1306 1310
@@ -1308,7 +1312,7 @@ fn test() {
1308fn infer_associated_method_struct() { 1312fn infer_associated_method_struct() {
1309 assert_snapshot_matches!( 1313 assert_snapshot_matches!(
1310 infer(r#" 1314 infer(r#"
1311struct A { x: u32 }; 1315struct A { x: u32 }
1312 1316
1313impl A { 1317impl A {
1314 fn new() -> A { 1318 fn new() -> A {
@@ -1321,15 +1325,17 @@ fn test() {
1321} 1325}
1322"#), 1326"#),
1323 @r###" 1327 @r###"
1324[50; 76) '{ ... }': A 1328
1325[60; 70) 'A { x: 0 }': A 1329 ⋮[49; 75) '{ ... }': A
1326[67; 68) '0': u32 1330 ⋮[59; 69) 'A { x: 0 }': A
1327[89; 123) '{ ...a.x; }': () 1331 ⋮[66; 67) '0': u32
1328[99; 100) 'a': A 1332 ⋮[88; 122) '{ ...a.x; }': ()
1329[103; 109) 'A::new': fn new() -> A 1333 ⋮[98; 99) 'a': A
1330[103; 111) 'A::new()': A 1334 ⋮[102; 108) 'A::new': fn new() -> A
1331[117; 118) 'a': A 1335 ⋮[102; 110) 'A::new()': A
1332[117; 120) 'a.x': u32"### 1336 ⋮[116; 117) 'a': A
1337 ⋮[116; 119) 'a.x': u32
1338 "###
1333 ); 1339 );
1334} 1340}
1335 1341
@@ -1337,7 +1343,7 @@ fn test() {
1337fn infer_associated_method_enum() { 1343fn infer_associated_method_enum() {
1338 assert_snapshot_matches!( 1344 assert_snapshot_matches!(
1339 infer(r#" 1345 infer(r#"
1340enum A { B, C }; 1346enum A { B, C }
1341 1347
1342impl A { 1348impl A {
1343 pub fn b() -> A { 1349 pub fn b() -> A {
@@ -1355,19 +1361,21 @@ fn test() {
1355} 1361}
1356"#), 1362"#),
1357 @r###" 1363 @r###"
1358[48; 68) '{ ... }': A 1364
1359[58; 62) 'A::B': A 1365 ⋮[47; 67) '{ ... }': A
1360[89; 109) '{ ... }': A 1366 ⋮[57; 61) 'A::B': A
1361[99; 103) 'A::C': A 1367 ⋮[88; 108) '{ ... }': A
1362[122; 179) '{ ... c; }': () 1368 ⋮[98; 102) 'A::C': A
1363[132; 133) 'a': A 1369 ⋮[121; 178) '{ ... c; }': ()
1364[136; 140) 'A::b': fn b() -> A 1370 ⋮[131; 132) 'a': A
1365[136; 142) 'A::b()': A 1371 ⋮[135; 139) 'A::b': fn b() -> A
1366[148; 149) 'a': A 1372 ⋮[135; 141) 'A::b()': A
1367[159; 160) 'c': A 1373 ⋮[147; 148) 'a': A
1368[163; 167) 'A::c': fn c() -> A 1374 ⋮[158; 159) 'c': A
1369[163; 169) 'A::c()': A 1375 ⋮[162; 166) 'A::c': fn c() -> A
1370[175; 176) 'c': A"### 1376 ⋮[162; 168) 'A::c()': A
1377 ⋮[174; 175) 'c': A
1378 "###
1371 ); 1379 );
1372} 1380}
1373 1381
@@ -1540,7 +1548,7 @@ fn test() {
1540fn infer_type_alias() { 1548fn infer_type_alias() {
1541 assert_snapshot_matches!( 1549 assert_snapshot_matches!(
1542 infer(r#" 1550 infer(r#"
1543struct A<X, Y> { x: X, y: Y }; 1551struct A<X, Y> { x: X, y: Y }
1544type Foo = A<u32, i128>; 1552type Foo = A<u32, i128>;
1545type Bar<T> = A<T, u128>; 1553type Bar<T> = A<T, u128>;
1546type Baz<U, V> = A<V, U>; 1554type Baz<U, V> = A<V, U>;
@@ -1554,22 +1562,24 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) {
1554} 1562}
1555"#), 1563"#),
1556 @r###" 1564 @r###"
1557[117; 118) 'x': A<u32, i128> 1565
1558[125; 126) 'y': A<&str, u128> 1566 ⋮[116; 117) 'x': A<u32, i128>
1559[139; 140) 'z': A<u8, i8> 1567 ⋮[124; 125) 'y': A<&str, u128>
1560[155; 212) '{ ...z.y; }': () 1568 ⋮[138; 139) 'z': A<u8, i8>
1561[161; 162) 'x': A<u32, i128> 1569 ⋮[154; 211) '{ ...z.y; }': ()
1562[161; 164) 'x.x': u32 1570 ⋮[160; 161) 'x': A<u32, i128>
1563[170; 171) 'x': A<u32, i128> 1571 ⋮[160; 163) 'x.x': u32
1564[170; 173) 'x.y': i128 1572 ⋮[169; 170) 'x': A<u32, i128>
1565[179; 180) 'y': A<&str, u128> 1573 ⋮[169; 172) 'x.y': i128
1566[179; 182) 'y.x': &str 1574 ⋮[178; 179) 'y': A<&str, u128>
1567[188; 189) 'y': A<&str, u128> 1575 ⋮[178; 181) 'y.x': &str
1568[188; 191) 'y.y': u128 1576 ⋮[187; 188) 'y': A<&str, u128>
1569[197; 198) 'z': A<u8, i8> 1577 ⋮[187; 190) 'y.y': u128
1570[197; 200) 'z.x': u8 1578 ⋮[196; 197) 'z': A<u8, i8>
1571[206; 207) 'z': A<u8, i8> 1579 ⋮[196; 199) 'z.x': u8
1572[206; 209) 'z.y': i8"### 1580 ⋮[205; 206) 'z': A<u8, i8>
1581 ⋮[205; 208) 'z.y': i8
1582 "###
1573 ) 1583 )
1574} 1584}
1575 1585
@@ -1578,7 +1588,7 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) {
1578fn recursive_type_alias() { 1588fn recursive_type_alias() {
1579 assert_snapshot_matches!( 1589 assert_snapshot_matches!(
1580 infer(r#" 1590 infer(r#"
1581struct A<X> {}; 1591struct A<X> {}
1582type Foo = Foo; 1592type Foo = Foo;
1583type Bar = A<Bar>; 1593type Bar = A<Bar>;
1584fn test(x: Foo) {} 1594fn test(x: Foo) {}
@@ -1795,18 +1805,21 @@ fn infer_std_crash_3() {
1795 assert_snapshot_matches!( 1805 assert_snapshot_matches!(
1796 infer(r#" 1806 infer(r#"
1797pub fn compute() { 1807pub fn compute() {
1798 match _ { 1808 match nope!() {
1799 SizeSkeleton::Pointer { non_zero: true, tail } => {} 1809 SizeSkeleton::Pointer { non_zero: true, tail } => {}
1800 } 1810 }
1801} 1811}
1802"#), 1812"#),
1803 @r###" 1813 @r###"
1804[18; 102) '{ ... } }': () 1814
1805[24; 100) 'match ... }': () 1815 ⋮[18; 108) '{ ... } }': ()
1806[42; 88) 'SizeSk...tail }': {unknown} 1816 ⋮[24; 106) 'match ... }': ()
1807[76; 80) 'true': {unknown} 1817 ⋮[30; 37) 'nope!()': {unknown}
1808[82; 86) 'tail': {unknown} 1818 ⋮[48; 94) 'SizeSk...tail }': {unknown}
1809[92; 94) '{}': ()"### 1819 ⋮[82; 86) 'true': {unknown}
1820 ⋮[88; 92) 'tail': {unknown}
1821 ⋮[98; 100) '{}': ()
1822 "###
1810 ); 1823 );
1811} 1824}
1812 1825
@@ -1817,20 +1830,21 @@ fn infer_std_crash_4() {
1817 infer(r#" 1830 infer(r#"
1818pub fn primitive_type() { 1831pub fn primitive_type() {
1819 match *self { 1832 match *self {
1820 BorrowedRef { type_: box Primitive(p), ..} => {}, 1833 BorrowedRef { type_: Primitive(p), ..} => {},
1821 } 1834 }
1822} 1835}
1823"#), 1836"#),
1824 @r###" 1837 @r###"
1825[25; 110) '{ ... } }': () 1838
1826[31; 108) 'match ... }': () 1839 ⋮[25; 106) '{ ... } }': ()
1827[37; 42) '*self': {unknown} 1840 ⋮[31; 104) 'match ... }': ()
1828[38; 42) 'self': {unknown} 1841 ⋮[37; 42) '*self': {unknown}
1829[53; 95) 'Borrow...), ..}': {unknown} 1842 ⋮[38; 42) 'self': {unknown}
1830[74; 77) 'box': {unknown} 1843 ⋮[53; 91) 'Borrow...), ..}': {unknown}
1831[78; 87) 'Primitive': {unknown} 1844 ⋮[74; 86) 'Primitive(p)': {unknown}
1832[88; 89) 'p': {unknown} 1845 ⋮[84; 85) 'p': {unknown}
1833[99; 101) '{}': ()"### 1846 ⋮[95; 97) '{}': ()
1847 "###
1834 ); 1848 );
1835} 1849}
1836 1850
@@ -2304,8 +2318,8 @@ trait Into<T> {
2304 fn into(self) -> T; 2318 fn into(self) -> T;
2305} 2319}
2306struct S; 2320struct S;
2307impl Into<u32> for S; 2321impl Into<u32> for S {}
2308impl Into<u64> for S; 2322impl Into<u64> for S {}
2309fn test() { 2323fn test() {
2310 let x: u32 = S.into(); 2324 let x: u32 = S.into();
2311 let y: u64 = S.into(); 2325 let y: u64 = S.into();
@@ -2313,18 +2327,20 @@ fn test() {
2313} 2327}
2314"#), 2328"#),
2315 @r###" 2329 @r###"
2316[29; 33) 'self': Self 2330
2317[107; 198) '{ ...(S); }': () 2331 ⋮[29; 33) 'self': Self
2318[117; 118) 'x': u32 2332 ⋮[111; 202) '{ ...(S); }': ()
2319[126; 127) 'S': S 2333 ⋮[121; 122) 'x': u32
2320[126; 134) 'S.into()': u32 2334 ⋮[130; 131) 'S': S
2321[144; 145) 'y': u64 2335 ⋮[130; 138) 'S.into()': u32
2322[153; 154) 'S': S 2336 ⋮[148; 149) 'y': u64
2323[153; 161) 'S.into()': u64 2337 ⋮[157; 158) 'S': S
2324[171; 172) 'z': {unknown} 2338 ⋮[157; 165) 'S.into()': u64
2325[175; 192) 'Into::...::into': {unknown} 2339 ⋮[175; 176) 'z': {unknown}
2326[175; 195) 'Into::...nto(S)': {unknown} 2340 ⋮[179; 196) 'Into::...::into': {unknown}
2327[193; 194) 'S': S"### 2341 ⋮[179; 199) 'Into::...nto(S)': {unknown}
2342 ⋮[197; 198) 'S': S
2343 "###
2328 ); 2344 );
2329} 2345}
2330 2346
@@ -2617,7 +2633,7 @@ fn method_resolution_where_clause_1() {
2617trait Clone {} 2633trait Clone {}
2618trait Trait { fn foo(self) -> u128; } 2634trait Trait { fn foo(self) -> u128; }
2619struct S; 2635struct S;
2620impl Clone for S {}; 2636impl Clone for S {}
2621impl<T> Trait for T where T: Clone {} 2637impl<T> Trait for T where T: Clone {}
2622fn test() { S.foo()<|>; } 2638fn test() { S.foo()<|>; }
2623"#, 2639"#,
@@ -2634,7 +2650,7 @@ trait Into<T> { fn into(self) -> T; }
2634trait From<T> { fn from(other: T) -> Self; } 2650trait From<T> { fn from(other: T) -> Self; }
2635struct S1; 2651struct S1;
2636struct S2; 2652struct S2;
2637impl From<S2> for S1 {}; 2653impl From<S2> for S1 {}
2638impl<T, U> Into<U> for T where U: From<T> {} 2654impl<T, U> Into<U> for T where U: From<T> {}
2639fn test() { S2.into()<|>; } 2655fn test() { S2.into()<|>; }
2640"#, 2656"#,
@@ -2651,7 +2667,7 @@ trait Into<T> { fn into(self) -> T; }
2651trait From<T> { fn from(other: T) -> Self; } 2667trait From<T> { fn from(other: T) -> Self; }
2652struct S1; 2668struct S1;
2653struct S2; 2669struct S2;
2654impl From<S2> for S1 {}; 2670impl From<S2> for S1 {}
2655impl<T, U: From<T>> Into<U> for T {} 2671impl<T, U: From<T>> Into<U> for T {}
2656fn test() { S2.into()<|>; } 2672fn test() { S2.into()<|>; }
2657"#, 2673"#,
@@ -2680,8 +2696,8 @@ fn method_resolution_slow() {
2680//- /main.rs 2696//- /main.rs
2681trait SendX {} 2697trait SendX {}
2682 2698
2683struct S1; impl SendX for S1; 2699struct S1; impl SendX for S1 {}
2684struct S2; impl SendX for S2; 2700struct S2; impl SendX for S2 {}
2685struct U1; 2701struct U1;
2686 2702
2687trait Trait { fn method(self); } 2703trait Trait { fn method(self); }
@@ -2702,7 +2718,7 @@ fn test() { (S {}).method()<|>; }
2702} 2718}
2703 2719
2704fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { 2720fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String {
2705 let file = db.parse(pos.file_id); 2721 let file = db.parse(pos.file_id).ok().unwrap();
2706 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); 2722 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap();
2707 let analyzer = SourceAnalyzer::new(db, pos.file_id, expr.syntax(), Some(pos.offset)); 2723 let analyzer = SourceAnalyzer::new(db, pos.file_id, expr.syntax(), Some(pos.offset));
2708 let ty = analyzer.type_of(db, expr).unwrap(); 2724 let ty = analyzer.type_of(db, expr).unwrap();
@@ -2716,7 +2732,7 @@ fn type_at(content: &str) -> String {
2716 2732
2717fn infer(content: &str) -> String { 2733fn infer(content: &str) -> String {
2718 let (db, _, file_id) = MockDatabase::with_single_file(content); 2734 let (db, _, file_id) = MockDatabase::with_single_file(content);
2719 let source_file = db.parse(file_id); 2735 let source_file = db.parse(file_id).ok().unwrap();
2720 2736
2721 let mut acc = String::new(); 2737 let mut acc = String::new();
2722 acc.push_str("\n"); 2738 acc.push_str("\n");
@@ -2794,7 +2810,7 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() {
2794 ", 2810 ",
2795 ); 2811 );
2796 { 2812 {
2797 let file = db.parse(pos.file_id); 2813 let file = db.parse(pos.file_id).ok().unwrap();
2798 let node = 2814 let node =
2799 algo::find_token_at_offset(file.syntax(), pos.offset).right_biased().unwrap().parent(); 2815 algo::find_token_at_offset(file.syntax(), pos.offset).right_biased().unwrap().parent();
2800 let events = db.log_executed(|| { 2816 let events = db.log_executed(|| {
@@ -2815,7 +2831,7 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() {
2815 db.query_mut(ra_db::FileTextQuery).set(pos.file_id, Arc::new(new_text)); 2831 db.query_mut(ra_db::FileTextQuery).set(pos.file_id, Arc::new(new_text));
2816 2832
2817 { 2833 {
2818 let file = db.parse(pos.file_id); 2834 let file = db.parse(pos.file_id).ok().unwrap();
2819 let node = 2835 let node =
2820 algo::find_token_at_offset(file.syntax(), pos.offset).right_biased().unwrap().parent(); 2836 algo::find_token_at_offset(file.syntax(), pos.offset).right_biased().unwrap().parent();
2821 let events = db.log_executed(|| { 2837 let events = db.log_executed(|| {