1
Fork 0

Rollup merge of #82720 - henryboisdequin:fix-79040, r=oli-obk

Fix diagnostic suggests adding type `[type error]`

Fixes #79040

### Unresolved questions:

<del>Why does this change output the diagnostic twice (`src/test/ui/79040.rs`)?</del> Thanks `````@oli-obk`````
This commit is contained in:
Yuki Okushi 2021-03-07 10:41:15 +09:00 committed by GitHub
commit a5a825e6a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 27 deletions

View file

@ -722,11 +722,12 @@ fn infer_placeholder_type(
format!("{}: {}", item_ident, ty),
Applicability::MachineApplicable,
)
.emit();
.emit_unless(ty.references_error());
}
None => {
let mut diag = bad_placeholder_type(tcx, vec![span]);
if !matches!(ty.kind(), ty::Error(_)) {
if !ty.references_error() {
diag.span_suggestion(
span,
"replace `_` with the correct type",
@ -734,6 +735,7 @@ fn infer_placeholder_type(
Applicability::MaybeIncorrect,
);
}
diag.emit();
}
}