aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-21 14:01:48 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-21 14:01:48 +0100
commit5e1c29543cd49ab9f0833acbffd572d6b9f50da8 (patch)
tree1fdbd68757a878026c560cc133ddd3cc2672295e /crates/ra_hir/src/ty/tests.rs
parent7f94119171658523bc854e8c8b4b6da28378b468 (diff)
parent787fb3e5ec56494f3856bb1ce33cbe296265d199 (diff)
Merge #1182
1182: Add HIR for where clauses & ignore impls with where clauses in trait resolution r=matklad a=flodiebold This prevents any `impl<T> Trait for T where ...` from being treated as a blanket impl while we don't handle where clauses yet. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 86f18b487..a4c99528d 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -2477,6 +2477,23 @@ fn test() { (&S).foo()<|>; }
2477 assert_eq!(t, "u128"); 2477 assert_eq!(t, "u128");
2478} 2478}
2479 2479
2480#[test]
2481fn method_resolution_where_clause_not_met() {
2482 // The blanket impl shouldn't apply because we can't prove S: Clone
2483 let t = type_at(
2484 r#"
2485//- /main.rs
2486trait Clone {}
2487trait Trait { fn foo(self) -> u128; }
2488struct S;
2489impl S { fn foo(self) -> i8 { 0 } }
2490impl<T> Trait for T where T: Clone { fn foo(self) -> u128 { 0 } }
2491fn test() { (&S).foo()<|>; }
2492"#,
2493 );
2494 assert_eq!(t, "i8");
2495}
2496
2480fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { 2497fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String {
2481 let file = db.parse(pos.file_id); 2498 let file = db.parse(pos.file_id);
2482 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); 2499 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap();