diff options
author | Florian Diebold <[email protected]> | 2019-07-07 17:14:56 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-07-08 20:20:17 +0100 |
commit | 15862fc04183c7f9b3f3af666336a594a6a52cd9 (patch) | |
tree | 3593ee969c943d4881839e527e4305a1c3db2991 /crates/ra_hir/src/ty/tests.rs | |
parent | b1b12072eddaf989fb08ed7a2e39ec2dbbb83dde (diff) |
Use environment for associated type normalization as well
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 594e82af2..7340bb9bd 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -3010,6 +3010,25 @@ fn test<T>(t: T) { t.foo()<|>; } | |||
3010 | assert_eq!(t, "{unknown}"); | 3010 | assert_eq!(t, "{unknown}"); |
3011 | } | 3011 | } |
3012 | 3012 | ||
3013 | #[test] | ||
3014 | fn generic_param_env_deref() { | ||
3015 | let t = type_at( | ||
3016 | r#" | ||
3017 | //- /main.rs | ||
3018 | #[lang = "deref"] | ||
3019 | trait Deref { | ||
3020 | type Target; | ||
3021 | } | ||
3022 | trait Trait {} | ||
3023 | impl<T> Deref for T where T: Trait { | ||
3024 | type Target = i128; | ||
3025 | } | ||
3026 | fn test<T: Trait>(t: T) { (*t)<|>; } | ||
3027 | "#, | ||
3028 | ); | ||
3029 | assert_eq!(t, "i128"); | ||
3030 | } | ||
3031 | |||
3013 | fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { | 3032 | fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { |
3014 | let file = db.parse(pos.file_id).ok().unwrap(); | 3033 | let file = db.parse(pos.file_id).ok().unwrap(); |
3015 | let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); | 3034 | let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); |