aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_ty/src/tests/simple.rs41
-rw-r--r--crates/hir_ty/src/tests/traits.rs51
2 files changed, 84 insertions, 8 deletions
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs
index b364c2e58..20ceb7415 100644
--- a/crates/hir_ty/src/tests/simple.rs
+++ b/crates/hir_ty/src/tests/simple.rs
@@ -2427,13 +2427,38 @@ fn infer_inner_type() {
2427 } 2427 }
2428 "#, 2428 "#,
2429 expect![[r#" 2429 expect![[r#"
2430 9..89 '{ ...eld; }': () 2430 9..89 '{ ...eld; }': ()
2431 47..48 's': S 2431 47..48 's': S
2432 51..65 'S { field: 0 }': S 2432 51..65 'S { field: 0 }': S
2433 62..63 '0': u32 2433 62..63 '0': u32
2434 75..76 'f': u32 2434 75..76 'f': u32
2435 79..80 's': S 2435 79..80 's': S
2436 79..86 's.field': u32 2436 79..86 's.field': u32
2437 "#]], 2437 "#]],
2438 );
2439}
2440
2441#[test]
2442fn infer_nested_inner_type() {
2443 check_infer(
2444 r#"
2445 fn foo() {
2446 {
2447 let s = S { field: 0 };
2448 let f = s.field;
2449 }
2450 struct S { field: u32 }
2451 }
2452 "#,
2453 expect![[r#"
2454 9..109 '{ ...32 } }': ()
2455 15..79 '{ ... }': ()
2456 29..30 's': S
2457 33..47 'S { field: 0 }': S
2458 44..45 '0': u32
2459 61..62 'f': u32
2460 65..66 's': S
2461 65..72 's.field': u32
2462 "#]],
2438 ); 2463 );
2439} 2464}
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index e5a3f95a6..e030f4a97 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -3151,3 +3151,54 @@ fn test() {
3151 "#, 3151 "#,
3152 ); 3152 );
3153} 3153}
3154
3155#[test]
3156fn inner_use() {
3157 check_types(
3158 r#"
3159mod m {
3160 pub trait Tr {
3161 fn method(&self) -> u8 { 0 }
3162 }
3163
3164 impl Tr for () {}
3165}
3166
3167fn f() {
3168 use m::Tr;
3169
3170 ().method();
3171 //^^^^^^^^^^^ u8
3172}
3173 "#,
3174 );
3175}
3176
3177#[test]
3178fn inner_use_in_block() {
3179 check_types(
3180 r#"
3181mod m {
3182 pub trait Tr {
3183 fn method(&self) -> u8 { 0 }
3184 }
3185
3186 impl Tr for () {}
3187}
3188
3189fn f() {
3190 {
3191 use m::Tr;
3192
3193 ().method();
3194 //^^^^^^^^^^^ u8
3195 }
3196
3197 {
3198 ().method();
3199 //^^^^^^^^^^^ {unknown}
3200 }
3201}
3202 "#,
3203 );
3204}