File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff 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)
Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments