aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/Cargo.toml2
-rw-r--r--crates/ra_hir/src/mock.rs2
-rw-r--r--crates/ra_hir/src/nameres/tests.rs32
-rw-r--r--crates/ra_hir/src/nameres/tests/globs.rs8
-rw-r--r--crates/ra_hir/src/nameres/tests/macros.rs8
-rw-r--r--crates/ra_hir/src/nameres/tests/mods.rs56
-rw-r--r--crates/ra_hir/src/nameres/tests/primitives.rs2
-rw-r--r--crates/ra_hir/src/ty/tests.rs2432
-rw-r--r--crates/ra_ide_api/Cargo.toml2
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs28
-rw-r--r--crates/ra_ide_api/src/completion/complete_fn_param.rs8
-rw-r--r--crates/ra_ide_api/src/completion/complete_keyword.rs28
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs30
-rw-r--r--crates/ra_ide_api/src/completion/complete_pattern.rs4
-rw-r--r--crates/ra_ide_api/src/completion/complete_postfix.rs6
-rw-r--r--crates/ra_ide_api/src/completion/complete_record_literal.rs10
-rw-r--r--crates/ra_ide_api/src/completion/complete_record_pattern.rs6
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs26
-rw-r--r--crates/ra_ide_api/src/completion/complete_snippet.rs10
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs14
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs4
-rw-r--r--crates/ra_ide_api/src/display/structure.rs4
-rw-r--r--crates/ra_ide_api/src/inlay_hints.rs14
-rw-r--r--crates/ra_ide_api/src/references.rs6
-rw-r--r--crates/ra_ide_api/src/runnables.rs10
25 files changed, 1425 insertions, 1327 deletions
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml
index 1a2f1b47c..646c96692 100644
--- a/crates/ra_hir/Cargo.toml
+++ b/crates/ra_hir/Cargo.toml
@@ -27,4 +27,4 @@ chalk-ir = { git = "https://github.com/rust-lang/chalk.git" }
27lalrpop-intern = "0.15.1" 27lalrpop-intern = "0.15.1"
28 28
29[dev-dependencies] 29[dev-dependencies]
30insta = "0.10.0" 30insta = "0.11.0"
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index ba33273b8..77a44a275 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -75,7 +75,7 @@ impl MockDatabase {
75 } 75 }
76 76
77 pub fn diagnostics(&self) -> String { 77 pub fn diagnostics(&self) -> String {
78 let mut buf = String::from("\n"); 78 let mut buf = String::new();
79 let mut files: Vec<FileId> = self.files.values().copied().collect(); 79 let mut files: Vec<FileId> = self.files.values().copied().collect();
80 files.sort(); 80 files.sort();
81 for file in files { 81 for file in files {
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs
index 8b0887fb5..c1dbad283 100644
--- a/crates/ra_hir/src/nameres/tests.rs
+++ b/crates/ra_hir/src/nameres/tests.rs
@@ -6,7 +6,7 @@ mod mods;
6 6
7use std::sync::Arc; 7use std::sync::Arc;
8 8
9use insta::assert_snapshot_matches; 9use insta::assert_snapshot;
10use ra_db::SourceDatabase; 10use ra_db::SourceDatabase;
11use test_utils::covers; 11use test_utils::covers;
12 12
@@ -97,7 +97,7 @@ fn crate_def_map_smoke_test() {
97 enum E { V } 97 enum E { V }
98 ", 98 ",
99 ); 99 );
100 assert_snapshot_matches!(map, @r###" 100 assert_snapshot!(map, @r###"
101 ⋮crate 101 ⋮crate
102 ⋮E: t 102 ⋮E: t
103 ⋮S: t v 103 ⋮S: t v
@@ -130,7 +130,7 @@ fn bogus_paths() {
130 130
131 ", 131 ",
132 ); 132 );
133 assert_snapshot_matches!(map, @r###" 133 assert_snapshot!(map, @r###"
134 ⋮crate 134 ⋮crate
135 ⋮S: t v 135 ⋮S: t v
136 ⋮foo: t 136 ⋮foo: t
@@ -153,7 +153,7 @@ fn use_as() {
153 pub struct Baz; 153 pub struct Baz;
154 ", 154 ",
155 ); 155 );
156 assert_snapshot_matches!(map, 156 assert_snapshot!(map,
157 @r###" 157 @r###"
158 ⋮crate 158 ⋮crate
159 ⋮Foo: t v 159 ⋮Foo: t v
@@ -182,7 +182,7 @@ fn use_trees() {
182 pub enum Quux {}; 182 pub enum Quux {};
183 ", 183 ",
184 ); 184 );
185 assert_snapshot_matches!(map, @r###" 185 assert_snapshot!(map, @r###"
186 ⋮crate 186 ⋮crate
187 ⋮Baz: t v 187 ⋮Baz: t v
188 ⋮Quux: t 188 ⋮Quux: t
@@ -215,7 +215,7 @@ fn re_exports() {
215 pub struct Baz; 215 pub struct Baz;
216 ", 216 ",
217 ); 217 );
218 assert_snapshot_matches!(map, @r###" 218 assert_snapshot!(map, @r###"
219 ⋮crate 219 ⋮crate
220 ⋮Baz: t v 220 ⋮Baz: t v
221 ⋮foo: t 221 ⋮foo: t
@@ -250,7 +250,7 @@ fn std_prelude() {
250 "test_crate": ("/lib.rs", []), 250 "test_crate": ("/lib.rs", []),
251 }, 251 },
252 ); 252 );
253 assert_snapshot_matches!(map, @r###" 253 assert_snapshot!(map, @r###"
254 ⋮crate 254 ⋮crate
255 ⋮Bar: t v 255 ⋮Bar: t v
256 ⋮Baz: t v 256 ⋮Baz: t v
@@ -267,7 +267,7 @@ fn can_import_enum_variant() {
267 use self::E::V; 267 use self::E::V;
268 ", 268 ",
269 ); 269 );
270 assert_snapshot_matches!(map, @r###" 270 assert_snapshot!(map, @r###"
271 ⋮crate 271 ⋮crate
272 ⋮E: t 272 ⋮E: t
273 ⋮V: t v 273 ⋮V: t v
@@ -299,7 +299,7 @@ fn edition_2015_imports() {
299 }, 299 },
300 ); 300 );
301 301
302 assert_snapshot_matches!(map, @r###" 302 assert_snapshot!(map, @r###"
303 ⋮crate 303 ⋮crate
304 ⋮bar: t 304 ⋮bar: t
305 ⋮foo: t 305 ⋮foo: t
@@ -326,7 +326,7 @@ fn item_map_using_self() {
326 pub struct Baz; 326 pub struct Baz;
327 ", 327 ",
328 ); 328 );
329 assert_snapshot_matches!(map, @r###" 329 assert_snapshot!(map, @r###"
330 ⋮crate 330 ⋮crate
331 ⋮Baz: t v 331 ⋮Baz: t v
332 ⋮foo: t 332 ⋮foo: t
@@ -355,7 +355,7 @@ fn item_map_across_crates() {
355 }, 355 },
356 ); 356 );
357 357
358 assert_snapshot_matches!(map, @r###" 358 assert_snapshot!(map, @r###"
359 ⋮crate 359 ⋮crate
360 ⋮Baz: t v 360 ⋮Baz: t v
361 "###); 361 "###);
@@ -383,7 +383,7 @@ fn extern_crate_rename() {
383 }, 383 },
384 ); 384 );
385 385
386 assert_snapshot_matches!(map, @r###" 386 assert_snapshot!(map, @r###"
387 ⋮crate 387 ⋮crate
388 ⋮alloc_crate: t 388 ⋮alloc_crate: t
389 ⋮sync: t 389 ⋮sync: t
@@ -415,7 +415,7 @@ fn extern_crate_rename_2015_edition() {
415 }, 415 },
416 ); 416 );
417 417
418 assert_snapshot_matches!(map, 418 assert_snapshot!(map,
419 @r###" 419 @r###"
420 ⋮crate 420 ⋮crate
421 ⋮alloc_crate: t 421 ⋮alloc_crate: t
@@ -449,7 +449,7 @@ fn import_across_source_roots() {
449 }, 449 },
450 ); 450 );
451 451
452 assert_snapshot_matches!(map, @r###" 452 assert_snapshot!(map, @r###"
453 ⋮crate 453 ⋮crate
454 ⋮C: t v 454 ⋮C: t v
455 "###); 455 "###);
@@ -476,7 +476,7 @@ fn reexport_across_crates() {
476 }, 476 },
477 ); 477 );
478 478
479 assert_snapshot_matches!(map, @r###" 479 assert_snapshot!(map, @r###"
480 ⋮crate 480 ⋮crate
481 ⋮Baz: t v 481 ⋮Baz: t v
482 "###); 482 "###);
@@ -499,7 +499,7 @@ fn values_dont_shadow_extern_crates() {
499 }, 499 },
500 ); 500 );
501 501
502 assert_snapshot_matches!(map, @r###" 502 assert_snapshot!(map, @r###"
503 ⋮crate 503 ⋮crate
504 ⋮Bar: t v 504 ⋮Bar: t v
505 ⋮foo: v 505 ⋮foo: v
diff --git a/crates/ra_hir/src/nameres/tests/globs.rs b/crates/ra_hir/src/nameres/tests/globs.rs
index e1519ca6b..7ac22b47b 100644
--- a/crates/ra_hir/src/nameres/tests/globs.rs
+++ b/crates/ra_hir/src/nameres/tests/globs.rs
@@ -17,7 +17,7 @@ fn glob_1() {
17 pub struct Baz; 17 pub struct Baz;
18 ", 18 ",
19 ); 19 );
20 assert_snapshot_matches!(map, @r###" 20 assert_snapshot!(map, @r###"
21 ⋮crate 21 ⋮crate
22 ⋮Baz: t v 22 ⋮Baz: t v
23 ⋮Foo: t v 23 ⋮Foo: t v
@@ -53,7 +53,7 @@ fn glob_2() {
53 pub use super::*; 53 pub use super::*;
54 ", 54 ",
55 ); 55 );
56 assert_snapshot_matches!(map, @r###" 56 assert_snapshot!(map, @r###"
57 ⋮crate 57 ⋮crate
58 ⋮Baz: t v 58 ⋮Baz: t v
59 ⋮Foo: t v 59 ⋮Foo: t v
@@ -89,7 +89,7 @@ fn glob_across_crates() {
89 "test_crate": ("/lib.rs", []), 89 "test_crate": ("/lib.rs", []),
90 }, 90 },
91 ); 91 );
92 assert_snapshot_matches!(map, @r###" 92 assert_snapshot!(map, @r###"
93 ⋮crate 93 ⋮crate
94 ⋮Baz: t v 94 ⋮Baz: t v
95 "### 95 "###
@@ -108,7 +108,7 @@ fn glob_enum() {
108 use self::Foo::*; 108 use self::Foo::*;
109 ", 109 ",
110 ); 110 );
111 assert_snapshot_matches!(map, @r###" 111 assert_snapshot!(map, @r###"
112 ⋮crate 112 ⋮crate
113 ⋮Bar: t v 113 ⋮Bar: t v
114 ⋮Baz: t v 114 ⋮Baz: t v
diff --git a/crates/ra_hir/src/nameres/tests/macros.rs b/crates/ra_hir/src/nameres/tests/macros.rs
index 4e04740eb..631df2cef 100644
--- a/crates/ra_hir/src/nameres/tests/macros.rs
+++ b/crates/ra_hir/src/nameres/tests/macros.rs
@@ -17,7 +17,7 @@ fn macro_rules_are_globally_visible() {
17 structs!(Bar, Baz); 17 structs!(Bar, Baz);
18 ", 18 ",
19 ); 19 );
20 assert_snapshot_matches!(map, @r###" 20 assert_snapshot!(map, @r###"
21 ⋮crate 21 ⋮crate
22 ⋮Foo: t v 22 ⋮Foo: t v
23 ⋮nested: t 23 ⋮nested: t
@@ -45,7 +45,7 @@ fn macro_rules_can_define_modules() {
45 struct X; 45 struct X;
46 ", 46 ",
47 ); 47 );
48 assert_snapshot_matches!(map, @r###" 48 assert_snapshot!(map, @r###"
49 ⋮crate 49 ⋮crate
50 ⋮m: m 50 ⋮m: m
51 ⋮n1: t 51 ⋮n1: t
@@ -82,7 +82,7 @@ fn macro_rules_from_other_crates_are_visible() {
82 "foo": ("/lib.rs", []), 82 "foo": ("/lib.rs", []),
83 }, 83 },
84 ); 84 );
85 assert_snapshot_matches!(map, @r###" 85 assert_snapshot!(map, @r###"
86 ⋮crate 86 ⋮crate
87 ⋮Bar: t v 87 ⋮Bar: t v
88 ⋮Foo: t v 88 ⋮Foo: t v
@@ -129,7 +129,7 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() {
129 "foo": ("/lib.rs", []), 129 "foo": ("/lib.rs", []),
130 }, 130 },
131 ); 131 );
132 assert_snapshot_matches!(map, @r###" 132 assert_snapshot!(map, @r###"
133 ⋮crate 133 ⋮crate
134 ⋮Foo: t v 134 ⋮Foo: t v
135 ⋮bar: m 135 ⋮bar: m
diff --git a/crates/ra_hir/src/nameres/tests/mods.rs b/crates/ra_hir/src/nameres/tests/mods.rs
index 6dd18df1a..4f8398460 100644
--- a/crates/ra_hir/src/nameres/tests/mods.rs
+++ b/crates/ra_hir/src/nameres/tests/mods.rs
@@ -19,7 +19,7 @@ fn name_res_works_for_broken_modules() {
19 pub struct Baz; 19 pub struct Baz;
20 ", 20 ",
21 ); 21 );
22 assert_snapshot_matches!(map, @r###" 22 assert_snapshot!(map, @r###"
23 ⋮crate 23 ⋮crate
24 ⋮Baz: _ 24 ⋮Baz: _
25 "###); 25 "###);
@@ -41,7 +41,7 @@ fn module_resolution_works_for_non_standard_filenames() {
41 }, 41 },
42 ); 42 );
43 43
44 assert_snapshot_matches!(map, @r###" 44 assert_snapshot!(map, @r###"
45 ⋮crate 45 ⋮crate
46 ⋮Bar: t v 46 ⋮Bar: t v
47 ⋮foo: t 47 ⋮foo: t
@@ -67,7 +67,7 @@ fn module_resolution_works_for_raw_modules() {
67 }, 67 },
68 ); 68 );
69 69
70 assert_snapshot_matches!(map, @r###" 70 assert_snapshot!(map, @r###"
71 ⋮crate 71 ⋮crate
72 ⋮Bar: t v 72 ⋮Bar: t v
73 ⋮async: t 73 ⋮async: t
@@ -94,7 +94,7 @@ fn module_resolution_decl_path() {
94 }, 94 },
95 ); 95 );
96 96
97 assert_snapshot_matches!(map, @r###" 97 assert_snapshot!(map, @r###"
98 ⋮crate 98 ⋮crate
99 ⋮Bar: t v 99 ⋮Bar: t v
100 ⋮foo: t 100 ⋮foo: t
@@ -110,7 +110,7 @@ fn module_resolution_module_with_path_in_mod_rs() {
110 r###" 110 r###"
111 //- /main.rs 111 //- /main.rs
112 mod foo; 112 mod foo;
113 113
114 //- /foo/mod.rs 114 //- /foo/mod.rs
115 #[path = "baz.rs"] 115 #[path = "baz.rs"]
116 pub mod bar; 116 pub mod bar;
@@ -125,7 +125,7 @@ fn module_resolution_module_with_path_in_mod_rs() {
125 }, 125 },
126 ); 126 );
127 127
128 assert_snapshot_matches!(map, @r###" 128 assert_snapshot!(map, @r###"
129 ⋮crate 129 ⋮crate
130 ⋮foo: t 130 ⋮foo: t
131 131
@@ -144,7 +144,7 @@ fn module_resolution_module_with_path_non_crate_root() {
144 r###" 144 r###"
145 //- /main.rs 145 //- /main.rs
146 mod foo; 146 mod foo;
147 147
148 //- /foo.rs 148 //- /foo.rs
149 #[path = "baz.rs"] 149 #[path = "baz.rs"]
150 pub mod bar; 150 pub mod bar;
@@ -159,7 +159,7 @@ fn module_resolution_module_with_path_non_crate_root() {
159 }, 159 },
160 ); 160 );
161 161
162 assert_snapshot_matches!(map, @r###" 162 assert_snapshot!(map, @r###"
163 ⋮crate 163 ⋮crate
164 ⋮foo: t 164 ⋮foo: t
165 165
@@ -189,7 +189,7 @@ fn module_resolution_module_decl_path_super() {
189 }, 189 },
190 ); 190 );
191 191
192 assert_snapshot_matches!(map, @r###" 192 assert_snapshot!(map, @r###"
193 ⋮crate 193 ⋮crate
194 ⋮Baz: t v 194 ⋮Baz: t v
195 ⋮foo: t 195 ⋮foo: t
@@ -215,7 +215,7 @@ fn module_resolution_explicit_path_mod_rs() {
215 }, 215 },
216 ); 216 );
217 217
218 assert_snapshot_matches!(map, @r###" 218 assert_snapshot!(map, @r###"
219 ⋮crate 219 ⋮crate
220 ⋮foo: t 220 ⋮foo: t
221 221
@@ -243,7 +243,7 @@ fn module_resolution_relative_path() {
243 }, 243 },
244 ); 244 );
245 245
246 assert_snapshot_matches!(map, @r###" 246 assert_snapshot!(map, @r###"
247 ⋮crate 247 ⋮crate
248 ⋮foo: t 248 ⋮foo: t
249 249
@@ -274,7 +274,7 @@ fn module_resolution_relative_path_2() {
274 }, 274 },
275 ); 275 );
276 276
277 assert_snapshot_matches!(map, @r###" 277 assert_snapshot!(map, @r###"
278 ⋮crate 278 ⋮crate
279 ⋮foo: t 279 ⋮foo: t
280 280
@@ -302,7 +302,7 @@ fn module_resolution_explicit_path_mod_rs_2() {
302 }, 302 },
303 ); 303 );
304 304
305 assert_snapshot_matches!(map, @r###" 305 assert_snapshot!(map, @r###"
306 ⋮crate 306 ⋮crate
307 ⋮foo: t 307 ⋮foo: t
308 308
@@ -327,7 +327,7 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() {
327 }, 327 },
328 ); 328 );
329 329
330 assert_snapshot_matches!(map, @r###" 330 assert_snapshot!(map, @r###"
331 ⋮crate 331 ⋮crate
332 ⋮foo: t 332 ⋮foo: t
333 333
@@ -354,7 +354,7 @@ fn module_resolution_decl_inside_inline_module_with_path_attribute() {
354 }, 354 },
355 ); 355 );
356 356
357 assert_snapshot_matches!(map, @r###" 357 assert_snapshot!(map, @r###"
358 ⋮crate 358 ⋮crate
359 ⋮foo: t 359 ⋮foo: t
360 360
@@ -383,7 +383,7 @@ fn module_resolution_decl_inside_inline_module() {
383 }, 383 },
384 ); 384 );
385 385
386 assert_snapshot_matches!(map, @r###" 386 assert_snapshot!(map, @r###"
387 ⋮crate 387 ⋮crate
388 ⋮foo: t 388 ⋮foo: t
389 389
@@ -413,7 +413,7 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() {
413 }, 413 },
414 ); 414 );
415 415
416 assert_snapshot_matches!(map, @r###" 416 assert_snapshot!(map, @r###"
417 ⋮crate 417 ⋮crate
418 ⋮foo: t 418 ⋮foo: t
419 419
@@ -444,7 +444,7 @@ fn module_resolution_decl_inside_inline_module_3() {
444 }, 444 },
445 ); 445 );
446 446
447 assert_snapshot_matches!(map, @r###" 447 assert_snapshot!(map, @r###"
448 ⋮crate 448 ⋮crate
449 ⋮foo: t 449 ⋮foo: t
450 450
@@ -475,7 +475,7 @@ fn module_resolution_decl_inside_inline_module_empty_path() {
475 }, 475 },
476 ); 476 );
477 477
478 assert_snapshot_matches!(map, @r###" 478 assert_snapshot!(map, @r###"
479 ⋮crate 479 ⋮crate
480 ⋮foo: t 480 ⋮foo: t
481 481
@@ -503,7 +503,7 @@ fn module_resolution_decl_empty_path() {
503 }, 503 },
504 ); 504 );
505 505
506 assert_snapshot_matches!(map, @r###" 506 assert_snapshot!(map, @r###"
507 ⋮crate 507 ⋮crate
508 ⋮foo: t 508 ⋮foo: t
509 509
@@ -530,7 +530,7 @@ fn module_resolution_decl_inside_inline_module_relative_path() {
530 }, 530 },
531 ); 531 );
532 532
533 assert_snapshot_matches!(map, @r###" 533 assert_snapshot!(map, @r###"
534 ⋮crate 534 ⋮crate
535 ⋮foo: t 535 ⋮foo: t
536 536
@@ -561,7 +561,7 @@ fn module_resolution_decl_inside_inline_module_in_crate_root() {
561 }, 561 },
562 ); 562 );
563 563
564 assert_snapshot_matches!(map, @r###" 564 assert_snapshot!(map, @r###"
565 ⋮crate 565 ⋮crate
566 ⋮Baz: t v 566 ⋮Baz: t v
567 ⋮foo: t 567 ⋮foo: t
@@ -596,7 +596,7 @@ fn module_resolution_decl_inside_inline_module_in_mod_rs() {
596 }, 596 },
597 ); 597 );
598 598
599 assert_snapshot_matches!(map, @r###" 599 assert_snapshot!(map, @r###"
600 ⋮crate 600 ⋮crate
601 ⋮foo: t 601 ⋮foo: t
602 602
@@ -634,7 +634,7 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() {
634 }, 634 },
635 ); 635 );
636 636
637 assert_snapshot_matches!(map, @r###" 637 assert_snapshot!(map, @r###"
638 ⋮crate 638 ⋮crate
639 ⋮foo: t 639 ⋮foo: t
640 640
@@ -672,7 +672,7 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() {
672 }, 672 },
673 ); 673 );
674 674
675 assert_snapshot_matches!(map, @r###" 675 assert_snapshot!(map, @r###"
676 ⋮crate 676 ⋮crate
677 ⋮foo: t 677 ⋮foo: t
678 678
@@ -701,8 +701,8 @@ fn unresolved_module_diagnostics() {
701 ) 701 )
702 .diagnostics(); 702 .diagnostics();
703 703
704 assert_snapshot_matches!(diagnostics, @r###" 704 assert_snapshot!(diagnostics, @r###"
705"mod bar;": unresolved module 705 "mod bar;": unresolved module
706"### 706 "###
707 ); 707 );
708} 708}
diff --git a/crates/ra_hir/src/nameres/tests/primitives.rs b/crates/ra_hir/src/nameres/tests/primitives.rs
index 734744835..0e2708658 100644
--- a/crates/ra_hir/src/nameres/tests/primitives.rs
+++ b/crates/ra_hir/src/nameres/tests/primitives.rs
@@ -12,7 +12,7 @@ fn primitive_reexport() {
12 pub use i32 as int; 12 pub use i32 as int;
13 ", 13 ",
14 ); 14 );
15 assert_snapshot_matches!(map, @r###" 15 assert_snapshot!(map, @r###"
16 ⋮crate 16 ⋮crate
17 ⋮foo: t 17 ⋮foo: t
18 ⋮int: t 18 ⋮int: t
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index e3eb0c3fa..b034fd59e 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -1,7 +1,7 @@
1use std::fmt::Write; 1use std::fmt::Write;
2use std::sync::Arc; 2use std::sync::Arc;
3 3
4use insta::assert_snapshot_matches; 4use insta::assert_snapshot;
5 5
6use ra_db::{salsa::Database, FilePosition, SourceDatabase}; 6use ra_db::{salsa::Database, FilePosition, SourceDatabase};
7use ra_syntax::{ 7use ra_syntax::{
@@ -166,7 +166,7 @@ fn test() {
166 166
167#[test] 167#[test]
168fn infer_basics() { 168fn infer_basics() {
169 assert_snapshot_matches!( 169 assert_snapshot!(
170 infer(r#" 170 infer(r#"
171fn test(a: u32, b: isize, c: !, d: &str) { 171fn test(a: u32, b: isize, c: !, d: &str) {
172 a; 172 a;
@@ -179,25 +179,27 @@ fn test(a: u32, b: isize, c: !, d: &str) {
179 1.0f32; 179 1.0f32;
180}"#), 180}"#),
181 @r###" 181 @r###"
182[9; 10) 'a': u32 182
183[17; 18) 'b': isize 183 [9; 10) 'a': u32
184[27; 28) 'c': ! 184 [17; 18) 'b': isize
185[33; 34) 'd': &str 185 [27; 28) 'c': !
186[42; 121) '{ ...f32; }': () 186 [33; 34) 'd': &str
187[48; 49) 'a': u32 187 [42; 121) '{ ...f32; }': ()
188[55; 56) 'b': isize 188 [48; 49) 'a': u32
189[62; 63) 'c': ! 189 [55; 56) 'b': isize
190[69; 70) 'd': &str 190 [62; 63) 'c': !
191[76; 82) '1usize': usize 191 [69; 70) 'd': &str
192[88; 94) '1isize': isize 192 [76; 82) '1usize': usize
193[100; 106) '"test"': &str 193 [88; 94) '1isize': isize
194[112; 118) '1.0f32': f32"### 194 [100; 106) '"test"': &str
195 [112; 118) '1.0f32': f32
196 "###
195 ); 197 );
196} 198}
197 199
198#[test] 200#[test]
199fn infer_let() { 201fn infer_let() {
200 assert_snapshot_matches!( 202 assert_snapshot!(
201 infer(r#" 203 infer(r#"
202fn test() { 204fn test() {
203 let a = 1isize; 205 let a = 1isize;
@@ -206,19 +208,21 @@ fn test() {
206} 208}
207"#), 209"#),
208 @r###" 210 @r###"
209[11; 71) '{ ...= b; }': () 211
210[21; 22) 'a': isize 212 [11; 71) '{ ...= b; }': ()
211[25; 31) '1isize': isize 213 [21; 22) 'a': isize
212[41; 42) 'b': usize 214 [25; 31) '1isize': isize
213[52; 53) '1': usize 215 [41; 42) 'b': usize
214[63; 64) 'c': usize 216 [52; 53) '1': usize
215[67; 68) 'b': usize"### 217 [63; 64) 'c': usize
218 [67; 68) 'b': usize
219 "###
216 ); 220 );
217} 221}
218 222
219#[test] 223#[test]
220fn infer_paths() { 224fn infer_paths() {
221 assert_snapshot_matches!( 225 assert_snapshot!(
222 infer(r#" 226 infer(r#"
223fn a() -> u32 { 1 } 227fn a() -> u32 { 1 }
224 228
@@ -232,21 +236,23 @@ fn test() {
232} 236}
233"#), 237"#),
234 @r###" 238 @r###"
235[15; 20) '{ 1 }': u32 239
236[17; 18) '1': u32 240 [15; 20) '{ 1 }': u32
237[48; 53) '{ 1 }': u32 241 [17; 18) '1': u32
238[50; 51) '1': u32 242 [48; 53) '{ 1 }': u32
239[67; 91) '{ ...c(); }': () 243 [50; 51) '1': u32
240[73; 74) 'a': fn a() -> u32 244 [67; 91) '{ ...c(); }': ()
241[73; 76) 'a()': u32 245 [73; 74) 'a': fn a() -> u32
242[82; 86) 'b::c': fn c() -> u32 246 [73; 76) 'a()': u32
243[82; 88) 'b::c()': u32"### 247 [82; 86) 'b::c': fn c() -> u32
248 [82; 88) 'b::c()': u32
249 "###
244 ); 250 );
245} 251}
246 252
247#[test] 253#[test]
248fn infer_struct() { 254fn infer_struct() {
249 assert_snapshot_matches!( 255 assert_snapshot!(
250 infer(r#" 256 infer(r#"
251struct A { 257struct A {
252 b: B, 258 b: B,
@@ -264,28 +270,30 @@ fn test() {
264} 270}
265"#), 271"#),
266 @r###" 272 @r###"
267[72; 154) '{ ...a.c; }': () 273
268[82; 83) 'c': C 274 [72; 154) '{ ...a.c; }': ()
269[86; 87) 'C': C(usize) -> C 275 [82; 83) 'c': C
270[86; 90) 'C(1)': C 276 [86; 87) 'C': C(usize) -> C
271[88; 89) '1': usize 277 [86; 90) 'C(1)': C
272[96; 97) 'B': B 278 [88; 89) '1': usize
273[107; 108) 'a': A 279 [96; 97) 'B': B
274[114; 133) 'A { b:...C(1) }': A 280 [107; 108) 'a': A
275[121; 122) 'B': B 281 [114; 133) 'A { b:...C(1) }': A
276[127; 128) 'C': C(usize) -> C 282 [121; 122) 'B': B
277[127; 131) 'C(1)': C 283 [127; 128) 'C': C(usize) -> C
278[129; 130) '1': usize 284 [127; 131) 'C(1)': C
279[139; 140) 'a': A 285 [129; 130) '1': usize
280[139; 142) 'a.b': B 286 [139; 140) 'a': A
281[148; 149) 'a': A 287 [139; 142) 'a.b': B
282[148; 151) 'a.c': C"### 288 [148; 149) 'a': A
289 [148; 151) 'a.c': C
290 "###
283 ); 291 );
284} 292}
285 293
286#[test] 294#[test]
287fn infer_enum() { 295fn infer_enum() {
288 assert_snapshot_matches!( 296 assert_snapshot!(
289 infer(r#" 297 infer(r#"
290enum E { 298enum E {
291 V1 { field: u32 }, 299 V1 { field: u32 },
@@ -296,16 +304,18 @@ fn test() {
296 E::V2; 304 E::V2;
297}"#), 305}"#),
298 @r###" 306 @r###"
299[48; 82) '{ E:...:V2; }': () 307
300[52; 70) 'E::V1 ...d: 1 }': E 308 [48; 82) '{ E:...:V2; }': ()
301[67; 68) '1': u32 309 [52; 70) 'E::V1 ...d: 1 }': E
302[74; 79) 'E::V2': E"### 310 [67; 68) '1': u32
311 [74; 79) 'E::V2': E
312 "###
303 ); 313 );
304} 314}
305 315
306#[test] 316#[test]
307fn infer_refs() { 317fn infer_refs() {
308 assert_snapshot_matches!( 318 assert_snapshot!(
309 infer(r#" 319 infer(r#"
310fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { 320fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) {
311 a; 321 a;
@@ -322,35 +332,37 @@ fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) {
322} 332}
323"#), 333"#),
324 @r###" 334 @r###"
325[9; 10) 'a': &u32 335
326[18; 19) 'b': &mut u32 336 [9; 10) 'a': &u32
327[31; 32) 'c': *const u32 337 [18; 19) 'b': &mut u32
328[46; 47) 'd': *mut u32 338 [31; 32) 'c': *const u32
329[59; 150) '{ ... *d; }': () 339 [46; 47) 'd': *mut u32
330[65; 66) 'a': &u32 340 [59; 150) '{ ... *d; }': ()
331[72; 74) '*a': u32 341 [65; 66) 'a': &u32
332[73; 74) 'a': &u32 342 [72; 74) '*a': u32
333[80; 82) '&a': &&u32 343 [73; 74) 'a': &u32
334[81; 82) 'a': &u32 344 [80; 82) '&a': &&u32
335[88; 94) '&mut a': &mut &u32 345 [81; 82) 'a': &u32
336[93; 94) 'a': &u32 346 [88; 94) '&mut a': &mut &u32
337[100; 101) 'b': &mut u32 347 [93; 94) 'a': &u32
338[107; 109) '*b': u32 348 [100; 101) 'b': &mut u32
339[108; 109) 'b': &mut u32 349 [107; 109) '*b': u32
340[115; 117) '&b': &&mut u32 350 [108; 109) 'b': &mut u32
341[116; 117) 'b': &mut u32 351 [115; 117) '&b': &&mut u32
342[123; 124) 'c': *const u32 352 [116; 117) 'b': &mut u32
343[130; 132) '*c': u32 353 [123; 124) 'c': *const u32
344[131; 132) 'c': *const u32 354 [130; 132) '*c': u32
345[138; 139) 'd': *mut u32 355 [131; 132) 'c': *const u32
346[145; 147) '*d': u32 356 [138; 139) 'd': *mut u32
347[146; 147) 'd': *mut u32"### 357 [145; 147) '*d': u32
358 [146; 147) 'd': *mut u32
359 "###
348 ); 360 );
349} 361}
350 362
351#[test] 363#[test]
352fn infer_literals() { 364fn infer_literals() {
353 assert_snapshot_matches!( 365 assert_snapshot!(
354 infer(r##" 366 infer(r##"
355fn test() { 367fn test() {
356 5i32; 368 5i32;
@@ -373,26 +385,28 @@ fn test() {
373} 385}
374"##), 386"##),
375 @r###" 387 @r###"
376[11; 221) '{ ...o"#; }': () 388
377[17; 21) '5i32': i32 389 [11; 221) '{ ...o"#; }': ()
378[27; 31) '5f32': f32 390 [17; 21) '5i32': i32
379[37; 41) '5f64': f64 391 [27; 31) '5f32': f32
380[47; 54) '"hello"': &str 392 [37; 41) '5f64': f64
381[60; 68) 'b"bytes"': &[u8] 393 [47; 54) '"hello"': &str
382[74; 77) ''c'': char 394 [60; 68) 'b"bytes"': &[u8]
383[83; 87) 'b'b'': u8 395 [74; 77) ''c'': char
384[93; 97) '3.14': f64 396 [83; 87) 'b'b'': u8
385[103; 107) '5000': i32 397 [93; 97) '3.14': f64
386[113; 118) 'false': bool 398 [103; 107) '5000': i32
387[124; 128) 'true': bool 399 [113; 118) 'false': bool
388[134; 202) 'r#" ... "#': &str 400 [124; 128) 'true': bool
389[208; 218) 'br#"yolo"#': &[u8]"### 401 [134; 202) 'r#" ... "#': &str
402 [208; 218) 'br#"yolo"#': &[u8]
403 "###
390 ); 404 );
391} 405}
392 406
393#[test] 407#[test]
394fn infer_unary_op() { 408fn infer_unary_op() {
395 assert_snapshot_matches!( 409 assert_snapshot!(
396 infer(r#" 410 infer(r#"
397enum SomeType {} 411enum SomeType {}
398 412
@@ -415,53 +429,55 @@ fn test(x: SomeType) {
415} 429}
416"#), 430"#),
417 @r###" 431 @r###"
418[27; 28) 'x': SomeType 432
419[40; 272) '{ ...lo"; }': () 433 [27; 28) 'x': SomeType
420[50; 51) 'b': bool 434 [40; 272) '{ ...lo"; }': ()
421[54; 59) 'false': bool 435 [50; 51) 'b': bool
422[69; 70) 'c': bool 436 [54; 59) 'false': bool
423[73; 75) '!b': bool 437 [69; 70) 'c': bool
424[74; 75) 'b': bool 438 [73; 75) '!b': bool
425[85; 86) 'a': i128 439 [74; 75) 'b': bool
426[89; 92) '100': i128 440 [85; 86) 'a': i128
427[102; 103) 'd': i128 441 [89; 92) '100': i128
428[112; 114) '-a': i128 442 [102; 103) 'd': i128
429[113; 114) 'a': i128 443 [112; 114) '-a': i128
430[124; 125) 'e': i32 444 [113; 114) 'a': i128
431[128; 132) '-100': i32 445 [124; 125) 'e': i32
432[129; 132) '100': i32 446 [128; 132) '-100': i32
433[142; 143) 'f': bool 447 [129; 132) '100': i32
434[146; 153) '!!!true': bool 448 [142; 143) 'f': bool
435[147; 153) '!!true': bool 449 [146; 153) '!!!true': bool
436[148; 153) '!true': bool 450 [147; 153) '!!true': bool
437[149; 153) 'true': bool 451 [148; 153) '!true': bool
438[163; 164) 'g': i32 452 [149; 153) 'true': bool
439[167; 170) '!42': i32 453 [163; 164) 'g': i32
440[168; 170) '42': i32 454 [167; 170) '!42': i32
441[180; 181) 'h': u32 455 [168; 170) '42': i32
442[184; 190) '!10u32': u32 456 [180; 181) 'h': u32
443[185; 190) '10u32': u32 457 [184; 190) '!10u32': u32
444[200; 201) 'j': i128 458 [185; 190) '10u32': u32
445[204; 206) '!a': i128 459 [200; 201) 'j': i128
446[205; 206) 'a': i128 460 [204; 206) '!a': i128
447[212; 217) '-3.14': f64 461 [205; 206) 'a': i128
448[213; 217) '3.14': f64 462 [212; 217) '-3.14': f64
449[223; 225) '!3': i32 463 [213; 217) '3.14': f64
450[224; 225) '3': i32 464 [223; 225) '!3': i32
451[231; 233) '-x': {unknown} 465 [224; 225) '3': i32
452[232; 233) 'x': SomeType 466 [231; 233) '-x': {unknown}
453[239; 241) '!x': {unknown} 467 [232; 233) 'x': SomeType
454[240; 241) 'x': SomeType 468 [239; 241) '!x': {unknown}
455[247; 255) '-"hello"': {unknown} 469 [240; 241) 'x': SomeType
456[248; 255) '"hello"': &str 470 [247; 255) '-"hello"': {unknown}
457[261; 269) '!"hello"': {unknown} 471 [248; 255) '"hello"': &str
458[262; 269) '"hello"': &str"### 472 [261; 269) '!"hello"': {unknown}
473 [262; 269) '"hello"': &str
474 "###
459 ); 475 );
460} 476}
461 477
462#[test] 478#[test]
463fn infer_backwards() { 479fn infer_backwards() {
464 assert_snapshot_matches!( 480 assert_snapshot!(
465 infer(r#" 481 infer(r#"
466fn takes_u32(x: u32) {} 482fn takes_u32(x: u32) {}
467 483
@@ -477,32 +493,34 @@ fn test() -> &mut &f64 {
477} 493}
478"#), 494"#),
479 @r###" 495 @r###"
480[14; 15) 'x': u32 496
481[22; 24) '{}': () 497 [14; 15) 'x': u32
482[78; 231) '{ ...t &c }': &mut &f64 498 [22; 24) '{}': ()
483[88; 89) 'a': u32 499 [78; 231) '{ ...t &c }': &mut &f64
484[92; 108) 'unknow...nction': {unknown} 500 [88; 89) 'a': u32
485[92; 110) 'unknow...tion()': u32 501 [92; 108) 'unknow...nction': {unknown}
486[116; 125) 'takes_u32': fn takes_u32(u32) -> () 502 [92; 110) 'unknow...tion()': u32
487[116; 128) 'takes_u32(a)': () 503 [116; 125) 'takes_u32': fn takes_u32(u32) -> ()
488[126; 127) 'a': u32 504 [116; 128) 'takes_u32(a)': ()
489[138; 139) 'b': i32 505 [126; 127) 'a': u32
490[142; 158) 'unknow...nction': {unknown} 506 [138; 139) 'b': i32
491[142; 160) 'unknow...tion()': i32 507 [142; 158) 'unknow...nction': {unknown}
492[166; 184) 'S { i3...d: b }': S 508 [142; 160) 'unknow...tion()': i32
493[181; 182) 'b': i32 509 [166; 184) 'S { i3...d: b }': S
494[194; 195) 'c': f64 510 [181; 182) 'b': i32
495[198; 214) 'unknow...nction': {unknown} 511 [194; 195) 'c': f64
496[198; 216) 'unknow...tion()': f64 512 [198; 214) 'unknow...nction': {unknown}
497[222; 229) '&mut &c': &mut &f64 513 [198; 216) 'unknow...tion()': f64
498[227; 229) '&c': &f64 514 [222; 229) '&mut &c': &mut &f64
499[228; 229) 'c': f64"### 515 [227; 229) '&c': &f64
516 [228; 229) 'c': f64
517 "###
500 ); 518 );
501} 519}
502 520
503#[test] 521#[test]
504fn infer_self() { 522fn infer_self() {
505 assert_snapshot_matches!( 523 assert_snapshot!(
506 infer(r#" 524 infer(r#"
507struct S; 525struct S;
508 526
@@ -522,22 +540,24 @@ impl S {
522} 540}
523"#), 541"#),
524 @r###" 542 @r###"
525[34; 38) 'self': &S 543
526[40; 61) '{ ... }': () 544 [34; 38) 'self': &S
527[50; 54) 'self': &S 545 [40; 61) '{ ... }': ()
528[75; 79) 'self': &S 546 [50; 54) 'self': &S
529[88; 109) '{ ... }': () 547 [75; 79) 'self': &S
530[98; 102) 'self': &S 548 [88; 109) '{ ... }': ()
531[133; 153) '{ ... }': S 549 [98; 102) 'self': &S
532[143; 147) 'S {}': S 550 [133; 153) '{ ... }': S
533[177; 200) '{ ... }': S 551 [143; 147) 'S {}': S
534[187; 194) 'Self {}': S"### 552 [177; 200) '{ ... }': S
553 [187; 194) 'Self {}': S
554 "###
535 ); 555 );
536} 556}
537 557
538#[test] 558#[test]
539fn infer_binary_op() { 559fn infer_binary_op() {
540 assert_snapshot_matches!( 560 assert_snapshot!(
541 infer(r#" 561 infer(r#"
542fn f(x: bool) -> i32 { 562fn f(x: bool) -> i32 {
543 0i32 563 0i32
@@ -560,62 +580,64 @@ fn test() -> bool {
560} 580}
561"#), 581"#),
562 @r###" 582 @r###"
563[6; 7) 'x': bool 583
564[22; 34) '{ 0i32 }': i32 584 [6; 7) 'x': bool
565[28; 32) '0i32': i32 585 [22; 34) '{ 0i32 }': i32
566[54; 370) '{ ... < 3 }': bool 586 [28; 32) '0i32': i32
567[64; 65) 'x': bool 587 [54; 370) '{ ... < 3 }': bool
568[68; 69) 'a': bool 588 [64; 65) 'x': bool
569[68; 74) 'a && b': bool 589 [68; 69) 'a': bool
570[73; 74) 'b': bool 590 [68; 74) 'a && b': bool
571[84; 85) 'y': bool 591 [73; 74) 'b': bool
572[88; 92) 'true': bool 592 [84; 85) 'y': bool
573[88; 101) 'true || false': bool 593 [88; 92) 'true': bool
574[96; 101) 'false': bool 594 [88; 101) 'true || false': bool
575[111; 112) 'z': bool 595 [96; 101) 'false': bool
576[115; 116) 'x': bool 596 [111; 112) 'z': bool
577[115; 121) 'x == y': bool 597 [115; 116) 'x': bool
578[120; 121) 'y': bool 598 [115; 121) 'x == y': bool
579[131; 132) 't': bool 599 [120; 121) 'y': bool
580[135; 136) 'x': bool 600 [131; 132) 't': bool
581[135; 141) 'x != y': bool 601 [135; 136) 'x': bool
582[140; 141) 'y': bool 602 [135; 141) 'x != y': bool
583[151; 162) 'minus_forty': isize 603 [140; 141) 'y': bool
584[172; 180) '-40isize': isize 604 [151; 162) 'minus_forty': isize
585[173; 180) '40isize': isize 605 [172; 180) '-40isize': isize
586[190; 191) 'h': bool 606 [173; 180) '40isize': isize
587[194; 205) 'minus_forty': isize 607 [190; 191) 'h': bool
588[194; 216) 'minus_...ONST_2': bool 608 [194; 205) 'minus_forty': isize
589[209; 216) 'CONST_2': isize 609 [194; 216) 'minus_...ONST_2': bool
590[226; 227) 'c': i32 610 [209; 216) 'CONST_2': isize
591[230; 231) 'f': fn f(bool) -> i32 611 [226; 227) 'c': i32
592[230; 239) 'f(z || y)': i32 612 [230; 231) 'f': fn f(bool) -> i32
593[230; 243) 'f(z || y) + 5': i32 613 [230; 239) 'f(z || y)': i32
594[232; 233) 'z': bool 614 [230; 243) 'f(z || y) + 5': i32
595[232; 238) 'z || y': bool 615 [232; 233) 'z': bool
596[237; 238) 'y': bool 616 [232; 238) 'z || y': bool
597[242; 243) '5': i32 617 [237; 238) 'y': bool
598[253; 254) 'd': {unknown} 618 [242; 243) '5': i32
599[257; 258) 'b': {unknown} 619 [253; 254) 'd': {unknown}
600[268; 269) 'g': () 620 [257; 258) 'b': {unknown}
601[272; 283) 'minus_forty': isize 621 [268; 269) 'g': ()
602[272; 288) 'minus_...y ^= i': () 622 [272; 283) 'minus_forty': isize
603[287; 288) 'i': isize 623 [272; 288) 'minus_...y ^= i': ()
604[298; 301) 'ten': usize 624 [287; 288) 'i': isize
605[311; 313) '10': usize 625 [298; 301) 'ten': usize
606[323; 336) 'ten_is_eleven': bool 626 [311; 313) '10': usize
607[339; 342) 'ten': usize 627 [323; 336) 'ten_is_eleven': bool
608[339; 354) 'ten == some_num': bool 628 [339; 342) 'ten': usize
609[346; 354) 'some_num': usize 629 [339; 354) 'ten == some_num': bool
610[361; 364) 'ten': usize 630 [346; 354) 'some_num': usize
611[361; 368) 'ten < 3': bool 631 [361; 364) 'ten': usize
612[367; 368) '3': usize"### 632 [361; 368) 'ten < 3': bool
633 [367; 368) '3': usize
634 "###
613 ); 635 );
614} 636}
615 637
616#[test] 638#[test]
617fn infer_field_autoderef() { 639fn infer_field_autoderef() {
618 assert_snapshot_matches!( 640 assert_snapshot!(
619 infer(r#" 641 infer(r#"
620struct A { 642struct A {
621 b: B, 643 b: B,
@@ -641,72 +663,76 @@ fn test2(a1: *const A, a2: *mut A) {
641} 663}
642"#), 664"#),
643 @r###" 665 @r###"
644[44; 45) 'a': A 666
645[50; 213) '{ ...5.b; }': () 667 [44; 45) 'a': A
646[60; 62) 'a1': A 668 [50; 213) '{ ...5.b; }': ()
647[65; 66) 'a': A 669 [60; 62) 'a1': A
648[72; 74) 'a1': A 670 [65; 66) 'a': A
649[72; 76) 'a1.b': B 671 [72; 74) 'a1': A
650[86; 88) 'a2': &A 672 [72; 76) 'a1.b': B
651[91; 93) '&a': &A 673 [86; 88) 'a2': &A
652[92; 93) 'a': A 674 [91; 93) '&a': &A
653[99; 101) 'a2': &A 675 [92; 93) 'a': A
654[99; 103) 'a2.b': B 676 [99; 101) 'a2': &A
655[113; 115) 'a3': &mut A 677 [99; 103) 'a2.b': B
656[118; 124) '&mut a': &mut A 678 [113; 115) 'a3': &mut A
657[123; 124) 'a': A 679 [118; 124) '&mut a': &mut A
658[130; 132) 'a3': &mut A 680 [123; 124) 'a': A
659[130; 134) 'a3.b': B 681 [130; 132) 'a3': &mut A
660[144; 146) 'a4': &&&&&&&A 682 [130; 134) 'a3.b': B
661[149; 157) '&&&&&&&a': &&&&&&&A 683 [144; 146) 'a4': &&&&&&&A
662[150; 157) '&&&&&&a': &&&&&&A 684 [149; 157) '&&&&&&&a': &&&&&&&A
663[151; 157) '&&&&&a': &&&&&A 685 [150; 157) '&&&&&&a': &&&&&&A
664[152; 157) '&&&&a': &&&&A 686 [151; 157) '&&&&&a': &&&&&A
665[153; 157) '&&&a': &&&A 687 [152; 157) '&&&&a': &&&&A
666[154; 157) '&&a': &&A 688 [153; 157) '&&&a': &&&A
667[155; 157) '&a': &A 689 [154; 157) '&&a': &&A
668[156; 157) 'a': A 690 [155; 157) '&a': &A
669[163; 165) 'a4': &&&&&&&A 691 [156; 157) 'a': A
670[163; 167) 'a4.b': B 692 [163; 165) 'a4': &&&&&&&A
671[177; 179) 'a5': &mut &&mut &&mut A 693 [163; 167) 'a4.b': B
672[182; 200) '&mut &...&mut a': &mut &&mut &&mut A 694 [177; 179) 'a5': &mut &&mut &&mut A
673[187; 200) '&&mut &&mut a': &&mut &&mut A 695 [182; 200) '&mut &...&mut a': &mut &&mut &&mut A
674[188; 200) '&mut &&mut a': &mut &&mut A 696 [187; 200) '&&mut &&mut a': &&mut &&mut A
675[193; 200) '&&mut a': &&mut A 697 [188; 200) '&mut &&mut a': &mut &&mut A
676[194; 200) '&mut a': &mut A 698 [193; 200) '&&mut a': &&mut A
677[199; 200) 'a': A 699 [194; 200) '&mut a': &mut A
678[206; 208) 'a5': &mut &&mut &&mut A 700 [199; 200) 'a': A
679[206; 210) 'a5.b': B 701 [206; 208) 'a5': &mut &&mut &&mut A
680[224; 226) 'a1': *const A 702 [206; 210) 'a5.b': B
681[238; 240) 'a2': *mut A 703 [224; 226) 'a1': *const A
682[250; 273) '{ ...2.b; }': () 704 [238; 240) 'a2': *mut A
683[256; 258) 'a1': *const A 705 [250; 273) '{ ...2.b; }': ()
684[256; 260) 'a1.b': B 706 [256; 258) 'a1': *const A
685[266; 268) 'a2': *mut A 707 [256; 260) 'a1.b': B
686[266; 270) 'a2.b': B"### 708 [266; 268) 'a2': *mut A
709 [266; 270) 'a2.b': B
710 "###
687 ); 711 );
688} 712}
689 713
690#[test] 714#[test]
691fn bug_484() { 715fn bug_484() {
692 assert_snapshot_matches!( 716 assert_snapshot!(
693 infer(r#" 717 infer(r#"
694fn test() { 718fn test() {
695 let x = if true {}; 719 let x = if true {};
696} 720}
697"#), 721"#),
698 @r###" 722 @r###"
699[11; 37) '{ l... {}; }': () 723
700[20; 21) 'x': () 724 [11; 37) '{ l... {}; }': ()
701[24; 34) 'if true {}': () 725 [20; 21) 'x': ()
702[27; 31) 'true': bool 726 [24; 34) 'if true {}': ()
703[32; 34) '{}': ()"### 727 [27; 31) 'true': bool
728 [32; 34) '{}': ()
729 "###
704 ); 730 );
705} 731}
706 732
707#[test] 733#[test]
708fn infer_in_elseif() { 734fn infer_in_elseif() {
709 assert_snapshot_matches!( 735 assert_snapshot!(
710 infer(r#" 736 infer(r#"
711struct Foo { field: i32 } 737struct Foo { field: i32 }
712fn main(foo: Foo) { 738fn main(foo: Foo) {
@@ -718,24 +744,23 @@ fn main(foo: Foo) {
718} 744}
719"#), 745"#),
720 @r###" 746 @r###"
721 747 [35; 38) 'foo': Foo
722 ⋮[35; 38) 'foo': Foo 748 [45; 109) '{ ... } }': ()
723 ⋮[45; 109) '{ ... } }': () 749 [51; 107) 'if tru... }': ()
724 ⋮[51; 107) 'if tru... }': () 750 [54; 58) 'true': bool
725 ⋮[54; 58) 'true': bool 751 [59; 67) '{ }': ()
726 ⋮[59; 67) '{ }': () 752 [73; 107) 'if fal... }': ()
727 ⋮[73; 107) 'if fal... }': () 753 [76; 81) 'false': bool
728 ⋮[76; 81) 'false': bool 754 [82; 107) '{ ... }': i32
729 ⋮[82; 107) '{ ... }': i32 755 [92; 95) 'foo': Foo
730 ⋮[92; 95) 'foo': Foo 756 [92; 101) 'foo.field': i32
731 ⋮[92; 101) 'foo.field': i32
732 "### 757 "###
733 ) 758 )
734} 759}
735 760
736#[test] 761#[test]
737fn infer_inherent_method() { 762fn infer_inherent_method() {
738 assert_snapshot_matches!( 763 assert_snapshot!(
739 infer(r#" 764 infer(r#"
740struct A; 765struct A;
741 766
@@ -756,30 +781,32 @@ fn test(a: A) {
756} 781}
757"#), 782"#),
758 @r###" 783 @r###"
759[32; 36) 'self': A 784
760[38; 39) 'x': u32 785 [32; 36) 'self': A
761[53; 55) '{}': () 786 [38; 39) 'x': u32
762[103; 107) 'self': &A 787 [53; 55) '{}': ()
763[109; 110) 'x': u64 788 [103; 107) 'self': &A
764[124; 126) '{}': () 789 [109; 110) 'x': u64
765[144; 145) 'a': A 790 [124; 126) '{}': ()
766[150; 198) '{ ...(1); }': () 791 [144; 145) 'a': A
767[156; 157) 'a': A 792 [150; 198) '{ ...(1); }': ()
768[156; 164) 'a.foo(1)': i32 793 [156; 157) 'a': A
769[162; 163) '1': u32 794 [156; 164) 'a.foo(1)': i32
770[170; 181) '(&a).bar(1)': i64 795 [162; 163) '1': u32
771[171; 173) '&a': &A 796 [170; 181) '(&a).bar(1)': i64
772[172; 173) 'a': A 797 [171; 173) '&a': &A
773[179; 180) '1': u64 798 [172; 173) 'a': A
774[187; 188) 'a': A 799 [179; 180) '1': u64
775[187; 195) 'a.bar(1)': i64 800 [187; 188) 'a': A
776[193; 194) '1': u64"### 801 [187; 195) 'a.bar(1)': i64
802 [193; 194) '1': u64
803 "###
777 ); 804 );
778} 805}
779 806
780#[test] 807#[test]
781fn infer_inherent_method_str() { 808fn infer_inherent_method_str() {
782 assert_snapshot_matches!( 809 assert_snapshot!(
783 infer(r#" 810 infer(r#"
784#[lang = "str"] 811#[lang = "str"]
785impl str { 812impl str {
@@ -791,17 +818,19 @@ fn test() {
791} 818}
792"#), 819"#),
793 @r###" 820 @r###"
794[40; 44) 'self': &str 821
795[53; 55) '{}': () 822 [40; 44) 'self': &str
796[69; 89) '{ ...o(); }': () 823 [53; 55) '{}': ()
797[75; 80) '"foo"': &str 824 [69; 89) '{ ...o(); }': ()
798[75; 86) '"foo".foo()': i32"### 825 [75; 80) '"foo"': &str
826 [75; 86) '"foo".foo()': i32
827 "###
799 ); 828 );
800} 829}
801 830
802#[test] 831#[test]
803fn infer_tuple() { 832fn infer_tuple() {
804 assert_snapshot_matches!( 833 assert_snapshot!(
805 infer(r#" 834 infer(r#"
806fn test(x: &str, y: isize) { 835fn test(x: &str, y: isize) {
807 let a: (u32, &str) = (1, "a"); 836 let a: (u32, &str) = (1, "a");
@@ -813,39 +842,41 @@ fn test(x: &str, y: isize) {
813} 842}
814"#), 843"#),
815 @r###" 844 @r###"
816[9; 10) 'x': &str 845
817[18; 19) 'y': isize 846 [9; 10) 'x': &str
818[28; 170) '{ ...d"); }': () 847 [18; 19) 'y': isize
819[38; 39) 'a': (u32, &str) 848 [28; 170) '{ ...d"); }': ()
820[55; 63) '(1, "a")': (u32, &str) 849 [38; 39) 'a': (u32, &str)
821[56; 57) '1': u32 850 [55; 63) '(1, "a")': (u32, &str)
822[59; 62) '"a"': &str 851 [56; 57) '1': u32
823[73; 74) 'b': ((u32, &str), &str) 852 [59; 62) '"a"': &str
824[77; 83) '(a, x)': ((u32, &str), &str) 853 [73; 74) 'b': ((u32, &str), &str)
825[78; 79) 'a': (u32, &str) 854 [77; 83) '(a, x)': ((u32, &str), &str)
826[81; 82) 'x': &str 855 [78; 79) 'a': (u32, &str)
827[93; 94) 'c': (isize, &str) 856 [81; 82) 'x': &str
828[97; 103) '(y, x)': (isize, &str) 857 [93; 94) 'c': (isize, &str)
829[98; 99) 'y': isize 858 [97; 103) '(y, x)': (isize, &str)
830[101; 102) 'x': &str 859 [98; 99) 'y': isize
831[113; 114) 'd': ((isize, &str), &str) 860 [101; 102) 'x': &str
832[117; 123) '(c, x)': ((isize, &str), &str) 861 [113; 114) 'd': ((isize, &str), &str)
833[118; 119) 'c': (isize, &str) 862 [117; 123) '(c, x)': ((isize, &str), &str)
834[121; 122) 'x': &str 863 [118; 119) 'c': (isize, &str)
835[133; 134) 'e': (i32, &str) 864 [121; 122) 'x': &str
836[137; 145) '(1, "e")': (i32, &str) 865 [133; 134) 'e': (i32, &str)
837[138; 139) '1': i32 866 [137; 145) '(1, "e")': (i32, &str)
838[141; 144) '"e"': &str 867 [138; 139) '1': i32
839[155; 156) 'f': ((i32, &str), &str) 868 [141; 144) '"e"': &str
840[159; 167) '(e, "d")': ((i32, &str), &str) 869 [155; 156) 'f': ((i32, &str), &str)
841[160; 161) 'e': (i32, &str) 870 [159; 167) '(e, "d")': ((i32, &str), &str)
842[163; 166) '"d"': &str"### 871 [160; 161) 'e': (i32, &str)
872 [163; 166) '"d"': &str
873 "###
843 ); 874 );
844} 875}
845 876
846#[test] 877#[test]
847fn infer_array() { 878fn infer_array() {
848 assert_snapshot_matches!( 879 assert_snapshot!(
849 infer(r#" 880 infer(r#"
850fn test(x: &str, y: isize) { 881fn test(x: &str, y: isize) {
851 let a = [x]; 882 let a = [x];
@@ -867,70 +898,72 @@ fn test(x: &str, y: isize) {
867} 898}
868"#), 899"#),
869 @r###" 900 @r###"
870[9; 10) 'x': &str 901
871[18; 19) 'y': isize 902 [9; 10) 'x': &str
872[28; 324) '{ ... 3]; }': () 903 [18; 19) 'y': isize
873[38; 39) 'a': [&str;_] 904 [28; 324) '{ ... 3]; }': ()
874[42; 45) '[x]': [&str;_] 905 [38; 39) 'a': [&str;_]
875[43; 44) 'x': &str 906 [42; 45) '[x]': [&str;_]
876[55; 56) 'b': [[&str;_];_] 907 [43; 44) 'x': &str
877[59; 65) '[a, a]': [[&str;_];_] 908 [55; 56) 'b': [[&str;_];_]
878[60; 61) 'a': [&str;_] 909 [59; 65) '[a, a]': [[&str;_];_]
879[63; 64) 'a': [&str;_] 910 [60; 61) 'a': [&str;_]
880[75; 76) 'c': [[[&str;_];_];_] 911 [63; 64) 'a': [&str;_]
881[79; 85) '[b, b]': [[[&str;_];_];_] 912 [75; 76) 'c': [[[&str;_];_];_]
882[80; 81) 'b': [[&str;_];_] 913 [79; 85) '[b, b]': [[[&str;_];_];_]
883[83; 84) 'b': [[&str;_];_] 914 [80; 81) 'b': [[&str;_];_]
884[96; 97) 'd': [isize;_] 915 [83; 84) 'b': [[&str;_];_]
885[100; 112) '[y, 1, 2, 3]': [isize;_] 916 [96; 97) 'd': [isize;_]
886[101; 102) 'y': isize 917 [100; 112) '[y, 1, 2, 3]': [isize;_]
887[104; 105) '1': isize 918 [101; 102) 'y': isize
888[107; 108) '2': isize 919 [104; 105) '1': isize
889[110; 111) '3': isize 920 [107; 108) '2': isize
890[122; 123) 'd': [isize;_] 921 [110; 111) '3': isize
891[126; 138) '[1, y, 2, 3]': [isize;_] 922 [122; 123) 'd': [isize;_]
892[127; 128) '1': isize 923 [126; 138) '[1, y, 2, 3]': [isize;_]
893[130; 131) 'y': isize 924 [127; 128) '1': isize
894[133; 134) '2': isize 925 [130; 131) 'y': isize
895[136; 137) '3': isize 926 [133; 134) '2': isize
896[148; 149) 'e': [isize;_] 927 [136; 137) '3': isize
897[152; 155) '[y]': [isize;_] 928 [148; 149) 'e': [isize;_]
898[153; 154) 'y': isize 929 [152; 155) '[y]': [isize;_]
899[165; 166) 'f': [[isize;_];_] 930 [153; 154) 'y': isize
900[169; 175) '[d, d]': [[isize;_];_] 931 [165; 166) 'f': [[isize;_];_]
901[170; 171) 'd': [isize;_] 932 [169; 175) '[d, d]': [[isize;_];_]
902[173; 174) 'd': [isize;_] 933 [170; 171) 'd': [isize;_]
903[185; 186) 'g': [[isize;_];_] 934 [173; 174) 'd': [isize;_]
904[189; 195) '[e, e]': [[isize;_];_] 935 [185; 186) 'g': [[isize;_];_]
905[190; 191) 'e': [isize;_] 936 [189; 195) '[e, e]': [[isize;_];_]
906[193; 194) 'e': [isize;_] 937 [190; 191) 'e': [isize;_]
907[206; 207) 'h': [i32;_] 938 [193; 194) 'e': [isize;_]
908[210; 216) '[1, 2]': [i32;_] 939 [206; 207) 'h': [i32;_]
909[211; 212) '1': i32 940 [210; 216) '[1, 2]': [i32;_]
910[214; 215) '2': i32 941 [211; 212) '1': i32
911[226; 227) 'i': [&str;_] 942 [214; 215) '2': i32
912[230; 240) '["a", "b"]': [&str;_] 943 [226; 227) 'i': [&str;_]
913[231; 234) '"a"': &str 944 [230; 240) '["a", "b"]': [&str;_]
914[236; 239) '"b"': &str 945 [231; 234) '"a"': &str
915[251; 252) 'b': [[&str;_];_] 946 [236; 239) '"b"': &str
916[255; 265) '[a, ["b"]]': [[&str;_];_] 947 [251; 252) 'b': [[&str;_];_]
917[256; 257) 'a': [&str;_] 948 [255; 265) '[a, ["b"]]': [[&str;_];_]
918[259; 264) '["b"]': [&str;_] 949 [256; 257) 'a': [&str;_]
919[260; 263) '"b"': &str 950 [259; 264) '["b"]': [&str;_]
920[275; 276) 'x': [u8;_] 951 [260; 263) '"b"': &str
921[288; 290) '[]': [u8;_] 952 [275; 276) 'x': [u8;_]
922[300; 301) 'z': &[u8;_] 953 [288; 290) '[]': [u8;_]
923[311; 321) '&[1, 2, 3]': &[u8;_] 954 [300; 301) 'z': &[u8;_]
924[312; 321) '[1, 2, 3]': [u8;_] 955 [311; 321) '&[1, 2, 3]': &[u8;_]
925[313; 314) '1': u8 956 [312; 321) '[1, 2, 3]': [u8;_]
926[316; 317) '2': u8 957 [313; 314) '1': u8
927[319; 320) '3': u8"### 958 [316; 317) '2': u8
959 [319; 320) '3': u8
960 "###
928 ); 961 );
929} 962}
930 963
931#[test] 964#[test]
932fn infer_pattern() { 965fn infer_pattern() {
933 assert_snapshot_matches!( 966 assert_snapshot!(
934 infer(r#" 967 infer(r#"
935fn test(x: &i32) { 968fn test(x: &i32) {
936 let y = x; 969 let y = x;
@@ -955,59 +988,61 @@ fn test(x: &i32) {
955} 988}
956"#), 989"#),
957 @r###" 990 @r###"
958[9; 10) 'x': &i32 991
959[18; 369) '{ ...o_x; }': () 992 [9; 10) 'x': &i32
960[28; 29) 'y': &i32 993 [18; 369) '{ ...o_x; }': ()
961[32; 33) 'x': &i32 994 [28; 29) 'y': &i32
962[43; 45) '&z': &i32 995 [32; 33) 'x': &i32
963[44; 45) 'z': i32 996 [43; 45) '&z': &i32
964[48; 49) 'x': &i32 997 [44; 45) 'z': i32
965[59; 60) 'a': i32 998 [48; 49) 'x': &i32
966[63; 64) 'z': i32 999 [59; 60) 'a': i32
967[74; 80) '(c, d)': (i32, &str) 1000 [63; 64) 'z': i32
968[75; 76) 'c': i32 1001 [74; 80) '(c, d)': (i32, &str)
969[78; 79) 'd': &str 1002 [75; 76) 'c': i32
970[83; 95) '(1, "hello")': (i32, &str) 1003 [78; 79) 'd': &str
971[84; 85) '1': i32 1004 [83; 95) '(1, "hello")': (i32, &str)
972[87; 94) '"hello"': &str 1005 [84; 85) '1': i32
973[102; 152) 'for (e... }': () 1006 [87; 94) '"hello"': &str
974[106; 112) '(e, f)': ({unknown}, {unknown}) 1007 [102; 152) 'for (e... }': ()
975[107; 108) 'e': {unknown} 1008 [106; 112) '(e, f)': ({unknown}, {unknown})
976[110; 111) 'f': {unknown} 1009 [107; 108) 'e': {unknown}
977[116; 125) 'some_iter': {unknown} 1010 [110; 111) 'f': {unknown}
978[126; 152) '{ ... }': () 1011 [116; 125) 'some_iter': {unknown}
979[140; 141) 'g': {unknown} 1012 [126; 152) '{ ... }': ()
980[144; 145) 'e': {unknown} 1013 [140; 141) 'g': {unknown}
981[158; 205) 'if let... }': () 1014 [144; 145) 'e': {unknown}
982[165; 170) '[val]': {unknown} 1015 [158; 205) 'if let... }': ()
983[173; 176) 'opt': {unknown} 1016 [165; 170) '[val]': {unknown}
984[177; 205) '{ ... }': () 1017 [173; 176) 'opt': {unknown}
985[191; 192) 'h': {unknown} 1018 [177; 205) '{ ... }': ()
986[195; 198) 'val': {unknown} 1019 [191; 192) 'h': {unknown}
987[215; 221) 'lambda': {unknown} 1020 [195; 198) 'val': {unknown}
988[224; 256) '|a: u6...b; c }': {unknown} 1021 [215; 221) 'lambda': {unknown}
989[225; 226) 'a': u64 1022 [224; 256) '|a: u6...b; c }': {unknown}
990[233; 234) 'b': u64 1023 [225; 226) 'a': u64
991[236; 237) 'c': i32 1024 [233; 234) 'b': u64
992[244; 256) '{ a + b; c }': i32 1025 [236; 237) 'c': i32
993[246; 247) 'a': u64 1026 [244; 256) '{ a + b; c }': i32
994[246; 251) 'a + b': u64 1027 [246; 247) 'a': u64
995[250; 251) 'b': u64 1028 [246; 251) 'a + b': u64
996[253; 254) 'c': i32 1029 [250; 251) 'b': u64
997[267; 279) 'ref ref_to_x': &&i32 1030 [253; 254) 'c': i32
998[282; 283) 'x': &i32 1031 [267; 279) 'ref ref_to_x': &&i32
999[293; 302) 'mut mut_x': &i32 1032 [282; 283) 'x': &i32
1000[305; 306) 'x': &i32 1033 [293; 302) 'mut mut_x': &i32
1001[316; 336) 'ref mu...f_to_x': &mut &i32 1034 [305; 306) 'x': &i32
1002[339; 340) 'x': &i32 1035 [316; 336) 'ref mu...f_to_x': &mut &i32
1003[350; 351) 'k': &mut &i32 1036 [339; 340) 'x': &i32
1004[354; 366) 'mut_ref_to_x': &mut &i32"### 1037 [350; 351) 'k': &mut &i32
1038 [354; 366) 'mut_ref_to_x': &mut &i32
1039 "###
1005 ); 1040 );
1006} 1041}
1007 1042
1008#[test] 1043#[test]
1009fn infer_pattern_match_ergonomics() { 1044fn infer_pattern_match_ergonomics() {
1010 assert_snapshot_matches!( 1045 assert_snapshot!(
1011 infer(r#" 1046 infer(r#"
1012struct A<T>(T); 1047struct A<T>(T);
1013 1048
@@ -1017,26 +1052,28 @@ fn test() {
1017} 1052}
1018"#), 1053"#),
1019 @r###" 1054 @r###"
1020[28; 79) '{ ...(1); }': () 1055
1021[38; 42) 'A(n)': A<i32> 1056 [28; 79) '{ ...(1); }': ()
1022[40; 41) 'n': &i32 1057 [38; 42) 'A(n)': A<i32>
1023[45; 50) '&A(1)': &A<i32> 1058 [40; 41) 'n': &i32
1024[46; 47) 'A': A<i32>(T) -> A<T> 1059 [45; 50) '&A(1)': &A<i32>
1025[46; 50) 'A(1)': A<i32> 1060 [46; 47) 'A': A<i32>(T) -> A<T>
1026[48; 49) '1': i32 1061 [46; 50) 'A(1)': A<i32>
1027[60; 64) 'A(n)': A<i32> 1062 [48; 49) '1': i32
1028[62; 63) 'n': &mut i32 1063 [60; 64) 'A(n)': A<i32>
1029[67; 76) '&mut A(1)': &mut A<i32> 1064 [62; 63) 'n': &mut i32
1030[72; 73) 'A': A<i32>(T) -> A<T> 1065 [67; 76) '&mut A(1)': &mut A<i32>
1031[72; 76) 'A(1)': A<i32> 1066 [72; 73) 'A': A<i32>(T) -> A<T>
1032[74; 75) '1': i32"### 1067 [72; 76) 'A(1)': A<i32>
1068 [74; 75) '1': i32
1069 "###
1033 ); 1070 );
1034} 1071}
1035 1072
1036#[test] 1073#[test]
1037fn infer_pattern_match_ergonomics_ref() { 1074fn infer_pattern_match_ergonomics_ref() {
1038 covers!(match_ergonomics_ref); 1075 covers!(match_ergonomics_ref);
1039 assert_snapshot_matches!( 1076 assert_snapshot!(
1040 infer(r#" 1077 infer(r#"
1041fn test() { 1078fn test() {
1042 let v = &(1, &2); 1079 let v = &(1, &2);
@@ -1044,24 +1081,26 @@ fn test() {
1044} 1081}
1045"#), 1082"#),
1046 @r###" 1083 @r###"
1047[11; 57) '{ ...= v; }': () 1084
1048[21; 22) 'v': &(i32, &i32) 1085 [11; 57) '{ ...= v; }': ()
1049[25; 33) '&(1, &2)': &(i32, &i32) 1086 [21; 22) 'v': &(i32, &i32)
1050[26; 33) '(1, &2)': (i32, &i32) 1087 [25; 33) '&(1, &2)': &(i32, &i32)
1051[27; 28) '1': i32 1088 [26; 33) '(1, &2)': (i32, &i32)
1052[30; 32) '&2': &i32 1089 [27; 28) '1': i32
1053[31; 32) '2': i32 1090 [30; 32) '&2': &i32
1054[43; 50) '(_, &w)': (i32, &i32) 1091 [31; 32) '2': i32
1055[44; 45) '_': i32 1092 [43; 50) '(_, &w)': (i32, &i32)
1056[47; 49) '&w': &i32 1093 [44; 45) '_': i32
1057[48; 49) 'w': i32 1094 [47; 49) '&w': &i32
1058[53; 54) 'v': &(i32, &i32)"### 1095 [48; 49) 'w': i32
1096 [53; 54) 'v': &(i32, &i32)
1097 "###
1059 ); 1098 );
1060} 1099}
1061 1100
1062#[test] 1101#[test]
1063fn infer_adt_pattern() { 1102fn infer_adt_pattern() {
1064 assert_snapshot_matches!( 1103 assert_snapshot!(
1065 infer(r#" 1104 infer(r#"
1066enum E { 1105enum E {
1067 A { x: usize }, 1106 A { x: usize },
@@ -1087,37 +1126,39 @@ fn test() {
1087} 1126}
1088"#), 1127"#),
1089 @r###" 1128 @r###"
1090[68; 289) '{ ... d; }': () 1129
1091[78; 79) 'e': E 1130 [68; 289) '{ ... d; }': ()
1092[82; 95) 'E::A { x: 3 }': E 1131 [78; 79) 'e': E
1093[92; 93) '3': usize 1132 [82; 95) 'E::A { x: 3 }': E
1094[106; 113) 'S(y, z)': S 1133 [92; 93) '3': usize
1095[108; 109) 'y': u32 1134 [106; 113) 'S(y, z)': S
1096[111; 112) 'z': E 1135 [108; 109) 'y': u32
1097[116; 119) 'foo': S 1136 [111; 112) 'z': E
1098[129; 148) 'E::A {..._var }': E 1137 [116; 119) 'foo': S
1099[139; 146) 'new_var': usize 1138 [129; 148) 'E::A {..._var }': E
1100[151; 152) 'e': E 1139 [139; 146) 'new_var': usize
1101[159; 245) 'match ... }': usize 1140 [151; 152) 'e': E
1102[165; 166) 'e': E 1141 [159; 245) 'match ... }': usize
1103[177; 187) 'E::A { x }': E 1142 [165; 166) 'e': E
1104[184; 185) 'x': usize 1143 [177; 187) 'E::A { x }': E
1105[191; 192) 'x': usize 1144 [184; 185) 'x': usize
1106[202; 206) 'E::B': E 1145 [191; 192) 'x': usize
1107[210; 213) 'foo': bool 1146 [202; 206) 'E::B': E
1108[217; 218) '1': usize 1147 [210; 213) 'foo': bool
1109[228; 232) 'E::B': E 1148 [217; 218) '1': usize
1110[236; 238) '10': usize 1149 [228; 232) 'E::B': E
1111[256; 275) 'ref d ...{ .. }': &E 1150 [236; 238) '10': usize
1112[264; 275) 'E::A { .. }': E 1151 [256; 275) 'ref d ...{ .. }': &E
1113[278; 279) 'e': E 1152 [264; 275) 'E::A { .. }': E
1114[285; 286) 'd': &E"### 1153 [278; 279) 'e': E
1154 [285; 286) 'd': &E
1155 "###
1115 ); 1156 );
1116} 1157}
1117 1158
1118#[test] 1159#[test]
1119fn infer_struct_generics() { 1160fn infer_struct_generics() {
1120 assert_snapshot_matches!( 1161 assert_snapshot!(
1121 infer(r#" 1162 infer(r#"
1122struct A<T> { 1163struct A<T> {
1123 x: T, 1164 x: T,
@@ -1132,27 +1173,29 @@ fn test(a1: A<u32>, i: i32) {
1132} 1173}
1133"#), 1174"#),
1134 @r###" 1175 @r###"
1135[36; 38) 'a1': A<u32> 1176
1136[48; 49) 'i': i32 1177 [36; 38) 'a1': A<u32>
1137[56; 147) '{ ...3.x; }': () 1178 [48; 49) 'i': i32
1138[62; 64) 'a1': A<u32> 1179 [56; 147) '{ ...3.x; }': ()
1139[62; 66) 'a1.x': u32 1180 [62; 64) 'a1': A<u32>
1140[76; 78) 'a2': A<i32> 1181 [62; 66) 'a1.x': u32
1141[81; 91) 'A { x: i }': A<i32> 1182 [76; 78) 'a2': A<i32>
1142[88; 89) 'i': i32 1183 [81; 91) 'A { x: i }': A<i32>
1143[97; 99) 'a2': A<i32> 1184 [88; 89) 'i': i32
1144[97; 101) 'a2.x': i32 1185 [97; 99) 'a2': A<i32>
1145[111; 113) 'a3': A<i128> 1186 [97; 101) 'a2.x': i32
1146[116; 134) 'A::<i1...x: 1 }': A<i128> 1187 [111; 113) 'a3': A<i128>
1147[131; 132) '1': i128 1188 [116; 134) 'A::<i1...x: 1 }': A<i128>
1148[140; 142) 'a3': A<i128> 1189 [131; 132) '1': i128
1149[140; 144) 'a3.x': i128"### 1190 [140; 142) 'a3': A<i128>
1191 [140; 144) 'a3.x': i128
1192 "###
1150 ); 1193 );
1151} 1194}
1152 1195
1153#[test] 1196#[test]
1154fn infer_tuple_struct_generics() { 1197fn infer_tuple_struct_generics() {
1155 assert_snapshot_matches!( 1198 assert_snapshot!(
1156 infer(r#" 1199 infer(r#"
1157struct A<T>(T); 1200struct A<T>(T);
1158enum Option<T> { Some(T), None } 1201enum Option<T> { Some(T), None }
@@ -1168,30 +1211,29 @@ fn test() {
1168} 1211}
1169"#), 1212"#),
1170 @r###" 1213 @r###"
1171 1214 [76; 184) '{ ...one; }': ()
1172 ⋮[76; 184) '{ ...one; }': () 1215 [82; 83) 'A': A<i32>(T) -> A<T>
1173 ⋮[82; 83) 'A': A<i32>(T) -> A<T> 1216 [82; 87) 'A(42)': A<i32>
1174 ⋮[82; 87) 'A(42)': A<i32> 1217 [84; 86) '42': i32
1175 ⋮[84; 86) '42': i32 1218 [93; 94) 'A': A<u128>(T) -> A<T>
1176 ⋮[93; 94) 'A': A<u128>(T) -> A<T> 1219 [93; 102) 'A(42u128)': A<u128>
1177 ⋮[93; 102) 'A(42u128)': A<u128> 1220 [95; 101) '42u128': u128
1178 ⋮[95; 101) '42u128': u128 1221 [108; 112) 'Some': Some<&str>(T) -> Option<T>
1179 ⋮[108; 112) 'Some': Some<&str>(T) -> Option<T> 1222 [108; 117) 'Some("x")': Option<&str>
1180 ⋮[108; 117) 'Some("x")': Option<&str> 1223 [113; 116) '"x"': &str
1181 ⋮[113; 116) '"x"': &str 1224 [123; 135) 'Option::Some': Some<&str>(T) -> Option<T>
1182 ⋮[123; 135) 'Option::Some': Some<&str>(T) -> Option<T> 1225 [123; 140) 'Option...e("x")': Option<&str>
1183 ⋮[123; 140) 'Option...e("x")': Option<&str> 1226 [136; 139) '"x"': &str
1184 ⋮[136; 139) '"x"': &str 1227 [146; 150) 'None': Option<{unknown}>
1185 ⋮[146; 150) 'None': Option<{unknown}> 1228 [160; 161) 'x': Option<i64>
1186 ⋮[160; 161) 'x': Option<i64> 1229 [177; 181) 'None': Option<i64>
1187 ⋮[177; 181) 'None': Option<i64>
1188 "### 1230 "###
1189 ); 1231 );
1190} 1232}
1191 1233
1192#[test] 1234#[test]
1193fn infer_generics_in_patterns() { 1235fn infer_generics_in_patterns() {
1194 assert_snapshot_matches!( 1236 assert_snapshot!(
1195 infer(r#" 1237 infer(r#"
1196struct A<T> { 1238struct A<T> {
1197 x: T, 1239 x: T,
@@ -1212,29 +1254,31 @@ fn test(a1: A<u32>, o: Option<u64>) {
1212} 1254}
1213"#), 1255"#),
1214 @r###" 1256 @r###"
1215[79; 81) 'a1': A<u32> 1257
1216[91; 92) 'o': Option<u64> 1258 [79; 81) 'a1': A<u32>
1217[107; 244) '{ ... }; }': () 1259 [91; 92) 'o': Option<u64>
1218[117; 128) 'A { x: x2 }': A<u32> 1260 [107; 244) '{ ... }; }': ()
1219[124; 126) 'x2': u32 1261 [117; 128) 'A { x: x2 }': A<u32>
1220[131; 133) 'a1': A<u32> 1262 [124; 126) 'x2': u32
1221[143; 161) 'A::<i6...: x3 }': A<i64> 1263 [131; 133) 'a1': A<u32>
1222[157; 159) 'x3': i64 1264 [143; 161) 'A::<i6...: x3 }': A<i64>
1223[164; 174) 'A { x: 1 }': A<i64> 1265 [157; 159) 'x3': i64
1224[171; 172) '1': i64 1266 [164; 174) 'A { x: 1 }': A<i64>
1225[180; 241) 'match ... }': u64 1267 [171; 172) '1': i64
1226[186; 187) 'o': Option<u64> 1268 [180; 241) 'match ... }': u64
1227[198; 213) 'Option::Some(t)': Option<u64> 1269 [186; 187) 'o': Option<u64>
1228[211; 212) 't': u64 1270 [198; 213) 'Option::Some(t)': Option<u64>
1229[217; 218) 't': u64 1271 [211; 212) 't': u64
1230[228; 229) '_': Option<u64> 1272 [217; 218) 't': u64
1231[233; 234) '1': u64"### 1273 [228; 229) '_': Option<u64>
1274 [233; 234) '1': u64
1275 "###
1232 ); 1276 );
1233} 1277}
1234 1278
1235#[test] 1279#[test]
1236fn infer_function_generics() { 1280fn infer_function_generics() {
1237 assert_snapshot_matches!( 1281 assert_snapshot!(
1238 infer(r#" 1282 infer(r#"
1239fn id<T>(t: T) -> T { t } 1283fn id<T>(t: T) -> T { t }
1240 1284
@@ -1245,26 +1289,28 @@ fn test() {
1245} 1289}
1246"#), 1290"#),
1247 @r###" 1291 @r###"
1248[10; 11) 't': T 1292
1249[21; 26) '{ t }': T 1293 [10; 11) 't': T
1250[23; 24) 't': T 1294 [21; 26) '{ t }': T
1251[38; 98) '{ ...(1); }': () 1295 [23; 24) 't': T
1252[44; 46) 'id': fn id<u32>(T) -> T 1296 [38; 98) '{ ...(1); }': ()
1253[44; 52) 'id(1u32)': u32 1297 [44; 46) 'id': fn id<u32>(T) -> T
1254[47; 51) '1u32': u32 1298 [44; 52) 'id(1u32)': u32
1255[58; 68) 'id::<i128>': fn id<i128>(T) -> T 1299 [47; 51) '1u32': u32
1256[58; 71) 'id::<i128>(1)': i128 1300 [58; 68) 'id::<i128>': fn id<i128>(T) -> T
1257[69; 70) '1': i128 1301 [58; 71) 'id::<i128>(1)': i128
1258[81; 82) 'x': u64 1302 [69; 70) '1': i128
1259[90; 92) 'id': fn id<u64>(T) -> T 1303 [81; 82) 'x': u64
1260[90; 95) 'id(1)': u64 1304 [90; 92) 'id': fn id<u64>(T) -> T
1261[93; 94) '1': u64"### 1305 [90; 95) 'id(1)': u64
1306 [93; 94) '1': u64
1307 "###
1262 ); 1308 );
1263} 1309}
1264 1310
1265#[test] 1311#[test]
1266fn infer_impl_generics() { 1312fn infer_impl_generics() {
1267 assert_snapshot_matches!( 1313 assert_snapshot!(
1268 infer(r#" 1314 infer(r#"
1269struct A<T1, T2> { 1315struct A<T1, T2> {
1270 x: T1, 1316 x: T1,
@@ -1291,44 +1337,46 @@ fn test() -> i128 {
1291} 1337}
1292"#), 1338"#),
1293 @r###" 1339 @r###"
1294[74; 78) 'self': A<X, Y> 1340
1295[85; 107) '{ ... }': X 1341 [74; 78) 'self': A<X, Y>
1296[95; 99) 'self': A<X, Y> 1342 [85; 107) '{ ... }': X
1297[95; 101) 'self.x': X 1343 [95; 99) 'self': A<X, Y>
1298[117; 121) 'self': A<X, Y> 1344 [95; 101) 'self.x': X
1299[128; 150) '{ ... }': Y 1345 [117; 121) 'self': A<X, Y>
1300[138; 142) 'self': A<X, Y> 1346 [128; 150) '{ ... }': Y
1301[138; 144) 'self.y': Y 1347 [138; 142) 'self': A<X, Y>
1302[163; 167) 'self': A<X, Y> 1348 [138; 144) 'self.y': Y
1303[169; 170) 't': T 1349 [163; 167) 'self': A<X, Y>
1304[188; 223) '{ ... }': (X, Y, T) 1350 [169; 170) 't': T
1305[198; 217) '(self.....y, t)': (X, Y, T) 1351 [188; 223) '{ ... }': (X, Y, T)
1306[199; 203) 'self': A<X, Y> 1352 [198; 217) '(self.....y, t)': (X, Y, T)
1307[199; 205) 'self.x': X 1353 [199; 203) 'self': A<X, Y>
1308[207; 211) 'self': A<X, Y> 1354 [199; 205) 'self.x': X
1309[207; 213) 'self.y': Y 1355 [207; 211) 'self': A<X, Y>
1310[215; 216) 't': T 1356 [207; 213) 'self.y': Y
1311[245; 342) '{ ...(1); }': () 1357 [215; 216) 't': T
1312[255; 256) 'a': A<u64, i64> 1358 [245; 342) '{ ...(1); }': ()
1313[259; 281) 'A { x:...1i64 }': A<u64, i64> 1359 [255; 256) 'a': A<u64, i64>
1314[266; 270) '1u64': u64 1360 [259; 281) 'A { x:...1i64 }': A<u64, i64>
1315[275; 279) '1i64': i64 1361 [266; 270) '1u64': u64
1316[287; 288) 'a': A<u64, i64> 1362 [275; 279) '1i64': i64
1317[287; 292) 'a.x()': u64 1363 [287; 288) 'a': A<u64, i64>
1318[298; 299) 'a': A<u64, i64> 1364 [287; 292) 'a.x()': u64
1319[298; 303) 'a.y()': i64 1365 [298; 299) 'a': A<u64, i64>
1320[309; 310) 'a': A<u64, i64> 1366 [298; 303) 'a.y()': i64
1321[309; 319) 'a.z(1i128)': (u64, i64, i128) 1367 [309; 310) 'a': A<u64, i64>
1322[313; 318) '1i128': i128 1368 [309; 319) 'a.z(1i128)': (u64, i64, i128)
1323[325; 326) 'a': A<u64, i64> 1369 [313; 318) '1i128': i128
1324[325; 339) 'a.z::<u128>(1)': (u64, i64, u128) 1370 [325; 326) 'a': A<u64, i64>
1325[337; 338) '1': u128"### 1371 [325; 339) 'a.z::<u128>(1)': (u64, i64, u128)
1372 [337; 338) '1': u128
1373 "###
1326 ); 1374 );
1327} 1375}
1328 1376
1329#[test] 1377#[test]
1330fn infer_impl_generics_with_autoderef() { 1378fn infer_impl_generics_with_autoderef() {
1331 assert_snapshot_matches!( 1379 assert_snapshot!(
1332 infer(r#" 1380 infer(r#"
1333enum Option<T> { 1381enum Option<T> {
1334 Some(T), 1382 Some(T),
@@ -1343,21 +1391,23 @@ fn test(o: Option<u32>) {
1343} 1391}
1344"#), 1392"#),
1345 @r###" 1393 @r###"
1346[78; 82) 'self': &Option<T> 1394
1347[98; 100) '{}': () 1395 [78; 82) 'self': &Option<T>
1348[111; 112) 'o': Option<u32> 1396 [98; 100) '{}': ()
1349[127; 165) '{ ...f(); }': () 1397 [111; 112) 'o': Option<u32>
1350[133; 146) '(&o).as_ref()': Option<&u32> 1398 [127; 165) '{ ...f(); }': ()
1351[134; 136) '&o': &Option<u32> 1399 [133; 146) '(&o).as_ref()': Option<&u32>
1352[135; 136) 'o': Option<u32> 1400 [134; 136) '&o': &Option<u32>
1353[152; 153) 'o': Option<u32> 1401 [135; 136) 'o': Option<u32>
1354[152; 162) 'o.as_ref()': Option<&u32>"### 1402 [152; 153) 'o': Option<u32>
1403 [152; 162) 'o.as_ref()': Option<&u32>
1404 "###
1355 ); 1405 );
1356} 1406}
1357 1407
1358#[test] 1408#[test]
1359fn infer_generic_chain() { 1409fn infer_generic_chain() {
1360 assert_snapshot_matches!( 1410 assert_snapshot!(
1361 infer(r#" 1411 infer(r#"
1362struct A<T> { 1412struct A<T> {
1363 x: T, 1413 x: T,
@@ -1379,41 +1429,43 @@ fn test() -> i128 {
1379} 1429}
1380"#), 1430"#),
1381 @r###" 1431 @r###"
1382[53; 57) 'self': A<T2> 1432
1383[65; 87) '{ ... }': T2 1433 [53; 57) 'self': A<T2>
1384[75; 79) 'self': A<T2> 1434 [65; 87) '{ ... }': T2
1385[75; 81) 'self.x': T2 1435 [75; 79) 'self': A<T2>
1386[99; 100) 't': T 1436 [75; 81) 'self.x': T2
1387[110; 115) '{ t }': T 1437 [99; 100) 't': T
1388[112; 113) 't': T 1438 [110; 115) '{ t }': T
1389[135; 261) '{ ....x() }': i128 1439 [112; 113) 't': T
1390[146; 147) 'x': i128 1440 [135; 261) '{ ....x() }': i128
1391[150; 151) '1': i128 1441 [146; 147) 'x': i128
1392[162; 163) 'y': i128 1442 [150; 151) '1': i128
1393[166; 168) 'id': fn id<i128>(T) -> T 1443 [162; 163) 'y': i128
1394[166; 171) 'id(x)': i128 1444 [166; 168) 'id': fn id<i128>(T) -> T
1395[169; 170) 'x': i128 1445 [166; 171) 'id(x)': i128
1396[182; 183) 'a': A<i128> 1446 [169; 170) 'x': i128
1397[186; 200) 'A { x: id(y) }': A<i128> 1447 [182; 183) 'a': A<i128>
1398[193; 195) 'id': fn id<i128>(T) -> T 1448 [186; 200) 'A { x: id(y) }': A<i128>
1399[193; 198) 'id(y)': i128 1449 [193; 195) 'id': fn id<i128>(T) -> T
1400[196; 197) 'y': i128 1450 [193; 198) 'id(y)': i128
1401[211; 212) 'z': i128 1451 [196; 197) 'y': i128
1402[215; 217) 'id': fn id<i128>(T) -> T 1452 [211; 212) 'z': i128
1403[215; 222) 'id(a.x)': i128 1453 [215; 217) 'id': fn id<i128>(T) -> T
1404[218; 219) 'a': A<i128> 1454 [215; 222) 'id(a.x)': i128
1405[218; 221) 'a.x': i128 1455 [218; 219) 'a': A<i128>
1406[233; 234) 'b': A<i128> 1456 [218; 221) 'a.x': i128
1407[237; 247) 'A { x: z }': A<i128> 1457 [233; 234) 'b': A<i128>
1408[244; 245) 'z': i128 1458 [237; 247) 'A { x: z }': A<i128>
1409[254; 255) 'b': A<i128> 1459 [244; 245) 'z': i128
1410[254; 259) 'b.x()': i128"### 1460 [254; 255) 'b': A<i128>
1461 [254; 259) 'b.x()': i128
1462 "###
1411 ); 1463 );
1412} 1464}
1413 1465
1414#[test] 1466#[test]
1415fn infer_associated_const() { 1467fn infer_associated_const() {
1416 assert_snapshot_matches!( 1468 assert_snapshot!(
1417 infer(r#" 1469 infer(r#"
1418struct Struct; 1470struct Struct;
1419 1471
@@ -1444,24 +1496,23 @@ fn test() {
1444} 1496}
1445"#), 1497"#),
1446 @r###" 1498 @r###"
1447 1499 [52; 53) '1': u32
1448 ⋮[52; 53) '1': u32 1500 [105; 106) '2': u32
1449 ⋮[105; 106) '2': u32 1501 [213; 214) '5': u32
1450 ⋮[213; 214) '5': u32 1502 [229; 307) '{ ...:ID; }': ()
1451 ⋮[229; 307) '{ ...:ID; }': () 1503 [239; 240) 'x': u32
1452 ⋮[239; 240) 'x': u32 1504 [243; 254) 'Struct::FOO': u32
1453 ⋮[243; 254) 'Struct::FOO': u32 1505 [264; 265) 'y': u32
1454 ⋮[264; 265) 'y': u32 1506 [268; 277) 'Enum::BAR': u32
1455 ⋮[268; 277) 'Enum::BAR': u32 1507 [287; 288) 'z': {unknown}
1456 ⋮[287; 288) 'z': {unknown} 1508 [291; 304) 'TraitTest::ID': {unknown}
1457 ⋮[291; 304) 'TraitTest::ID': {unknown}
1458 "### 1509 "###
1459 ); 1510 );
1460} 1511}
1461 1512
1462#[test] 1513#[test]
1463fn infer_associated_method_struct() { 1514fn infer_associated_method_struct() {
1464 assert_snapshot_matches!( 1515 assert_snapshot!(
1465 infer(r#" 1516 infer(r#"
1466struct A { x: u32 } 1517struct A { x: u32 }
1467 1518
@@ -1476,23 +1527,22 @@ fn test() {
1476} 1527}
1477"#), 1528"#),
1478 @r###" 1529 @r###"
1479 1530 [49; 75) '{ ... }': A
1480 ⋮[49; 75) '{ ... }': A 1531 [59; 69) 'A { x: 0 }': A
1481 ⋮[59; 69) 'A { x: 0 }': A 1532 [66; 67) '0': u32
1482 ⋮[66; 67) '0': u32 1533 [88; 122) '{ ...a.x; }': ()
1483 ⋮[88; 122) '{ ...a.x; }': () 1534 [98; 99) 'a': A
1484 ⋮[98; 99) 'a': A 1535 [102; 108) 'A::new': fn new() -> A
1485 ⋮[102; 108) 'A::new': fn new() -> A 1536 [102; 110) 'A::new()': A
1486 ⋮[102; 110) 'A::new()': A 1537 [116; 117) 'a': A
1487 ⋮[116; 117) 'a': A 1538 [116; 119) 'a.x': u32
1488 ⋮[116; 119) 'a.x': u32
1489 "### 1539 "###
1490 ); 1540 );
1491} 1541}
1492 1542
1493#[test] 1543#[test]
1494fn infer_associated_method_enum() { 1544fn infer_associated_method_enum() {
1495 assert_snapshot_matches!( 1545 assert_snapshot!(
1496 infer(r#" 1546 infer(r#"
1497enum A { B, C } 1547enum A { B, C }
1498 1548
@@ -1512,27 +1562,26 @@ fn test() {
1512} 1562}
1513"#), 1563"#),
1514 @r###" 1564 @r###"
1515 1565 [47; 67) '{ ... }': A
1516 ⋮[47; 67) '{ ... }': A 1566 [57; 61) 'A::B': A
1517 ⋮[57; 61) 'A::B': A 1567 [88; 108) '{ ... }': A
1518 ⋮[88; 108) '{ ... }': A 1568 [98; 102) 'A::C': A
1519 ⋮[98; 102) 'A::C': A 1569 [121; 178) '{ ... c; }': ()
1520 ⋮[121; 178) '{ ... c; }': () 1570 [131; 132) 'a': A
1521 ⋮[131; 132) 'a': A 1571 [135; 139) 'A::b': fn b() -> A
1522 ⋮[135; 139) 'A::b': fn b() -> A 1572 [135; 141) 'A::b()': A
1523 ⋮[135; 141) 'A::b()': A 1573 [147; 148) 'a': A
1524 ⋮[147; 148) 'a': A 1574 [158; 159) 'c': A
1525 ⋮[158; 159) 'c': A 1575 [162; 166) 'A::c': fn c() -> A
1526 ⋮[162; 166) 'A::c': fn c() -> A 1576 [162; 168) 'A::c()': A
1527 ⋮[162; 168) 'A::c()': A 1577 [174; 175) 'c': A
1528 ⋮[174; 175) 'c': A
1529 "### 1578 "###
1530 ); 1579 );
1531} 1580}
1532 1581
1533#[test] 1582#[test]
1534fn infer_associated_method_with_modules() { 1583fn infer_associated_method_with_modules() {
1535 assert_snapshot_matches!( 1584 assert_snapshot!(
1536 infer(r#" 1585 infer(r#"
1537mod a { 1586mod a {
1538 struct A; 1587 struct A;
@@ -1557,28 +1606,30 @@ fn test() {
1557} 1606}
1558"#), 1607"#),
1559 @r###" 1608 @r###"
1560[56; 64) '{ A {} }': A 1609
1561[58; 62) 'A {}': A 1610 [56; 64) '{ A {} }': A
1562[126; 132) '{ 99 }': u32 1611 [58; 62) 'A {}': A
1563[128; 130) '99': u32 1612 [126; 132) '{ 99 }': u32
1564[202; 210) '{ C {} }': C 1613 [128; 130) '99': u32
1565[204; 208) 'C {}': C 1614 [202; 210) '{ C {} }': C
1566[241; 325) '{ ...g(); }': () 1615 [204; 208) 'C {}': C
1567[251; 252) 'x': A 1616 [241; 325) '{ ...g(); }': ()
1568[255; 266) 'a::A::thing': fn thing() -> A 1617 [251; 252) 'x': A
1569[255; 268) 'a::A::thing()': A 1618 [255; 266) 'a::A::thing': fn thing() -> A
1570[278; 279) 'y': u32 1619 [255; 268) 'a::A::thing()': A
1571[282; 293) 'b::B::thing': fn thing() -> u32 1620 [278; 279) 'y': u32
1572[282; 295) 'b::B::thing()': u32 1621 [282; 293) 'b::B::thing': fn thing() -> u32
1573[305; 306) 'z': C 1622 [282; 295) 'b::B::thing()': u32
1574[309; 320) 'c::C::thing': fn thing() -> C 1623 [305; 306) 'z': C
1575[309; 322) 'c::C::thing()': C"### 1624 [309; 320) 'c::C::thing': fn thing() -> C
1625 [309; 322) 'c::C::thing()': C
1626 "###
1576 ); 1627 );
1577} 1628}
1578 1629
1579#[test] 1630#[test]
1580fn infer_associated_method_generics() { 1631fn infer_associated_method_generics() {
1581 assert_snapshot_matches!( 1632 assert_snapshot!(
1582 infer(r#" 1633 infer(r#"
1583struct Gen<T> { 1634struct Gen<T> {
1584 val: T 1635 val: T
@@ -1595,21 +1646,23 @@ fn test() {
1595} 1646}
1596"#), 1647"#),
1597 @r###" 1648 @r###"
1598[64; 67) 'val': T 1649
1599[82; 109) '{ ... }': Gen<T> 1650 [64; 67) 'val': T
1600[92; 103) 'Gen { val }': Gen<T> 1651 [82; 109) '{ ... }': Gen<T>
1601[98; 101) 'val': T 1652 [92; 103) 'Gen { val }': Gen<T>
1602[123; 155) '{ ...32); }': () 1653 [98; 101) 'val': T
1603[133; 134) 'a': Gen<u32> 1654 [123; 155) '{ ...32); }': ()
1604[137; 146) 'Gen::make': fn make<u32>(T) -> Gen<T> 1655 [133; 134) 'a': Gen<u32>
1605[137; 152) 'Gen::make(0u32)': Gen<u32> 1656 [137; 146) 'Gen::make': fn make<u32>(T) -> Gen<T>
1606[147; 151) '0u32': u32"### 1657 [137; 152) 'Gen::make(0u32)': Gen<u32>
1658 [147; 151) '0u32': u32
1659 "###
1607 ); 1660 );
1608} 1661}
1609 1662
1610#[test] 1663#[test]
1611fn infer_associated_method_generics_with_default_param() { 1664fn infer_associated_method_generics_with_default_param() {
1612 assert_snapshot_matches!( 1665 assert_snapshot!(
1613 infer(r#" 1666 infer(r#"
1614struct Gen<T=u32> { 1667struct Gen<T=u32> {
1615 val: T 1668 val: T
@@ -1626,19 +1679,21 @@ fn test() {
1626} 1679}
1627"#), 1680"#),
1628 @r###" 1681 @r###"
1629[80; 104) '{ ... }': ! 1682
1630[90; 98) 'loop { }': ! 1683 [80; 104) '{ ... }': !
1631[95; 98) '{ }': () 1684 [90; 98) 'loop { }': !
1632[118; 146) '{ ...e(); }': () 1685 [95; 98) '{ }': ()
1633[128; 129) 'a': Gen<u32> 1686 [118; 146) '{ ...e(); }': ()
1634[132; 141) 'Gen::make': fn make<u32>() -> Gen<T> 1687 [128; 129) 'a': Gen<u32>
1635[132; 143) 'Gen::make()': Gen<u32>"### 1688 [132; 141) 'Gen::make': fn make<u32>() -> Gen<T>
1689 [132; 143) 'Gen::make()': Gen<u32>
1690 "###
1636 ); 1691 );
1637} 1692}
1638 1693
1639#[test] 1694#[test]
1640fn infer_associated_method_generics_without_args() { 1695fn infer_associated_method_generics_without_args() {
1641 assert_snapshot_matches!( 1696 assert_snapshot!(
1642 infer(r#" 1697 infer(r#"
1643struct Gen<T> { 1698struct Gen<T> {
1644 val: T 1699 val: T
@@ -1655,19 +1710,21 @@ fn test() {
1655} 1710}
1656"#), 1711"#),
1657 @r###" 1712 @r###"
1658[76; 100) '{ ... }': ! 1713
1659[86; 94) 'loop { }': ! 1714 [76; 100) '{ ... }': !
1660[91; 94) '{ }': () 1715 [86; 94) 'loop { }': !
1661[114; 149) '{ ...e(); }': () 1716 [91; 94) '{ }': ()
1662[124; 125) 'a': Gen<u32> 1717 [114; 149) '{ ...e(); }': ()
1663[128; 144) 'Gen::<...::make': fn make<u32>() -> Gen<T> 1718 [124; 125) 'a': Gen<u32>
1664[128; 146) 'Gen::<...make()': Gen<u32>"### 1719 [128; 144) 'Gen::<...::make': fn make<u32>() -> Gen<T>
1720 [128; 146) 'Gen::<...make()': Gen<u32>
1721 "###
1665 ); 1722 );
1666} 1723}
1667 1724
1668#[test] 1725#[test]
1669fn infer_associated_method_generics_2_type_params_without_args() { 1726fn infer_associated_method_generics_2_type_params_without_args() {
1670 assert_snapshot_matches!( 1727 assert_snapshot!(
1671 infer(r#" 1728 infer(r#"
1672struct Gen<T, U> { 1729struct Gen<T, U> {
1673 val: T, 1730 val: T,
@@ -1685,19 +1742,21 @@ fn test() {
1685} 1742}
1686"#), 1743"#),
1687 @r###" 1744 @r###"
1688[102; 126) '{ ... }': ! 1745
1689[112; 120) 'loop { }': ! 1746 [102; 126) '{ ... }': !
1690[117; 120) '{ }': () 1747 [112; 120) 'loop { }': !
1691[140; 180) '{ ...e(); }': () 1748 [117; 120) '{ }': ()
1692[150; 151) 'a': Gen<u32, u64> 1749 [140; 180) '{ ...e(); }': ()
1693[154; 175) 'Gen::<...::make': fn make<u64>() -> Gen<u32, T> 1750 [150; 151) 'a': Gen<u32, u64>
1694[154; 177) 'Gen::<...make()': Gen<u32, u64>"### 1751 [154; 175) 'Gen::<...::make': fn make<u64>() -> Gen<u32, T>
1752 [154; 177) 'Gen::<...make()': Gen<u32, u64>
1753 "###
1695 ); 1754 );
1696} 1755}
1697 1756
1698#[test] 1757#[test]
1699fn infer_type_alias() { 1758fn infer_type_alias() {
1700 assert_snapshot_matches!( 1759 assert_snapshot!(
1701 infer(r#" 1760 infer(r#"
1702struct A<X, Y> { x: X, y: Y } 1761struct A<X, Y> { x: X, y: Y }
1703type Foo = A<u32, i128>; 1762type Foo = A<u32, i128>;
@@ -1713,23 +1772,22 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) {
1713} 1772}
1714"#), 1773"#),
1715 @r###" 1774 @r###"
1716 1775 [116; 117) 'x': A<u32, i128>
1717 ⋮[116; 117) 'x': A<u32, i128> 1776 [124; 125) 'y': A<&str, u128>
1718 ⋮[124; 125) 'y': A<&str, u128> 1777 [138; 139) 'z': A<u8, i8>
1719 ⋮[138; 139) 'z': A<u8, i8> 1778 [154; 211) '{ ...z.y; }': ()
1720 ⋮[154; 211) '{ ...z.y; }': () 1779 [160; 161) 'x': A<u32, i128>
1721 ⋮[160; 161) 'x': A<u32, i128> 1780 [160; 163) 'x.x': u32
1722 ⋮[160; 163) 'x.x': u32 1781 [169; 170) 'x': A<u32, i128>
1723 ⋮[169; 170) 'x': A<u32, i128> 1782 [169; 172) 'x.y': i128
1724 ⋮[169; 172) 'x.y': i128 1783 [178; 179) 'y': A<&str, u128>
1725 ⋮[178; 179) 'y': A<&str, u128> 1784 [178; 181) 'y.x': &str
1726 ⋮[178; 181) 'y.x': &str 1785 [187; 188) 'y': A<&str, u128>
1727 ⋮[187; 188) 'y': A<&str, u128> 1786 [187; 190) 'y.y': u128
1728 ⋮[187; 190) 'y.y': u128 1787 [196; 197) 'z': A<u8, i8>
1729 ⋮[196; 197) 'z': A<u8, i8> 1788 [196; 199) 'z.x': u8
1730 ⋮[196; 199) 'z.x': u8 1789 [205; 206) 'z': A<u8, i8>
1731 ⋮[205; 206) 'z': A<u8, i8> 1790 [205; 208) 'z.y': i8
1732 ⋮[205; 208) 'z.y': i8
1733 "### 1791 "###
1734 ) 1792 )
1735} 1793}
@@ -1737,7 +1795,7 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) {
1737#[test] 1795#[test]
1738#[should_panic] // we currently can't handle this 1796#[should_panic] // we currently can't handle this
1739fn recursive_type_alias() { 1797fn recursive_type_alias() {
1740 assert_snapshot_matches!( 1798 assert_snapshot!(
1741 infer(r#" 1799 infer(r#"
1742struct A<X> {} 1800struct A<X> {}
1743type Foo = Foo; 1801type Foo = Foo;
@@ -1750,7 +1808,7 @@ fn test(x: Foo) {}
1750 1808
1751#[test] 1809#[test]
1752fn no_panic_on_field_of_enum() { 1810fn no_panic_on_field_of_enum() {
1753 assert_snapshot_matches!( 1811 assert_snapshot!(
1754 infer(r#" 1812 infer(r#"
1755enum X {} 1813enum X {}
1756 1814
@@ -1759,16 +1817,18 @@ fn test(x: X) {
1759} 1817}
1760"#), 1818"#),
1761 @r###" 1819 @r###"
1762[20; 21) 'x': X 1820
1763[26; 47) '{ ...eld; }': () 1821 [20; 21) 'x': X
1764[32; 33) 'x': X 1822 [26; 47) '{ ...eld; }': ()
1765[32; 44) 'x.some_field': {unknown}"### 1823 [32; 33) 'x': X
1824 [32; 44) 'x.some_field': {unknown}
1825 "###
1766 ); 1826 );
1767} 1827}
1768 1828
1769#[test] 1829#[test]
1770fn bug_585() { 1830fn bug_585() {
1771 assert_snapshot_matches!( 1831 assert_snapshot!(
1772 infer(r#" 1832 infer(r#"
1773fn test() { 1833fn test() {
1774 X {}; 1834 X {};
@@ -1779,20 +1839,22 @@ fn test() {
1779} 1839}
1780"#), 1840"#),
1781 @r###" 1841 @r###"
1782[11; 89) '{ ... } }': () 1842
1783[17; 21) 'X {}': {unknown} 1843 [11; 89) '{ ... } }': ()
1784[27; 87) 'match ... }': () 1844 [17; 21) 'X {}': {unknown}
1785[33; 34) 'x': {unknown} 1845 [27; 87) 'match ... }': ()
1786[45; 52) 'A::B {}': {unknown} 1846 [33; 34) 'x': {unknown}
1787[56; 58) '()': () 1847 [45; 52) 'A::B {}': {unknown}
1788[68; 74) 'A::Y()': {unknown} 1848 [56; 58) '()': ()
1789[78; 80) '()': ()"### 1849 [68; 74) 'A::Y()': {unknown}
1850 [78; 80) '()': ()
1851 "###
1790 ); 1852 );
1791} 1853}
1792 1854
1793#[test] 1855#[test]
1794fn bug_651() { 1856fn bug_651() {
1795 assert_snapshot_matches!( 1857 assert_snapshot!(
1796 infer(r#" 1858 infer(r#"
1797fn quux() { 1859fn quux() {
1798 let y = 92; 1860 let y = 92;
@@ -1800,12 +1862,14 @@ fn quux() {
1800} 1862}
1801"#), 1863"#),
1802 @r###" 1864 @r###"
1803[11; 41) '{ ...+ y; }': () 1865
1804[21; 22) 'y': i32 1866 [11; 41) '{ ...+ y; }': ()
1805[25; 27) '92': i32 1867 [21; 22) 'y': i32
1806[33; 34) '1': i32 1868 [25; 27) '92': i32
1807[33; 38) '1 + y': i32 1869 [33; 34) '1': i32
1808[37; 38) 'y': i32"### 1870 [33; 38) '1 + y': i32
1871 [37; 38) 'y': i32
1872 "###
1809 ); 1873 );
1810} 1874}
1811 1875
@@ -1813,7 +1877,7 @@ fn quux() {
1813fn recursive_vars() { 1877fn recursive_vars() {
1814 covers!(type_var_cycles_resolve_completely); 1878 covers!(type_var_cycles_resolve_completely);
1815 covers!(type_var_cycles_resolve_as_possible); 1879 covers!(type_var_cycles_resolve_as_possible);
1816 assert_snapshot_matches!( 1880 assert_snapshot!(
1817 infer(r#" 1881 infer(r#"
1818fn test() { 1882fn test() {
1819 let y = unknown; 1883 let y = unknown;
@@ -1821,13 +1885,15 @@ fn test() {
1821} 1885}
1822"#), 1886"#),
1823 @r###" 1887 @r###"
1824[11; 48) '{ ...&y]; }': () 1888
1825[21; 22) 'y': &{unknown} 1889 [11; 48) '{ ...&y]; }': ()
1826[25; 32) 'unknown': &{unknown} 1890 [21; 22) 'y': &{unknown}
1827[38; 45) '[y, &y]': [&&{unknown};_] 1891 [25; 32) 'unknown': &{unknown}
1828[39; 40) 'y': &{unknown} 1892 [38; 45) '[y, &y]': [&&{unknown};_]
1829[42; 44) '&y': &&{unknown} 1893 [39; 40) 'y': &{unknown}
1830[43; 44) 'y': &{unknown}"### 1894 [42; 44) '&y': &&{unknown}
1895 [43; 44) 'y': &{unknown}
1896 "###
1831 ); 1897 );
1832} 1898}
1833 1899
@@ -1835,7 +1901,7 @@ fn test() {
1835fn recursive_vars_2() { 1901fn recursive_vars_2() {
1836 covers!(type_var_cycles_resolve_completely); 1902 covers!(type_var_cycles_resolve_completely);
1837 covers!(type_var_cycles_resolve_as_possible); 1903 covers!(type_var_cycles_resolve_as_possible);
1838 assert_snapshot_matches!( 1904 assert_snapshot!(
1839 infer(r#" 1905 infer(r#"
1840fn test() { 1906fn test() {
1841 let x = unknown; 1907 let x = unknown;
@@ -1844,26 +1910,28 @@ fn test() {
1844} 1910}
1845"#), 1911"#),
1846 @r###" 1912 @r###"
1847[11; 80) '{ ...x)]; }': () 1913
1848[21; 22) 'x': &&{unknown} 1914 [11; 80) '{ ...x)]; }': ()
1849[25; 32) 'unknown': &&{unknown} 1915 [21; 22) 'x': &&{unknown}
1850[42; 43) 'y': &&{unknown} 1916 [25; 32) 'unknown': &&{unknown}
1851[46; 53) 'unknown': &&{unknown} 1917 [42; 43) 'y': &&{unknown}
1852[59; 77) '[(x, y..., &x)]': [(&&{unknown}, &&{unknown});_] 1918 [46; 53) 'unknown': &&{unknown}
1853[60; 66) '(x, y)': (&&{unknown}, &&{unknown}) 1919 [59; 77) '[(x, y..., &x)]': [(&&{unknown}, &&{unknown});_]
1854[61; 62) 'x': &&{unknown} 1920 [60; 66) '(x, y)': (&&{unknown}, &&{unknown})
1855[64; 65) 'y': &&{unknown} 1921 [61; 62) 'x': &&{unknown}
1856[68; 76) '(&y, &x)': (&&&{unknown}, &&&{unknown}) 1922 [64; 65) 'y': &&{unknown}
1857[69; 71) '&y': &&&{unknown} 1923 [68; 76) '(&y, &x)': (&&&{unknown}, &&&{unknown})
1858[70; 71) 'y': &&{unknown} 1924 [69; 71) '&y': &&&{unknown}
1859[73; 75) '&x': &&&{unknown} 1925 [70; 71) 'y': &&{unknown}
1860[74; 75) 'x': &&{unknown}"### 1926 [73; 75) '&x': &&&{unknown}
1927 [74; 75) 'x': &&{unknown}
1928 "###
1861 ); 1929 );
1862} 1930}
1863 1931
1864#[test] 1932#[test]
1865fn infer_type_param() { 1933fn infer_type_param() {
1866 assert_snapshot_matches!( 1934 assert_snapshot!(
1867 infer(r#" 1935 infer(r#"
1868fn id<T>(x: T) -> T { 1936fn id<T>(x: T) -> T {
1869 x 1937 x
@@ -1881,32 +1949,34 @@ fn test() {
1881} 1949}
1882"#), 1950"#),
1883 @r###" 1951 @r###"
1884[10; 11) 'x': T 1952
1885[21; 30) '{ x }': T 1953 [10; 11) 'x': T
1886[27; 28) 'x': T 1954 [21; 30) '{ x }': T
1887[44; 45) 'x': &T 1955 [27; 28) 'x': T
1888[56; 65) '{ x }': &T 1956 [44; 45) 'x': &T
1889[62; 63) 'x': &T 1957 [56; 65) '{ x }': &T
1890[77; 157) '{ ...(1); }': () 1958 [62; 63) 'x': &T
1891[87; 88) 'y': u32 1959 [77; 157) '{ ...(1); }': ()
1892[91; 96) '10u32': u32 1960 [87; 88) 'y': u32
1893[102; 104) 'id': fn id<u32>(T) -> T 1961 [91; 96) '10u32': u32
1894[102; 107) 'id(y)': u32 1962 [102; 104) 'id': fn id<u32>(T) -> T
1895[105; 106) 'y': u32 1963 [102; 107) 'id(y)': u32
1896[117; 118) 'x': bool 1964 [105; 106) 'y': u32
1897[127; 132) 'clone': fn clone<bool>(&T) -> T 1965 [117; 118) 'x': bool
1898[127; 135) 'clone(z)': bool 1966 [127; 132) 'clone': fn clone<bool>(&T) -> T
1899[133; 134) 'z': &bool 1967 [127; 135) 'clone(z)': bool
1900[141; 151) 'id::<i128>': fn id<i128>(T) -> T 1968 [133; 134) 'z': &bool
1901[141; 154) 'id::<i128>(1)': i128 1969 [141; 151) 'id::<i128>': fn id<i128>(T) -> T
1902[152; 153) '1': i128"### 1970 [141; 154) 'id::<i128>(1)': i128
1971 [152; 153) '1': i128
1972 "###
1903 ); 1973 );
1904} 1974}
1905 1975
1906#[test] 1976#[test]
1907fn infer_std_crash_1() { 1977fn infer_std_crash_1() {
1908 // caused stack overflow, taken from std 1978 // caused stack overflow, taken from std
1909 assert_snapshot_matches!( 1979 assert_snapshot!(
1910 infer(r#" 1980 infer(r#"
1911enum Maybe<T> { 1981enum Maybe<T> {
1912 Real(T), 1982 Real(T),
@@ -1920,12 +1990,14 @@ fn write() {
1920} 1990}
1921"#), 1991"#),
1922 @r###" 1992 @r###"
1923[54; 139) '{ ... } }': () 1993
1924[60; 137) 'match ... }': () 1994 [54; 139) '{ ... } }': ()
1925[66; 83) 'someth...nknown': Maybe<{unknown}> 1995 [60; 137) 'match ... }': ()
1926[94; 124) 'Maybe:...thing)': Maybe<{unknown}> 1996 [66; 83) 'someth...nknown': Maybe<{unknown}>
1927[106; 123) 'ref mu...ething': &mut {unknown} 1997 [94; 124) 'Maybe:...thing)': Maybe<{unknown}>
1928[128; 130) '()': ()"### 1998 [106; 123) 'ref mu...ething': &mut {unknown}
1999 [128; 130) '()': ()
2000 "###
1929 ); 2001 );
1930} 2002}
1931 2003
@@ -1933,27 +2005,29 @@ fn write() {
1933fn infer_std_crash_2() { 2005fn infer_std_crash_2() {
1934 covers!(type_var_resolves_to_int_var); 2006 covers!(type_var_resolves_to_int_var);
1935 // caused "equating two type variables, ...", taken from std 2007 // caused "equating two type variables, ...", taken from std
1936 assert_snapshot_matches!( 2008 assert_snapshot!(
1937 infer(r#" 2009 infer(r#"
1938fn test_line_buffer() { 2010fn test_line_buffer() {
1939 &[0, b'\n', 1, b'\n']; 2011 &[0, b'\n', 1, b'\n'];
1940} 2012}
1941"#), 2013"#),
1942 @r###" 2014 @r###"
1943[23; 53) '{ ...n']; }': () 2015
1944[29; 50) '&[0, b...b'\n']': &[u8;_] 2016 [23; 53) '{ ...n']; }': ()
1945[30; 50) '[0, b'...b'\n']': [u8;_] 2017 [29; 50) '&[0, b...b'\n']': &[u8;_]
1946[31; 32) '0': u8 2018 [30; 50) '[0, b'...b'\n']': [u8;_]
1947[34; 39) 'b'\n'': u8 2019 [31; 32) '0': u8
1948[41; 42) '1': u8 2020 [34; 39) 'b'\n'': u8
1949[44; 49) 'b'\n'': u8"### 2021 [41; 42) '1': u8
2022 [44; 49) 'b'\n'': u8
2023 "###
1950 ); 2024 );
1951} 2025}
1952 2026
1953#[test] 2027#[test]
1954fn infer_std_crash_3() { 2028fn infer_std_crash_3() {
1955 // taken from rustc 2029 // taken from rustc
1956 assert_snapshot_matches!( 2030 assert_snapshot!(
1957 infer(r#" 2031 infer(r#"
1958pub fn compute() { 2032pub fn compute() {
1959 match nope!() { 2033 match nope!() {
@@ -1962,14 +2036,13 @@ pub fn compute() {
1962} 2036}
1963"#), 2037"#),
1964 @r###" 2038 @r###"
1965 2039 [18; 108) '{ ... } }': ()
1966 ⋮[18; 108) '{ ... } }': () 2040 [24; 106) 'match ... }': ()
1967 ⋮[24; 106) 'match ... }': () 2041 [30; 37) 'nope!()': {unknown}
1968 ⋮[30; 37) 'nope!()': {unknown} 2042 [48; 94) 'SizeSk...tail }': {unknown}
1969 ⋮[48; 94) 'SizeSk...tail }': {unknown} 2043 [82; 86) 'true': {unknown}
1970 ⋮[82; 86) 'true': {unknown} 2044 [88; 92) 'tail': {unknown}
1971 ⋮[88; 92) 'tail': {unknown} 2045 [98; 100) '{}': ()
1972 ⋮[98; 100) '{}': ()
1973 "### 2046 "###
1974 ); 2047 );
1975} 2048}
@@ -1977,7 +2050,7 @@ pub fn compute() {
1977#[test] 2050#[test]
1978fn infer_std_crash_4() { 2051fn infer_std_crash_4() {
1979 // taken from rustc 2052 // taken from rustc
1980 assert_snapshot_matches!( 2053 assert_snapshot!(
1981 infer(r#" 2054 infer(r#"
1982pub fn primitive_type() { 2055pub fn primitive_type() {
1983 match *self { 2056 match *self {
@@ -1986,15 +2059,14 @@ pub fn primitive_type() {
1986} 2059}
1987"#), 2060"#),
1988 @r###" 2061 @r###"
1989 2062 [25; 106) '{ ... } }': ()
1990 ⋮[25; 106) '{ ... } }': () 2063 [31; 104) 'match ... }': ()
1991 ⋮[31; 104) 'match ... }': () 2064 [37; 42) '*self': {unknown}
1992 ⋮[37; 42) '*self': {unknown} 2065 [38; 42) 'self': {unknown}
1993 ⋮[38; 42) 'self': {unknown} 2066 [53; 91) 'Borrow...), ..}': {unknown}
1994 ⋮[53; 91) 'Borrow...), ..}': {unknown} 2067 [74; 86) 'Primitive(p)': {unknown}
1995 ⋮[74; 86) 'Primitive(p)': {unknown} 2068 [84; 85) 'p': {unknown}
1996 ⋮[84; 85) 'p': {unknown} 2069 [95; 97) '{}': ()
1997 ⋮[95; 97) '{}': ()
1998 "### 2070 "###
1999 ); 2071 );
2000} 2072}
@@ -2002,7 +2074,7 @@ pub fn primitive_type() {
2002#[test] 2074#[test]
2003fn infer_std_crash_5() { 2075fn infer_std_crash_5() {
2004 // taken from rustc 2076 // taken from rustc
2005 assert_snapshot_matches!( 2077 assert_snapshot!(
2006 infer(r#" 2078 infer(r#"
2007fn extra_compiler_flags() { 2079fn extra_compiler_flags() {
2008 for content in doesnt_matter { 2080 for content in doesnt_matter {
@@ -2021,36 +2093,38 @@ fn extra_compiler_flags() {
2021} 2093}
2022"#), 2094"#),
2023 @r###" 2095 @r###"
2024[27; 323) '{ ... } }': () 2096
2025[33; 321) 'for co... }': () 2097 [27; 323) '{ ... } }': ()
2026[37; 44) 'content': &{unknown} 2098 [33; 321) 'for co... }': ()
2027[48; 61) 'doesnt_matter': {unknown} 2099 [37; 44) 'content': &{unknown}
2028[62; 321) '{ ... }': () 2100 [48; 61) 'doesnt_matter': {unknown}
2029[76; 80) 'name': &&{unknown} 2101 [62; 321) '{ ... }': ()
2030[83; 167) 'if doe... }': &&{unknown} 2102 [76; 80) 'name': &&{unknown}
2031[86; 99) 'doesnt_matter': bool 2103 [83; 167) 'if doe... }': &&{unknown}
2032[100; 129) '{ ... }': &&{unknown} 2104 [86; 99) 'doesnt_matter': bool
2033[114; 119) 'first': &&{unknown} 2105 [100; 129) '{ ... }': &&{unknown}
2034[135; 167) '{ ... }': &&{unknown} 2106 [114; 119) 'first': &&{unknown}
2035[149; 157) '&content': &&{unknown} 2107 [135; 167) '{ ... }': &&{unknown}
2036[150; 157) 'content': &{unknown} 2108 [149; 157) '&content': &&{unknown}
2037[182; 189) 'content': &&{unknown} 2109 [150; 157) 'content': &{unknown}
2038[192; 314) 'if ICE... }': &&{unknown} 2110 [182; 189) 'content': &&{unknown}
2039[195; 232) 'ICE_RE..._VALUE': {unknown} 2111 [192; 314) 'if ICE... }': &&{unknown}
2040[195; 248) 'ICE_RE...&name)': bool 2112 [195; 232) 'ICE_RE..._VALUE': {unknown}
2041[242; 247) '&name': &&&{unknown} 2113 [195; 248) 'ICE_RE...&name)': bool
2042[243; 247) 'name': &&{unknown} 2114 [242; 247) '&name': &&&{unknown}
2043[249; 277) '{ ... }': &&{unknown} 2115 [243; 247) 'name': &&{unknown}
2044[263; 267) 'name': &&{unknown} 2116 [249; 277) '{ ... }': &&{unknown}
2045[283; 314) '{ ... }': &{unknown} 2117 [263; 267) 'name': &&{unknown}
2046[297; 304) 'content': &{unknown}"### 2118 [283; 314) '{ ... }': &{unknown}
2119 [297; 304) 'content': &{unknown}
2120 "###
2047 ); 2121 );
2048} 2122}
2049 2123
2050#[test] 2124#[test]
2051fn infer_nested_generics_crash() { 2125fn infer_nested_generics_crash() {
2052 // another crash found typechecking rustc 2126 // another crash found typechecking rustc
2053 assert_snapshot_matches!( 2127 assert_snapshot!(
2054 infer(r#" 2128 infer(r#"
2055struct Canonical<V> { 2129struct Canonical<V> {
2056 value: V, 2130 value: V,
@@ -2063,17 +2137,19 @@ fn test<R>(query_response: Canonical<QueryResponse<R>>) {
2063} 2137}
2064"#), 2138"#),
2065 @r###" 2139 @r###"
2066[92; 106) 'query_response': Canonical<QueryResponse<R>> 2140
2067[137; 167) '{ ...lue; }': () 2141 [92; 106) 'query_response': Canonical<QueryResponse<R>>
2068[143; 164) '&query....value': &QueryResponse<R> 2142 [137; 167) '{ ...lue; }': ()
2069[144; 158) 'query_response': Canonical<QueryResponse<R>> 2143 [143; 164) '&query....value': &QueryResponse<R>
2070[144; 164) 'query_....value': QueryResponse<R>"### 2144 [144; 158) 'query_response': Canonical<QueryResponse<R>>
2145 [144; 164) 'query_....value': QueryResponse<R>
2146 "###
2071 ); 2147 );
2072} 2148}
2073 2149
2074#[test] 2150#[test]
2075fn bug_1030() { 2151fn bug_1030() {
2076 assert_snapshot_matches!(infer(r#" 2152 assert_snapshot!(infer(r#"
2077struct HashSet<T, H>; 2153struct HashSet<T, H>;
2078struct FxHasher; 2154struct FxHasher;
2079type FxHashSet<T> = HashSet<T, FxHasher>; 2155type FxHashSet<T> = HashSet<T, FxHasher>;
@@ -2087,10 +2163,12 @@ pub fn main_loop() {
2087} 2163}
2088"#), 2164"#),
2089 @r###" 2165 @r###"
2090[144; 146) '{}': () 2166
2091[169; 198) '{ ...t(); }': () 2167 [144; 146) '{}': ()
2092[175; 193) 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<T, H> 2168 [169; 198) '{ ...t(); }': ()
2093[175; 195) 'FxHash...ault()': HashSet<{unknown}, FxHasher>"### 2169 [175; 193) 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<T, H>
2170 [175; 195) 'FxHash...ault()': HashSet<{unknown}, FxHasher>
2171 "###
2094 ); 2172 );
2095} 2173}
2096 2174
@@ -2122,7 +2200,7 @@ mod foo {
2122 2200
2123#[test] 2201#[test]
2124fn infer_const() { 2202fn infer_const() {
2125 assert_snapshot_matches!( 2203 assert_snapshot!(
2126 infer(r#" 2204 infer(r#"
2127struct Foo; 2205struct Foo;
2128impl Foo { const ASSOC_CONST: u32 = 0; } 2206impl Foo { const ASSOC_CONST: u32 = 0; }
@@ -2135,22 +2213,24 @@ fn test() {
2135} 2213}
2136"#), 2214"#),
2137 @r###" 2215 @r###"
2138[49; 50) '0': u32 2216
2139[80; 83) '101': u32 2217 [49; 50) '0': u32
2140[95; 213) '{ ...NST; }': () 2218 [80; 83) '101': u32
2141[138; 139) 'x': {unknown} 2219 [95; 213) '{ ...NST; }': ()
2142[142; 153) 'LOCAL_CONST': {unknown} 2220 [138; 139) 'x': {unknown}
2143[163; 164) 'z': u32 2221 [142; 153) 'LOCAL_CONST': {unknown}
2144[167; 179) 'GLOBAL_CONST': u32 2222 [163; 164) 'z': u32
2145[189; 191) 'id': u32 2223 [167; 179) 'GLOBAL_CONST': u32
2146[194; 210) 'Foo::A..._CONST': u32 2224 [189; 191) 'id': u32
2147[126; 128) '99': u32"### 2225 [194; 210) 'Foo::A..._CONST': u32
2226 [126; 128) '99': u32
2227 "###
2148 ); 2228 );
2149} 2229}
2150 2230
2151#[test] 2231#[test]
2152fn infer_static() { 2232fn infer_static() {
2153 assert_snapshot_matches!( 2233 assert_snapshot!(
2154 infer(r#" 2234 infer(r#"
2155static GLOBAL_STATIC: u32 = 101; 2235static GLOBAL_STATIC: u32 = 101;
2156static mut GLOBAL_STATIC_MUT: u32 = 101; 2236static mut GLOBAL_STATIC_MUT: u32 = 101;
@@ -2164,26 +2244,28 @@ fn test() {
2164} 2244}
2165"#), 2245"#),
2166 @r###" 2246 @r###"
2167[29; 32) '101': u32 2247
2168[70; 73) '101': u32 2248 [29; 32) '101': u32
2169[85; 280) '{ ...MUT; }': () 2249 [70; 73) '101': u32
2170[173; 174) 'x': {unknown} 2250 [85; 280) '{ ...MUT; }': ()
2171[177; 189) 'LOCAL_STATIC': {unknown} 2251 [173; 174) 'x': {unknown}
2172[199; 200) 'y': {unknown} 2252 [177; 189) 'LOCAL_STATIC': {unknown}
2173[203; 219) 'LOCAL_...IC_MUT': {unknown} 2253 [199; 200) 'y': {unknown}
2174[229; 230) 'z': u32 2254 [203; 219) 'LOCAL_...IC_MUT': {unknown}
2175[233; 246) 'GLOBAL_STATIC': u32 2255 [229; 230) 'z': u32
2176[256; 257) 'w': u32 2256 [233; 246) 'GLOBAL_STATIC': u32
2177[260; 277) 'GLOBAL...IC_MUT': u32 2257 [256; 257) 'w': u32
2178[118; 120) '99': u32 2258 [260; 277) 'GLOBAL...IC_MUT': u32
2179[161; 163) '99': u32"### 2259 [118; 120) '99': u32
2260 [161; 163) '99': u32
2261 "###
2180 ); 2262 );
2181} 2263}
2182 2264
2183#[test] 2265#[test]
2184fn infer_trait_method_simple() { 2266fn infer_trait_method_simple() {
2185 // the trait implementation is intentionally incomplete -- it shouldn't matter 2267 // the trait implementation is intentionally incomplete -- it shouldn't matter
2186 assert_snapshot_matches!( 2268 assert_snapshot!(
2187 infer(r#" 2269 infer(r#"
2188trait Trait1 { 2270trait Trait1 {
2189 fn method(&self) -> u32; 2271 fn method(&self) -> u32;
@@ -2201,20 +2283,22 @@ fn test() {
2201} 2283}
2202"#), 2284"#),
2203 @r###" 2285 @r###"
2204[31; 35) 'self': &Self 2286
2205[110; 114) 'self': &Self 2287 [31; 35) 'self': &Self
2206[170; 228) '{ ...i128 }': () 2288 [110; 114) 'self': &Self
2207[176; 178) 'S1': S1 2289 [170; 228) '{ ...i128 }': ()
2208[176; 187) 'S1.method()': u32 2290 [176; 178) 'S1': S1
2209[203; 205) 'S2': S2 2291 [176; 187) 'S1.method()': u32
2210[203; 214) 'S2.method()': i128"### 2292 [203; 205) 'S2': S2
2293 [203; 214) 'S2.method()': i128
2294 "###
2211 ); 2295 );
2212} 2296}
2213 2297
2214#[test] 2298#[test]
2215fn infer_trait_method_scoped() { 2299fn infer_trait_method_scoped() {
2216 // the trait implementation is intentionally incomplete -- it shouldn't matter 2300 // the trait implementation is intentionally incomplete -- it shouldn't matter
2217 assert_snapshot_matches!( 2301 assert_snapshot!(
2218 infer(r#" 2302 infer(r#"
2219struct S; 2303struct S;
2220mod foo { 2304mod foo {
@@ -2247,21 +2331,23 @@ mod bar_test {
2247} 2331}
2248"#), 2332"#),
2249 @r###" 2333 @r###"
2250[63; 67) 'self': &Self 2334
2251[169; 173) 'self': &Self 2335 [63; 67) 'self': &Self
2252[300; 337) '{ ... }': () 2336 [169; 173) 'self': &Self
2253[310; 311) 'S': S 2337 [300; 337) '{ ... }': ()
2254[310; 320) 'S.method()': u32 2338 [310; 311) 'S': S
2255[416; 454) '{ ... }': () 2339 [310; 320) 'S.method()': u32
2256[426; 427) 'S': S 2340 [416; 454) '{ ... }': ()
2257[426; 436) 'S.method()': i128"### 2341 [426; 427) 'S': S
2342 [426; 436) 'S.method()': i128
2343 "###
2258 ); 2344 );
2259} 2345}
2260 2346
2261#[test] 2347#[test]
2262fn infer_trait_method_generic_1() { 2348fn infer_trait_method_generic_1() {
2263 // the trait implementation is intentionally incomplete -- it shouldn't matter 2349 // the trait implementation is intentionally incomplete -- it shouldn't matter
2264 assert_snapshot_matches!( 2350 assert_snapshot!(
2265 infer(r#" 2351 infer(r#"
2266trait Trait<T> { 2352trait Trait<T> {
2267 fn method(&self) -> T; 2353 fn method(&self) -> T;
@@ -2273,17 +2359,19 @@ fn test() {
2273} 2359}
2274"#), 2360"#),
2275 @r###" 2361 @r###"
2276[33; 37) 'self': &Self 2362
2277[92; 111) '{ ...d(); }': () 2363 [33; 37) 'self': &Self
2278[98; 99) 'S': S 2364 [92; 111) '{ ...d(); }': ()
2279[98; 108) 'S.method()': u32"### 2365 [98; 99) 'S': S
2366 [98; 108) 'S.method()': u32
2367 "###
2280 ); 2368 );
2281} 2369}
2282 2370
2283#[test] 2371#[test]
2284fn infer_trait_method_generic_more_params() { 2372fn infer_trait_method_generic_more_params() {
2285 // the trait implementation is intentionally incomplete -- it shouldn't matter 2373 // the trait implementation is intentionally incomplete -- it shouldn't matter
2286 assert_snapshot_matches!( 2374 assert_snapshot!(
2287 infer(r#" 2375 infer(r#"
2288trait Trait<T1, T2, T3> { 2376trait Trait<T1, T2, T3> {
2289 fn method1(&self) -> (T1, T2, T3); 2377 fn method1(&self) -> (T1, T2, T3);
@@ -2301,24 +2389,26 @@ fn test() {
2301} 2389}
2302"#), 2390"#),
2303 @r###" 2391 @r###"
2304[43; 47) 'self': &Self 2392
2305[82; 86) 'self': &Self 2393 [43; 47) 'self': &Self
2306[210; 361) '{ ..., i8 }': () 2394 [82; 86) 'self': &Self
2307[216; 218) 'S1': S1 2395 [210; 361) '{ ..., i8 }': ()
2308[216; 228) 'S1.method1()': (u8, u16, u32) 2396 [216; 218) 'S1': S1
2309[250; 252) 'S1': S1 2397 [216; 228) 'S1.method1()': (u8, u16, u32)
2310[250; 262) 'S1.method2()': (u32, u16, u8) 2398 [250; 252) 'S1': S1
2311[284; 286) 'S2': S2 2399 [250; 262) 'S1.method2()': (u32, u16, u8)
2312[284; 296) 'S2.method1()': (i8, i16, {unknown}) 2400 [284; 286) 'S2': S2
2313[324; 326) 'S2': S2 2401 [284; 296) 'S2.method1()': (i8, i16, {unknown})
2314[324; 336) 'S2.method2()': ({unknown}, i16, i8)"### 2402 [324; 326) 'S2': S2
2403 [324; 336) 'S2.method2()': ({unknown}, i16, i8)
2404 "###
2315 ); 2405 );
2316} 2406}
2317 2407
2318#[test] 2408#[test]
2319fn infer_trait_method_generic_2() { 2409fn infer_trait_method_generic_2() {
2320 // the trait implementation is intentionally incomplete -- it shouldn't matter 2410 // the trait implementation is intentionally incomplete -- it shouldn't matter
2321 assert_snapshot_matches!( 2411 assert_snapshot!(
2322 infer(r#" 2412 infer(r#"
2323trait Trait<T> { 2413trait Trait<T> {
2324 fn method(&self) -> T; 2414 fn method(&self) -> T;
@@ -2330,18 +2420,20 @@ fn test() {
2330} 2420}
2331"#), 2421"#),
2332 @r###" 2422 @r###"
2333[33; 37) 'self': &Self 2423
2334[102; 127) '{ ...d(); }': () 2424 [33; 37) 'self': &Self
2335[108; 109) 'S': S<u32>(T) -> S<T> 2425 [102; 127) '{ ...d(); }': ()
2336[108; 115) 'S(1u32)': S<u32> 2426 [108; 109) 'S': S<u32>(T) -> S<T>
2337[108; 124) 'S(1u32...thod()': u32 2427 [108; 115) 'S(1u32)': S<u32>
2338[110; 114) '1u32': u32"### 2428 [108; 124) 'S(1u32...thod()': u32
2429 [110; 114) '1u32': u32
2430 "###
2339 ); 2431 );
2340} 2432}
2341 2433
2342#[test] 2434#[test]
2343fn infer_trait_assoc_method() { 2435fn infer_trait_assoc_method() {
2344 assert_snapshot_matches!( 2436 assert_snapshot!(
2345 infer(r#" 2437 infer(r#"
2346trait Default { 2438trait Default {
2347 fn default() -> Self; 2439 fn default() -> Self;
@@ -2355,22 +2447,24 @@ fn test() {
2355} 2447}
2356"#), 2448"#),
2357 @r###" 2449 @r###"
2358[87; 193) '{ ...t(); }': () 2450
2359[97; 99) 's1': S 2451 [87; 193) '{ ...t(); }': ()
2360[105; 121) 'Defaul...efault': {unknown} 2452 [97; 99) 's1': S
2361[105; 123) 'Defaul...ault()': S 2453 [105; 121) 'Defaul...efault': {unknown}
2362[133; 135) 's2': {unknown} 2454 [105; 123) 'Defaul...ault()': S
2363[138; 148) 'S::default': {unknown} 2455 [133; 135) 's2': {unknown}
2364[138; 150) 'S::default()': {unknown} 2456 [138; 148) 'S::default': {unknown}
2365[160; 162) 's3': {unknown} 2457 [138; 150) 'S::default()': {unknown}
2366[165; 188) '<S as ...efault': {unknown} 2458 [160; 162) 's3': {unknown}
2367[165; 190) '<S as ...ault()': {unknown}"### 2459 [165; 188) '<S as ...efault': {unknown}
2460 [165; 190) '<S as ...ault()': {unknown}
2461 "###
2368 ); 2462 );
2369} 2463}
2370 2464
2371#[test] 2465#[test]
2372fn infer_from_bound_1() { 2466fn infer_from_bound_1() {
2373 assert_snapshot_matches!( 2467 assert_snapshot!(
2374 infer(r#" 2468 infer(r#"
2375trait Trait<T> {} 2469trait Trait<T> {}
2376struct S<T>(T); 2470struct S<T>(T);
@@ -2382,24 +2476,23 @@ fn test() {
2382} 2476}
2383"#), 2477"#),
2384 @r###" 2478 @r###"
2385 2479 [86; 87) 't': T
2386 ⋮[86; 87) 't': T 2480 [92; 94) '{}': ()
2387 ⋮[92; 94) '{}': () 2481 [105; 144) '{ ...(s); }': ()
2388 ⋮[105; 144) '{ ...(s); }': () 2482 [115; 116) 's': S<u32>
2389 ⋮[115; 116) 's': S<u32> 2483 [119; 120) 'S': S<u32>(T) -> S<T>
2390 ⋮[119; 120) 'S': S<u32>(T) -> S<T> 2484 [119; 129) 'S(unknown)': S<u32>
2391 ⋮[119; 129) 'S(unknown)': S<u32> 2485 [121; 128) 'unknown': u32
2392 ⋮[121; 128) 'unknown': u32 2486 [135; 138) 'foo': fn foo<S<u32>>(T) -> ()
2393 ⋮[135; 138) 'foo': fn foo<S<u32>>(T) -> () 2487 [135; 141) 'foo(s)': ()
2394 ⋮[135; 141) 'foo(s)': () 2488 [139; 140) 's': S<u32>
2395 ⋮[139; 140) 's': S<u32>
2396 "### 2489 "###
2397 ); 2490 );
2398} 2491}
2399 2492
2400#[test] 2493#[test]
2401fn infer_from_bound_2() { 2494fn infer_from_bound_2() {
2402 assert_snapshot_matches!( 2495 assert_snapshot!(
2403 infer(r#" 2496 infer(r#"
2404trait Trait<T> {} 2497trait Trait<T> {}
2405struct S<T>(T); 2498struct S<T>(T);
@@ -2411,25 +2504,24 @@ fn test() {
2411} 2504}
2412"#), 2505"#),
2413 @r###" 2506 @r###"
2414 2507 [87; 88) 't': T
2415 ⋮[87; 88) 't': T 2508 [98; 100) '{}': ()
2416 ⋮[98; 100) '{}': () 2509 [111; 163) '{ ...(s); }': ()
2417 ⋮[111; 163) '{ ...(s); }': () 2510 [121; 122) 's': S<u32>
2418 ⋮[121; 122) 's': S<u32> 2511 [125; 126) 'S': S<u32>(T) -> S<T>
2419 ⋮[125; 126) 'S': S<u32>(T) -> S<T> 2512 [125; 135) 'S(unknown)': S<u32>
2420 ⋮[125; 135) 'S(unknown)': S<u32> 2513 [127; 134) 'unknown': u32
2421 ⋮[127; 134) 'unknown': u32 2514 [145; 146) 'x': u32
2422 ⋮[145; 146) 'x': u32 2515 [154; 157) 'foo': fn foo<u32, S<u32>>(T) -> U
2423 ⋮[154; 157) 'foo': fn foo<u32, S<u32>>(T) -> U 2516 [154; 160) 'foo(s)': u32
2424 ⋮[154; 160) 'foo(s)': u32 2517 [158; 159) 's': S<u32>
2425 ⋮[158; 159) 's': S<u32>
2426 "### 2518 "###
2427 ); 2519 );
2428} 2520}
2429 2521
2430#[test] 2522#[test]
2431fn infer_call_trait_method_on_generic_param_1() { 2523fn infer_call_trait_method_on_generic_param_1() {
2432 assert_snapshot_matches!( 2524 assert_snapshot!(
2433 infer(r#" 2525 infer(r#"
2434trait Trait { 2526trait Trait {
2435 fn method() -> u32; 2527 fn method() -> u32;
@@ -2439,16 +2531,18 @@ fn test<T: Trait>(t: T) {
2439} 2531}
2440"#), 2532"#),
2441 @r###" 2533 @r###"
2442[59; 60) 't': T 2534
2443[65; 84) '{ ...d(); }': () 2535 [59; 60) 't': T
2444[71; 72) 't': T 2536 [65; 84) '{ ...d(); }': ()
2445[71; 81) 't.method()': {unknown}"### 2537 [71; 72) 't': T
2538 [71; 81) 't.method()': {unknown}
2539 "###
2446 ); 2540 );
2447} 2541}
2448 2542
2449#[test] 2543#[test]
2450fn infer_call_trait_method_on_generic_param_2() { 2544fn infer_call_trait_method_on_generic_param_2() {
2451 assert_snapshot_matches!( 2545 assert_snapshot!(
2452 infer(r#" 2546 infer(r#"
2453trait Trait<T> { 2547trait Trait<T> {
2454 fn method() -> T; 2548 fn method() -> T;
@@ -2458,16 +2552,18 @@ fn test<U, T: Trait<U>>(t: T) {
2458} 2552}
2459"#), 2553"#),
2460 @r###" 2554 @r###"
2461[66; 67) 't': T 2555
2462[72; 91) '{ ...d(); }': () 2556 [66; 67) 't': T
2463[78; 79) 't': T 2557 [72; 91) '{ ...d(); }': ()
2464[78; 88) 't.method()': {unknown}"### 2558 [78; 79) 't': T
2559 [78; 88) 't.method()': {unknown}
2560 "###
2465 ); 2561 );
2466} 2562}
2467 2563
2468#[test] 2564#[test]
2469fn infer_with_multiple_trait_impls() { 2565fn infer_with_multiple_trait_impls() {
2470 assert_snapshot_matches!( 2566 assert_snapshot!(
2471 infer(r#" 2567 infer(r#"
2472trait Into<T> { 2568trait Into<T> {
2473 fn into(self) -> T; 2569 fn into(self) -> T;
@@ -2482,26 +2578,25 @@ fn test() {
2482} 2578}
2483"#), 2579"#),
2484 @r###" 2580 @r###"
2485 2581 [29; 33) 'self': Self
2486 ⋮[29; 33) 'self': Self 2582 [111; 202) '{ ...(S); }': ()
2487 ⋮[111; 202) '{ ...(S); }': () 2583 [121; 122) 'x': u32
2488 ⋮[121; 122) 'x': u32 2584 [130; 131) 'S': S
2489 ⋮[130; 131) 'S': S 2585 [130; 138) 'S.into()': u32
2490 ⋮[130; 138) 'S.into()': u32 2586 [148; 149) 'y': u64
2491 ⋮[148; 149) 'y': u64 2587 [157; 158) 'S': S
2492 ⋮[157; 158) 'S': S 2588 [157; 165) 'S.into()': u64
2493 ⋮[157; 165) 'S.into()': u64 2589 [175; 176) 'z': {unknown}
2494 ⋮[175; 176) 'z': {unknown} 2590 [179; 196) 'Into::...::into': {unknown}
2495 ⋮[179; 196) 'Into::...::into': {unknown} 2591 [179; 199) 'Into::...nto(S)': {unknown}
2496 ⋮[179; 199) 'Into::...nto(S)': {unknown} 2592 [197; 198) 'S': S
2497 ⋮[197; 198) 'S': S
2498 "### 2593 "###
2499 ); 2594 );
2500} 2595}
2501 2596
2502#[test] 2597#[test]
2503fn infer_project_associated_type() { 2598fn infer_project_associated_type() {
2504 assert_snapshot_matches!( 2599 assert_snapshot!(
2505 infer(r#" 2600 infer(r#"
2506trait Iterable { 2601trait Iterable {
2507 type Item; 2602 type Item;
@@ -2515,21 +2610,20 @@ fn test<T: Iterable>() {
2515} 2610}
2516"#), 2611"#),
2517 @r###" 2612 @r###"
2518 2613 [108; 227) '{ ...ter; }': ()
2519 ⋮[108; 227) '{ ...ter; }': () 2614 [118; 119) 'x': u32
2520 ⋮[118; 119) 'x': u32 2615 [145; 146) '1': u32
2521 ⋮[145; 146) '1': u32 2616 [156; 157) 'y': {unknown}
2522 ⋮[156; 157) 'y': {unknown} 2617 [183; 192) 'no_matter': {unknown}
2523 ⋮[183; 192) 'no_matter': {unknown} 2618 [202; 203) 'z': {unknown}
2524 ⋮[202; 203) 'z': {unknown} 2619 [215; 224) 'no_matter': {unknown}
2525 ⋮[215; 224) 'no_matter': {unknown}
2526 "### 2620 "###
2527 ); 2621 );
2528} 2622}
2529 2623
2530#[test] 2624#[test]
2531fn infer_return_associated_type() { 2625fn infer_return_associated_type() {
2532 assert_snapshot_matches!( 2626 assert_snapshot!(
2533 infer(r#" 2627 infer(r#"
2534trait Iterable { 2628trait Iterable {
2535 type Item; 2629 type Item;
@@ -2544,27 +2638,26 @@ fn test() {
2544} 2638}
2545"#), 2639"#),
2546 @r###" 2640 @r###"
2547 2641 [106; 107) 't': T
2548 ⋮[106; 107) 't': T 2642 [123; 125) '{}': ()
2549 ⋮[123; 125) '{}': () 2643 [147; 148) 't': T
2550 ⋮[147; 148) 't': T 2644 [178; 180) '{}': ()
2551 ⋮[178; 180) '{}': () 2645 [191; 236) '{ ...(S); }': ()
2552 ⋮[191; 236) '{ ...(S); }': () 2646 [201; 202) 'x': {unknown}
2553 ⋮[201; 202) 'x': {unknown} 2647 [205; 209) 'foo1': fn foo1<S>(T) -> {unknown}
2554 ⋮[205; 209) 'foo1': fn foo1<S>(T) -> {unknown} 2648 [205; 212) 'foo1(S)': {unknown}
2555 ⋮[205; 212) 'foo1(S)': {unknown} 2649 [210; 211) 'S': S
2556 ⋮[210; 211) 'S': S 2650 [222; 223) 'y': u32
2557 ⋮[222; 223) 'y': u32 2651 [226; 230) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item
2558 ⋮[226; 230) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item 2652 [226; 233) 'foo2(S)': u32
2559 ⋮[226; 233) 'foo2(S)': u32 2653 [231; 232) 'S': S
2560 ⋮[231; 232) 'S': S
2561 "### 2654 "###
2562 ); 2655 );
2563} 2656}
2564 2657
2565#[test] 2658#[test]
2566fn infer_associated_type_bound() { 2659fn infer_associated_type_bound() {
2567 assert_snapshot_matches!( 2660 assert_snapshot!(
2568 infer(r#" 2661 infer(r#"
2569trait Iterable { 2662trait Iterable {
2570 type Item; 2663 type Item;
@@ -2574,33 +2667,37 @@ fn test<T: Iterable<Item=u32>>() {
2574} 2667}
2575"#), 2668"#),
2576 @r###" 2669 @r###"
2577[67; 100) '{ ...own; }': () 2670
2578[77; 78) 'y': {unknown} 2671 [67; 100) '{ ...own; }': ()
2579[90; 97) 'unknown': {unknown}"### 2672 [77; 78) 'y': {unknown}
2673 [90; 97) 'unknown': {unknown}
2674 "###
2580 ); 2675 );
2581} 2676}
2582 2677
2583#[test] 2678#[test]
2584fn infer_const_body() { 2679fn infer_const_body() {
2585 assert_snapshot_matches!( 2680 assert_snapshot!(
2586 infer(r#" 2681 infer(r#"
2587const A: u32 = 1 + 1; 2682const A: u32 = 1 + 1;
2588static B: u64 = { let x = 1; x }; 2683static B: u64 = { let x = 1; x };
2589"#), 2684"#),
2590 @r###" 2685 @r###"
2591[16; 17) '1': u32 2686
2592[16; 21) '1 + 1': u32 2687 [16; 17) '1': u32
2593[20; 21) '1': u32 2688 [16; 21) '1 + 1': u32
2594[39; 55) '{ let ...1; x }': u64 2689 [20; 21) '1': u32
2595[45; 46) 'x': u64 2690 [39; 55) '{ let ...1; x }': u64
2596[49; 50) '1': u64 2691 [45; 46) 'x': u64
2597[52; 53) 'x': u64"### 2692 [49; 50) '1': u64
2693 [52; 53) 'x': u64
2694 "###
2598 ); 2695 );
2599} 2696}
2600 2697
2601#[test] 2698#[test]
2602fn tuple_struct_fields() { 2699fn tuple_struct_fields() {
2603 assert_snapshot_matches!( 2700 assert_snapshot!(
2604 infer(r#" 2701 infer(r#"
2605struct S(i32, u64); 2702struct S(i32, u64);
2606fn test() -> u64 { 2703fn test() -> u64 {
@@ -2610,23 +2707,25 @@ fn test() -> u64 {
2610} 2707}
2611"#), 2708"#),
2612 @r###" 2709 @r###"
2613[38; 87) '{ ... a.1 }': u64 2710
2614[48; 49) 'a': S 2711 [38; 87) '{ ... a.1 }': u64
2615[52; 53) 'S': S(i32, u64) -> S 2712 [48; 49) 'a': S
2616[52; 59) 'S(4, 6)': S 2713 [52; 53) 'S': S(i32, u64) -> S
2617[54; 55) '4': i32 2714 [52; 59) 'S(4, 6)': S
2618[57; 58) '6': u64 2715 [54; 55) '4': i32
2619[69; 70) 'b': i32 2716 [57; 58) '6': u64
2620[73; 74) 'a': S 2717 [69; 70) 'b': i32
2621[73; 76) 'a.0': i32 2718 [73; 74) 'a': S
2622[82; 83) 'a': S 2719 [73; 76) 'a.0': i32
2623[82; 85) 'a.1': u64"### 2720 [82; 83) 'a': S
2721 [82; 85) 'a.1': u64
2722 "###
2624 ); 2723 );
2625} 2724}
2626 2725
2627#[test] 2726#[test]
2628fn tuple_struct_with_fn() { 2727fn tuple_struct_with_fn() {
2629 assert_snapshot_matches!( 2728 assert_snapshot!(
2630 infer(r#" 2729 infer(r#"
2631struct S(fn(u32) -> u64); 2730struct S(fn(u32) -> u64);
2632fn test() -> u64 { 2731fn test() -> u64 {
@@ -2636,44 +2735,48 @@ fn test() -> u64 {
2636} 2735}
2637"#), 2736"#),
2638 @r###" 2737 @r###"
2639[44; 102) '{ ...0(2) }': u64 2738
2640[54; 55) 'a': S 2739 [44; 102) '{ ...0(2) }': u64
2641[58; 59) 'S': S(fn(u32) -> u64) -> S 2740 [54; 55) 'a': S
2642[58; 68) 'S(|i| 2*i)': S 2741 [58; 59) 'S': S(fn(u32) -> u64) -> S
2643[60; 67) '|i| 2*i': fn(u32) -> u64 2742 [58; 68) 'S(|i| 2*i)': S
2644[61; 62) 'i': i32 2743 [60; 67) '|i| 2*i': fn(u32) -> u64
2645[64; 65) '2': i32 2744 [61; 62) 'i': i32
2646[64; 67) '2*i': i32 2745 [64; 65) '2': i32
2647[66; 67) 'i': i32 2746 [64; 67) '2*i': i32
2648[78; 79) 'b': u64 2747 [66; 67) 'i': i32
2649[82; 83) 'a': S 2748 [78; 79) 'b': u64
2650[82; 85) 'a.0': fn(u32) -> u64 2749 [82; 83) 'a': S
2651[82; 88) 'a.0(4)': u64 2750 [82; 85) 'a.0': fn(u32) -> u64
2652[86; 87) '4': u32 2751 [82; 88) 'a.0(4)': u64
2653[94; 95) 'a': S 2752 [86; 87) '4': u32
2654[94; 97) 'a.0': fn(u32) -> u64 2753 [94; 95) 'a': S
2655[94; 100) 'a.0(2)': u64 2754 [94; 97) 'a.0': fn(u32) -> u64
2656[98; 99) '2': u32"### 2755 [94; 100) 'a.0(2)': u64
2756 [98; 99) '2': u32
2757 "###
2657 ); 2758 );
2658} 2759}
2659 2760
2660#[test] 2761#[test]
2661fn indexing_arrays() { 2762fn indexing_arrays() {
2662 assert_snapshot_matches!( 2763 assert_snapshot!(
2663 infer("fn main() { &mut [9][2]; }"), 2764 infer("fn main() { &mut [9][2]; }"),
2664 @r###" 2765 @r###"
2665[10; 26) '{ &mut...[2]; }': () 2766
2666[12; 23) '&mut [9][2]': &mut {unknown} 2767 [10; 26) '{ &mut...[2]; }': ()
2667[17; 20) '[9]': [i32;_] 2768 [12; 23) '&mut [9][2]': &mut {unknown}
2668[17; 23) '[9][2]': {unknown} 2769 [17; 20) '[9]': [i32;_]
2669[18; 19) '9': i32 2770 [17; 23) '[9][2]': {unknown}
2670[21; 22) '2': i32"### 2771 [18; 19) '9': i32
2772 [21; 22) '2': i32
2773 "###
2671 ) 2774 )
2672} 2775}
2673 2776
2674#[test] 2777#[test]
2675fn infer_macros_expanded() { 2778fn infer_macros_expanded() {
2676 assert_snapshot_matches!( 2779 assert_snapshot!(
2677 infer(r#" 2780 infer(r#"
2678struct Foo(Vec<i32>); 2781struct Foo(Vec<i32>);
2679 2782
@@ -2690,9 +2793,8 @@ fn main() {
2690} 2793}
2691"#), 2794"#),
2692 @r###" 2795 @r###"
2693 2796 [156; 182) '{ ...,2); }': ()
2694 ⋮[156; 182) '{ ...,2); }': () 2797 [166; 167) 'x': Foo
2695 ⋮[166; 167) 'x': Foo
2696 "### 2798 "###
2697 ); 2799 );
2698} 2800}
@@ -3277,7 +3379,7 @@ fn test<T: ApplyL>(t: T) {
3277 3379
3278#[test] 3380#[test]
3279fn impl_trait() { 3381fn impl_trait() {
3280 assert_snapshot_matches!( 3382 assert_snapshot!(
3281 infer(r#" 3383 infer(r#"
3282trait Trait<T> { 3384trait Trait<T> {
3283 fn foo(&self) -> T; 3385 fn foo(&self) -> T;
@@ -3298,37 +3400,36 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u64>) {
3298} 3400}
3299"#), 3401"#),
3300 @r###" 3402 @r###"
3301 3403 [30; 34) 'self': &Self
3302 ⋮[30; 34) 'self': &Self 3404 [55; 59) 'self': &Self
3303 ⋮[55; 59) 'self': &Self 3405 [99; 101) '{}': ()
3304 ⋮[99; 101) '{}': () 3406 [111; 112) 'x': impl Trait<u64>
3305 ⋮[111; 112) 'x': impl Trait<u64> 3407 [131; 132) 'y': &impl Trait<u64>
3306 ⋮[131; 132) 'y': &impl Trait<u64> 3408 [152; 269) '{ ...2(); }': ()
3307 ⋮[152; 269) '{ ...2(); }': () 3409 [158; 159) 'x': impl Trait<u64>
3308 ⋮[158; 159) 'x': impl Trait<u64> 3410 [165; 166) 'y': &impl Trait<u64>
3309 ⋮[165; 166) 'y': &impl Trait<u64> 3411 [176; 177) 'z': impl Trait<u64>
3310 ⋮[176; 177) 'z': impl Trait<u64> 3412 [180; 183) 'bar': fn bar() -> impl Trait<u64>
3311 ⋮[180; 183) 'bar': fn bar() -> impl Trait<u64> 3413 [180; 185) 'bar()': impl Trait<u64>
3312 ⋮[180; 185) 'bar()': impl Trait<u64> 3414 [191; 192) 'x': impl Trait<u64>
3313 ⋮[191; 192) 'x': impl Trait<u64> 3415 [191; 198) 'x.foo()': {unknown}
3314 ⋮[191; 198) 'x.foo()': {unknown} 3416 [204; 205) 'y': &impl Trait<u64>
3315 ⋮[204; 205) 'y': &impl Trait<u64> 3417 [204; 211) 'y.foo()': {unknown}
3316 ⋮[204; 211) 'y.foo()': {unknown} 3418 [217; 218) 'z': impl Trait<u64>
3317 ⋮[217; 218) 'z': impl Trait<u64> 3419 [217; 224) 'z.foo()': {unknown}
3318 ⋮[217; 224) 'z.foo()': {unknown} 3420 [230; 231) 'x': impl Trait<u64>
3319 ⋮[230; 231) 'x': impl Trait<u64> 3421 [230; 238) 'x.foo2()': i64
3320 ⋮[230; 238) 'x.foo2()': i64 3422 [244; 245) 'y': &impl Trait<u64>
3321 ⋮[244; 245) 'y': &impl Trait<u64> 3423 [244; 252) 'y.foo2()': i64
3322 ⋮[244; 252) 'y.foo2()': i64 3424 [258; 259) 'z': impl Trait<u64>
3323 ⋮[258; 259) 'z': impl Trait<u64> 3425 [258; 266) 'z.foo2()': i64
3324 ⋮[258; 266) 'z.foo2()': i64
3325 "### 3426 "###
3326 ); 3427 );
3327} 3428}
3328 3429
3329#[test] 3430#[test]
3330fn dyn_trait() { 3431fn dyn_trait() {
3331 assert_snapshot_matches!( 3432 assert_snapshot!(
3332 infer(r#" 3433 infer(r#"
3333trait Trait<T> { 3434trait Trait<T> {
3334 fn foo(&self) -> T; 3435 fn foo(&self) -> T;
@@ -3349,37 +3450,36 @@ fn test(x: dyn Trait<u64>, y: &dyn Trait<u64>) {
3349} 3450}
3350"#), 3451"#),
3351 @r###" 3452 @r###"
3352 3453 [30; 34) 'self': &Self
3353 ⋮[30; 34) 'self': &Self 3454 [55; 59) 'self': &Self
3354 ⋮[55; 59) 'self': &Self 3455 [98; 100) '{}': ()
3355 ⋮[98; 100) '{}': () 3456 [110; 111) 'x': dyn Trait<u64>
3356 ⋮[110; 111) 'x': dyn Trait<u64> 3457 [129; 130) 'y': &dyn Trait<u64>
3357 ⋮[129; 130) 'y': &dyn Trait<u64> 3458 [149; 266) '{ ...2(); }': ()
3358 ⋮[149; 266) '{ ...2(); }': () 3459 [155; 156) 'x': dyn Trait<u64>
3359 ⋮[155; 156) 'x': dyn Trait<u64> 3460 [162; 163) 'y': &dyn Trait<u64>
3360 ⋮[162; 163) 'y': &dyn Trait<u64> 3461 [173; 174) 'z': dyn Trait<u64>
3361 ⋮[173; 174) 'z': dyn Trait<u64> 3462 [177; 180) 'bar': fn bar() -> dyn Trait<u64>
3362 ⋮[177; 180) 'bar': fn bar() -> dyn Trait<u64> 3463 [177; 182) 'bar()': dyn Trait<u64>
3363 ⋮[177; 182) 'bar()': dyn Trait<u64> 3464 [188; 189) 'x': dyn Trait<u64>
3364 ⋮[188; 189) 'x': dyn Trait<u64> 3465 [188; 195) 'x.foo()': {unknown}
3365 ⋮[188; 195) 'x.foo()': {unknown} 3466 [201; 202) 'y': &dyn Trait<u64>
3366 ⋮[201; 202) 'y': &dyn Trait<u64> 3467 [201; 208) 'y.foo()': {unknown}
3367 ⋮[201; 208) 'y.foo()': {unknown} 3468 [214; 215) 'z': dyn Trait<u64>
3368 ⋮[214; 215) 'z': dyn Trait<u64> 3469 [214; 221) 'z.foo()': {unknown}
3369 ⋮[214; 221) 'z.foo()': {unknown} 3470 [227; 228) 'x': dyn Trait<u64>
3370 ⋮[227; 228) 'x': dyn Trait<u64> 3471 [227; 235) 'x.foo2()': i64
3371 ⋮[227; 235) 'x.foo2()': i64 3472 [241; 242) 'y': &dyn Trait<u64>
3372 ⋮[241; 242) 'y': &dyn Trait<u64> 3473 [241; 249) 'y.foo2()': i64
3373 ⋮[241; 249) 'y.foo2()': i64 3474 [255; 256) 'z': dyn Trait<u64>
3374 ⋮[255; 256) 'z': dyn Trait<u64> 3475 [255; 263) 'z.foo2()': i64
3375 ⋮[255; 263) 'z.foo2()': i64
3376 "### 3476 "###
3377 ); 3477 );
3378} 3478}
3379 3479
3380#[test] 3480#[test]
3381fn dyn_trait_bare() { 3481fn dyn_trait_bare() {
3382 assert_snapshot_matches!( 3482 assert_snapshot!(
3383 infer(r#" 3483 infer(r#"
3384trait Trait { 3484trait Trait {
3385 fn foo(&self) -> u64; 3485 fn foo(&self) -> u64;
@@ -3396,30 +3496,29 @@ fn test(x: Trait, y: &Trait) -> u64 {
3396} 3496}
3397"#), 3497"#),
3398 @r###" 3498 @r###"
3399 3499 [27; 31) 'self': &Self
3400 ⋮[27; 31) 'self': &Self 3500 [61; 63) '{}': ()
3401 ⋮[61; 63) '{}': () 3501 [73; 74) 'x': {unknown}
3402 ⋮[73; 74) 'x': {unknown} 3502 [83; 84) 'y': &{unknown}
3403 ⋮[83; 84) 'y': &{unknown} 3503 [101; 176) '{ ...o(); }': ()
3404 ⋮[101; 176) '{ ...o(); }': () 3504 [107; 108) 'x': {unknown}
3405 ⋮[107; 108) 'x': {unknown} 3505 [114; 115) 'y': &{unknown}
3406 ⋮[114; 115) 'y': &{unknown} 3506 [125; 126) 'z': {unknown}
3407 ⋮[125; 126) 'z': {unknown} 3507 [129; 132) 'bar': fn bar() -> {unknown}
3408 ⋮[129; 132) 'bar': fn bar() -> {unknown} 3508 [129; 134) 'bar()': {unknown}
3409 ⋮[129; 134) 'bar()': {unknown} 3509 [140; 141) 'x': {unknown}
3410 ⋮[140; 141) 'x': {unknown} 3510 [140; 147) 'x.foo()': {unknown}
3411 ⋮[140; 147) 'x.foo()': {unknown} 3511 [153; 154) 'y': &{unknown}
3412 ⋮[153; 154) 'y': &{unknown} 3512 [153; 160) 'y.foo()': {unknown}
3413 ⋮[153; 160) 'y.foo()': {unknown} 3513 [166; 167) 'z': {unknown}
3414 ⋮[166; 167) 'z': {unknown} 3514 [166; 173) 'z.foo()': {unknown}
3415 ⋮[166; 173) 'z.foo()': {unknown}
3416 "### 3515 "###
3417 ); 3516 );
3418} 3517}
3419 3518
3420#[test] 3519#[test]
3421fn weird_bounds() { 3520fn weird_bounds() {
3422 assert_snapshot_matches!( 3521 assert_snapshot!(
3423 infer(r#" 3522 infer(r#"
3424trait Trait {} 3523trait Trait {}
3425fn test() { 3524fn test() {
@@ -3432,20 +3531,19 @@ fn test() {
3432} 3531}
3433"#), 3532"#),
3434 @r###" 3533 @r###"
3435 3534 [26; 237) '{ ...foo; }': ()
3436 ⋮[26; 237) '{ ...foo; }': () 3535 [36; 37) 'a': impl Trait + {error}
3437 ⋮[36; 37) 'a': impl Trait + {error} 3536 [64; 67) 'foo': impl Trait + {error}
3438 ⋮[64; 67) 'foo': impl Trait + {error} 3537 [77; 78) 'b': impl {error}
3439 ⋮[77; 78) 'b': impl {error} 3538 [97; 100) 'foo': impl {error}
3440 ⋮[97; 100) 'foo': impl {error} 3539 [110; 111) 'b': impl Trait
3441 ⋮[110; 111) 'b': impl Trait 3540 [128; 131) 'foo': impl Trait
3442 ⋮[128; 131) 'foo': impl Trait 3541 [141; 142) 'b': impl {error}
3443 ⋮[141; 142) 'b': impl {error} 3542 [163; 166) 'foo': impl {error}
3444 ⋮[163; 166) 'foo': impl {error} 3543 [176; 177) 'd': impl {error}
3445 ⋮[176; 177) 'd': impl {error} 3544 [193; 196) 'foo': impl {error}
3446 ⋮[193; 196) 'foo': impl {error} 3545 [206; 207) 'e': impl Trait + {error}
3447 ⋮[206; 207) 'e': impl Trait + {error} 3546 [231; 234) 'foo': impl Trait + {error}
3448 ⋮[231; 234) 'foo': impl Trait + {error}
3449 "### 3547 "###
3450 ); 3548 );
3451} 3549}
@@ -3468,7 +3566,7 @@ fn infer(content: &str) -> String {
3468 let source_file = db.parse(file_id).ok().unwrap(); 3566 let source_file = db.parse(file_id).ok().unwrap();
3469 3567
3470 let mut acc = String::new(); 3568 let mut acc = String::new();
3471 acc.push_str("\n"); 3569 // acc.push_str("\n");
3472 3570
3473 let mut infer_def = |inference_result: Arc<InferenceResult>, 3571 let mut infer_def = |inference_result: Arc<InferenceResult>,
3474 body_source_map: Arc<BodySourceMap>| { 3572 body_source_map: Arc<BodySourceMap>| {
@@ -3590,10 +3688,10 @@ fn no_such_field_diagnostics() {
3590 ) 3688 )
3591 .diagnostics(); 3689 .diagnostics();
3592 3690
3593 assert_snapshot_matches!(diagnostics, @r###" 3691 assert_snapshot!(diagnostics, @r###"
3594"baz: 62": no such field 3692 "baz: 62": no such field
3595"{\n foo: 92,\n baz: 62,\n }": fill structure fields 3693 "{\n foo: 92,\n baz: 62,\n }": fill structure fields
3596"### 3694 "###
3597 ); 3695 );
3598} 3696}
3599 3697
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml
index a7dc0b63a..000694620 100644
--- a/crates/ra_ide_api/Cargo.toml
+++ b/crates/ra_ide_api/Cargo.toml
@@ -27,7 +27,7 @@ test_utils = { path = "../test_utils" }
27ra_assists = { path = "../ra_assists" } 27ra_assists = { path = "../ra_assists" }
28 28
29[dev-dependencies] 29[dev-dependencies]
30insta = "0.10.0" 30insta = "0.11.0"
31 31
32[dev-dependencies.proptest] 32[dev-dependencies.proptest]
33version = "0.9.0" 33version = "0.9.0"
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index 27256f879..2325cdf08 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -68,7 +68,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty
68#[cfg(test)] 68#[cfg(test)]
69mod tests { 69mod tests {
70 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 70 use crate::completion::{do_completion, CompletionItem, CompletionKind};
71 use insta::assert_debug_snapshot_matches; 71 use insta::assert_debug_snapshot;
72 72
73 fn do_ref_completion(code: &str) -> Vec<CompletionItem> { 73 fn do_ref_completion(code: &str) -> Vec<CompletionItem> {
74 do_completion(code, CompletionKind::Reference) 74 do_completion(code, CompletionKind::Reference)
@@ -76,7 +76,7 @@ mod tests {
76 76
77 #[test] 77 #[test]
78 fn test_struct_field_completion() { 78 fn test_struct_field_completion() {
79 assert_debug_snapshot_matches!( 79 assert_debug_snapshot!(
80 do_ref_completion( 80 do_ref_completion(
81 r" 81 r"
82 struct A { the_field: u32 } 82 struct A { the_field: u32 }
@@ -102,7 +102,7 @@ mod tests {
102 102
103 #[test] 103 #[test]
104 fn test_struct_field_completion_self() { 104 fn test_struct_field_completion_self() {
105 assert_debug_snapshot_matches!( 105 assert_debug_snapshot!(
106 do_ref_completion( 106 do_ref_completion(
107 r" 107 r"
108 struct A { 108 struct A {
@@ -144,7 +144,7 @@ mod tests {
144 144
145 #[test] 145 #[test]
146 fn test_struct_field_completion_autoderef() { 146 fn test_struct_field_completion_autoderef() {
147 assert_debug_snapshot_matches!( 147 assert_debug_snapshot!(
148 do_ref_completion( 148 do_ref_completion(
149 r" 149 r"
150 struct A { the_field: (u32, i32) } 150 struct A { the_field: (u32, i32) }
@@ -180,7 +180,7 @@ mod tests {
180 180
181 #[test] 181 #[test]
182 fn test_no_struct_field_completion_for_method_call() { 182 fn test_no_struct_field_completion_for_method_call() {
183 assert_debug_snapshot_matches!( 183 assert_debug_snapshot!(
184 do_ref_completion( 184 do_ref_completion(
185 r" 185 r"
186 struct A { the_field: u32 } 186 struct A { the_field: u32 }
@@ -195,7 +195,7 @@ mod tests {
195 195
196 #[test] 196 #[test]
197 fn test_method_completion() { 197 fn test_method_completion() {
198 assert_debug_snapshot_matches!( 198 assert_debug_snapshot!(
199 do_ref_completion( 199 do_ref_completion(
200 r" 200 r"
201 struct A {} 201 struct A {}
@@ -224,7 +224,7 @@ mod tests {
224 224
225 #[test] 225 #[test]
226 fn test_trait_method_completion() { 226 fn test_trait_method_completion() {
227 assert_debug_snapshot_matches!( 227 assert_debug_snapshot!(
228 do_ref_completion( 228 do_ref_completion(
229 r" 229 r"
230 struct A {} 230 struct A {}
@@ -252,7 +252,7 @@ mod tests {
252 252
253 #[test] 253 #[test]
254 fn test_trait_method_completion_deduplicated() { 254 fn test_trait_method_completion_deduplicated() {
255 assert_debug_snapshot_matches!( 255 assert_debug_snapshot!(
256 do_ref_completion( 256 do_ref_completion(
257 r" 257 r"
258 struct A {} 258 struct A {}
@@ -280,7 +280,7 @@ mod tests {
280 280
281 #[test] 281 #[test]
282 fn test_no_non_self_method() { 282 fn test_no_non_self_method() {
283 assert_debug_snapshot_matches!( 283 assert_debug_snapshot!(
284 do_ref_completion( 284 do_ref_completion(
285 r" 285 r"
286 struct A {} 286 struct A {}
@@ -298,7 +298,7 @@ mod tests {
298 298
299 #[test] 299 #[test]
300 fn test_method_attr_filtering() { 300 fn test_method_attr_filtering() {
301 assert_debug_snapshot_matches!( 301 assert_debug_snapshot!(
302 do_ref_completion( 302 do_ref_completion(
303 r" 303 r"
304 struct A {} 304 struct A {}
@@ -331,7 +331,7 @@ mod tests {
331 331
332 #[test] 332 #[test]
333 fn test_tuple_field_completion() { 333 fn test_tuple_field_completion() {
334 assert_debug_snapshot_matches!( 334 assert_debug_snapshot!(
335 do_ref_completion( 335 do_ref_completion(
336 r" 336 r"
337 fn foo() { 337 fn foo() {
@@ -365,7 +365,7 @@ mod tests {
365 365
366 #[test] 366 #[test]
367 fn test_tuple_field_inference() { 367 fn test_tuple_field_inference() {
368 assert_debug_snapshot_matches!( 368 assert_debug_snapshot!(
369 do_ref_completion( 369 do_ref_completion(
370 r" 370 r"
371 pub struct S; 371 pub struct S;
@@ -400,7 +400,7 @@ mod tests {
400 400
401 #[test] 401 #[test]
402 fn test_completion_works_in_consts() { 402 fn test_completion_works_in_consts() {
403 assert_debug_snapshot_matches!( 403 assert_debug_snapshot!(
404 do_ref_completion( 404 do_ref_completion(
405 r" 405 r"
406 struct A { the_field: u32 } 406 struct A { the_field: u32 }
@@ -426,7 +426,7 @@ mod tests {
426 426
427 #[test] 427 #[test]
428 fn test_completion_await_impls_future() { 428 fn test_completion_await_impls_future() {
429 assert_debug_snapshot_matches!( 429 assert_debug_snapshot!(
430 do_completion( 430 do_completion(
431 r###" 431 r###"
432 //- /main.rs 432 //- /main.rs
diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs
index 0887ef1f6..6639b6fff 100644
--- a/crates/ra_ide_api/src/completion/complete_fn_param.rs
+++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs
@@ -51,7 +51,7 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
51#[cfg(test)] 51#[cfg(test)]
52mod tests { 52mod tests {
53 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 53 use crate::completion::{do_completion, CompletionItem, CompletionKind};
54 use insta::assert_debug_snapshot_matches; 54 use insta::assert_debug_snapshot;
55 55
56 fn do_magic_completion(code: &str) -> Vec<CompletionItem> { 56 fn do_magic_completion(code: &str) -> Vec<CompletionItem> {
57 do_completion(code, CompletionKind::Magic) 57 do_completion(code, CompletionKind::Magic)
@@ -59,7 +59,7 @@ mod tests {
59 59
60 #[test] 60 #[test]
61 fn test_param_completion_last_param() { 61 fn test_param_completion_last_param() {
62 assert_debug_snapshot_matches!( 62 assert_debug_snapshot!(
63 do_magic_completion( 63 do_magic_completion(
64 r" 64 r"
65 fn foo(file_id: FileId) {} 65 fn foo(file_id: FileId) {}
@@ -83,7 +83,7 @@ mod tests {
83 83
84 #[test] 84 #[test]
85 fn test_param_completion_nth_param() { 85 fn test_param_completion_nth_param() {
86 assert_debug_snapshot_matches!( 86 assert_debug_snapshot!(
87 do_magic_completion( 87 do_magic_completion(
88 r" 88 r"
89 fn foo(file_id: FileId) {} 89 fn foo(file_id: FileId) {}
@@ -107,7 +107,7 @@ mod tests {
107 107
108 #[test] 108 #[test]
109 fn test_param_completion_trait_param() { 109 fn test_param_completion_trait_param() {
110 assert_debug_snapshot_matches!( 110 assert_debug_snapshot!(
111 do_magic_completion( 111 do_magic_completion(
112 r" 112 r"
113 pub(crate) trait SourceRoot { 113 pub(crate) trait SourceRoot {
diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs
index 18c1839dc..c527a9f63 100644
--- a/crates/ra_ide_api/src/completion/complete_keyword.rs
+++ b/crates/ra_ide_api/src/completion/complete_keyword.rs
@@ -113,7 +113,7 @@ fn complete_return(
113#[cfg(test)] 113#[cfg(test)]
114mod tests { 114mod tests {
115 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 115 use crate::completion::{do_completion, CompletionItem, CompletionKind};
116 use insta::assert_debug_snapshot_matches; 116 use insta::assert_debug_snapshot;
117 117
118 fn do_keyword_completion(code: &str) -> Vec<CompletionItem> { 118 fn do_keyword_completion(code: &str) -> Vec<CompletionItem> {
119 do_completion(code, CompletionKind::Keyword) 119 do_completion(code, CompletionKind::Keyword)
@@ -121,7 +121,7 @@ mod tests {
121 121
122 #[test] 122 #[test]
123 fn completes_keywords_in_use_stmt() { 123 fn completes_keywords_in_use_stmt() {
124 assert_debug_snapshot_matches!( 124 assert_debug_snapshot!(
125 do_keyword_completion( 125 do_keyword_completion(
126 r" 126 r"
127 use <|> 127 use <|>
@@ -152,7 +152,7 @@ mod tests {
152]"### 152]"###
153 ); 153 );
154 154
155 assert_debug_snapshot_matches!( 155 assert_debug_snapshot!(
156 do_keyword_completion( 156 do_keyword_completion(
157 r" 157 r"
158 use a::<|> 158 use a::<|>
@@ -176,7 +176,7 @@ mod tests {
176]"### 176]"###
177 ); 177 );
178 178
179 assert_debug_snapshot_matches!( 179 assert_debug_snapshot!(
180 do_keyword_completion( 180 do_keyword_completion(
181 r" 181 r"
182 use a::{b, <|>} 182 use a::{b, <|>}
@@ -203,7 +203,7 @@ mod tests {
203 203
204 #[test] 204 #[test]
205 fn completes_various_keywords_in_function() { 205 fn completes_various_keywords_in_function() {
206 assert_debug_snapshot_matches!( 206 assert_debug_snapshot!(
207 do_keyword_completion( 207 do_keyword_completion(
208 r" 208 r"
209 fn quux() { 209 fn quux() {
@@ -253,7 +253,7 @@ mod tests {
253 253
254 #[test] 254 #[test]
255 fn completes_else_after_if() { 255 fn completes_else_after_if() {
256 assert_debug_snapshot_matches!( 256 assert_debug_snapshot!(
257 do_keyword_completion( 257 do_keyword_completion(
258 r" 258 r"
259 fn quux() { 259 fn quux() {
@@ -319,7 +319,7 @@ mod tests {
319 319
320 #[test] 320 #[test]
321 fn test_completion_return_value() { 321 fn test_completion_return_value() {
322 assert_debug_snapshot_matches!( 322 assert_debug_snapshot!(
323 do_keyword_completion( 323 do_keyword_completion(
324 r" 324 r"
325 fn quux() -> i32 { 325 fn quux() -> i32 {
@@ -366,7 +366,7 @@ mod tests {
366 }, 366 },
367]"### 367]"###
368 ); 368 );
369 assert_debug_snapshot_matches!( 369 assert_debug_snapshot!(
370 do_keyword_completion( 370 do_keyword_completion(
371 r" 371 r"
372 fn quux() { 372 fn quux() {
@@ -417,7 +417,7 @@ mod tests {
417 417
418 #[test] 418 #[test]
419 fn dont_add_semi_after_return_if_not_a_statement() { 419 fn dont_add_semi_after_return_if_not_a_statement() {
420 assert_debug_snapshot_matches!( 420 assert_debug_snapshot!(
421 do_keyword_completion( 421 do_keyword_completion(
422 r" 422 r"
423 fn quux() -> i32 { 423 fn quux() -> i32 {
@@ -469,7 +469,7 @@ mod tests {
469 469
470 #[test] 470 #[test]
471 fn last_return_in_block_has_semi() { 471 fn last_return_in_block_has_semi() {
472 assert_debug_snapshot_matches!( 472 assert_debug_snapshot!(
473 do_keyword_completion( 473 do_keyword_completion(
474 r" 474 r"
475 fn quux() -> i32 { 475 fn quux() -> i32 {
@@ -517,7 +517,7 @@ mod tests {
517 }, 517 },
518]"### 518]"###
519 ); 519 );
520 assert_debug_snapshot_matches!( 520 assert_debug_snapshot!(
521 do_keyword_completion( 521 do_keyword_completion(
522 r" 522 r"
523 fn quux() -> i32 { 523 fn quux() -> i32 {
@@ -571,7 +571,7 @@ mod tests {
571 571
572 #[test] 572 #[test]
573 fn completes_break_and_continue_in_loops() { 573 fn completes_break_and_continue_in_loops() {
574 assert_debug_snapshot_matches!( 574 assert_debug_snapshot!(
575 do_keyword_completion( 575 do_keyword_completion(
576 r" 576 r"
577 fn quux() -> i32 { 577 fn quux() -> i32 {
@@ -633,7 +633,7 @@ mod tests {
633 ); 633 );
634 634
635 // No completion: lambda isolates control flow 635 // No completion: lambda isolates control flow
636 assert_debug_snapshot_matches!( 636 assert_debug_snapshot!(
637 do_keyword_completion( 637 do_keyword_completion(
638 r" 638 r"
639 fn quux() -> i32 { 639 fn quux() -> i32 {
@@ -683,7 +683,7 @@ mod tests {
683 683
684 #[test] 684 #[test]
685 fn no_semi_after_break_continue_in_expr() { 685 fn no_semi_after_break_continue_in_expr() {
686 assert_debug_snapshot_matches!( 686 assert_debug_snapshot!(
687 do_keyword_completion( 687 do_keyword_completion(
688 r" 688 r"
689 fn f() { 689 fn f() {
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 5fd41eeb3..d6b5ac9ad 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -79,7 +79,7 @@ mod tests {
79 use test_utils::covers; 79 use test_utils::covers;
80 80
81 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 81 use crate::completion::{do_completion, CompletionItem, CompletionKind};
82 use insta::assert_debug_snapshot_matches; 82 use insta::assert_debug_snapshot;
83 83
84 fn do_reference_completion(code: &str) -> Vec<CompletionItem> { 84 fn do_reference_completion(code: &str) -> Vec<CompletionItem> {
85 do_completion(code, CompletionKind::Reference) 85 do_completion(code, CompletionKind::Reference)
@@ -120,7 +120,7 @@ mod tests {
120 120
121 #[test] 121 #[test]
122 fn completes_mod_with_docs() { 122 fn completes_mod_with_docs() {
123 assert_debug_snapshot_matches!( 123 assert_debug_snapshot!(
124 do_reference_completion( 124 do_reference_completion(
125 r" 125 r"
126 use self::my<|>; 126 use self::my<|>;
@@ -149,7 +149,7 @@ mod tests {
149 149
150 #[test] 150 #[test]
151 fn completes_use_item_starting_with_self() { 151 fn completes_use_item_starting_with_self() {
152 assert_debug_snapshot_matches!( 152 assert_debug_snapshot!(
153 do_reference_completion( 153 do_reference_completion(
154 r" 154 r"
155 use self::m::<|>; 155 use self::m::<|>;
@@ -173,7 +173,7 @@ mod tests {
173 173
174 #[test] 174 #[test]
175 fn completes_use_item_starting_with_crate() { 175 fn completes_use_item_starting_with_crate() {
176 assert_debug_snapshot_matches!( 176 assert_debug_snapshot!(
177 do_reference_completion( 177 do_reference_completion(
178 " 178 "
179 //- /lib.rs 179 //- /lib.rs
@@ -204,7 +204,7 @@ mod tests {
204 204
205 #[test] 205 #[test]
206 fn completes_nested_use_tree() { 206 fn completes_nested_use_tree() {
207 assert_debug_snapshot_matches!( 207 assert_debug_snapshot!(
208 do_reference_completion( 208 do_reference_completion(
209 " 209 "
210 //- /lib.rs 210 //- /lib.rs
@@ -235,7 +235,7 @@ mod tests {
235 235
236 #[test] 236 #[test]
237 fn completes_deeply_nested_use_tree() { 237 fn completes_deeply_nested_use_tree() {
238 assert_debug_snapshot_matches!( 238 assert_debug_snapshot!(
239 do_reference_completion( 239 do_reference_completion(
240 " 240 "
241 //- /lib.rs 241 //- /lib.rs
@@ -263,7 +263,7 @@ mod tests {
263 263
264 #[test] 264 #[test]
265 fn completes_enum_variant() { 265 fn completes_enum_variant() {
266 assert_debug_snapshot_matches!( 266 assert_debug_snapshot!(
267 do_reference_completion( 267 do_reference_completion(
268 " 268 "
269 //- /lib.rs 269 //- /lib.rs
@@ -306,7 +306,7 @@ mod tests {
306 306
307 #[test] 307 #[test]
308 fn completes_enum_variant_with_details() { 308 fn completes_enum_variant_with_details() {
309 assert_debug_snapshot_matches!( 309 assert_debug_snapshot!(
310 do_reference_completion( 310 do_reference_completion(
311 " 311 "
312 //- /lib.rs 312 //- /lib.rs
@@ -363,7 +363,7 @@ mod tests {
363 363
364 #[test] 364 #[test]
365 fn completes_struct_associated_method() { 365 fn completes_struct_associated_method() {
366 assert_debug_snapshot_matches!( 366 assert_debug_snapshot!(
367 do_reference_completion( 367 do_reference_completion(
368 " 368 "
369 //- /lib.rs 369 //- /lib.rs
@@ -396,7 +396,7 @@ mod tests {
396 396
397 #[test] 397 #[test]
398 fn completes_struct_associated_const() { 398 fn completes_struct_associated_const() {
399 assert_debug_snapshot_matches!( 399 assert_debug_snapshot!(
400 do_reference_completion( 400 do_reference_completion(
401 " 401 "
402 //- /lib.rs 402 //- /lib.rs
@@ -429,7 +429,7 @@ mod tests {
429 429
430 #[test] 430 #[test]
431 fn completes_struct_associated_type() { 431 fn completes_struct_associated_type() {
432 assert_debug_snapshot_matches!( 432 assert_debug_snapshot!(
433 do_reference_completion( 433 do_reference_completion(
434 " 434 "
435 //- /lib.rs 435 //- /lib.rs
@@ -462,7 +462,7 @@ mod tests {
462 462
463 #[test] 463 #[test]
464 fn completes_enum_associated_method() { 464 fn completes_enum_associated_method() {
465 assert_debug_snapshot_matches!( 465 assert_debug_snapshot!(
466 do_reference_completion( 466 do_reference_completion(
467 " 467 "
468 //- /lib.rs 468 //- /lib.rs
@@ -495,7 +495,7 @@ mod tests {
495 495
496 #[test] 496 #[test]
497 fn completes_union_associated_method() { 497 fn completes_union_associated_method() {
498 assert_debug_snapshot_matches!( 498 assert_debug_snapshot!(
499 do_reference_completion( 499 do_reference_completion(
500 " 500 "
501 //- /lib.rs 501 //- /lib.rs
@@ -528,7 +528,7 @@ mod tests {
528 528
529 #[test] 529 #[test]
530 fn completes_use_paths_across_crates() { 530 fn completes_use_paths_across_crates() {
531 assert_debug_snapshot_matches!( 531 assert_debug_snapshot!(
532 do_reference_completion( 532 do_reference_completion(
533 " 533 "
534 //- /main.rs 534 //- /main.rs
@@ -554,7 +554,7 @@ mod tests {
554 554
555 #[test] 555 #[test]
556 fn completes_type_alias() { 556 fn completes_type_alias() {
557 assert_debug_snapshot_matches!( 557 assert_debug_snapshot!(
558 do_reference_completion( 558 do_reference_completion(
559 " 559 "
560 struct S; 560 struct S;
diff --git a/crates/ra_ide_api/src/completion/complete_pattern.rs b/crates/ra_ide_api/src/completion/complete_pattern.rs
index f12dfcc17..fb02844fa 100644
--- a/crates/ra_ide_api/src/completion/complete_pattern.rs
+++ b/crates/ra_ide_api/src/completion/complete_pattern.rs
@@ -28,7 +28,7 @@ pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) {
28#[cfg(test)] 28#[cfg(test)]
29mod tests { 29mod tests {
30 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 30 use crate::completion::{do_completion, CompletionItem, CompletionKind};
31 use insta::assert_debug_snapshot_matches; 31 use insta::assert_debug_snapshot;
32 32
33 fn complete(code: &str) -> Vec<CompletionItem> { 33 fn complete(code: &str) -> Vec<CompletionItem> {
34 do_completion(code, CompletionKind::Reference) 34 do_completion(code, CompletionKind::Reference)
@@ -53,7 +53,7 @@ mod tests {
53 } 53 }
54 ", 54 ",
55 ); 55 );
56 assert_debug_snapshot_matches!(completions, @r###" 56 assert_debug_snapshot!(completions, @r###"
57 ⋮[ 57 ⋮[
58 ⋮ CompletionItem { 58 ⋮ CompletionItem {
59 ⋮ label: "E", 59 ⋮ label: "E",
diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs
index 6d834f6ce..3970d1af3 100644
--- a/crates/ra_ide_api/src/completion/complete_postfix.rs
+++ b/crates/ra_ide_api/src/completion/complete_postfix.rs
@@ -72,7 +72,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
72#[cfg(test)] 72#[cfg(test)]
73mod tests { 73mod tests {
74 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 74 use crate::completion::{do_completion, CompletionItem, CompletionKind};
75 use insta::assert_debug_snapshot_matches; 75 use insta::assert_debug_snapshot;
76 76
77 fn do_postfix_completion(code: &str) -> Vec<CompletionItem> { 77 fn do_postfix_completion(code: &str) -> Vec<CompletionItem> {
78 do_completion(code, CompletionKind::Postfix) 78 do_completion(code, CompletionKind::Postfix)
@@ -80,7 +80,7 @@ mod tests {
80 80
81 #[test] 81 #[test]
82 fn postfix_completion_works_for_trivial_path_expression() { 82 fn postfix_completion_works_for_trivial_path_expression() {
83 assert_debug_snapshot_matches!( 83 assert_debug_snapshot!(
84 do_postfix_completion( 84 do_postfix_completion(
85 r#" 85 r#"
86 fn main() { 86 fn main() {
@@ -152,7 +152,7 @@ mod tests {
152 152
153 #[test] 153 #[test]
154 fn some_postfix_completions_ignored() { 154 fn some_postfix_completions_ignored() {
155 assert_debug_snapshot_matches!( 155 assert_debug_snapshot!(
156 do_postfix_completion( 156 do_postfix_completion(
157 r#" 157 r#"
158 fn main() { 158 fn main() {
diff --git a/crates/ra_ide_api/src/completion/complete_record_literal.rs b/crates/ra_ide_api/src/completion/complete_record_literal.rs
index 6b929a8ac..ed4029964 100644
--- a/crates/ra_ide_api/src/completion/complete_record_literal.rs
+++ b/crates/ra_ide_api/src/completion/complete_record_literal.rs
@@ -23,7 +23,7 @@ pub(super) fn complete_record_literal(acc: &mut Completions, ctx: &CompletionCon
23#[cfg(test)] 23#[cfg(test)]
24mod tests { 24mod tests {
25 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 25 use crate::completion::{do_completion, CompletionItem, CompletionKind};
26 use insta::assert_debug_snapshot_matches; 26 use insta::assert_debug_snapshot;
27 27
28 fn complete(code: &str) -> Vec<CompletionItem> { 28 fn complete(code: &str) -> Vec<CompletionItem> {
29 do_completion(code, CompletionKind::Reference) 29 do_completion(code, CompletionKind::Reference)
@@ -39,7 +39,7 @@ mod tests {
39 } 39 }
40 ", 40 ",
41 ); 41 );
42 assert_debug_snapshot_matches!(completions, @r###" 42 assert_debug_snapshot!(completions, @r###"
43 ⋮[ 43 ⋮[
44 ⋮ CompletionItem { 44 ⋮ CompletionItem {
45 ⋮ label: "the_field", 45 ⋮ label: "the_field",
@@ -65,7 +65,7 @@ mod tests {
65 } 65 }
66 ", 66 ",
67 ); 67 );
68 assert_debug_snapshot_matches!(completions, @r###" 68 assert_debug_snapshot!(completions, @r###"
69 ⋮[ 69 ⋮[
70 ⋮ CompletionItem { 70 ⋮ CompletionItem {
71 ⋮ label: "a", 71 ⋮ label: "a",
@@ -91,7 +91,7 @@ mod tests {
91 } 91 }
92 ", 92 ",
93 ); 93 );
94 assert_debug_snapshot_matches!(completions, @r###" 94 assert_debug_snapshot!(completions, @r###"
95 ⋮[ 95 ⋮[
96 ⋮ CompletionItem { 96 ⋮ CompletionItem {
97 ⋮ label: "b", 97 ⋮ label: "b",
@@ -116,7 +116,7 @@ mod tests {
116 } 116 }
117 ", 117 ",
118 ); 118 );
119 assert_debug_snapshot_matches!(completions, @r###" 119 assert_debug_snapshot!(completions, @r###"
120 ⋮[ 120 ⋮[
121 ⋮ CompletionItem { 121 ⋮ CompletionItem {
122 ⋮ label: "a", 122 ⋮ label: "a",
diff --git a/crates/ra_ide_api/src/completion/complete_record_pattern.rs b/crates/ra_ide_api/src/completion/complete_record_pattern.rs
index 8c8b47ea4..70716b3d6 100644
--- a/crates/ra_ide_api/src/completion/complete_record_pattern.rs
+++ b/crates/ra_ide_api/src/completion/complete_record_pattern.rs
@@ -22,7 +22,7 @@ pub(super) fn complete_record_pattern(acc: &mut Completions, ctx: &CompletionCon
22#[cfg(test)] 22#[cfg(test)]
23mod tests { 23mod tests {
24 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 24 use crate::completion::{do_completion, CompletionItem, CompletionKind};
25 use insta::assert_debug_snapshot_matches; 25 use insta::assert_debug_snapshot;
26 26
27 fn complete(code: &str) -> Vec<CompletionItem> { 27 fn complete(code: &str) -> Vec<CompletionItem> {
28 do_completion(code, CompletionKind::Reference) 28 do_completion(code, CompletionKind::Reference)
@@ -41,7 +41,7 @@ mod tests {
41 } 41 }
42 ", 42 ",
43 ); 43 );
44 assert_debug_snapshot_matches!(completions, @r###" 44 assert_debug_snapshot!(completions, @r###"
45 ⋮[ 45 ⋮[
46 ⋮ CompletionItem { 46 ⋮ CompletionItem {
47 ⋮ label: "foo", 47 ⋮ label: "foo",
@@ -70,7 +70,7 @@ mod tests {
70 } 70 }
71 ", 71 ",
72 ); 72 );
73 assert_debug_snapshot_matches!(completions, @r###" 73 assert_debug_snapshot!(completions, @r###"
74 ⋮[ 74 ⋮[
75 ⋮ CompletionItem { 75 ⋮ CompletionItem {
76 ⋮ label: "bar", 76 ⋮ label: "bar",
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index 2000d953a..d6a44c3e0 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -122,7 +122,7 @@ impl ImportResolver {
122#[cfg(test)] 122#[cfg(test)]
123mod tests { 123mod tests {
124 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 124 use crate::completion::{do_completion, CompletionItem, CompletionKind};
125 use insta::assert_debug_snapshot_matches; 125 use insta::assert_debug_snapshot;
126 126
127 fn do_reference_completion(code: &str) -> Vec<CompletionItem> { 127 fn do_reference_completion(code: &str) -> Vec<CompletionItem> {
128 do_completion(code, CompletionKind::Reference) 128 do_completion(code, CompletionKind::Reference)
@@ -130,7 +130,7 @@ mod tests {
130 130
131 #[test] 131 #[test]
132 fn completes_bindings_from_let() { 132 fn completes_bindings_from_let() {
133 assert_debug_snapshot_matches!( 133 assert_debug_snapshot!(
134 do_reference_completion( 134 do_reference_completion(
135 r" 135 r"
136 fn quux(x: i32) { 136 fn quux(x: i32) {
@@ -171,7 +171,7 @@ mod tests {
171 171
172 #[test] 172 #[test]
173 fn completes_bindings_from_if_let() { 173 fn completes_bindings_from_if_let() {
174 assert_debug_snapshot_matches!( 174 assert_debug_snapshot!(
175 do_reference_completion( 175 do_reference_completion(
176 r" 176 r"
177 fn quux() { 177 fn quux() {
@@ -215,7 +215,7 @@ mod tests {
215 215
216 #[test] 216 #[test]
217 fn completes_bindings_from_for() { 217 fn completes_bindings_from_for() {
218 assert_debug_snapshot_matches!( 218 assert_debug_snapshot!(
219 do_reference_completion( 219 do_reference_completion(
220 r" 220 r"
221 fn quux() { 221 fn quux() {
@@ -247,7 +247,7 @@ mod tests {
247 247
248 #[test] 248 #[test]
249 fn completes_generic_params() { 249 fn completes_generic_params() {
250 assert_debug_snapshot_matches!( 250 assert_debug_snapshot!(
251 do_reference_completion( 251 do_reference_completion(
252 r" 252 r"
253 fn quux<T>() { 253 fn quux<T>() {
@@ -277,7 +277,7 @@ mod tests {
277 277
278 #[test] 278 #[test]
279 fn completes_generic_params_in_struct() { 279 fn completes_generic_params_in_struct() {
280 assert_debug_snapshot_matches!( 280 assert_debug_snapshot!(
281 do_reference_completion( 281 do_reference_completion(
282 r" 282 r"
283 struct X<T> { 283 struct X<T> {
@@ -306,7 +306,7 @@ mod tests {
306 306
307 #[test] 307 #[test]
308 fn completes_module_items() { 308 fn completes_module_items() {
309 assert_debug_snapshot_matches!( 309 assert_debug_snapshot!(
310 do_reference_completion( 310 do_reference_completion(
311 r" 311 r"
312 struct Foo; 312 struct Foo;
@@ -345,7 +345,7 @@ mod tests {
345 345
346 #[test] 346 #[test]
347 fn completes_extern_prelude() { 347 fn completes_extern_prelude() {
348 assert_debug_snapshot_matches!( 348 assert_debug_snapshot!(
349 do_reference_completion( 349 do_reference_completion(
350 r" 350 r"
351 //- /lib.rs 351 //- /lib.rs
@@ -369,7 +369,7 @@ mod tests {
369 369
370 #[test] 370 #[test]
371 fn completes_module_items_in_nested_modules() { 371 fn completes_module_items_in_nested_modules() {
372 assert_debug_snapshot_matches!( 372 assert_debug_snapshot!(
373 do_reference_completion( 373 do_reference_completion(
374 r" 374 r"
375 struct Foo; 375 struct Foo;
@@ -401,7 +401,7 @@ mod tests {
401 401
402 #[test] 402 #[test]
403 fn completes_return_type() { 403 fn completes_return_type() {
404 assert_debug_snapshot_matches!( 404 assert_debug_snapshot!(
405 do_reference_completion( 405 do_reference_completion(
406 r" 406 r"
407 struct Foo; 407 struct Foo;
@@ -430,7 +430,7 @@ mod tests {
430 430
431 #[test] 431 #[test]
432 fn dont_show_both_completions_for_shadowing() { 432 fn dont_show_both_completions_for_shadowing() {
433 assert_debug_snapshot_matches!( 433 assert_debug_snapshot!(
434 do_reference_completion( 434 do_reference_completion(
435 r" 435 r"
436 fn foo() { 436 fn foo() {
@@ -465,7 +465,7 @@ mod tests {
465 465
466 #[test] 466 #[test]
467 fn completes_self_in_methods() { 467 fn completes_self_in_methods() {
468 assert_debug_snapshot_matches!( 468 assert_debug_snapshot!(
469 do_reference_completion(r"impl S { fn foo(&self) { <|> } }"), 469 do_reference_completion(r"impl S { fn foo(&self) { <|> } }"),
470 @r#"[ 470 @r#"[
471 CompletionItem { 471 CompletionItem {
@@ -489,7 +489,7 @@ mod tests {
489 489
490 #[test] 490 #[test]
491 fn completes_prelude() { 491 fn completes_prelude() {
492 assert_debug_snapshot_matches!( 492 assert_debug_snapshot!(
493 do_reference_completion( 493 do_reference_completion(
494 " 494 "
495 //- /main.rs 495 //- /main.rs
diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs
index a35f31511..b06221c2a 100644
--- a/crates/ra_ide_api/src/completion/complete_snippet.rs
+++ b/crates/ra_ide_api/src/completion/complete_snippet.rs
@@ -40,7 +40,7 @@ fn ${1:feature}() {
40#[cfg(test)] 40#[cfg(test)]
41mod tests { 41mod tests {
42 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 42 use crate::completion::{do_completion, CompletionItem, CompletionKind};
43 use insta::assert_debug_snapshot_matches; 43 use insta::assert_debug_snapshot;
44 44
45 fn do_snippet_completion(code: &str) -> Vec<CompletionItem> { 45 fn do_snippet_completion(code: &str) -> Vec<CompletionItem> {
46 do_completion(code, CompletionKind::Snippet) 46 do_completion(code, CompletionKind::Snippet)
@@ -48,7 +48,7 @@ mod tests {
48 48
49 #[test] 49 #[test]
50 fn completes_snippets_in_expressions() { 50 fn completes_snippets_in_expressions() {
51 assert_debug_snapshot_matches!( 51 assert_debug_snapshot!(
52 do_snippet_completion(r"fn foo(x: i32) { <|> }"), 52 do_snippet_completion(r"fn foo(x: i32) { <|> }"),
53 @r#"[ 53 @r#"[
54 CompletionItem { 54 CompletionItem {
@@ -71,11 +71,11 @@ mod tests {
71 71
72 #[test] 72 #[test]
73 fn should_not_complete_snippets_in_path() { 73 fn should_not_complete_snippets_in_path() {
74 assert_debug_snapshot_matches!( 74 assert_debug_snapshot!(
75 do_snippet_completion(r"fn foo(x: i32) { ::foo<|> }"), 75 do_snippet_completion(r"fn foo(x: i32) { ::foo<|> }"),
76 @r#"[]"# 76 @r#"[]"#
77 ); 77 );
78 assert_debug_snapshot_matches!( 78 assert_debug_snapshot!(
79 do_snippet_completion(r"fn foo(x: i32) { ::<|> }"), 79 do_snippet_completion(r"fn foo(x: i32) { ::<|> }"),
80 @r#"[]"# 80 @r#"[]"#
81 ); 81 );
@@ -83,7 +83,7 @@ mod tests {
83 83
84 #[test] 84 #[test]
85 fn completes_snippets_in_items() { 85 fn completes_snippets_in_items() {
86 assert_debug_snapshot_matches!( 86 assert_debug_snapshot!(
87 do_snippet_completion( 87 do_snippet_completion(
88 r" 88 r"
89 #[cfg(test)] 89 #[cfg(test)]
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index 147ceda0c..f19eec9b7 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -186,7 +186,7 @@ impl Completions {
186#[cfg(test)] 186#[cfg(test)]
187mod tests { 187mod tests {
188 use crate::completion::{do_completion, CompletionItem, CompletionKind}; 188 use crate::completion::{do_completion, CompletionItem, CompletionKind};
189 use insta::assert_debug_snapshot_matches; 189 use insta::assert_debug_snapshot;
190 use test_utils::covers; 190 use test_utils::covers;
191 191
192 fn do_reference_completion(code: &str) -> Vec<CompletionItem> { 192 fn do_reference_completion(code: &str) -> Vec<CompletionItem> {
@@ -196,7 +196,7 @@ mod tests {
196 #[test] 196 #[test]
197 fn inserts_parens_for_function_calls() { 197 fn inserts_parens_for_function_calls() {
198 covers!(inserts_parens_for_function_calls); 198 covers!(inserts_parens_for_function_calls);
199 assert_debug_snapshot_matches!( 199 assert_debug_snapshot!(
200 do_reference_completion( 200 do_reference_completion(
201 r" 201 r"
202 fn no_args() {} 202 fn no_args() {}
@@ -222,7 +222,7 @@ mod tests {
222 }, 222 },
223]"### 223]"###
224 ); 224 );
225 assert_debug_snapshot_matches!( 225 assert_debug_snapshot!(
226 do_reference_completion( 226 do_reference_completion(
227 r" 227 r"
228 fn with_args(x: i32, y: String) {} 228 fn with_args(x: i32, y: String) {}
@@ -248,7 +248,7 @@ mod tests {
248 }, 248 },
249]"### 249]"###
250 ); 250 );
251 assert_debug_snapshot_matches!( 251 assert_debug_snapshot!(
252 do_reference_completion( 252 do_reference_completion(
253 r" 253 r"
254 struct S {} 254 struct S {}
@@ -275,7 +275,7 @@ mod tests {
275 275
276 #[test] 276 #[test]
277 fn dont_render_function_parens_in_use_item() { 277 fn dont_render_function_parens_in_use_item() {
278 assert_debug_snapshot_matches!( 278 assert_debug_snapshot!(
279 do_reference_completion( 279 do_reference_completion(
280 " 280 "
281 //- /lib.rs 281 //- /lib.rs
@@ -298,7 +298,7 @@ mod tests {
298 298
299 #[test] 299 #[test]
300 fn dont_render_function_parens_if_already_call() { 300 fn dont_render_function_parens_if_already_call() {
301 assert_debug_snapshot_matches!( 301 assert_debug_snapshot!(
302 do_reference_completion( 302 do_reference_completion(
303 " 303 "
304 //- /lib.rs 304 //- /lib.rs
@@ -327,7 +327,7 @@ mod tests {
327 }, 327 },
328]"# 328]"#
329 ); 329 );
330 assert_debug_snapshot_matches!( 330 assert_debug_snapshot!(
331 do_reference_completion( 331 do_reference_completion(
332 " 332 "
333 //- /lib.rs 333 //- /lib.rs
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs
index 1a4882824..c448aa8c5 100644
--- a/crates/ra_ide_api/src/diagnostics.rs
+++ b/crates/ra_ide_api/src/diagnostics.rs
@@ -183,7 +183,7 @@ fn check_struct_shorthand_initialization(
183 183
184#[cfg(test)] 184#[cfg(test)]
185mod tests { 185mod tests {
186 use insta::assert_debug_snapshot_matches; 186 use insta::assert_debug_snapshot;
187 use join_to_string::join; 187 use join_to_string::join;
188 use ra_syntax::SourceFile; 188 use ra_syntax::SourceFile;
189 use test_utils::assert_eq_text; 189 use test_utils::assert_eq_text;
@@ -519,7 +519,7 @@ mod tests {
519 fn test_unresolved_module_diagnostic() { 519 fn test_unresolved_module_diagnostic() {
520 let (analysis, file_id) = single_file("mod foo;"); 520 let (analysis, file_id) = single_file("mod foo;");
521 let diagnostics = analysis.diagnostics(file_id).unwrap(); 521 let diagnostics = analysis.diagnostics(file_id).unwrap();
522 assert_debug_snapshot_matches!(diagnostics, @r###" 522 assert_debug_snapshot!(diagnostics, @r###"
523 ⋮[ 523 ⋮[
524 ⋮ Diagnostic { 524 ⋮ Diagnostic {
525 ⋮ message: "unresolved module", 525 ⋮ message: "unresolved module",
diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs
index a2025ed59..be042ed17 100644
--- a/crates/ra_ide_api/src/display/structure.rs
+++ b/crates/ra_ide_api/src/display/structure.rs
@@ -161,7 +161,7 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
161#[cfg(test)] 161#[cfg(test)]
162mod tests { 162mod tests {
163 use super::*; 163 use super::*;
164 use insta::assert_debug_snapshot_matches; 164 use insta::assert_debug_snapshot;
165 165
166 #[test] 166 #[test]
167 fn test_file_structure() { 167 fn test_file_structure() {
@@ -204,7 +204,7 @@ fn very_obsolete() {}
204 .ok() 204 .ok()
205 .unwrap(); 205 .unwrap();
206 let structure = file_structure(&file); 206 let structure = file_structure(&file);
207 assert_debug_snapshot_matches!(structure, 207 assert_debug_snapshot!(structure,
208 @r#"[ 208 @r#"[
209 StructureNode { 209 StructureNode {
210 parent: None, 210 parent: None,
diff --git a/crates/ra_ide_api/src/inlay_hints.rs b/crates/ra_ide_api/src/inlay_hints.rs
index 61ccb74b6..16bdcf9d1 100644
--- a/crates/ra_ide_api/src/inlay_hints.rs
+++ b/crates/ra_ide_api/src/inlay_hints.rs
@@ -169,7 +169,7 @@ fn get_node_displayable_type(
169#[cfg(test)] 169#[cfg(test)]
170mod tests { 170mod tests {
171 use crate::mock_analysis::single_file; 171 use crate::mock_analysis::single_file;
172 use insta::assert_debug_snapshot_matches; 172 use insta::assert_debug_snapshot;
173 173
174 #[test] 174 #[test]
175 fn let_statement() { 175 fn let_statement() {
@@ -210,7 +210,7 @@ fn main() {
210}"#, 210}"#,
211 ); 211 );
212 212
213 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 213 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[
214 InlayHint { 214 InlayHint {
215 range: [193; 197), 215 range: [193; 197),
216 kind: TypeHint, 216 kind: TypeHint,
@@ -277,7 +277,7 @@ fn main() {
277}"#, 277}"#,
278 ); 278 );
279 279
280 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 280 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[
281 InlayHint { 281 InlayHint {
282 range: [21; 30), 282 range: [21; 30),
283 kind: TypeHint, 283 kind: TypeHint,
@@ -304,7 +304,7 @@ fn main() {
304}"#, 304}"#,
305 ); 305 );
306 306
307 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 307 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[
308 InlayHint { 308 InlayHint {
309 range: [21; 30), 309 range: [21; 30),
310 kind: TypeHint, 310 kind: TypeHint,
@@ -350,7 +350,7 @@ fn main() {
350}"#, 350}"#,
351 ); 351 );
352 352
353 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 353 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[
354 InlayHint { 354 InlayHint {
355 range: [166; 170), 355 range: [166; 170),
356 kind: TypeHint, 356 kind: TypeHint,
@@ -411,7 +411,7 @@ fn main() {
411}"#, 411}"#,
412 ); 412 );
413 413
414 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r###" 414 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r###"
415 ⋮[ 415 ⋮[
416 ⋮ InlayHint { 416 ⋮ InlayHint {
417 ⋮ range: [166; 170), 417 ⋮ range: [166; 170),
@@ -474,7 +474,7 @@ fn main() {
474}"#, 474}"#,
475 ); 475 );
476 476
477 assert_debug_snapshot_matches!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 477 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[
478 InlayHint { 478 InlayHint {
479 range: [311; 315), 479 range: [311; 315),
480 kind: TypeHint, 480 kind: TypeHint,
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs
index 342e73fd3..d8a00067f 100644
--- a/crates/ra_ide_api/src/references.rs
+++ b/crates/ra_ide_api/src/references.rs
@@ -200,7 +200,7 @@ mod tests {
200 mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId, 200 mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId,
201 ReferenceSearchResult, 201 ReferenceSearchResult,
202 }; 202 };
203 use insta::assert_debug_snapshot_matches; 203 use insta::assert_debug_snapshot;
204 use test_utils::assert_eq_text; 204 use test_utils::assert_eq_text;
205 205
206 #[test] 206 #[test]
@@ -341,7 +341,7 @@ mod tests {
341 ); 341 );
342 let new_name = "foo2"; 342 let new_name = "foo2";
343 let source_change = analysis.rename(position, new_name).unwrap(); 343 let source_change = analysis.rename(position, new_name).unwrap();
344 assert_debug_snapshot_matches!(&source_change, 344 assert_debug_snapshot!(&source_change,
345@r#"Some( 345@r#"Some(
346 SourceChange { 346 SourceChange {
347 label: "rename", 347 label: "rename",
@@ -388,7 +388,7 @@ mod tests {
388 ); 388 );
389 let new_name = "foo2"; 389 let new_name = "foo2";
390 let source_change = analysis.rename(position, new_name).unwrap(); 390 let source_change = analysis.rename(position, new_name).unwrap();
391 assert_debug_snapshot_matches!(&source_change, 391 assert_debug_snapshot!(&source_change,
392 @r###"Some( 392 @r###"Some(
393 SourceChange { 393 SourceChange {
394 label: "rename", 394 label: "rename",
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs
index 9ea96909e..9d84b3d08 100644
--- a/crates/ra_ide_api/src/runnables.rs
+++ b/crates/ra_ide_api/src/runnables.rs
@@ -71,7 +71,7 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: ast::Module) -> Opti
71 71
72#[cfg(test)] 72#[cfg(test)]
73mod tests { 73mod tests {
74 use insta::assert_debug_snapshot_matches; 74 use insta::assert_debug_snapshot;
75 75
76 use crate::mock_analysis::analysis_and_position; 76 use crate::mock_analysis::analysis_and_position;
77 77
@@ -92,7 +92,7 @@ mod tests {
92 "#, 92 "#,
93 ); 93 );
94 let runnables = analysis.runnables(pos.file_id).unwrap(); 94 let runnables = analysis.runnables(pos.file_id).unwrap();
95 assert_debug_snapshot_matches!(&runnables, 95 assert_debug_snapshot!(&runnables,
96 @r#"[ 96 @r#"[
97 Runnable { 97 Runnable {
98 range: [1; 21), 98 range: [1; 21),
@@ -127,7 +127,7 @@ mod tests {
127 "#, 127 "#,
128 ); 128 );
129 let runnables = analysis.runnables(pos.file_id).unwrap(); 129 let runnables = analysis.runnables(pos.file_id).unwrap();
130 assert_debug_snapshot_matches!(&runnables, 130 assert_debug_snapshot!(&runnables,
131 @r#"[ 131 @r#"[
132 Runnable { 132 Runnable {
133 range: [1; 59), 133 range: [1; 59),
@@ -160,7 +160,7 @@ mod tests {
160 "#, 160 "#,
161 ); 161 );
162 let runnables = analysis.runnables(pos.file_id).unwrap(); 162 let runnables = analysis.runnables(pos.file_id).unwrap();
163 assert_debug_snapshot_matches!(&runnables, 163 assert_debug_snapshot!(&runnables,
164 @r#"[ 164 @r#"[
165 Runnable { 165 Runnable {
166 range: [23; 85), 166 range: [23; 85),
@@ -195,7 +195,7 @@ mod tests {
195 "#, 195 "#,
196 ); 196 );
197 let runnables = analysis.runnables(pos.file_id).unwrap(); 197 let runnables = analysis.runnables(pos.file_id).unwrap();
198 assert_debug_snapshot_matches!(&runnables, 198 assert_debug_snapshot!(&runnables,
199 @r#"[ 199 @r#"[
200 Runnable { 200 Runnable {
201 range: [41; 115), 201 range: [41; 115),