Rollup merge of #121803 - estebank:dont-mention-type-error-e0277, r=compiler-errors
Never say "`Trait` is implemented for `{type error}`" When a trait bound error occurs, we look for alternative types that would have made the bound succeed. For some reason `{type error}` sometimes would appear as a type that would do so. We now remove `{type error}` from the list in every case to avoid nonsensical `note`s.
This commit is contained in:
commit
06ca0de91c
2 changed files with 5 additions and 3 deletions
|
@ -1916,6 +1916,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
ct_op: |ct| ct.normalize(self.tcx, ty::ParamEnv::empty()),
|
ct_op: |ct| ct.normalize(self.tcx, ty::ParamEnv::empty()),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
if cand.references_error() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
err.highlighted_help(vec![
|
err.highlighted_help(vec![
|
||||||
StringPart::normal(format!("the trait `{}` ", cand.print_trait_sugared())),
|
StringPart::normal(format!("the trait `{}` ", cand.print_trait_sugared())),
|
||||||
StringPart::highlighted("is"),
|
StringPart::highlighted("is"),
|
||||||
|
@ -1940,7 +1943,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let other = if other { "other " } else { "" };
|
let other = if other { "other " } else { "" };
|
||||||
let report = |candidates: Vec<TraitRef<'tcx>>, err: &mut Diag<'_>| {
|
let report = |mut candidates: Vec<TraitRef<'tcx>>, err: &mut Diag<'_>| {
|
||||||
|
candidates.retain(|tr| !tr.references_error());
|
||||||
if candidates.is_empty() {
|
if candidates.is_empty() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
|
||||||
LL | foo::<Demo>()();
|
LL | foo::<Demo>()();
|
||||||
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
|
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
|
||||||
|
|
|
|
||||||
= help: the trait `TraitWAssocConst` is implemented for `{type error}`
|
|
||||||
note: required by a bound in `foo`
|
note: required by a bound in `foo`
|
||||||
--> $DIR/issue-105330.rs:11:11
|
--> $DIR/issue-105330.rs:11:11
|
||||||
|
|
|
|
||||||
|
@ -92,7 +91,6 @@ error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
|
||||||
LL | foo::<Demo>();
|
LL | foo::<Demo>();
|
||||||
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
|
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
|
||||||
|
|
|
|
||||||
= help: the trait `TraitWAssocConst` is implemented for `{type error}`
|
|
||||||
note: required by a bound in `foo`
|
note: required by a bound in `foo`
|
||||||
--> $DIR/issue-105330.rs:11:11
|
--> $DIR/issue-105330.rs:11:11
|
||||||
|
|
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue