mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-27 18:26:19 +00:00
Merge pull request #20665 from ChayimFriedman2/error-notable
fix: Don't mark unknown type as implementing every notable trait
This commit is contained in:
commit
3a675445ac
2 changed files with 29 additions and 0 deletions
|
|
@ -483,6 +483,12 @@ fn notable_traits<'db>(
|
|||
db: &'db RootDatabase,
|
||||
ty: &hir::Type<'db>,
|
||||
) -> Vec<(hir::Trait, Vec<(Option<hir::Type<'db>>, 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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue