aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/ty/tests.rs33
-rw-r--r--crates/ra_hir/src/type_ref.rs6
2 files changed, 35 insertions, 4 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();
diff --git a/crates/ra_hir/src/type_ref.rs b/crates/ra_hir/src/type_ref.rs
index 949fa7a2c..fa91bfb22 100644
--- a/crates/ra_hir/src/type_ref.rs
+++ b/crates/ra_hir/src/type_ref.rs
@@ -136,7 +136,7 @@ pub(crate) fn type_bounds_from_ast(type_bounds_opt: Option<ast::TypeBoundList>)
136impl TypeBound { 136impl TypeBound {
137 pub(crate) fn from_ast(node: ast::TypeBound) -> Self { 137 pub(crate) fn from_ast(node: ast::TypeBound) -> Self {
138 match node.kind() { 138 match node.kind() {
139 Some(ast::TypeBoundKind::PathType(path_type)) => { 139 ast::TypeBoundKind::PathType(path_type) => {
140 let path = match path_type.path() { 140 let path = match path_type.path() {
141 Some(p) => p, 141 Some(p) => p,
142 None => return TypeBound::Error, 142 None => return TypeBound::Error,
@@ -147,9 +147,7 @@ impl TypeBound {
147 }; 147 };
148 TypeBound::Path(path) 148 TypeBound::Path(path)
149 } 149 }
150 Some(ast::TypeBoundKind::ForType(_)) | Some(ast::TypeBoundKind::Lifetime(_)) | None => { 150 ast::TypeBoundKind::ForType(_) | ast::TypeBoundKind::Lifetime(_) => TypeBound::Error,
151 TypeBound::Error
152 }
153 } 151 }
154 } 152 }
155} 153}