fix flyimport showing other types in impl trait statement

This commit is contained in:
dfireBird 2024-02-13 19:31:04 +05:30
parent 9897662bf7
commit 0e47befaf3
No known key found for this signature in database
GPG Key ID: 26D522CA5FC2B93D
2 changed files with 21 additions and 0 deletions

View File

@ -238,6 +238,8 @@ fn import_on_the_fly(
(PathKind::Type { location }, ItemInNs::Types(ty)) => {
if matches!(location, TypeLocation::TypeBound) {
matches!(ty, ModuleDef::Trait(_))
} else if matches!(location, TypeLocation::ImplTrait) {
matches!(ty, ModuleDef::Trait(_)) || matches!(ty, ModuleDef::Module(_))
} else {
true
}

View File

@ -1397,3 +1397,22 @@ pub use bridge2::server2::Span2;
"#]],
);
}
#[test]
fn flyimport_only_traits_in_impl_trait_block() {
check(
r#"
//- /main.rs crate:main deps:dep
pub struct Bar;
impl Foo$0 for Bar { }
//- /lib.rs crate:dep
pub trait FooTrait;
pub struct FooStruct;
"#,
expect![[r#"
tt FooTrait (use dep::FooTrait)
"#]],
);
}