From 4768f5e7177159b894d65a50b1e4492cb4048ac3 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 22 Aug 2019 17:43:09 +0200 Subject: Improve/fix type bound lowering --- crates/ra_hir/src/ty/tests.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 41cea9564..c5818b738 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -3415,6 +3415,39 @@ fn test(x: Trait, y: &Trait) -> u64 { ); } +#[test] +fn weird_bounds() { + assert_snapshot_matches!( + infer(r#" +trait Trait {} +fn test() { + let a: impl Trait + 'lifetime = foo; + let b: impl 'lifetime = foo; + let b: impl (Trait) = foo; + let b: impl ('lifetime) = foo; + let d: impl ?Sized = foo; + let e: impl Trait + ?Sized = foo; +} +"#), + @r###" + ⋮ + ⋮[26; 237) '{ ...foo; }': () + ⋮[36; 37) 'a': impl Trait + {error} + ⋮[64; 67) 'foo': impl Trait + {error} + ⋮[77; 78) 'b': impl {error} + ⋮[97; 100) 'foo': impl {error} + ⋮[110; 111) 'b': impl Trait + ⋮[128; 131) 'foo': impl Trait + ⋮[141; 142) 'b': impl {error} + ⋮[163; 166) 'foo': impl {error} + ⋮[176; 177) 'd': impl {error} + ⋮[193; 196) 'foo': impl {error} + ⋮[206; 207) 'e': impl Trait + {error} + ⋮[231; 234) 'foo': impl Trait + {error} + "### + ); +} + fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { let file = db.parse(pos.file_id).ok().unwrap(); let expr = algo::find_node_at_offset::(file.syntax(), pos.offset).unwrap(); -- cgit v1.2.3