aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-02-29 21:48:23 +0000
committerFlorian Diebold <[email protected]>2020-02-29 21:48:53 +0000
commit31171eed5eeab217280237e63ffe6adda62baf96 (patch)
tree0597ebf09ac6c3216477c4993a8f16686f0ca452 /crates/ra_hir_ty/src/tests
parente313efb9926be80a5d7614d800e425b6891cf7d9 (diff)
Do autoderef for indexing
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs
index 7d796d0b9..547010b35 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -568,6 +568,34 @@ mod ops {
568} 568}
569 569
570#[test] 570#[test]
571fn infer_ops_index_autoderef() {
572 let (db, pos) = TestDB::with_position(
573 r#"
574//- /main.rs crate:main deps:std
575fn test() {
576 let a = &[1u32, 2, 3];
577 let b = a[1];
578 b<|>;
579}
580
581//- /std.rs crate:std
582impl<T> ops::Index<u32> for [T] {
583 type Output = T;
584}
585
586#[prelude_import] use ops::*;
587mod ops {
588 #[lang = "index"]
589 pub trait Index<Idx> {
590 type Output;
591 }
592}
593"#,
594 );
595 assert_eq!("u32", type_at_pos(&db, pos));
596}
597
598#[test]
571fn deref_trait() { 599fn deref_trait() {
572 let t = type_at( 600 let t = type_at(
573 r#" 601 r#"