From 3a346412cf8ce2f04e123195452bf1b1c86211a7 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 8 May 2021 23:30:19 +0200 Subject: Don't handle Self as a usage for TraitDefs --- crates/ide/src/references.rs | 49 ++++++++++++++++++++++++-------------------- crates/ide_db/src/search.rs | 1 - 2 files changed, 27 insertions(+), 23 deletions(-) (limited to 'crates') 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() -> usize { } #[test] - fn test_find_self_ty_in_trait_def() { + fn test_trait() { check( r#" -trait Foo where Self: { - fn f() -> Self$0; +trait Foo$0 where Self: {} + +impl Foo for () {} +"#, + expect![[r#" + Foo Trait FileId(0) 0..24 6..9 + + FileId(0) 31..34 + "#]], + ); + } + + #[test] + fn test_trait_self() { + check( + r#" +trait Foo where Self$0 { + fn f() -> Self; } + +impl Foo for () {} "#, expect![[r#" Self TypeParam FileId(0) 6..9 6..9 FileId(0) 16..20 - FileId(0) 38..42 + FileId(0) 37..41 "#]], ); - // check( - // r#" - // trait Foo$0 where Self: { - // fn f() -> Self; - // } - // "#, - // expect![[r#" - // Foo Trait FileId(0) 0..45 6..9 - - // FileId(0) 16..20 - // FileId(0) 38..42 - // "#]], - // ); } #[test] @@ -1203,12 +1208,12 @@ trait Foo where Self: { } "#, expect![[r#" - Foo Struct FileId(0) 0..11 7..10 + Foo Struct FileId(0) 0..11 7..10 - FileId(0) 18..21 - FileId(0) 28..32 - FileId(0) 50..54 - "#]], + FileId(0) 18..21 + FileId(0) 28..32 + FileId(0) 50..54 + "#]], ); check( 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, def: &Definition) -> Option None, // FIXME turn trait into its self-type _ => None, }, Definition::SelfType(it) => Some(it.self_ty(sema.db)), -- cgit v1.2.3