Skip to content

Commit 3a34641

Browse files
committed
Don't handle Self as a usage for TraitDefs
1 parent 04717b9 commit 3a34641

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

crates/ide/src/references.rs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,33 +1163,38 @@ fn foo<const FOO$0: usize>() -> usize {
11631163
}
11641164

11651165
#[test]
1166-
fn test_find_self_ty_in_trait_def() {
1166+
fn test_trait() {
11671167
check(
11681168
r#"
1169-
trait Foo where Self: {
1170-
fn f() -> Self$0;
1169+
trait Foo$0 where Self: {}
1170+
1171+
impl 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#"
1185+
trait Foo where Self$0 {
1186+
fn f() -> Self;
11711187
}
1188+
1189+
impl Foo for () {}
11721190
"#,
11731191
expect![[r#"
11741192
Self TypeParam FileId(0) 6..9 6..9
11751193
11761194
FileId(0) 16..20
1177-
FileId(0) 38..42
1195+
FileId(0) 37..41
11781196
"#]],
11791197
);
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-
// );
11931198
}
11941199

11951200
#[test]
@@ -1203,12 +1208,12 @@ trait Foo where Self: {
12031208
}
12041209
"#,
12051210
expect![[r#"
1206-
Foo Struct FileId(0) 0..11 7..10
1211+
Foo Struct FileId(0) 0..11 7..10
12071212
1208-
FileId(0) 18..21
1209-
FileId(0) 28..32
1210-
FileId(0) 50..54
1211-
"#]],
1213+
FileId(0) 18..21
1214+
FileId(0) 28..32
1215+
FileId(0) 50..54
1216+
"#]],
12121217
);
12131218
check(
12141219
r#"

crates/ide_db/src/search.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ fn def_to_ty(sema: &Semantics<RootDatabase>, def: &Definition) -> Option<hir::Ty
548548
let module = sema.to_module_def(root_file)?;
549549
Some(it.ty(sema.db, module))
550550
}
551-
ModuleDef::Trait(_it) => None, // FIXME turn trait into its self-type
552551
_ => None,
553552
},
554553
Definition::SelfType(it) => Some(it.self_ty(sema.db)),

0 commit comments

Comments
 (0)