diff options
author | Edwin Cheng <[email protected]> | 2019-12-19 04:45:07 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-12-19 04:45:07 +0000 |
commit | dddee23f43a0e1939124a607ba534e69a810843a (patch) | |
tree | 02fd55e52fcd54b43f218303b9a9fc2fd7d623b0 /crates/ra_hir_ty/src/tests | |
parent | 242f0ae1d8e6766091a6050431c3d417a43a2a3e (diff) |
Add std::ops::Index support for infering
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 802937cb0..2d92a5eec 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs | |||
@@ -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#" |