aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-08-22 16:43:09 +0100
committerFlorian Diebold <[email protected]>2019-08-22 20:58:29 +0100
commit4768f5e7177159b894d65a50b1e4492cb4048ac3 (patch)
treede5d4388124443eb51847a390f259acd44ef1a65 /crates/ra_hir/src/ty
parentb1a40042e8f595af0486cf1cc70b63be1ff302b3 (diff)
Improve/fix type bound lowering
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs33
1 files changed, 33 insertions, 0 deletions
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 {
3415 ); 3415 );
3416} 3416}
3417 3417
3418#[test]
3419fn weird_bounds() {
3420 assert_snapshot_matches!(
3421 infer(r#"
3422trait Trait {}
3423fn test() {
3424 let a: impl Trait + 'lifetime = foo;
3425 let b: impl 'lifetime = foo;
3426 let b: impl (Trait) = foo;
3427 let b: impl ('lifetime) = foo;
3428 let d: impl ?Sized = foo;
3429 let e: impl Trait + ?Sized = foo;
3430}
3431"#),
3432 @r###"
3433
3434 ⋮[26; 237) '{ ...foo; }': ()
3435 ⋮[36; 37) 'a': impl Trait + {error}
3436 ⋮[64; 67) 'foo': impl Trait + {error}
3437 ⋮[77; 78) 'b': impl {error}
3438 ⋮[97; 100) 'foo': impl {error}
3439 ⋮[110; 111) 'b': impl Trait
3440 ⋮[128; 131) 'foo': impl Trait
3441 ⋮[141; 142) 'b': impl {error}
3442 ⋮[163; 166) 'foo': impl {error}
3443 ⋮[176; 177) 'd': impl {error}
3444 ⋮[193; 196) 'foo': impl {error}
3445 ⋮[206; 207) 'e': impl Trait + {error}
3446 ⋮[231; 234) 'foo': impl Trait + {error}
3447 "###
3448 );
3449}
3450
3418fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String { 3451fn type_at_pos(db: &MockDatabase, pos: FilePosition) -> String {
3419 let file = db.parse(pos.file_id).ok().unwrap(); 3452 let file = db.parse(pos.file_id).ok().unwrap();
3420 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap(); 3453 let expr = algo::find_node_at_offset::<ast::Expr>(file.syntax(), pos.offset).unwrap();