Skip to content

Commit 4dbb8b4

Browse files
Don't mark unknown type as implementing every notable trait
Because the new solver, will return "yes" for them (which is a good thing).
1 parent 760d378 commit 4dbb8b4

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

crates/ide/src/hover.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,12 @@ fn notable_traits<'db>(
483483
db: &'db RootDatabase,
484484
ty: &hir::Type<'db>,
485485
) -> Vec<(hir::Trait, Vec<(Option<hir::Type<'db>>, hir::Name)>)> {
486+
if ty.is_unknown() {
487+
// The trait solver returns "yes" to the question whether the error type
488+
// impls any trait, and we don't want to show it as having any notable trait.
489+
return Vec::new();
490+
}
491+
486492
db.notable_traits_in_deps(ty.krate(db).into())
487493
.iter()
488494
.flat_map(|it| &**it)

crates/ide/src/hover/tests.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11097,3 +11097,26 @@ impl Enum<'_, Borrowed> {
1109711097
"#]],
1109811098
);
1109911099
}
11100+
11101+
#[test]
11102+
fn unknown_should_not_implement_notable_traits() {
11103+
check(
11104+
r#"
11105+
//- minicore: future, iterator
11106+
fn foo() {
11107+
let x$0;
11108+
}
11109+
"#,
11110+
expect![[r#"
11111+
*x*
11112+
11113+
```rust
11114+
let x: {unknown}
11115+
```
11116+
11117+
---
11118+
11119+
no Drop
11120+
"#]],
11121+
);
11122+
}

0 commit comments

Comments
 (0)