aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-12-19 04:45:07 +0000
committerEdwin Cheng <[email protected]>2019-12-19 04:45:07 +0000
commitdddee23f43a0e1939124a607ba534e69a810843a (patch)
tree02fd55e52fcd54b43f218303b9a9fc2fd7d623b0 /crates/ra_hir_ty/src/tests
parent242f0ae1d8e6766091a6050431c3d417a43a2a3e (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.rs32
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]
430fn infer_ops_index() {
431 let (db, pos) = TestDB::with_position(
432 r#"
433//- /main.rs crate:main deps:std
434
435struct Bar;
436struct Foo;
437
438impl std::ops::Index<u32> for Bar {
439 type Output = Foo;
440}
441
442fn 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::*;
451mod 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]
430fn deref_trait() { 462fn deref_trait() {
431 let t = type_at( 463 let t = type_at(
432 r#" 464 r#"