From 4dbb8b4c6434ae639a52b2732a2e7fcf87d83165 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Mon, 15 Sep 2025 07:56:35 +0300 Subject: [PATCH] Don't mark unknown type as implementing every notable trait Because the new solver, will return "yes" for them (which is a good thing). --- crates/ide/src/hover.rs | 6 ++++++ crates/ide/src/hover/tests.rs | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 3f52303d74..03b9b36775 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -483,6 +483,12 @@ fn notable_traits<'db>( db: &'db RootDatabase, ty: &hir::Type<'db>, ) -> Vec<(hir::Trait, Vec<(Option>, hir::Name)>)> { + if ty.is_unknown() { + // The trait solver returns "yes" to the question whether the error type + // impls any trait, and we don't want to show it as having any notable trait. + return Vec::new(); + } + db.notable_traits_in_deps(ty.krate(db).into()) .iter() .flat_map(|it| &**it) diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 58d8a7edbe..a88c0c9866 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -11097,3 +11097,26 @@ impl Enum<'_, Borrowed> { "#]], ); } + +#[test] +fn unknown_should_not_implement_notable_traits() { + check( + r#" +//- minicore: future, iterator +fn foo() { + let x$0; +} + "#, + expect![[r#" + *x* + + ```rust + let x: {unknown} + ``` + + --- + + no Drop + "#]], + ); +}