diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests/simple.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests/simple.rs | 1818 |
1 files changed, 1004 insertions, 814 deletions
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index 88309157b..6d3e264af 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs | |||
@@ -1,19 +1,17 @@ | |||
1 | use super::{infer, type_at, type_at_pos}; | ||
2 | use crate::test_db::TestDB; | ||
3 | use insta::assert_snapshot; | 1 | use insta::assert_snapshot; |
4 | use ra_db::fixture::WithFixture; | 2 | |
3 | use super::{check_types, infer}; | ||
5 | 4 | ||
6 | #[test] | 5 | #[test] |
7 | fn infer_box() { | 6 | fn infer_box() { |
8 | let (db, pos) = TestDB::with_position( | 7 | check_types( |
9 | r#" | 8 | r#" |
10 | //- /main.rs crate:main deps:std | 9 | //- /main.rs crate:main deps:std |
11 | |||
12 | fn test() { | 10 | fn test() { |
13 | let x = box 1; | 11 | let x = box 1; |
14 | let t = (x, box x, box &1, box [1]); | 12 | let t = (x, box x, box &1, box [1]); |
15 | t<|>; | 13 | t; |
16 | } | 14 | } //^ (Box<i32>, Box<Box<i32>>, Box<&i32>, Box<[i32; _]>) |
17 | 15 | ||
18 | //- /std.rs crate:std | 16 | //- /std.rs crate:std |
19 | #[prelude_import] use prelude::*; | 17 | #[prelude_import] use prelude::*; |
@@ -25,29 +23,24 @@ mod boxed { | |||
25 | inner: *mut T, | 23 | inner: *mut T, |
26 | } | 24 | } |
27 | } | 25 | } |
28 | |||
29 | "#, | 26 | "#, |
30 | ); | 27 | ); |
31 | assert_eq!("(Box<i32>, Box<Box<i32>>, Box<&i32>, Box<[i32; _]>)", type_at_pos(&db, pos)); | ||
32 | } | 28 | } |
33 | 29 | ||
34 | #[test] | 30 | #[test] |
35 | fn infer_adt_self() { | 31 | fn infer_adt_self() { |
36 | let (db, pos) = TestDB::with_position( | 32 | check_types( |
37 | r#" | 33 | r#" |
38 | //- /main.rs | ||
39 | enum Nat { Succ(Self), Demo(Nat), Zero } | 34 | enum Nat { Succ(Self), Demo(Nat), Zero } |
40 | 35 | ||
41 | fn test() { | 36 | fn test() { |
42 | let foo: Nat = Nat::Zero; | 37 | let foo: Nat = Nat::Zero; |
43 | if let Nat::Succ(x) = foo { | 38 | if let Nat::Succ(x) = foo { |
44 | x<|> | 39 | x |
45 | } | 40 | } //^ Nat |
46 | } | 41 | } |
47 | |||
48 | "#, | 42 | "#, |
49 | ); | 43 | ); |
50 | assert_eq!("Nat", type_at_pos(&db, pos)); | ||
51 | } | 44 | } |
52 | 45 | ||
53 | #[test] | 46 | #[test] |
@@ -64,9 +57,9 @@ impl S<u32> { | |||
64 | } | 57 | } |
65 | "#, | 58 | "#, |
66 | ), @r###" | 59 | ), @r###" |
67 | 63..93 '{ ... }': () | 60 | 49..79 '{ ... }': () |
68 | 73..86 'Self { x: 1 }': S<u32> | 61 | 59..72 'Self { x: 1 }': S<u32> |
69 | 83..84 '1': u32 | 62 | 69..70 '1': u32 |
70 | "###); | 63 | "###); |
71 | } | 64 | } |
72 | 65 | ||
@@ -85,17 +78,17 @@ fn foo() { | |||
85 | 78 | ||
86 | "#, | 79 | "#, |
87 | ), @r###" | 80 | ), @r###" |
88 | 64..84 '{ ...1 }; }': () | 81 | 50..70 '{ ...1 }; }': () |
89 | 70..81 'SS { x: 1 }': S<u32> | 82 | 56..67 'SS { x: 1 }': S<u32> |
90 | 78..79 '1': u32 | 83 | 64..65 '1': u32 |
91 | "###); | 84 | "###); |
92 | } | 85 | } |
93 | 86 | ||
94 | #[test] | 87 | #[test] |
95 | fn infer_ranges() { | 88 | fn infer_ranges() { |
96 | let (db, pos) = TestDB::with_position( | 89 | check_types( |
97 | r#" | 90 | r#" |
98 | //- /main.rs crate:main deps:std | 91 | //- /main.rs crate:main deps:core |
99 | fn test() { | 92 | fn test() { |
100 | let a = ..; | 93 | let a = ..; |
101 | let b = 1..; | 94 | let b = 1..; |
@@ -105,10 +98,10 @@ fn test() { | |||
105 | let f = 'a'..='z'; | 98 | let f = 'a'..='z'; |
106 | 99 | ||
107 | let t = (a, b, c, d, e, f); | 100 | let t = (a, b, c, d, e, f); |
108 | t<|>; | 101 | t; |
109 | } | 102 | } //^ (RangeFull, RangeFrom<i32>, RangeTo<u32>, Range<usize>, RangeToInclusive<i32>, RangeInclusive<char>) |
110 | 103 | ||
111 | //- /std.rs crate:std | 104 | //- /core.rs crate:core |
112 | #[prelude_import] use prelude::*; | 105 | #[prelude_import] use prelude::*; |
113 | mod prelude {} | 106 | mod prelude {} |
114 | 107 | ||
@@ -135,29 +128,22 @@ pub mod ops { | |||
135 | } | 128 | } |
136 | "#, | 129 | "#, |
137 | ); | 130 | ); |
138 | assert_eq!( | ||
139 | "(RangeFull, RangeFrom<i32>, RangeTo<u32>, Range<usize>, RangeToInclusive<i32>, RangeInclusive<char>)", | ||
140 | type_at_pos(&db, pos), | ||
141 | ); | ||
142 | } | 131 | } |
143 | 132 | ||
144 | #[test] | 133 | #[test] |
145 | fn infer_while_let() { | 134 | fn infer_while_let() { |
146 | let (db, pos) = TestDB::with_position( | 135 | check_types( |
147 | r#" | 136 | r#" |
148 | //- /main.rs | ||
149 | enum Option<T> { Some(T), None } | 137 | enum Option<T> { Some(T), None } |
150 | 138 | ||
151 | fn test() { | 139 | fn test() { |
152 | let foo: Option<f32> = None; | 140 | let foo: Option<f32> = None; |
153 | while let Option::Some(x) = foo { | 141 | while let Option::Some(x) = foo { |
154 | <|>x | 142 | x |
155 | } | 143 | } //^ f32 |
156 | } | 144 | } |
157 | |||
158 | "#, | 145 | "#, |
159 | ); | 146 | ); |
160 | assert_eq!("f32", type_at_pos(&db, pos)); | ||
161 | } | 147 | } |
162 | 148 | ||
163 | #[test] | 149 | #[test] |
@@ -175,19 +161,19 @@ fn test(a: u32, b: isize, c: !, d: &str) { | |||
175 | 1.0f32; | 161 | 1.0f32; |
176 | }"#), | 162 | }"#), |
177 | @r###" | 163 | @r###" |
178 | 9..10 'a': u32 | 164 | 8..9 'a': u32 |
179 | 17..18 'b': isize | 165 | 16..17 'b': isize |
180 | 27..28 'c': ! | 166 | 26..27 'c': ! |
181 | 33..34 'd': &str | 167 | 32..33 'd': &str |
182 | 42..121 '{ ...f32; }': () | 168 | 41..120 '{ ...f32; }': () |
183 | 48..49 'a': u32 | 169 | 47..48 'a': u32 |
184 | 55..56 'b': isize | 170 | 54..55 'b': isize |
185 | 62..63 'c': ! | 171 | 61..62 'c': ! |
186 | 69..70 'd': &str | 172 | 68..69 'd': &str |
187 | 76..82 '1usize': usize | 173 | 75..81 '1usize': usize |
188 | 88..94 '1isize': isize | 174 | 87..93 '1isize': isize |
189 | 100..106 '"test"': &str | 175 | 99..105 '"test"': &str |
190 | 112..118 '1.0f32': f32 | 176 | 111..117 '1.0f32': f32 |
191 | "### | 177 | "### |
192 | ); | 178 | ); |
193 | } | 179 | } |
@@ -206,17 +192,17 @@ fn test() { | |||
206 | } | 192 | } |
207 | "#), | 193 | "#), |
208 | @r###" | 194 | @r###" |
209 | 11..118 '{ ...= e; }': () | 195 | 10..117 '{ ...= e; }': () |
210 | 21..22 'a': isize | 196 | 20..21 'a': isize |
211 | 25..31 '1isize': isize | 197 | 24..30 '1isize': isize |
212 | 41..42 'b': usize | 198 | 40..41 'b': usize |
213 | 52..53 '1': usize | 199 | 51..52 '1': usize |
214 | 63..64 'c': usize | 200 | 62..63 'c': usize |
215 | 67..68 'b': usize | 201 | 66..67 'b': usize |
216 | 78..79 'd': u32 | 202 | 77..78 'd': u32 |
217 | 94..95 'e': i32 | 203 | 93..94 'e': i32 |
218 | 105..106 'f': i32 | 204 | 104..105 'f': i32 |
219 | 114..115 'e': i32 | 205 | 113..114 'e': i32 |
220 | "### | 206 | "### |
221 | ); | 207 | ); |
222 | } | 208 | } |
@@ -237,15 +223,15 @@ fn test() { | |||
237 | } | 223 | } |
238 | "#), | 224 | "#), |
239 | @r###" | 225 | @r###" |
240 | 15..20 '{ 1 }': u32 | 226 | 14..19 '{ 1 }': u32 |
241 | 17..18 '1': u32 | 227 | 16..17 '1': u32 |
242 | 48..53 '{ 1 }': u32 | 228 | 47..52 '{ 1 }': u32 |
243 | 50..51 '1': u32 | 229 | 49..50 '1': u32 |
244 | 67..91 '{ ...c(); }': () | 230 | 66..90 '{ ...c(); }': () |
245 | 73..74 'a': fn a() -> u32 | 231 | 72..73 'a': fn a() -> u32 |
246 | 73..76 'a()': u32 | 232 | 72..75 'a()': u32 |
247 | 82..86 'b::c': fn c() -> u32 | 233 | 81..85 'b::c': fn c() -> u32 |
248 | 82..88 'b::c()': u32 | 234 | 81..87 'b::c()': u32 |
249 | "### | 235 | "### |
250 | ); | 236 | ); |
251 | } | 237 | } |
@@ -266,13 +252,13 @@ fn test() { | |||
266 | } | 252 | } |
267 | "#), | 253 | "#), |
268 | @r###" | 254 | @r###" |
269 | 41..46 '{ 1 }': i32 | 255 | 40..45 '{ 1 }': i32 |
270 | 43..44 '1': i32 | 256 | 42..43 '1': i32 |
271 | 60..93 '{ ...o(); }': () | 257 | 59..92 '{ ...o(); }': () |
272 | 66..72 'S::foo': fn foo() -> i32 | 258 | 65..71 'S::foo': fn foo() -> i32 |
273 | 66..74 'S::foo()': i32 | 259 | 65..73 'S::foo()': i32 |
274 | 80..88 '<S>::foo': fn foo() -> i32 | 260 | 79..87 '<S>::foo': fn foo() -> i32 |
275 | 80..90 '<S>::foo()': i32 | 261 | 79..89 '<S>::foo()': i32 |
276 | "### | 262 | "### |
277 | ); | 263 | ); |
278 | } | 264 | } |
@@ -297,22 +283,22 @@ fn test() { | |||
297 | } | 283 | } |
298 | "#), | 284 | "#), |
299 | @r###" | 285 | @r###" |
300 | 72..154 '{ ...a.c; }': () | 286 | 71..153 '{ ...a.c; }': () |
301 | 82..83 'c': C | 287 | 81..82 'c': C |
302 | 86..87 'C': C(usize) -> C | 288 | 85..86 'C': C(usize) -> C |
303 | 86..90 'C(1)': C | 289 | 85..89 'C(1)': C |
304 | 88..89 '1': usize | 290 | 87..88 '1': usize |
305 | 96..97 'B': B | 291 | 95..96 'B': B |
306 | 107..108 'a': A | 292 | 106..107 'a': A |
307 | 114..133 'A { b:...C(1) }': A | 293 | 113..132 'A { b:...C(1) }': A |
308 | 121..122 'B': B | 294 | 120..121 'B': B |
309 | 127..128 'C': C(usize) -> C | 295 | 126..127 'C': C(usize) -> C |
310 | 127..131 'C(1)': C | 296 | 126..130 'C(1)': C |
311 | 129..130 '1': usize | 297 | 128..129 '1': usize |
312 | 139..140 'a': A | 298 | 138..139 'a': A |
313 | 139..142 'a.b': B | 299 | 138..141 'a.b': B |
314 | 148..149 'a': A | 300 | 147..148 'a': A |
315 | 148..151 'a.c': C | 301 | 147..150 'a.c': C |
316 | "### | 302 | "### |
317 | ); | 303 | ); |
318 | } | 304 | } |
@@ -330,10 +316,33 @@ fn test() { | |||
330 | E::V2; | 316 | E::V2; |
331 | }"#), | 317 | }"#), |
332 | @r###" | 318 | @r###" |
333 | 48..82 '{ E:...:V2; }': () | 319 | 47..81 '{ E:...:V2; }': () |
334 | 52..70 'E::V1 ...d: 1 }': E | 320 | 51..69 'E::V1 ...d: 1 }': E |
335 | 67..68 '1': u32 | 321 | 66..67 '1': u32 |
336 | 74..79 'E::V2': E | 322 | 73..78 'E::V2': E |
323 | "### | ||
324 | ); | ||
325 | } | ||
326 | |||
327 | #[test] | ||
328 | fn infer_union() { | ||
329 | assert_snapshot!( | ||
330 | infer(r#" | ||
331 | union MyUnion { | ||
332 | foo: u32, | ||
333 | bar: f32, | ||
334 | } | ||
335 | |||
336 | unsafe fn baz(u: MyUnion) { | ||
337 | let inner = u.foo; | ||
338 | } | ||
339 | "#), | ||
340 | @r###" | ||
341 | 61..62 'u': MyUnion | ||
342 | 73..99 '{ ...foo; }': () | ||
343 | 83..88 'inner': u32 | ||
344 | 91..92 'u': MyUnion | ||
345 | 91..96 'u.foo': u32 | ||
337 | "### | 346 | "### |
338 | ); | 347 | ); |
339 | } | 348 | } |
@@ -357,29 +366,29 @@ fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { | |||
357 | } | 366 | } |
358 | "#), | 367 | "#), |
359 | @r###" | 368 | @r###" |
360 | 9..10 'a': &u32 | 369 | 8..9 'a': &u32 |
361 | 18..19 'b': &mut u32 | 370 | 17..18 'b': &mut u32 |
362 | 31..32 'c': *const u32 | 371 | 30..31 'c': *const u32 |
363 | 46..47 'd': *mut u32 | 372 | 45..46 'd': *mut u32 |
364 | 59..150 '{ ... *d; }': () | 373 | 58..149 '{ ... *d; }': () |
365 | 65..66 'a': &u32 | 374 | 64..65 'a': &u32 |
366 | 72..74 '*a': u32 | 375 | 71..73 '*a': u32 |
367 | 73..74 'a': &u32 | 376 | 72..73 'a': &u32 |
368 | 80..82 '&a': &&u32 | 377 | 79..81 '&a': &&u32 |
369 | 81..82 'a': &u32 | 378 | 80..81 'a': &u32 |
370 | 88..94 '&mut a': &mut &u32 | 379 | 87..93 '&mut a': &mut &u32 |
371 | 93..94 'a': &u32 | 380 | 92..93 'a': &u32 |
372 | 100..101 'b': &mut u32 | 381 | 99..100 'b': &mut u32 |
373 | 107..109 '*b': u32 | 382 | 106..108 '*b': u32 |
374 | 108..109 'b': &mut u32 | 383 | 107..108 'b': &mut u32 |
375 | 115..117 '&b': &&mut u32 | 384 | 114..116 '&b': &&mut u32 |
376 | 116..117 'b': &mut u32 | 385 | 115..116 'b': &mut u32 |
377 | 123..124 'c': *const u32 | 386 | 122..123 'c': *const u32 |
378 | 130..132 '*c': u32 | 387 | 129..131 '*c': u32 |
379 | 131..132 'c': *const u32 | 388 | 130..131 'c': *const u32 |
380 | 138..139 'd': *mut u32 | 389 | 137..138 'd': *mut u32 |
381 | 145..147 '*d': u32 | 390 | 144..146 '*d': u32 |
382 | 146..147 'd': *mut u32 | 391 | 145..146 'd': *mut u32 |
383 | "### | 392 | "### |
384 | ); | 393 | ); |
385 | } | 394 | } |
@@ -394,12 +403,12 @@ fn test(a: i32) { | |||
394 | } | 403 | } |
395 | "#), | 404 | "#), |
396 | @r###" | 405 | @r###" |
397 | 9..10 'a': i32 | 406 | 8..9 'a': i32 |
398 | 17..54 '{ ...t a; }': () | 407 | 16..53 '{ ...t a; }': () |
399 | 23..33 '&raw mut a': *mut i32 | 408 | 22..32 '&raw mut a': *mut i32 |
400 | 32..33 'a': i32 | 409 | 31..32 'a': i32 |
401 | 39..51 '&raw const a': *const i32 | 410 | 38..50 '&raw const a': *const i32 |
402 | 50..51 'a': i32 | 411 | 49..50 'a': i32 |
403 | "### | 412 | "### |
404 | ); | 413 | ); |
405 | } | 414 | } |
@@ -429,20 +438,20 @@ fn test() { | |||
429 | } | 438 | } |
430 | "##), | 439 | "##), |
431 | @r###" | 440 | @r###" |
432 | 11..221 '{ ...o"#; }': () | 441 | 10..220 '{ ...o"#; }': () |
433 | 17..21 '5i32': i32 | 442 | 16..20 '5i32': i32 |
434 | 27..31 '5f32': f32 | 443 | 26..30 '5f32': f32 |
435 | 37..41 '5f64': f64 | 444 | 36..40 '5f64': f64 |
436 | 47..54 '"hello"': &str | 445 | 46..53 '"hello"': &str |
437 | 60..68 'b"bytes"': &[u8; _] | 446 | 59..67 'b"bytes"': &[u8; _] |
438 | 74..77 ''c'': char | 447 | 73..76 ''c'': char |
439 | 83..87 'b'b'': u8 | 448 | 82..86 'b'b'': u8 |
440 | 93..97 '3.14': f64 | 449 | 92..96 '3.14': f64 |
441 | 103..107 '5000': i32 | 450 | 102..106 '5000': i32 |
442 | 113..118 'false': bool | 451 | 112..117 'false': bool |
443 | 124..128 'true': bool | 452 | 123..127 'true': bool |
444 | 134..202 'r#" ... "#': &str | 453 | 133..201 'r#" ... "#': &str |
445 | 208..218 'br#"yolo"#': &[u8; _] | 454 | 207..217 'br#"yolo"#': &[u8; _] |
446 | "### | 455 | "### |
447 | ); | 456 | ); |
448 | } | 457 | } |
@@ -472,47 +481,47 @@ fn test(x: SomeType) { | |||
472 | } | 481 | } |
473 | "#), | 482 | "#), |
474 | @r###" | 483 | @r###" |
475 | 27..28 'x': SomeType | 484 | 26..27 'x': SomeType |
476 | 40..272 '{ ...lo"; }': () | 485 | 39..271 '{ ...lo"; }': () |
477 | 50..51 'b': bool | 486 | 49..50 'b': bool |
478 | 54..59 'false': bool | 487 | 53..58 'false': bool |
479 | 69..70 'c': bool | 488 | 68..69 'c': bool |
480 | 73..75 '!b': bool | 489 | 72..74 '!b': bool |
481 | 74..75 'b': bool | 490 | 73..74 'b': bool |
482 | 85..86 'a': i128 | 491 | 84..85 'a': i128 |
483 | 89..92 '100': i128 | 492 | 88..91 '100': i128 |
484 | 102..103 'd': i128 | 493 | 101..102 'd': i128 |
485 | 112..114 '-a': i128 | 494 | 111..113 '-a': i128 |
486 | 113..114 'a': i128 | 495 | 112..113 'a': i128 |
487 | 124..125 'e': i32 | 496 | 123..124 'e': i32 |
488 | 128..132 '-100': i32 | 497 | 127..131 '-100': i32 |
489 | 129..132 '100': i32 | 498 | 128..131 '100': i32 |
490 | 142..143 'f': bool | 499 | 141..142 'f': bool |
491 | 146..153 '!!!true': bool | 500 | 145..152 '!!!true': bool |
492 | 147..153 '!!true': bool | 501 | 146..152 '!!true': bool |
493 | 148..153 '!true': bool | 502 | 147..152 '!true': bool |
494 | 149..153 'true': bool | 503 | 148..152 'true': bool |
495 | 163..164 'g': i32 | 504 | 162..163 'g': i32 |
496 | 167..170 '!42': i32 | 505 | 166..169 '!42': i32 |
497 | 168..170 '42': i32 | 506 | 167..169 '42': i32 |
498 | 180..181 'h': u32 | 507 | 179..180 'h': u32 |
499 | 184..190 '!10u32': u32 | 508 | 183..189 '!10u32': u32 |
500 | 185..190 '10u32': u32 | 509 | 184..189 '10u32': u32 |
501 | 200..201 'j': i128 | 510 | 199..200 'j': i128 |
502 | 204..206 '!a': i128 | 511 | 203..205 '!a': i128 |
503 | 205..206 'a': i128 | 512 | 204..205 'a': i128 |
504 | 212..217 '-3.14': f64 | 513 | 211..216 '-3.14': f64 |
505 | 213..217 '3.14': f64 | 514 | 212..216 '3.14': f64 |
506 | 223..225 '!3': i32 | 515 | 222..224 '!3': i32 |
507 | 224..225 '3': i32 | 516 | 223..224 '3': i32 |
508 | 231..233 '-x': {unknown} | 517 | 230..232 '-x': {unknown} |
509 | 232..233 'x': SomeType | 518 | 231..232 'x': SomeType |
510 | 239..241 '!x': {unknown} | 519 | 238..240 '!x': {unknown} |
511 | 240..241 'x': SomeType | 520 | 239..240 'x': SomeType |
512 | 247..255 '-"hello"': {unknown} | 521 | 246..254 '-"hello"': {unknown} |
513 | 248..255 '"hello"': &str | 522 | 247..254 '"hello"': &str |
514 | 261..269 '!"hello"': {unknown} | 523 | 260..268 '!"hello"': {unknown} |
515 | 262..269 '"hello"': &str | 524 | 261..268 '"hello"': &str |
516 | "### | 525 | "### |
517 | ); | 526 | ); |
518 | } | 527 | } |
@@ -535,26 +544,26 @@ fn test() -> &mut &f64 { | |||
535 | } | 544 | } |
536 | "#), | 545 | "#), |
537 | @r###" | 546 | @r###" |
538 | 14..15 'x': u32 | 547 | 13..14 'x': u32 |
539 | 22..24 '{}': () | 548 | 21..23 '{}': () |
540 | 78..231 '{ ...t &c }': &mut &f64 | 549 | 77..230 '{ ...t &c }': &mut &f64 |
541 | 88..89 'a': u32 | 550 | 87..88 'a': u32 |
542 | 92..108 'unknow...nction': {unknown} | 551 | 91..107 'unknow...nction': {unknown} |
543 | 92..110 'unknow...tion()': u32 | 552 | 91..109 'unknow...tion()': u32 |
544 | 116..125 'takes_u32': fn takes_u32(u32) | 553 | 115..124 'takes_u32': fn takes_u32(u32) |
545 | 116..128 'takes_u32(a)': () | 554 | 115..127 'takes_u32(a)': () |
546 | 126..127 'a': u32 | 555 | 125..126 'a': u32 |
547 | 138..139 'b': i32 | 556 | 137..138 'b': i32 |
548 | 142..158 'unknow...nction': {unknown} | 557 | 141..157 'unknow...nction': {unknown} |
549 | 142..160 'unknow...tion()': i32 | 558 | 141..159 'unknow...tion()': i32 |
550 | 166..184 'S { i3...d: b }': S | 559 | 165..183 'S { i3...d: b }': S |
551 | 181..182 'b': i32 | 560 | 180..181 'b': i32 |
552 | 194..195 'c': f64 | 561 | 193..194 'c': f64 |
553 | 198..214 'unknow...nction': {unknown} | 562 | 197..213 'unknow...nction': {unknown} |
554 | 198..216 'unknow...tion()': f64 | 563 | 197..215 'unknow...tion()': f64 |
555 | 222..229 '&mut &c': &mut &f64 | 564 | 221..228 '&mut &c': &mut &f64 |
556 | 227..229 '&c': &f64 | 565 | 226..228 '&c': &f64 |
557 | 228..229 'c': f64 | 566 | 227..228 'c': f64 |
558 | "### | 567 | "### |
559 | ); | 568 | ); |
560 | } | 569 | } |
@@ -581,16 +590,16 @@ impl S { | |||
581 | } | 590 | } |
582 | "#), | 591 | "#), |
583 | @r###" | 592 | @r###" |
584 | 34..38 'self': &S | 593 | 33..37 'self': &S |
585 | 40..61 '{ ... }': () | 594 | 39..60 '{ ... }': () |
586 | 50..54 'self': &S | 595 | 49..53 'self': &S |
587 | 75..79 'self': &S | 596 | 74..78 'self': &S |
588 | 88..109 '{ ... }': () | 597 | 87..108 '{ ... }': () |
589 | 98..102 'self': &S | 598 | 97..101 'self': &S |
590 | 133..153 '{ ... }': S | 599 | 132..152 '{ ... }': S |
591 | 143..147 'S {}': S | 600 | 142..146 'S {}': S |
592 | 177..200 '{ ... }': S | 601 | 176..199 '{ ... }': S |
593 | 187..194 'Self {}': S | 602 | 186..193 'Self {}': S |
594 | "### | 603 | "### |
595 | ); | 604 | ); |
596 | } | 605 | } |
@@ -624,17 +633,17 @@ impl E { | |||
624 | } | 633 | } |
625 | "#), | 634 | "#), |
626 | @r###" | 635 | @r###" |
627 | 87..108 '{ ... }': () | 636 | 86..107 '{ ... }': () |
628 | 97..101 'Self': S1 | 637 | 96..100 'Self': S1 |
629 | 135..159 '{ ... }': () | 638 | 134..158 '{ ... }': () |
630 | 145..149 'Self': S2(isize) -> S2 | 639 | 144..148 'Self': S2(isize) -> S2 |
631 | 145..152 'Self(1)': S2 | 640 | 144..151 'Self(1)': S2 |
632 | 150..151 '1': isize | 641 | 149..150 '1': isize |
633 | 185..231 '{ ... }': () | 642 | 184..230 '{ ... }': () |
634 | 195..203 'Self::V1': E | 643 | 194..202 'Self::V1': E |
635 | 213..221 'Self::V2': V2(u32) -> E | 644 | 212..220 'Self::V2': V2(u32) -> E |
636 | 213..224 'Self::V2(1)': E | 645 | 212..223 'Self::V2(1)': E |
637 | 222..223 '1': u32 | 646 | 221..222 '1': u32 |
638 | "### | 647 | "### |
639 | ); | 648 | ); |
640 | } | 649 | } |
@@ -664,56 +673,56 @@ fn test() -> bool { | |||
664 | } | 673 | } |
665 | "#), | 674 | "#), |
666 | @r###" | 675 | @r###" |
667 | 6..7 'x': bool | 676 | 5..6 'x': bool |
668 | 22..34 '{ 0i32 }': i32 | 677 | 21..33 '{ 0i32 }': i32 |
669 | 28..32 '0i32': i32 | 678 | 27..31 '0i32': i32 |
670 | 54..370 '{ ... < 3 }': bool | 679 | 53..369 '{ ... < 3 }': bool |
671 | 64..65 'x': bool | 680 | 63..64 'x': bool |
672 | 68..69 'a': bool | 681 | 67..68 'a': bool |
673 | 68..74 'a && b': bool | 682 | 67..73 'a && b': bool |
674 | 73..74 'b': bool | 683 | 72..73 'b': bool |
675 | 84..85 'y': bool | 684 | 83..84 'y': bool |
676 | 88..92 'true': bool | 685 | 87..91 'true': bool |
677 | 88..101 'true || false': bool | 686 | 87..100 'true || false': bool |
678 | 96..101 'false': bool | 687 | 95..100 'false': bool |
679 | 111..112 'z': bool | 688 | 110..111 'z': bool |
680 | 115..116 'x': bool | 689 | 114..115 'x': bool |
681 | 115..121 'x == y': bool | 690 | 114..120 'x == y': bool |
682 | 120..121 'y': bool | 691 | 119..120 'y': bool |
683 | 131..132 't': bool | 692 | 130..131 't': bool |
684 | 135..136 'x': bool | 693 | 134..135 'x': bool |
685 | 135..141 'x != y': bool | 694 | 134..140 'x != y': bool |
686 | 140..141 'y': bool | 695 | 139..140 'y': bool |
687 | 151..162 'minus_forty': isize | 696 | 150..161 'minus_forty': isize |
688 | 172..180 '-40isize': isize | 697 | 171..179 '-40isize': isize |
689 | 173..180 '40isize': isize | 698 | 172..179 '40isize': isize |
690 | 190..191 'h': bool | 699 | 189..190 'h': bool |
691 | 194..205 'minus_forty': isize | 700 | 193..204 'minus_forty': isize |
692 | 194..216 'minus_...ONST_2': bool | 701 | 193..215 'minus_...ONST_2': bool |
693 | 209..216 'CONST_2': isize | 702 | 208..215 'CONST_2': isize |
694 | 226..227 'c': i32 | 703 | 225..226 'c': i32 |
695 | 230..231 'f': fn f(bool) -> i32 | 704 | 229..230 'f': fn f(bool) -> i32 |
696 | 230..239 'f(z || y)': i32 | 705 | 229..238 'f(z || y)': i32 |
697 | 230..243 'f(z || y) + 5': i32 | 706 | 229..242 'f(z || y) + 5': i32 |
698 | 232..233 'z': bool | 707 | 231..232 'z': bool |
699 | 232..238 'z || y': bool | 708 | 231..237 'z || y': bool |
700 | 237..238 'y': bool | 709 | 236..237 'y': bool |
701 | 242..243 '5': i32 | 710 | 241..242 '5': i32 |
702 | 253..254 'd': {unknown} | 711 | 252..253 'd': {unknown} |
703 | 257..258 'b': {unknown} | 712 | 256..257 'b': {unknown} |
704 | 268..269 'g': () | 713 | 267..268 'g': () |
705 | 272..283 'minus_forty': isize | 714 | 271..282 'minus_forty': isize |
706 | 272..288 'minus_...y ^= i': () | 715 | 271..287 'minus_...y ^= i': () |
707 | 287..288 'i': isize | 716 | 286..287 'i': isize |
708 | 298..301 'ten': usize | 717 | 297..300 'ten': usize |
709 | 311..313 '10': usize | 718 | 310..312 '10': usize |
710 | 323..336 'ten_is_eleven': bool | 719 | 322..335 'ten_is_eleven': bool |
711 | 339..342 'ten': usize | 720 | 338..341 'ten': usize |
712 | 339..354 'ten == some_num': bool | 721 | 338..353 'ten == some_num': bool |
713 | 346..354 'some_num': usize | 722 | 345..353 'some_num': usize |
714 | 361..364 'ten': usize | 723 | 360..363 'ten': usize |
715 | 361..368 'ten < 3': bool | 724 | 360..367 'ten < 3': bool |
716 | 367..368 '3': usize | 725 | 366..367 '3': usize |
717 | "### | 726 | "### |
718 | ); | 727 | ); |
719 | } | 728 | } |
@@ -728,13 +737,13 @@ fn test() { | |||
728 | } | 737 | } |
729 | "#), | 738 | "#), |
730 | @r###" | 739 | @r###" |
731 | 11..48 '{ ...5u8; }': () | 740 | 10..47 '{ ...5u8; }': () |
732 | 17..21 '1u32': u32 | 741 | 16..20 '1u32': u32 |
733 | 17..28 '1u32 << 5u8': u32 | 742 | 16..27 '1u32 << 5u8': u32 |
734 | 25..28 '5u8': u8 | 743 | 24..27 '5u8': u8 |
735 | 34..38 '1u32': u32 | 744 | 33..37 '1u32': u32 |
736 | 34..45 '1u32 >> 5u8': u32 | 745 | 33..44 '1u32 >> 5u8': u32 |
737 | 42..45 '5u8': u8 | 746 | 41..44 '5u8': u8 |
738 | "### | 747 | "### |
739 | ); | 748 | ); |
740 | } | 749 | } |
@@ -767,49 +776,49 @@ fn test2(a1: *const A, a2: *mut A) { | |||
767 | } | 776 | } |
768 | "#), | 777 | "#), |
769 | @r###" | 778 | @r###" |
770 | 44..45 'a': A | 779 | 43..44 'a': A |
771 | 50..213 '{ ...5.b; }': () | 780 | 49..212 '{ ...5.b; }': () |
772 | 60..62 'a1': A | 781 | 59..61 'a1': A |
773 | 65..66 'a': A | 782 | 64..65 'a': A |
774 | 72..74 'a1': A | 783 | 71..73 'a1': A |
775 | 72..76 'a1.b': B | 784 | 71..75 'a1.b': B |
776 | 86..88 'a2': &A | 785 | 85..87 'a2': &A |
777 | 91..93 '&a': &A | 786 | 90..92 '&a': &A |
778 | 92..93 'a': A | 787 | 91..92 'a': A |
779 | 99..101 'a2': &A | 788 | 98..100 'a2': &A |
780 | 99..103 'a2.b': B | 789 | 98..102 'a2.b': B |
781 | 113..115 'a3': &mut A | 790 | 112..114 'a3': &mut A |
782 | 118..124 '&mut a': &mut A | 791 | 117..123 '&mut a': &mut A |
783 | 123..124 'a': A | 792 | 122..123 'a': A |
784 | 130..132 'a3': &mut A | 793 | 129..131 'a3': &mut A |
785 | 130..134 'a3.b': B | 794 | 129..133 'a3.b': B |
786 | 144..146 'a4': &&&&&&&A | 795 | 143..145 'a4': &&&&&&&A |
787 | 149..157 '&&&&&&&a': &&&&&&&A | 796 | 148..156 '&&&&&&&a': &&&&&&&A |
788 | 150..157 '&&&&&&a': &&&&&&A | 797 | 149..156 '&&&&&&a': &&&&&&A |
789 | 151..157 '&&&&&a': &&&&&A | 798 | 150..156 '&&&&&a': &&&&&A |
790 | 152..157 '&&&&a': &&&&A | 799 | 151..156 '&&&&a': &&&&A |
791 | 153..157 '&&&a': &&&A | 800 | 152..156 '&&&a': &&&A |
792 | 154..157 '&&a': &&A | 801 | 153..156 '&&a': &&A |
793 | 155..157 '&a': &A | 802 | 154..156 '&a': &A |
794 | 156..157 'a': A | 803 | 155..156 'a': A |
795 | 163..165 'a4': &&&&&&&A | 804 | 162..164 'a4': &&&&&&&A |
796 | 163..167 'a4.b': B | 805 | 162..166 'a4.b': B |
797 | 177..179 'a5': &mut &&mut &&mut A | 806 | 176..178 'a5': &mut &&mut &&mut A |
798 | 182..200 '&mut &...&mut a': &mut &&mut &&mut A | 807 | 181..199 '&mut &...&mut a': &mut &&mut &&mut A |
799 | 187..200 '&&mut &&mut a': &&mut &&mut A | 808 | 186..199 '&&mut &&mut a': &&mut &&mut A |
800 | 188..200 '&mut &&mut a': &mut &&mut A | 809 | 187..199 '&mut &&mut a': &mut &&mut A |
801 | 193..200 '&&mut a': &&mut A | 810 | 192..199 '&&mut a': &&mut A |
802 | 194..200 '&mut a': &mut A | 811 | 193..199 '&mut a': &mut A |
803 | 199..200 'a': A | 812 | 198..199 'a': A |
804 | 206..208 'a5': &mut &&mut &&mut A | 813 | 205..207 'a5': &mut &&mut &&mut A |
805 | 206..210 'a5.b': B | 814 | 205..209 'a5.b': B |
806 | 224..226 'a1': *const A | 815 | 223..225 'a1': *const A |
807 | 238..240 'a2': *mut A | 816 | 237..239 'a2': *mut A |
808 | 250..273 '{ ...2.b; }': () | 817 | 249..272 '{ ...2.b; }': () |
809 | 256..258 'a1': *const A | 818 | 255..257 'a1': *const A |
810 | 256..260 'a1.b': B | 819 | 255..259 'a1.b': B |
811 | 266..268 'a2': *mut A | 820 | 265..267 'a2': *mut A |
812 | 266..270 'a2.b': B | 821 | 265..269 'a2.b': B |
813 | "### | 822 | "### |
814 | ); | 823 | ); |
815 | } | 824 | } |
@@ -846,30 +855,30 @@ fn test() { | |||
846 | } | 855 | } |
847 | "#), | 856 | "#), |
848 | @r###" | 857 | @r###" |
849 | 68..72 'self': &Self | 858 | 67..71 'self': &Self |
850 | 139..143 'self': &A<T> | 859 | 138..142 'self': &A<T> |
851 | 151..174 '{ ... }': &T | 860 | 150..173 '{ ... }': &T |
852 | 161..168 '&self.0': &T | 861 | 160..167 '&self.0': &T |
853 | 162..166 'self': &A<T> | 862 | 161..165 'self': &A<T> |
854 | 162..168 'self.0': T | 863 | 161..167 'self.0': T |
855 | 255..259 'self': &B<T> | 864 | 254..258 'self': &B<T> |
856 | 278..301 '{ ... }': &T | 865 | 277..300 '{ ... }': &T |
857 | 288..295 '&self.0': &T | 866 | 287..294 '&self.0': &T |
858 | 289..293 'self': &B<T> | 867 | 288..292 'self': &B<T> |
859 | 289..295 'self.0': T | 868 | 288..294 'self.0': T |
860 | 315..353 '{ ...))); }': () | 869 | 314..352 '{ ...))); }': () |
861 | 325..326 't': &i32 | 870 | 324..325 't': &i32 |
862 | 329..335 'A::foo': fn foo<i32>(&A<i32>) -> &i32 | 871 | 328..334 'A::foo': fn foo<i32>(&A<i32>) -> &i32 |
863 | 329..350 'A::foo...42))))': &i32 | 872 | 328..349 'A::foo...42))))': &i32 |
864 | 336..349 '&&B(B(A(42)))': &&B<B<A<i32>>> | 873 | 335..348 '&&B(B(A(42)))': &&B<B<A<i32>>> |
865 | 337..349 '&B(B(A(42)))': &B<B<A<i32>>> | 874 | 336..348 '&B(B(A(42)))': &B<B<A<i32>>> |
866 | 338..339 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>> | 875 | 337..338 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>> |
867 | 338..349 'B(B(A(42)))': B<B<A<i32>>> | 876 | 337..348 'B(B(A(42)))': B<B<A<i32>>> |
868 | 340..341 'B': B<A<i32>>(A<i32>) -> B<A<i32>> | 877 | 339..340 'B': B<A<i32>>(A<i32>) -> B<A<i32>> |
869 | 340..348 'B(A(42))': B<A<i32>> | 878 | 339..347 'B(A(42))': B<A<i32>> |
870 | 342..343 'A': A<i32>(i32) -> A<i32> | 879 | 341..342 'A': A<i32>(i32) -> A<i32> |
871 | 342..347 'A(42)': A<i32> | 880 | 341..346 'A(42)': A<i32> |
872 | 344..346 '42': i32 | 881 | 343..345 '42': i32 |
873 | "### | 882 | "### |
874 | ); | 883 | ); |
875 | } | 884 | } |
@@ -906,34 +915,34 @@ fn test(a: A<i32>) { | |||
906 | } | 915 | } |
907 | "#), | 916 | "#), |
908 | @r###" | 917 | @r###" |
909 | 68..72 'self': &Self | 918 | 67..71 'self': &Self |
910 | 144..148 'self': &A<T> | 919 | 143..147 'self': &A<T> |
911 | 150..151 'x': &A<T> | 920 | 149..150 'x': &A<T> |
912 | 166..187 '{ ... }': &T | 921 | 165..186 '{ ... }': &T |
913 | 176..181 '&*x.0': &T | 922 | 175..180 '&*x.0': &T |
914 | 177..181 '*x.0': T | 923 | 176..180 '*x.0': T |
915 | 178..179 'x': &A<T> | 924 | 177..178 'x': &A<T> |
916 | 178..181 'x.0': *mut T | 925 | 177..180 'x.0': *mut T |
917 | 268..272 'self': &B<T> | 926 | 267..271 'self': &B<T> |
918 | 291..314 '{ ... }': &T | 927 | 290..313 '{ ... }': &T |
919 | 301..308 '&self.0': &T | 928 | 300..307 '&self.0': &T |
920 | 302..306 'self': &B<T> | 929 | 301..305 'self': &B<T> |
921 | 302..308 'self.0': T | 930 | 301..307 'self.0': T |
922 | 326..327 'a': A<i32> | 931 | 325..326 'a': A<i32> |
923 | 337..383 '{ ...))); }': () | 932 | 336..382 '{ ...))); }': () |
924 | 347..348 't': &i32 | 933 | 346..347 't': &i32 |
925 | 351..352 'A': A<i32>(*mut i32) -> A<i32> | 934 | 350..351 'A': A<i32>(*mut i32) -> A<i32> |
926 | 351..365 'A(0 as *mut _)': A<i32> | 935 | 350..364 'A(0 as *mut _)': A<i32> |
927 | 351..380 'A(0 as...B(a)))': &i32 | 936 | 350..379 'A(0 as...B(a)))': &i32 |
928 | 353..354 '0': i32 | 937 | 352..353 '0': i32 |
929 | 353..364 '0 as *mut _': *mut i32 | 938 | 352..363 '0 as *mut _': *mut i32 |
930 | 370..379 '&&B(B(a))': &&B<B<A<i32>>> | 939 | 369..378 '&&B(B(a))': &&B<B<A<i32>>> |
931 | 371..379 '&B(B(a))': &B<B<A<i32>>> | 940 | 370..378 '&B(B(a))': &B<B<A<i32>>> |
932 | 372..373 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>> | 941 | 371..372 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>> |
933 | 372..379 'B(B(a))': B<B<A<i32>>> | 942 | 371..378 'B(B(a))': B<B<A<i32>>> |
934 | 374..375 'B': B<A<i32>>(A<i32>) -> B<A<i32>> | 943 | 373..374 'B': B<A<i32>>(A<i32>) -> B<A<i32>> |
935 | 374..378 'B(a)': B<A<i32>> | 944 | 373..377 'B(a)': B<A<i32>> |
936 | 376..377 'a': A<i32> | 945 | 375..376 'a': A<i32> |
937 | "### | 946 | "### |
938 | ); | 947 | ); |
939 | } | 948 | } |
@@ -952,16 +961,16 @@ fn main(foo: Foo) { | |||
952 | } | 961 | } |
953 | "#), | 962 | "#), |
954 | @r###" | 963 | @r###" |
955 | 35..38 'foo': Foo | 964 | 34..37 'foo': Foo |
956 | 45..109 '{ ... } }': () | 965 | 44..108 '{ ... } }': () |
957 | 51..107 'if tru... }': () | 966 | 50..106 'if tru... }': () |
958 | 54..58 'true': bool | 967 | 53..57 'true': bool |
959 | 59..67 '{ }': () | 968 | 58..66 '{ }': () |
960 | 73..107 'if fal... }': i32 | 969 | 72..106 'if fal... }': i32 |
961 | 76..81 'false': bool | 970 | 75..80 'false': bool |
962 | 82..107 '{ ... }': i32 | 971 | 81..106 '{ ... }': i32 |
963 | 92..95 'foo': Foo | 972 | 91..94 'foo': Foo |
964 | 92..101 'foo.field': i32 | 973 | 91..100 'foo.field': i32 |
965 | "### | 974 | "### |
966 | ) | 975 | ) |
967 | } | 976 | } |
@@ -993,38 +1002,38 @@ fn foo() { | |||
993 | }; | 1002 | }; |
994 | }"#), | 1003 | }"#), |
995 | @r###" | 1004 | @r###" |
996 | 10..323 '{ ... }; }': () | 1005 | 9..322 '{ ... }; }': () |
997 | 20..23 '_x1': i32 | 1006 | 19..22 '_x1': i32 |
998 | 26..80 'if tru... }': i32 | 1007 | 25..79 'if tru... }': i32 |
999 | 29..33 'true': bool | 1008 | 28..32 'true': bool |
1000 | 34..51 '{ ... }': i32 | 1009 | 33..50 '{ ... }': i32 |
1001 | 44..45 '1': i32 | 1010 | 43..44 '1': i32 |
1002 | 57..80 '{ ... }': i32 | 1011 | 56..79 '{ ... }': i32 |
1003 | 67..73 'return': ! | 1012 | 66..72 'return': ! |
1004 | 90..93 '_x2': i32 | 1013 | 89..92 '_x2': i32 |
1005 | 96..149 'if tru... }': i32 | 1014 | 95..148 'if tru... }': i32 |
1006 | 99..103 'true': bool | 1015 | 98..102 'true': bool |
1007 | 104..121 '{ ... }': i32 | 1016 | 103..120 '{ ... }': i32 |
1008 | 114..115 '2': i32 | 1017 | 113..114 '2': i32 |
1009 | 127..149 '{ ... }': ! | 1018 | 126..148 '{ ... }': ! |
1010 | 137..143 'return': ! | 1019 | 136..142 'return': ! |
1011 | 159..162 '_x3': i32 | 1020 | 158..161 '_x3': i32 |
1012 | 165..247 'match ... }': i32 | 1021 | 164..246 'match ... }': i32 |
1013 | 171..175 'true': bool | 1022 | 170..174 'true': bool |
1014 | 186..190 'true': bool | 1023 | 185..189 'true': bool |
1015 | 186..190 'true': bool | 1024 | 185..189 'true': bool |
1016 | 194..195 '3': i32 | 1025 | 193..194 '3': i32 |
1017 | 205..206 '_': bool | 1026 | 204..205 '_': bool |
1018 | 210..241 '{ ... }': i32 | 1027 | 209..240 '{ ... }': i32 |
1019 | 224..230 'return': ! | 1028 | 223..229 'return': ! |
1020 | 257..260 '_x4': i32 | 1029 | 256..259 '_x4': i32 |
1021 | 263..320 'match ... }': i32 | 1030 | 262..319 'match ... }': i32 |
1022 | 269..273 'true': bool | 1031 | 268..272 'true': bool |
1023 | 284..288 'true': bool | 1032 | 283..287 'true': bool |
1024 | 284..288 'true': bool | 1033 | 283..287 'true': bool |
1025 | 292..293 '4': i32 | 1034 | 291..292 '4': i32 |
1026 | 303..304 '_': bool | 1035 | 302..303 '_': bool |
1027 | 308..314 'return': ! | 1036 | 307..313 'return': ! |
1028 | "### | 1037 | "### |
1029 | ) | 1038 | ) |
1030 | } | 1039 | } |
@@ -1052,24 +1061,24 @@ fn test(a: A) { | |||
1052 | } | 1061 | } |
1053 | "#), | 1062 | "#), |
1054 | @r###" | 1063 | @r###" |
1055 | 32..36 'self': A | 1064 | 31..35 'self': A |
1056 | 38..39 'x': u32 | 1065 | 37..38 'x': u32 |
1057 | 53..55 '{}': () | 1066 | 52..54 '{}': () |
1058 | 103..107 'self': &A | 1067 | 102..106 'self': &A |
1059 | 109..110 'x': u64 | 1068 | 108..109 'x': u64 |
1060 | 124..126 '{}': () | 1069 | 123..125 '{}': () |
1061 | 144..145 'a': A | 1070 | 143..144 'a': A |
1062 | 150..198 '{ ...(1); }': () | 1071 | 149..197 '{ ...(1); }': () |
1063 | 156..157 'a': A | 1072 | 155..156 'a': A |
1064 | 156..164 'a.foo(1)': i32 | 1073 | 155..163 'a.foo(1)': i32 |
1065 | 162..163 '1': u32 | 1074 | 161..162 '1': u32 |
1066 | 170..181 '(&a).bar(1)': i64 | 1075 | 169..180 '(&a).bar(1)': i64 |
1067 | 171..173 '&a': &A | 1076 | 170..172 '&a': &A |
1068 | 172..173 'a': A | 1077 | 171..172 'a': A |
1069 | 179..180 '1': u64 | 1078 | 178..179 '1': u64 |
1070 | 187..188 'a': A | 1079 | 186..187 'a': A |
1071 | 187..195 'a.bar(1)': i64 | 1080 | 186..194 'a.bar(1)': i64 |
1072 | 193..194 '1': u64 | 1081 | 192..193 '1': u64 |
1073 | "### | 1082 | "### |
1074 | ); | 1083 | ); |
1075 | } | 1084 | } |
@@ -1088,11 +1097,11 @@ fn test() { | |||
1088 | } | 1097 | } |
1089 | "#), | 1098 | "#), |
1090 | @r###" | 1099 | @r###" |
1091 | 40..44 'self': &str | 1100 | 39..43 'self': &str |
1092 | 53..55 '{}': () | 1101 | 52..54 '{}': () |
1093 | 69..89 '{ ...o(); }': () | 1102 | 68..88 '{ ...o(); }': () |
1094 | 75..80 '"foo"': &str | 1103 | 74..79 '"foo"': &str |
1095 | 75..86 '"foo".foo()': i32 | 1104 | 74..85 '"foo".foo()': i32 |
1096 | "### | 1105 | "### |
1097 | ); | 1106 | ); |
1098 | } | 1107 | } |
@@ -1111,33 +1120,33 @@ fn test(x: &str, y: isize) { | |||
1111 | } | 1120 | } |
1112 | "#), | 1121 | "#), |
1113 | @r###" | 1122 | @r###" |
1114 | 9..10 'x': &str | 1123 | 8..9 'x': &str |
1115 | 18..19 'y': isize | 1124 | 17..18 'y': isize |
1116 | 28..170 '{ ...d"); }': () | 1125 | 27..169 '{ ...d"); }': () |
1117 | 38..39 'a': (u32, &str) | 1126 | 37..38 'a': (u32, &str) |
1118 | 55..63 '(1, "a")': (u32, &str) | 1127 | 54..62 '(1, "a")': (u32, &str) |
1119 | 56..57 '1': u32 | 1128 | 55..56 '1': u32 |
1120 | 59..62 '"a"': &str | 1129 | 58..61 '"a"': &str |
1121 | 73..74 'b': ((u32, &str), &str) | 1130 | 72..73 'b': ((u32, &str), &str) |
1122 | 77..83 '(a, x)': ((u32, &str), &str) | 1131 | 76..82 '(a, x)': ((u32, &str), &str) |
1123 | 78..79 'a': (u32, &str) | 1132 | 77..78 'a': (u32, &str) |
1124 | 81..82 'x': &str | 1133 | 80..81 'x': &str |
1125 | 93..94 'c': (isize, &str) | 1134 | 92..93 'c': (isize, &str) |
1126 | 97..103 '(y, x)': (isize, &str) | 1135 | 96..102 '(y, x)': (isize, &str) |
1127 | 98..99 'y': isize | 1136 | 97..98 'y': isize |
1128 | 101..102 'x': &str | 1137 | 100..101 'x': &str |
1129 | 113..114 'd': ((isize, &str), &str) | 1138 | 112..113 'd': ((isize, &str), &str) |
1130 | 117..123 '(c, x)': ((isize, &str), &str) | 1139 | 116..122 '(c, x)': ((isize, &str), &str) |
1131 | 118..119 'c': (isize, &str) | 1140 | 117..118 'c': (isize, &str) |
1132 | 121..122 'x': &str | 1141 | 120..121 'x': &str |
1133 | 133..134 'e': (i32, &str) | 1142 | 132..133 'e': (i32, &str) |
1134 | 137..145 '(1, "e")': (i32, &str) | 1143 | 136..144 '(1, "e")': (i32, &str) |
1135 | 138..139 '1': i32 | 1144 | 137..138 '1': i32 |
1136 | 141..144 '"e"': &str | 1145 | 140..143 '"e"': &str |
1137 | 155..156 'f': ((i32, &str), &str) | 1146 | 154..155 'f': ((i32, &str), &str) |
1138 | 159..167 '(e, "d")': ((i32, &str), &str) | 1147 | 158..166 '(e, "d")': ((i32, &str), &str) |
1139 | 160..161 'e': (i32, &str) | 1148 | 159..160 'e': (i32, &str) |
1140 | 163..166 '"d"': &str | 1149 | 162..165 '"d"': &str |
1141 | "### | 1150 | "### |
1142 | ); | 1151 | ); |
1143 | } | 1152 | } |
@@ -1165,58 +1174,58 @@ fn test(x: &str, y: isize) { | |||
1165 | } | 1174 | } |
1166 | "#), | 1175 | "#), |
1167 | @r###" | 1176 | @r###" |
1168 | 9..10 'x': &str | 1177 | 8..9 'x': &str |
1169 | 18..19 'y': isize | 1178 | 17..18 'y': isize |
1170 | 28..293 '{ ... []; }': () | 1179 | 27..292 '{ ... []; }': () |
1171 | 38..39 'a': [&str; _] | 1180 | 37..38 'a': [&str; _] |
1172 | 42..45 '[x]': [&str; _] | 1181 | 41..44 '[x]': [&str; _] |
1173 | 43..44 'x': &str | 1182 | 42..43 'x': &str |
1174 | 55..56 'b': [[&str; _]; _] | 1183 | 54..55 'b': [[&str; _]; _] |
1175 | 59..65 '[a, a]': [[&str; _]; _] | 1184 | 58..64 '[a, a]': [[&str; _]; _] |
1176 | 60..61 'a': [&str; _] | 1185 | 59..60 'a': [&str; _] |
1177 | 63..64 'a': [&str; _] | 1186 | 62..63 'a': [&str; _] |
1178 | 75..76 'c': [[[&str; _]; _]; _] | 1187 | 74..75 'c': [[[&str; _]; _]; _] |
1179 | 79..85 '[b, b]': [[[&str; _]; _]; _] | 1188 | 78..84 '[b, b]': [[[&str; _]; _]; _] |
1180 | 80..81 'b': [[&str; _]; _] | 1189 | 79..80 'b': [[&str; _]; _] |
1181 | 83..84 'b': [[&str; _]; _] | 1190 | 82..83 'b': [[&str; _]; _] |
1182 | 96..97 'd': [isize; _] | 1191 | 95..96 'd': [isize; _] |
1183 | 100..112 '[y, 1, 2, 3]': [isize; _] | 1192 | 99..111 '[y, 1, 2, 3]': [isize; _] |
1184 | 101..102 'y': isize | 1193 | 100..101 'y': isize |
1185 | 104..105 '1': isize | 1194 | 103..104 '1': isize |
1186 | 107..108 '2': isize | 1195 | 106..107 '2': isize |
1187 | 110..111 '3': isize | 1196 | 109..110 '3': isize |
1188 | 122..123 'd': [isize; _] | 1197 | 121..122 'd': [isize; _] |
1189 | 126..138 '[1, y, 2, 3]': [isize; _] | 1198 | 125..137 '[1, y, 2, 3]': [isize; _] |
1190 | 127..128 '1': isize | 1199 | 126..127 '1': isize |
1191 | 130..131 'y': isize | 1200 | 129..130 'y': isize |
1192 | 133..134 '2': isize | 1201 | 132..133 '2': isize |
1193 | 136..137 '3': isize | 1202 | 135..136 '3': isize |
1194 | 148..149 'e': [isize; _] | 1203 | 147..148 'e': [isize; _] |
1195 | 152..155 '[y]': [isize; _] | 1204 | 151..154 '[y]': [isize; _] |
1196 | 153..154 'y': isize | 1205 | 152..153 'y': isize |
1197 | 165..166 'f': [[isize; _]; _] | 1206 | 164..165 'f': [[isize; _]; _] |
1198 | 169..175 '[d, d]': [[isize; _]; _] | 1207 | 168..174 '[d, d]': [[isize; _]; _] |
1199 | 170..171 'd': [isize; _] | 1208 | 169..170 'd': [isize; _] |
1200 | 173..174 'd': [isize; _] | 1209 | 172..173 'd': [isize; _] |
1201 | 185..186 'g': [[isize; _]; _] | 1210 | 184..185 'g': [[isize; _]; _] |
1202 | 189..195 '[e, e]': [[isize; _]; _] | 1211 | 188..194 '[e, e]': [[isize; _]; _] |
1203 | 190..191 'e': [isize; _] | 1212 | 189..190 'e': [isize; _] |
1204 | 193..194 'e': [isize; _] | 1213 | 192..193 'e': [isize; _] |
1205 | 206..207 'h': [i32; _] | 1214 | 205..206 'h': [i32; _] |
1206 | 210..216 '[1, 2]': [i32; _] | 1215 | 209..215 '[1, 2]': [i32; _] |
1207 | 211..212 '1': i32 | 1216 | 210..211 '1': i32 |
1208 | 214..215 '2': i32 | 1217 | 213..214 '2': i32 |
1209 | 226..227 'i': [&str; _] | 1218 | 225..226 'i': [&str; _] |
1210 | 230..240 '["a", "b"]': [&str; _] | 1219 | 229..239 '["a", "b"]': [&str; _] |
1211 | 231..234 '"a"': &str | 1220 | 230..233 '"a"': &str |
1212 | 236..239 '"b"': &str | 1221 | 235..238 '"b"': &str |
1213 | 251..252 'b': [[&str; _]; _] | 1222 | 250..251 'b': [[&str; _]; _] |
1214 | 255..265 '[a, ["b"]]': [[&str; _]; _] | 1223 | 254..264 '[a, ["b"]]': [[&str; _]; _] |
1215 | 256..257 'a': [&str; _] | 1224 | 255..256 'a': [&str; _] |
1216 | 259..264 '["b"]': [&str; _] | 1225 | 258..263 '["b"]': [&str; _] |
1217 | 260..263 '"b"': &str | 1226 | 259..262 '"b"': &str |
1218 | 275..276 'x': [u8; _] | 1227 | 274..275 'x': [u8; _] |
1219 | 288..290 '[]': [u8; _] | 1228 | 287..289 '[]': [u8; _] |
1220 | "### | 1229 | "### |
1221 | ); | 1230 | ); |
1222 | } | 1231 | } |
@@ -1238,21 +1247,21 @@ fn test(a1: A<u32>, i: i32) { | |||
1238 | } | 1247 | } |
1239 | "#), | 1248 | "#), |
1240 | @r###" | 1249 | @r###" |
1241 | 36..38 'a1': A<u32> | 1250 | 35..37 'a1': A<u32> |
1242 | 48..49 'i': i32 | 1251 | 47..48 'i': i32 |
1243 | 56..147 '{ ...3.x; }': () | 1252 | 55..146 '{ ...3.x; }': () |
1244 | 62..64 'a1': A<u32> | 1253 | 61..63 'a1': A<u32> |
1245 | 62..66 'a1.x': u32 | 1254 | 61..65 'a1.x': u32 |
1246 | 76..78 'a2': A<i32> | 1255 | 75..77 'a2': A<i32> |
1247 | 81..91 'A { x: i }': A<i32> | 1256 | 80..90 'A { x: i }': A<i32> |
1248 | 88..89 'i': i32 | 1257 | 87..88 'i': i32 |
1249 | 97..99 'a2': A<i32> | 1258 | 96..98 'a2': A<i32> |
1250 | 97..101 'a2.x': i32 | 1259 | 96..100 'a2.x': i32 |
1251 | 111..113 'a3': A<i128> | 1260 | 110..112 'a3': A<i128> |
1252 | 116..134 'A::<i1...x: 1 }': A<i128> | 1261 | 115..133 'A::<i1...x: 1 }': A<i128> |
1253 | 131..132 '1': i128 | 1262 | 130..131 '1': i128 |
1254 | 140..142 'a3': A<i128> | 1263 | 139..141 'a3': A<i128> |
1255 | 140..144 'a3.x': i128 | 1264 | 139..143 'a3.x': i128 |
1256 | "### | 1265 | "### |
1257 | ); | 1266 | ); |
1258 | } | 1267 | } |
@@ -1275,22 +1284,22 @@ fn test() { | |||
1275 | } | 1284 | } |
1276 | "#), | 1285 | "#), |
1277 | @r###" | 1286 | @r###" |
1278 | 76..184 '{ ...one; }': () | 1287 | 75..183 '{ ...one; }': () |
1279 | 82..83 'A': A<i32>(i32) -> A<i32> | 1288 | 81..82 'A': A<i32>(i32) -> A<i32> |
1280 | 82..87 'A(42)': A<i32> | 1289 | 81..86 'A(42)': A<i32> |
1281 | 84..86 '42': i32 | 1290 | 83..85 '42': i32 |
1282 | 93..94 'A': A<u128>(u128) -> A<u128> | 1291 | 92..93 'A': A<u128>(u128) -> A<u128> |
1283 | 93..102 'A(42u128)': A<u128> | 1292 | 92..101 'A(42u128)': A<u128> |
1284 | 95..101 '42u128': u128 | 1293 | 94..100 '42u128': u128 |
1285 | 108..112 'Some': Some<&str>(&str) -> Option<&str> | 1294 | 107..111 'Some': Some<&str>(&str) -> Option<&str> |
1286 | 108..117 'Some("x")': Option<&str> | 1295 | 107..116 'Some("x")': Option<&str> |
1287 | 113..116 '"x"': &str | 1296 | 112..115 '"x"': &str |
1288 | 123..135 'Option::Some': Some<&str>(&str) -> Option<&str> | 1297 | 122..134 'Option::Some': Some<&str>(&str) -> Option<&str> |
1289 | 123..140 'Option...e("x")': Option<&str> | 1298 | 122..139 'Option...e("x")': Option<&str> |
1290 | 136..139 '"x"': &str | 1299 | 135..138 '"x"': &str |
1291 | 146..150 'None': Option<{unknown}> | 1300 | 145..149 'None': Option<{unknown}> |
1292 | 160..161 'x': Option<i64> | 1301 | 159..160 'x': Option<i64> |
1293 | 177..181 'None': Option<i64> | 1302 | 176..180 'None': Option<i64> |
1294 | "### | 1303 | "### |
1295 | ); | 1304 | ); |
1296 | } | 1305 | } |
@@ -1308,20 +1317,20 @@ fn test() { | |||
1308 | } | 1317 | } |
1309 | "#), | 1318 | "#), |
1310 | @r###" | 1319 | @r###" |
1311 | 10..11 't': T | 1320 | 9..10 't': T |
1312 | 21..26 '{ t }': T | 1321 | 20..25 '{ t }': T |
1313 | 23..24 't': T | 1322 | 22..23 't': T |
1314 | 38..98 '{ ...(1); }': () | 1323 | 37..97 '{ ...(1); }': () |
1315 | 44..46 'id': fn id<u32>(u32) -> u32 | 1324 | 43..45 'id': fn id<u32>(u32) -> u32 |
1316 | 44..52 'id(1u32)': u32 | 1325 | 43..51 'id(1u32)': u32 |
1317 | 47..51 '1u32': u32 | 1326 | 46..50 '1u32': u32 |
1318 | 58..68 'id::<i128>': fn id<i128>(i128) -> i128 | 1327 | 57..67 'id::<i128>': fn id<i128>(i128) -> i128 |
1319 | 58..71 'id::<i128>(1)': i128 | 1328 | 57..70 'id::<i128>(1)': i128 |
1320 | 69..70 '1': i128 | 1329 | 68..69 '1': i128 |
1321 | 81..82 'x': u64 | 1330 | 80..81 'x': u64 |
1322 | 90..92 'id': fn id<u64>(u64) -> u64 | 1331 | 89..91 'id': fn id<u64>(u64) -> u64 |
1323 | 90..95 'id(1)': u64 | 1332 | 89..94 'id(1)': u64 |
1324 | 93..94 '1': u64 | 1333 | 92..93 '1': u64 |
1325 | "### | 1334 | "### |
1326 | ); | 1335 | ); |
1327 | } | 1336 | } |
@@ -1355,38 +1364,38 @@ fn test() -> i128 { | |||
1355 | } | 1364 | } |
1356 | "#), | 1365 | "#), |
1357 | @r###" | 1366 | @r###" |
1358 | 74..78 'self': A<X, Y> | 1367 | 73..77 'self': A<X, Y> |
1359 | 85..107 '{ ... }': X | 1368 | 84..106 '{ ... }': X |
1360 | 95..99 'self': A<X, Y> | 1369 | 94..98 'self': A<X, Y> |
1361 | 95..101 'self.x': X | 1370 | 94..100 'self.x': X |
1362 | 117..121 'self': A<X, Y> | 1371 | 116..120 'self': A<X, Y> |
1363 | 128..150 '{ ... }': Y | 1372 | 127..149 '{ ... }': Y |
1364 | 138..142 'self': A<X, Y> | 1373 | 137..141 'self': A<X, Y> |
1365 | 138..144 'self.y': Y | 1374 | 137..143 'self.y': Y |
1366 | 163..167 'self': A<X, Y> | 1375 | 162..166 'self': A<X, Y> |
1367 | 169..170 't': T | 1376 | 168..169 't': T |
1368 | 188..223 '{ ... }': (X, Y, T) | 1377 | 187..222 '{ ... }': (X, Y, T) |
1369 | 198..217 '(self.....y, t)': (X, Y, T) | 1378 | 197..216 '(self.....y, t)': (X, Y, T) |
1370 | 199..203 'self': A<X, Y> | 1379 | 198..202 'self': A<X, Y> |
1371 | 199..205 'self.x': X | 1380 | 198..204 'self.x': X |
1372 | 207..211 'self': A<X, Y> | 1381 | 206..210 'self': A<X, Y> |
1373 | 207..213 'self.y': Y | 1382 | 206..212 'self.y': Y |
1374 | 215..216 't': T | 1383 | 214..215 't': T |
1375 | 245..342 '{ ...(1); }': () | 1384 | 244..341 '{ ...(1); }': () |
1376 | 255..256 'a': A<u64, i64> | 1385 | 254..255 'a': A<u64, i64> |
1377 | 259..281 'A { x:...1i64 }': A<u64, i64> | 1386 | 258..280 'A { x:...1i64 }': A<u64, i64> |
1378 | 266..270 '1u64': u64 | 1387 | 265..269 '1u64': u64 |
1379 | 275..279 '1i64': i64 | 1388 | 274..278 '1i64': i64 |
1380 | 287..288 'a': A<u64, i64> | 1389 | 286..287 'a': A<u64, i64> |
1381 | 287..292 'a.x()': u64 | 1390 | 286..291 'a.x()': u64 |
1382 | 298..299 'a': A<u64, i64> | 1391 | 297..298 'a': A<u64, i64> |
1383 | 298..303 'a.y()': i64 | 1392 | 297..302 'a.y()': i64 |
1384 | 309..310 'a': A<u64, i64> | 1393 | 308..309 'a': A<u64, i64> |
1385 | 309..319 'a.z(1i128)': (u64, i64, i128) | 1394 | 308..318 'a.z(1i128)': (u64, i64, i128) |
1386 | 313..318 '1i128': i128 | 1395 | 312..317 '1i128': i128 |
1387 | 325..326 'a': A<u64, i64> | 1396 | 324..325 'a': A<u64, i64> |
1388 | 325..339 'a.z::<u128>(1)': (u64, i64, u128) | 1397 | 324..338 'a.z::<u128>(1)': (u64, i64, u128) |
1389 | 337..338 '1': u128 | 1398 | 336..337 '1': u128 |
1390 | "### | 1399 | "### |
1391 | ); | 1400 | ); |
1392 | } | 1401 | } |
@@ -1408,15 +1417,15 @@ fn test(o: Option<u32>) { | |||
1408 | } | 1417 | } |
1409 | "#), | 1418 | "#), |
1410 | @r###" | 1419 | @r###" |
1411 | 78..82 'self': &Option<T> | 1420 | 77..81 'self': &Option<T> |
1412 | 98..100 '{}': () | 1421 | 97..99 '{}': () |
1413 | 111..112 'o': Option<u32> | 1422 | 110..111 'o': Option<u32> |
1414 | 127..165 '{ ...f(); }': () | 1423 | 126..164 '{ ...f(); }': () |
1415 | 133..146 '(&o).as_ref()': Option<&u32> | 1424 | 132..145 '(&o).as_ref()': Option<&u32> |
1416 | 134..136 '&o': &Option<u32> | 1425 | 133..135 '&o': &Option<u32> |
1417 | 135..136 'o': Option<u32> | 1426 | 134..135 'o': Option<u32> |
1418 | 152..153 'o': Option<u32> | 1427 | 151..152 'o': Option<u32> |
1419 | 152..162 'o.as_ref()': Option<&u32> | 1428 | 151..161 'o.as_ref()': Option<&u32> |
1420 | "### | 1429 | "### |
1421 | ); | 1430 | ); |
1422 | } | 1431 | } |
@@ -1445,35 +1454,35 @@ fn test() -> i128 { | |||
1445 | } | 1454 | } |
1446 | "#), | 1455 | "#), |
1447 | @r###" | 1456 | @r###" |
1448 | 53..57 'self': A<T2> | 1457 | 52..56 'self': A<T2> |
1449 | 65..87 '{ ... }': T2 | 1458 | 64..86 '{ ... }': T2 |
1450 | 75..79 'self': A<T2> | 1459 | 74..78 'self': A<T2> |
1451 | 75..81 'self.x': T2 | 1460 | 74..80 'self.x': T2 |
1452 | 99..100 't': T | 1461 | 98..99 't': T |
1453 | 110..115 '{ t }': T | 1462 | 109..114 '{ t }': T |
1454 | 112..113 't': T | 1463 | 111..112 't': T |
1455 | 135..261 '{ ....x() }': i128 | 1464 | 134..260 '{ ....x() }': i128 |
1456 | 146..147 'x': i128 | 1465 | 145..146 'x': i128 |
1457 | 150..151 '1': i128 | 1466 | 149..150 '1': i128 |
1458 | 162..163 'y': i128 | 1467 | 161..162 'y': i128 |
1459 | 166..168 'id': fn id<i128>(i128) -> i128 | 1468 | 165..167 'id': fn id<i128>(i128) -> i128 |
1460 | 166..171 'id(x)': i128 | 1469 | 165..170 'id(x)': i128 |
1461 | 169..170 'x': i128 | 1470 | 168..169 'x': i128 |
1462 | 182..183 'a': A<i128> | 1471 | 181..182 'a': A<i128> |
1463 | 186..200 'A { x: id(y) }': A<i128> | 1472 | 185..199 'A { x: id(y) }': A<i128> |
1464 | 193..195 'id': fn id<i128>(i128) -> i128 | 1473 | 192..194 'id': fn id<i128>(i128) -> i128 |
1465 | 193..198 'id(y)': i128 | 1474 | 192..197 'id(y)': i128 |
1466 | 196..197 'y': i128 | 1475 | 195..196 'y': i128 |
1467 | 211..212 'z': i128 | 1476 | 210..211 'z': i128 |
1468 | 215..217 'id': fn id<i128>(i128) -> i128 | 1477 | 214..216 'id': fn id<i128>(i128) -> i128 |
1469 | 215..222 'id(a.x)': i128 | 1478 | 214..221 'id(a.x)': i128 |
1470 | 218..219 'a': A<i128> | 1479 | 217..218 'a': A<i128> |
1471 | 218..221 'a.x': i128 | 1480 | 217..220 'a.x': i128 |
1472 | 233..234 'b': A<i128> | 1481 | 232..233 'b': A<i128> |
1473 | 237..247 'A { x: z }': A<i128> | 1482 | 236..246 'A { x: z }': A<i128> |
1474 | 244..245 'z': i128 | 1483 | 243..244 'z': i128 |
1475 | 254..255 'b': A<i128> | 1484 | 253..254 'b': A<i128> |
1476 | 254..259 'b.x()': i128 | 1485 | 253..258 'b.x()': i128 |
1477 | "### | 1486 | "### |
1478 | ); | 1487 | ); |
1479 | } | 1488 | } |
@@ -1511,16 +1520,16 @@ fn test() { | |||
1511 | } | 1520 | } |
1512 | "#), | 1521 | "#), |
1513 | @r###" | 1522 | @r###" |
1514 | 52..53 '1': u32 | 1523 | 51..52 '1': u32 |
1515 | 105..106 '2': u32 | 1524 | 104..105 '2': u32 |
1516 | 213..214 '5': u32 | 1525 | 212..213 '5': u32 |
1517 | 229..307 '{ ...:ID; }': () | 1526 | 228..306 '{ ...:ID; }': () |
1518 | 239..240 'x': u32 | 1527 | 238..239 'x': u32 |
1519 | 243..254 'Struct::FOO': u32 | 1528 | 242..253 'Struct::FOO': u32 |
1520 | 264..265 'y': u32 | 1529 | 263..264 'y': u32 |
1521 | 268..277 'Enum::BAR': u32 | 1530 | 267..276 'Enum::BAR': u32 |
1522 | 287..288 'z': u32 | 1531 | 286..287 'z': u32 |
1523 | 291..304 'TraitTest::ID': u32 | 1532 | 290..303 'TraitTest::ID': u32 |
1524 | "### | 1533 | "### |
1525 | ); | 1534 | ); |
1526 | } | 1535 | } |
@@ -1543,22 +1552,22 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) { | |||
1543 | } | 1552 | } |
1544 | "#), | 1553 | "#), |
1545 | @r###" | 1554 | @r###" |
1546 | 116..117 'x': A<u32, i128> | 1555 | 115..116 'x': A<u32, i128> |
1547 | 124..125 'y': A<&str, u128> | 1556 | 123..124 'y': A<&str, u128> |
1548 | 138..139 'z': A<u8, i8> | 1557 | 137..138 'z': A<u8, i8> |
1549 | 154..211 '{ ...z.y; }': () | 1558 | 153..210 '{ ...z.y; }': () |
1550 | 160..161 'x': A<u32, i128> | 1559 | 159..160 'x': A<u32, i128> |
1551 | 160..163 'x.x': u32 | 1560 | 159..162 'x.x': u32 |
1552 | 169..170 'x': A<u32, i128> | 1561 | 168..169 'x': A<u32, i128> |
1553 | 169..172 'x.y': i128 | 1562 | 168..171 'x.y': i128 |
1554 | 178..179 'y': A<&str, u128> | 1563 | 177..178 'y': A<&str, u128> |
1555 | 178..181 'y.x': &str | 1564 | 177..180 'y.x': &str |
1556 | 187..188 'y': A<&str, u128> | 1565 | 186..187 'y': A<&str, u128> |
1557 | 187..190 'y.y': u128 | 1566 | 186..189 'y.y': u128 |
1558 | 196..197 'z': A<u8, i8> | 1567 | 195..196 'z': A<u8, i8> |
1559 | 196..199 'z.x': u8 | 1568 | 195..198 'z.x': u8 |
1560 | 205..206 'z': A<u8, i8> | 1569 | 204..205 'z': A<u8, i8> |
1561 | 205..208 'z.y': i8 | 1570 | 204..207 'z.y': i8 |
1562 | "### | 1571 | "### |
1563 | ) | 1572 | ) |
1564 | } | 1573 | } |
@@ -1573,8 +1582,8 @@ type Bar = A<Bar>; | |||
1573 | fn test(x: Foo) {} | 1582 | fn test(x: Foo) {} |
1574 | "#), | 1583 | "#), |
1575 | @r###" | 1584 | @r###" |
1576 | 59..60 'x': {unknown} | 1585 | 58..59 'x': {unknown} |
1577 | 67..69 '{}': () | 1586 | 66..68 '{}': () |
1578 | "### | 1587 | "### |
1579 | ) | 1588 | ) |
1580 | } | 1589 | } |
@@ -1599,26 +1608,26 @@ fn test() { | |||
1599 | } | 1608 | } |
1600 | "#), | 1609 | "#), |
1601 | @r###" | 1610 | @r###" |
1602 | 10..11 'x': T | 1611 | 9..10 'x': T |
1603 | 21..30 '{ x }': T | 1612 | 20..29 '{ x }': T |
1604 | 27..28 'x': T | 1613 | 26..27 'x': T |
1605 | 44..45 'x': &T | 1614 | 43..44 'x': &T |
1606 | 56..66 '{ *x }': T | 1615 | 55..65 '{ *x }': T |
1607 | 62..64 '*x': T | 1616 | 61..63 '*x': T |
1608 | 63..64 'x': &T | 1617 | 62..63 'x': &T |
1609 | 78..158 '{ ...(1); }': () | 1618 | 77..157 '{ ...(1); }': () |
1610 | 88..89 'y': u32 | 1619 | 87..88 'y': u32 |
1611 | 92..97 '10u32': u32 | 1620 | 91..96 '10u32': u32 |
1612 | 103..105 'id': fn id<u32>(u32) -> u32 | 1621 | 102..104 'id': fn id<u32>(u32) -> u32 |
1613 | 103..108 'id(y)': u32 | 1622 | 102..107 'id(y)': u32 |
1614 | 106..107 'y': u32 | 1623 | 105..106 'y': u32 |
1615 | 118..119 'x': bool | 1624 | 117..118 'x': bool |
1616 | 128..133 'clone': fn clone<bool>(&bool) -> bool | 1625 | 127..132 'clone': fn clone<bool>(&bool) -> bool |
1617 | 128..136 'clone(z)': bool | 1626 | 127..135 'clone(z)': bool |
1618 | 134..135 'z': &bool | 1627 | 133..134 'z': &bool |
1619 | 142..152 'id::<i128>': fn id<i128>(i128) -> i128 | 1628 | 141..151 'id::<i128>': fn id<i128>(i128) -> i128 |
1620 | 142..155 'id::<i128>(1)': i128 | 1629 | 141..154 'id::<i128>(1)': i128 |
1621 | 153..154 '1': i128 | 1630 | 152..153 '1': i128 |
1622 | "### | 1631 | "### |
1623 | ); | 1632 | ); |
1624 | } | 1633 | } |
@@ -1638,16 +1647,16 @@ fn test() { | |||
1638 | } | 1647 | } |
1639 | "#), | 1648 | "#), |
1640 | @r###" | 1649 | @r###" |
1641 | 49..50 '0': u32 | 1650 | 48..49 '0': u32 |
1642 | 80..83 '101': u32 | 1651 | 79..82 '101': u32 |
1643 | 95..213 '{ ...NST; }': () | 1652 | 94..212 '{ ...NST; }': () |
1644 | 138..139 'x': u32 | 1653 | 137..138 'x': u32 |
1645 | 142..153 'LOCAL_CONST': u32 | 1654 | 141..152 'LOCAL_CONST': u32 |
1646 | 163..164 'z': u32 | 1655 | 162..163 'z': u32 |
1647 | 167..179 'GLOBAL_CONST': u32 | 1656 | 166..178 'GLOBAL_CONST': u32 |
1648 | 189..191 'id': u32 | 1657 | 188..190 'id': u32 |
1649 | 194..210 'Foo::A..._CONST': u32 | 1658 | 193..209 'Foo::A..._CONST': u32 |
1650 | 126..128 '99': u32 | 1659 | 125..127 '99': u32 |
1651 | "### | 1660 | "### |
1652 | ); | 1661 | ); |
1653 | } | 1662 | } |
@@ -1668,28 +1677,27 @@ fn test() { | |||
1668 | } | 1677 | } |
1669 | "#), | 1678 | "#), |
1670 | @r###" | 1679 | @r###" |
1671 | 29..32 '101': u32 | 1680 | 28..31 '101': u32 |
1672 | 70..73 '101': u32 | 1681 | 69..72 '101': u32 |
1673 | 85..280 '{ ...MUT; }': () | 1682 | 84..279 '{ ...MUT; }': () |
1674 | 173..174 'x': u32 | 1683 | 172..173 'x': u32 |
1675 | 177..189 'LOCAL_STATIC': u32 | 1684 | 176..188 'LOCAL_STATIC': u32 |
1676 | 199..200 'y': u32 | 1685 | 198..199 'y': u32 |
1677 | 203..219 'LOCAL_...IC_MUT': u32 | 1686 | 202..218 'LOCAL_...IC_MUT': u32 |
1678 | 229..230 'z': u32 | 1687 | 228..229 'z': u32 |
1679 | 233..246 'GLOBAL_STATIC': u32 | 1688 | 232..245 'GLOBAL_STATIC': u32 |
1680 | 256..257 'w': u32 | 1689 | 255..256 'w': u32 |
1681 | 260..277 'GLOBAL...IC_MUT': u32 | 1690 | 259..276 'GLOBAL...IC_MUT': u32 |
1682 | 118..120 '99': u32 | 1691 | 117..119 '99': u32 |
1683 | 161..163 '99': u32 | 1692 | 160..162 '99': u32 |
1684 | "### | 1693 | "### |
1685 | ); | 1694 | ); |
1686 | } | 1695 | } |
1687 | 1696 | ||
1688 | #[test] | 1697 | #[test] |
1689 | fn shadowing_primitive() { | 1698 | fn shadowing_primitive() { |
1690 | let t = type_at( | 1699 | check_types( |
1691 | r#" | 1700 | r#" |
1692 | //- /main.rs | ||
1693 | struct i32; | 1701 | struct i32; |
1694 | struct Foo; | 1702 | struct Foo; |
1695 | 1703 | ||
@@ -1697,15 +1705,15 @@ impl i32 { fn foo(&self) -> Foo { Foo } } | |||
1697 | 1705 | ||
1698 | fn main() { | 1706 | fn main() { |
1699 | let x: i32 = i32; | 1707 | let x: i32 = i32; |
1700 | x.foo()<|>; | 1708 | x.foo(); |
1709 | //^ Foo | ||
1701 | }"#, | 1710 | }"#, |
1702 | ); | 1711 | ); |
1703 | assert_eq!(t, "Foo"); | ||
1704 | } | 1712 | } |
1705 | 1713 | ||
1706 | #[test] | 1714 | #[test] |
1707 | fn not_shadowing_primitive_by_module() { | 1715 | fn not_shadowing_primitive_by_module() { |
1708 | let t = type_at( | 1716 | check_types( |
1709 | r#" | 1717 | r#" |
1710 | //- /str.rs | 1718 | //- /str.rs |
1711 | fn foo() {} | 1719 | fn foo() {} |
@@ -1715,15 +1723,15 @@ mod str; | |||
1715 | fn foo() -> &'static str { "" } | 1723 | fn foo() -> &'static str { "" } |
1716 | 1724 | ||
1717 | fn main() { | 1725 | fn main() { |
1718 | foo()<|>; | 1726 | foo(); |
1727 | //^ &str | ||
1719 | }"#, | 1728 | }"#, |
1720 | ); | 1729 | ); |
1721 | assert_eq!(t, "&str"); | ||
1722 | } | 1730 | } |
1723 | 1731 | ||
1724 | #[test] | 1732 | #[test] |
1725 | fn not_shadowing_module_by_primitive() { | 1733 | fn not_shadowing_module_by_primitive() { |
1726 | let t = type_at( | 1734 | check_types( |
1727 | r#" | 1735 | r#" |
1728 | //- /str.rs | 1736 | //- /str.rs |
1729 | fn foo() -> u32 {0} | 1737 | fn foo() -> u32 {0} |
@@ -1733,10 +1741,38 @@ mod str; | |||
1733 | fn foo() -> &'static str { "" } | 1741 | fn foo() -> &'static str { "" } |
1734 | 1742 | ||
1735 | fn main() { | 1743 | fn main() { |
1736 | str::foo()<|>; | 1744 | str::foo(); |
1745 | //^ u32 | ||
1746 | }"#, | ||
1747 | ); | ||
1748 | } | ||
1749 | |||
1750 | // This test is actually testing the shadowing behavior within ra_hir_def. It | ||
1751 | // lives here because the testing infrastructure in ra_hir_def isn't currently | ||
1752 | // capable of asserting the necessary conditions. | ||
1753 | #[test] | ||
1754 | fn should_be_shadowing_imports() { | ||
1755 | check_types( | ||
1756 | r#" | ||
1757 | mod a { | ||
1758 | pub fn foo() -> i8 {0} | ||
1759 | pub struct foo { a: i8 } | ||
1760 | } | ||
1761 | mod b { pub fn foo () -> u8 {0} } | ||
1762 | mod c { pub struct foo { a: u8 } } | ||
1763 | mod d { | ||
1764 | pub use super::a::*; | ||
1765 | pub use super::c::foo; | ||
1766 | pub use super::b::foo; | ||
1767 | } | ||
1768 | |||
1769 | fn main() { | ||
1770 | d::foo(); | ||
1771 | //^ u8 | ||
1772 | d::foo{a:0}; | ||
1773 | //^ u8 | ||
1737 | }"#, | 1774 | }"#, |
1738 | ); | 1775 | ); |
1739 | assert_eq!(t, "u32"); | ||
1740 | } | 1776 | } |
1741 | 1777 | ||
1742 | #[test] | 1778 | #[test] |
@@ -1748,12 +1784,12 @@ fn foo() -> u32 { | |||
1748 | } | 1784 | } |
1749 | "#), | 1785 | "#), |
1750 | @r###" | 1786 | @r###" |
1751 | 17..59 '{ ...; }; }': () | 1787 | 16..58 '{ ...; }; }': () |
1752 | 27..28 'x': || -> usize | 1788 | 26..27 'x': || -> usize |
1753 | 31..56 '|| -> ...n 1; }': || -> usize | 1789 | 30..55 '|| -> ...n 1; }': || -> usize |
1754 | 43..56 '{ return 1; }': usize | 1790 | 42..55 '{ return 1; }': usize |
1755 | 45..53 'return 1': ! | 1791 | 44..52 'return 1': ! |
1756 | 52..53 '1': usize | 1792 | 51..52 '1': usize |
1757 | "### | 1793 | "### |
1758 | ); | 1794 | ); |
1759 | } | 1795 | } |
@@ -1767,11 +1803,11 @@ fn foo() -> u32 { | |||
1767 | } | 1803 | } |
1768 | "#), | 1804 | "#), |
1769 | @r###" | 1805 | @r###" |
1770 | 17..48 '{ ...; }; }': () | 1806 | 16..47 '{ ...; }; }': () |
1771 | 27..28 'x': || -> () | 1807 | 26..27 'x': || -> () |
1772 | 31..45 '|| { return; }': || -> () | 1808 | 30..44 '|| { return; }': || -> () |
1773 | 34..45 '{ return; }': () | 1809 | 33..44 '{ return; }': () |
1774 | 36..42 'return': ! | 1810 | 35..41 'return': ! |
1775 | "### | 1811 | "### |
1776 | ); | 1812 | ); |
1777 | } | 1813 | } |
@@ -1785,11 +1821,11 @@ fn foo() -> u32 { | |||
1785 | } | 1821 | } |
1786 | "#), | 1822 | "#), |
1787 | @r###" | 1823 | @r###" |
1788 | 17..47 '{ ..." }; }': () | 1824 | 16..46 '{ ..." }; }': () |
1789 | 27..28 'x': || -> &str | 1825 | 26..27 'x': || -> &str |
1790 | 31..44 '|| { "test" }': || -> &str | 1826 | 30..43 '|| { "test" }': || -> &str |
1791 | 34..44 '{ "test" }': &str | 1827 | 33..43 '{ "test" }': &str |
1792 | 36..42 '"test"': &str | 1828 | 35..41 '"test"': &str |
1793 | "### | 1829 | "### |
1794 | ); | 1830 | ); |
1795 | } | 1831 | } |
@@ -1808,14 +1844,14 @@ fn main() { | |||
1808 | } | 1844 | } |
1809 | "#), | 1845 | "#), |
1810 | @r###" | 1846 | @r###" |
1811 | 48..121 '{ ...hod; }': () | 1847 | 47..120 '{ ...hod; }': () |
1812 | 58..64 'vtable': Vtable | 1848 | 57..63 'vtable': Vtable |
1813 | 67..91 'Vtable...| {} }': Vtable | 1849 | 66..90 'Vtable...| {} }': Vtable |
1814 | 84..89 '|| {}': || -> () | 1850 | 83..88 '|| {}': || -> () |
1815 | 87..89 '{}': () | 1851 | 86..88 '{}': () |
1816 | 101..102 'm': fn() | 1852 | 100..101 'm': fn() |
1817 | 105..111 'vtable': Vtable | 1853 | 104..110 'vtable': Vtable |
1818 | 105..118 'vtable.method': fn() | 1854 | 104..117 'vtable.method': fn() |
1819 | "### | 1855 | "### |
1820 | ); | 1856 | ); |
1821 | } | 1857 | } |
@@ -1832,22 +1868,23 @@ fn main() { | |||
1832 | } | 1868 | } |
1833 | "#), | 1869 | "#), |
1834 | @r###" | 1870 | @r###" |
1835 | 11..131 '{ ...2 }; }': () | 1871 | 10..130 '{ ...2 }; }': () |
1836 | 21..22 'x': i32 | 1872 | 20..21 'x': i32 |
1837 | 32..38 '{ 92 }': i32 | 1873 | 24..37 'unsafe { 92 }': i32 |
1838 | 34..36 '92': i32 | 1874 | 31..37 '{ 92 }': i32 |
1839 | 48..49 'y': {unknown} | 1875 | 33..35 '92': i32 |
1840 | 58..80 '{ asyn...wait }': {unknown} | 1876 | 47..48 'y': {unknown} |
1841 | 60..78 'async ....await': {unknown} | 1877 | 57..79 '{ asyn...wait }': {unknown} |
1842 | 66..72 '{ () }': () | 1878 | 59..77 'async ....await': {unknown} |
1843 | 68..70 '()': () | 1879 | 65..71 '{ () }': () |
1844 | 90..91 'z': {unknown} | 1880 | 67..69 '()': () |
1845 | 94..104 'try { () }': {unknown} | 1881 | 89..90 'z': {unknown} |
1846 | 98..104 '{ () }': () | 1882 | 93..103 'try { () }': {unknown} |
1847 | 100..102 '()': () | 1883 | 97..103 '{ () }': () |
1848 | 114..115 't': i32 | 1884 | 99..101 '()': () |
1849 | 122..128 '{ 92 }': i32 | 1885 | 113..114 't': i32 |
1850 | 124..126 '92': i32 | 1886 | 121..127 '{ 92 }': i32 |
1887 | 123..125 '92': i32 | ||
1851 | "### | 1888 | "### |
1852 | ) | 1889 | ) |
1853 | } | 1890 | } |
@@ -1867,16 +1904,16 @@ fn test() { | |||
1867 | } | 1904 | } |
1868 | "#), | 1905 | "#), |
1869 | @r###" | 1906 | @r###" |
1870 | 60..130 '{ ... } }': () | 1907 | 59..129 '{ ... } }': () |
1871 | 70..77 'mut end': Option<bool> | 1908 | 69..76 'mut end': Option<bool> |
1872 | 80..84 'None': Option<bool> | 1909 | 79..83 'None': Option<bool> |
1873 | 90..128 'loop {... }': ! | 1910 | 89..127 'loop {... }': ! |
1874 | 95..128 '{ ... }': () | 1911 | 94..127 '{ ... }': () |
1875 | 105..108 'end': Option<bool> | 1912 | 104..107 'end': Option<bool> |
1876 | 105..121 'end = ...(true)': () | 1913 | 104..120 'end = ...(true)': () |
1877 | 111..115 'Some': Some<bool>(bool) -> Option<bool> | 1914 | 110..114 'Some': Some<bool>(bool) -> Option<bool> |
1878 | 111..121 'Some(true)': Option<bool> | 1915 | 110..120 'Some(true)': Option<bool> |
1879 | 116..120 'true': bool | 1916 | 115..119 'true': bool |
1880 | "### | 1917 | "### |
1881 | ); | 1918 | ); |
1882 | } | 1919 | } |
@@ -1899,19 +1936,19 @@ fn test() { | |||
1899 | } | 1936 | } |
1900 | "#), | 1937 | "#), |
1901 | @r###" | 1938 | @r###" |
1902 | 60..169 '{ ... }; }': () | 1939 | 59..168 '{ ... }; }': () |
1903 | 70..71 'x': Option<bool> | 1940 | 69..70 'x': Option<bool> |
1904 | 74..166 'loop {... }': Option<bool> | 1941 | 73..165 'loop {... }': Option<bool> |
1905 | 79..166 '{ ... }': () | 1942 | 78..165 '{ ... }': () |
1906 | 89..133 'if fal... }': () | 1943 | 88..132 'if fal... }': () |
1907 | 92..97 'false': bool | 1944 | 91..96 'false': bool |
1908 | 98..133 '{ ... }': () | 1945 | 97..132 '{ ... }': () |
1909 | 112..122 'break None': ! | 1946 | 111..121 'break None': ! |
1910 | 118..122 'None': Option<bool> | 1947 | 117..121 'None': Option<bool> |
1911 | 143..159 'break ...(true)': ! | 1948 | 142..158 'break ...(true)': ! |
1912 | 149..153 'Some': Some<bool>(bool) -> Option<bool> | 1949 | 148..152 'Some': Some<bool>(bool) -> Option<bool> |
1913 | 149..159 'Some(true)': Option<bool> | 1950 | 148..158 'Some(true)': Option<bool> |
1914 | 154..158 'true': bool | 1951 | 153..157 'true': bool |
1915 | "### | 1952 | "### |
1916 | ); | 1953 | ); |
1917 | } | 1954 | } |
@@ -1932,14 +1969,14 @@ fn test() { | |||
1932 | } | 1969 | } |
1933 | "#), | 1970 | "#), |
1934 | @r###" | 1971 | @r###" |
1935 | 60..137 '{ ... }; }': () | 1972 | 59..136 '{ ... }; }': () |
1936 | 70..71 'x': () | 1973 | 69..70 'x': () |
1937 | 74..134 'loop {... }': () | 1974 | 73..133 'loop {... }': () |
1938 | 79..134 '{ ... }': () | 1975 | 78..133 '{ ... }': () |
1939 | 89..128 'if fal... }': () | 1976 | 88..127 'if fal... }': () |
1940 | 92..97 'false': bool | 1977 | 91..96 'false': bool |
1941 | 98..128 '{ ... }': () | 1978 | 97..127 '{ ... }': () |
1942 | 112..117 'break': ! | 1979 | 111..116 'break': ! |
1943 | "### | 1980 | "### |
1944 | ); | 1981 | ); |
1945 | } | 1982 | } |
@@ -1964,36 +2001,189 @@ fn foo() { | |||
1964 | } | 2001 | } |
1965 | "#), | 2002 | "#), |
1966 | @r###" | 2003 | @r###" |
1967 | 10..336 '{ ... }; }': () | 2004 | 9..335 '{ ... }; }': () |
1968 | 20..22 '_x': || -> bool | 2005 | 19..21 '_x': || -> bool |
1969 | 25..333 '|| 'ou... }': || -> bool | 2006 | 24..332 '|| 'ou... }': || -> bool |
1970 | 28..333 ''outer... }': bool | 2007 | 27..332 ''outer... }': bool |
1971 | 41..333 '{ ... }': () | 2008 | 40..332 '{ ... }': () |
1972 | 55..60 'inner': i8 | 2009 | 54..59 'inner': i8 |
1973 | 63..301 ''inner... }': i8 | 2010 | 62..300 ''inner... }': i8 |
1974 | 76..301 '{ ... }': () | 2011 | 75..300 '{ ... }': () |
1975 | 94..95 'i': bool | 2012 | 93..94 'i': bool |
1976 | 98..114 'Defaul...efault': {unknown} | 2013 | 97..113 'Defaul...efault': {unknown} |
1977 | 98..116 'Defaul...ault()': bool | 2014 | 97..115 'Defaul...ault()': bool |
1978 | 130..270 'if (br... }': () | 2015 | 129..269 'if (br... }': () |
1979 | 134..148 'break 'outer i': ! | 2016 | 133..147 'break 'outer i': ! |
1980 | 147..148 'i': bool | 2017 | 146..147 'i': bool |
1981 | 150..209 '{ ... }': () | 2018 | 149..208 '{ ... }': () |
1982 | 168..194 'loop {...5i8; }': ! | 2019 | 167..193 'loop {...5i8; }': ! |
1983 | 173..194 '{ brea...5i8; }': () | 2020 | 172..193 '{ brea...5i8; }': () |
1984 | 175..191 'break ...er 5i8': ! | 2021 | 174..190 'break ...er 5i8': ! |
1985 | 188..191 '5i8': i8 | 2022 | 187..190 '5i8': i8 |
1986 | 215..270 'if tru... }': () | 2023 | 214..269 'if tru... }': () |
1987 | 218..222 'true': bool | 2024 | 217..221 'true': bool |
1988 | 223..270 '{ ... }': () | 2025 | 222..269 '{ ... }': () |
1989 | 241..255 'break 'inner 6': ! | 2026 | 240..254 'break 'inner 6': ! |
1990 | 254..255 '6': i8 | 2027 | 253..254 '6': i8 |
1991 | 283..290 'break 7': ! | 2028 | 282..289 'break 7': ! |
1992 | 289..290 '7': i8 | 2029 | 288..289 '7': i8 |
1993 | 311..326 'break inner < 8': ! | 2030 | 310..325 'break inner < 8': ! |
1994 | 317..322 'inner': i8 | 2031 | 316..321 'inner': i8 |
1995 | 317..326 'inner < 8': bool | 2032 | 316..325 'inner < 8': bool |
1996 | 325..326 '8': i8 | 2033 | 324..325 '8': i8 |
2034 | "### | ||
2035 | ); | ||
2036 | } | ||
2037 | |||
2038 | #[test] | ||
2039 | fn generic_default() { | ||
2040 | assert_snapshot!( | ||
2041 | infer(r#" | ||
2042 | struct Thing<T = ()> { t: T } | ||
2043 | enum OtherThing<T = ()> { | ||
2044 | One { t: T }, | ||
2045 | Two(T), | ||
2046 | } | ||
2047 | |||
2048 | fn test(t1: Thing, t2: OtherThing, t3: Thing<i32>, t4: OtherThing<i32>) { | ||
2049 | t1.t; | ||
2050 | t3.t; | ||
2051 | match t2 { | ||
2052 | OtherThing::One { t } => { t; }, | ||
2053 | OtherThing::Two(t) => { t; }, | ||
2054 | } | ||
2055 | match t4 { | ||
2056 | OtherThing::One { t } => { t; }, | ||
2057 | OtherThing::Two(t) => { t; }, | ||
2058 | } | ||
2059 | } | ||
2060 | "#), | ||
2061 | @r###" | ||
2062 | 97..99 't1': Thing<()> | ||
2063 | 108..110 't2': OtherThing<()> | ||
2064 | 124..126 't3': Thing<i32> | ||
2065 | 140..142 't4': OtherThing<i32> | ||
2066 | 161..384 '{ ... } }': () | ||
2067 | 167..169 't1': Thing<()> | ||
2068 | 167..171 't1.t': () | ||
2069 | 177..179 't3': Thing<i32> | ||
2070 | 177..181 't3.t': i32 | ||
2071 | 187..282 'match ... }': () | ||
2072 | 193..195 't2': OtherThing<()> | ||
2073 | 206..227 'OtherT... { t }': OtherThing<()> | ||
2074 | 224..225 't': () | ||
2075 | 231..237 '{ t; }': () | ||
2076 | 233..234 't': () | ||
2077 | 247..265 'OtherT...Two(t)': OtherThing<()> | ||
2078 | 263..264 't': () | ||
2079 | 269..275 '{ t; }': () | ||
2080 | 271..272 't': () | ||
2081 | 287..382 'match ... }': () | ||
2082 | 293..295 't4': OtherThing<i32> | ||
2083 | 306..327 'OtherT... { t }': OtherThing<i32> | ||
2084 | 324..325 't': i32 | ||
2085 | 331..337 '{ t; }': () | ||
2086 | 333..334 't': i32 | ||
2087 | 347..365 'OtherT...Two(t)': OtherThing<i32> | ||
2088 | 363..364 't': i32 | ||
2089 | 369..375 '{ t; }': () | ||
2090 | 371..372 't': i32 | ||
2091 | "### | ||
2092 | ); | ||
2093 | } | ||
2094 | |||
2095 | #[test] | ||
2096 | fn generic_default_in_struct_literal() { | ||
2097 | assert_snapshot!( | ||
2098 | infer(r#" | ||
2099 | struct Thing<T = ()> { t: T } | ||
2100 | enum OtherThing<T = ()> { | ||
2101 | One { t: T }, | ||
2102 | Two(T), | ||
2103 | } | ||
2104 | |||
2105 | fn test() { | ||
2106 | let x = Thing { t: loop {} }; | ||
2107 | let y = Thing { t: () }; | ||
2108 | let z = Thing { t: 1i32 }; | ||
2109 | if let Thing { t } = z { | ||
2110 | t; | ||
2111 | } | ||
2112 | |||
2113 | let a = OtherThing::One { t: 1i32 }; | ||
2114 | let b = OtherThing::Two(1i32); | ||
2115 | } | ||
2116 | "#), | ||
2117 | @r###" | ||
2118 | 99..319 '{ ...32); }': () | ||
2119 | 109..110 'x': Thing<!> | ||
2120 | 113..133 'Thing ...p {} }': Thing<!> | ||
2121 | 124..131 'loop {}': ! | ||
2122 | 129..131 '{}': () | ||
2123 | 143..144 'y': Thing<()> | ||
2124 | 147..162 'Thing { t: () }': Thing<()> | ||
2125 | 158..160 '()': () | ||
2126 | 172..173 'z': Thing<i32> | ||
2127 | 176..193 'Thing ...1i32 }': Thing<i32> | ||
2128 | 187..191 '1i32': i32 | ||
2129 | 199..240 'if let... }': () | ||
2130 | 206..217 'Thing { t }': Thing<i32> | ||
2131 | 214..215 't': i32 | ||
2132 | 220..221 'z': Thing<i32> | ||
2133 | 222..240 '{ ... }': () | ||
2134 | 232..233 't': i32 | ||
2135 | 250..251 'a': OtherThing<i32> | ||
2136 | 254..281 'OtherT...1i32 }': OtherThing<i32> | ||
2137 | 275..279 '1i32': i32 | ||
2138 | 291..292 'b': OtherThing<i32> | ||
2139 | 295..310 'OtherThing::Two': Two<i32>(i32) -> OtherThing<i32> | ||
2140 | 295..316 'OtherT...(1i32)': OtherThing<i32> | ||
2141 | 311..315 '1i32': i32 | ||
2142 | "### | ||
2143 | ); | ||
2144 | } | ||
2145 | |||
2146 | #[test] | ||
2147 | fn generic_default_depending_on_other_type_arg() { | ||
2148 | assert_snapshot!( | ||
2149 | infer(r#" | ||
2150 | struct Thing<T = u128, F = fn() -> T> { t: T } | ||
2151 | |||
2152 | fn test(t1: Thing<u32>, t2: Thing) { | ||
2153 | t1; | ||
2154 | t2; | ||
2155 | Thing::<_> { t: 1u32 }; | ||
2156 | } | ||
2157 | "#), | ||
2158 | // FIXME: the {unknown} is a bug | ||
2159 | @r###" | ||
2160 | 56..58 't1': Thing<u32, fn() -> u32> | ||
2161 | 72..74 't2': Thing<u128, fn() -> u128> | ||
2162 | 83..130 '{ ...2 }; }': () | ||
2163 | 89..91 't1': Thing<u32, fn() -> u32> | ||
2164 | 97..99 't2': Thing<u128, fn() -> u128> | ||
2165 | 105..127 'Thing:...1u32 }': Thing<u32, fn() -> {unknown}> | ||
2166 | 121..125 '1u32': u32 | ||
2167 | "### | ||
2168 | ); | ||
2169 | } | ||
2170 | |||
2171 | #[test] | ||
2172 | fn generic_default_depending_on_other_type_arg_forward() { | ||
2173 | assert_snapshot!( | ||
2174 | infer(r#" | ||
2175 | struct Thing<F = fn() -> T, T = u128> { t: T } | ||
2176 | |||
2177 | fn test(t1: Thing) { | ||
2178 | t1; | ||
2179 | } | ||
2180 | "#), | ||
2181 | // the {unknown} here is intentional, as defaults are not allowed to | ||
2182 | // refer to type parameters coming later | ||
2183 | @r###" | ||
2184 | 56..58 't1': Thing<fn() -> {unknown}, u128> | ||
2185 | 67..78 '{ t1; }': () | ||
2186 | 73..75 't1': Thing<fn() -> {unknown}, u128> | ||
1997 | "### | 2187 | "### |
1998 | ); | 2188 | ); |
1999 | } | 2189 | } |