aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ide/src/references.rs49
-rw-r--r--crates/ide_db/src/search.rs1
2 files changed, 27 insertions, 23 deletions
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs
index 1551cd2a8..ae492a264 100644
--- a/crates/ide/src/references.rs
+++ b/crates/ide/src/references.rs
@@ -1163,33 +1163,38 @@ fn foo<const FOO$0: usize>() -> usize {
1163 } 1163 }
1164 1164
1165 #[test] 1165 #[test]
1166 fn test_find_self_ty_in_trait_def() { 1166 fn test_trait() {
1167 check( 1167 check(
1168 r#" 1168 r#"
1169trait Foo where Self: { 1169trait Foo$0 where Self: {}
1170 fn f() -> Self$0; 1170
1171impl Foo for () {}
1172"#,
1173 expect![[r#"
1174 Foo Trait FileId(0) 0..24 6..9
1175
1176 FileId(0) 31..34
1177 "#]],
1178 );
1179 }
1180
1181 #[test]
1182 fn test_trait_self() {
1183 check(
1184 r#"
1185trait Foo where Self$0 {
1186 fn f() -> Self;
1171} 1187}
1188
1189impl Foo for () {}
1172"#, 1190"#,
1173 expect![[r#" 1191 expect![[r#"
1174 Self TypeParam FileId(0) 6..9 6..9 1192 Self TypeParam FileId(0) 6..9 6..9
1175 1193
1176 FileId(0) 16..20 1194 FileId(0) 16..20
1177 FileId(0) 38..42 1195 FileId(0) 37..41
1178 "#]], 1196 "#]],
1179 ); 1197 );
1180 // check(
1181 // r#"
1182 // trait Foo$0 where Self: {
1183 // fn f() -> Self;
1184 // }
1185 // "#,
1186 // expect![[r#"
1187 // Foo Trait FileId(0) 0..45 6..9
1188
1189 // FileId(0) 16..20
1190 // FileId(0) 38..42
1191 // "#]],
1192 // );
1193 } 1198 }
1194 1199
1195 #[test] 1200 #[test]
@@ -1203,12 +1208,12 @@ trait Foo where Self: {
1203 } 1208 }
1204 "#, 1209 "#,
1205 expect![[r#" 1210 expect![[r#"
1206 Foo Struct FileId(0) 0..11 7..10 1211 Foo Struct FileId(0) 0..11 7..10
1207 1212
1208 FileId(0) 18..21 1213 FileId(0) 18..21
1209 FileId(0) 28..32 1214 FileId(0) 28..32
1210 FileId(0) 50..54 1215 FileId(0) 50..54
1211 "#]], 1216 "#]],
1212 ); 1217 );
1213 check( 1218 check(
1214 r#" 1219 r#"
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs
index d8abef491..67840602b 100644
--- a/crates/ide_db/src/search.rs
+++ b/crates/ide_db/src/search.rs
@@ -548,7 +548,6 @@ fn def_to_ty(sema: &Semantics<RootDatabase>, def: &Definition) -> Option<hir::Ty
548 let module = sema.to_module_def(root_file)?; 548 let module = sema.to_module_def(root_file)?;
549 Some(it.ty(sema.db, module)) 549 Some(it.ty(sema.db, module))
550 } 550 }
551 ModuleDef::Trait(_it) => None, // FIXME turn trait into its self-type
552 _ => None, 551 _ => None,
553 }, 552 },
554 Definition::SelfType(it) => Some(it.self_ty(sema.db)), 553 Definition::SelfType(it) => Some(it.self_ty(sema.db)),