diff options
Diffstat (limited to 'crates/ra_hir_ty/src/tests/traits.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 802937cb0..76e2198b6 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -393,11 +393,11 @@ fn test() -> u64 { | |||
393 | [54; 55) 'a': S | 393 | [54; 55) 'a': S |
394 | [58; 59) 'S': S(fn(u32) -> u64) -> S | 394 | [58; 59) 'S': S(fn(u32) -> u64) -> S |
395 | [58; 68) 'S(|i| 2*i)': S | 395 | [58; 68) 'S(|i| 2*i)': S |
396 | [60; 67) '|i| 2*i': |i32| -> i32 | 396 | [60; 67) '|i| 2*i': |u32| -> u64 |
397 | [61; 62) 'i': i32 | 397 | [61; 62) 'i': u32 |
398 | [64; 65) '2': i32 | 398 | [64; 65) '2': u32 |
399 | [64; 67) '2*i': i32 | 399 | [64; 67) '2*i': u32 |
400 | [66; 67) 'i': i32 | 400 | [66; 67) 'i': u32 |
401 | [78; 79) 'b': u64 | 401 | [78; 79) 'b': u64 |
402 | [82; 83) 'a': S | 402 | [82; 83) 'a': S |
403 | [82; 85) 'a.0': fn(u32) -> u64 | 403 | [82; 85) 'a.0': fn(u32) -> u64 |
@@ -427,6 +427,38 @@ fn indexing_arrays() { | |||
427 | } | 427 | } |
428 | 428 | ||
429 | #[test] | 429 | #[test] |
430 | fn infer_ops_index() { | ||
431 | let (db, pos) = TestDB::with_position( | ||
432 | r#" | ||
433 | //- /main.rs crate:main deps:std | ||
434 | |||
435 | struct Bar; | ||
436 | struct Foo; | ||
437 | |||
438 | impl std::ops::Index<u32> for Bar { | ||
439 | type Output = Foo; | ||
440 | } | ||
441 | |||
442 | fn test() { | ||
443 | let a = Bar; | ||
444 | let b = a[1]; | ||
445 | b<|>; | ||
446 | } | ||
447 | |||
448 | //- /std.rs crate:std | ||
449 | |||
450 | #[prelude_import] use ops::*; | ||
451 | mod ops { | ||
452 | pub trait Index<Idx> { | ||
453 | type Output; | ||
454 | } | ||
455 | } | ||
456 | "#, | ||
457 | ); | ||
458 | assert_eq!("Foo", type_at_pos(&db, pos)); | ||
459 | } | ||
460 | |||
461 | #[test] | ||
430 | fn deref_trait() { | 462 | fn deref_trait() { |
431 | let t = type_at( | 463 | let t = type_at( |
432 | r#" | 464 | r#" |