aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-05-30 13:14:11 +0100
committerAleksey Kladov <[email protected]>2019-05-30 13:14:11 +0100
commitc6ee9d681c7c745e95f19badef271fec34ec2e36 (patch)
treeed0511c6c0927b14ea39bf9f34032260b588b2d4 /crates/ra_hir/src/ty/tests.rs
parent97158f5c8a6dadf3bcf28601f739ab6b7c4464aa (diff)
add tests for primitive types
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index da9aeec6d..c34e89af7 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -2717,6 +2717,24 @@ fn test() { (S {}).method()<|>; }
2717 assert_eq!(t, "{unknown}"); 2717 assert_eq!(t, "{unknown}");
2718} 2718}
2719 2719
2720#[test]
2721fn shadowing_primitive() {
2722 let t = type_at(
2723 r#"
2724//- /main.rs
2725struct i32;
2726struct Foo;
2727
2728impl i32 { fn foo(&self) -> Foo { Foo } }
2729
2730fn main() {
2731 let x: i32 = i32;
2732 x.foo()<|>;
2733}"#,
2734 );
2735 assert_eq!(t, "Foo");
2736}
2737
2720fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { 2738fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String {
2721 let file = db.parse(pos.file_id).ok().unwrap(); 2739 let file = db.parse(pos.file_id).ok().unwrap();
2722 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); 2740 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap();