Skip to content

Commit dbd678b

Browse files
authored
Unrolled build for rust-lang#121803
Rollup merge of rust-lang#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.
2 parents e612d07 + dab3d5b commit dbd678b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19101910
ct_op: |ct| ct.normalize(self.tcx, ty::ParamEnv::empty()),
19111911
},
19121912
);
1913+
if cand.references_error() {
1914+
return false;
1915+
}
19131916
err.highlighted_help(vec![
19141917
StringPart::normal(format!("the trait `{}` ", cand.print_trait_sugared())),
19151918
StringPart::highlighted("is"),
@@ -1934,7 +1937,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19341937
}
19351938

19361939
let other = if other { "other " } else { "" };
1937-
let report = |candidates: Vec<TraitRef<'tcx>>, err: &mut Diag<'_>| {
1940+
let report = |mut candidates: Vec<TraitRef<'tcx>>, err: &mut Diag<'_>| {
1941+
candidates.retain(|tr| !tr.references_error());
19381942
if candidates.is_empty() {
19391943
return false;
19401944
}

tests/ui/associated-consts/issue-105330.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
5555
LL | foo::<Demo>()();
5656
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
5757
|
58-
= help: the trait `TraitWAssocConst` is implemented for `{type error}`
5958
note: required by a bound in `foo`
6059
--> $DIR/issue-105330.rs:11:11
6160
|
@@ -92,7 +91,6 @@ error[E0277]: the trait bound `Demo: TraitWAssocConst` is not satisfied
9291
LL | foo::<Demo>();
9392
| ^^^^ the trait `TraitWAssocConst` is not implemented for `Demo`
9493
|
95-
= help: the trait `TraitWAssocConst` is implemented for `{type error}`
9694
note: required by a bound in `foo`
9795
--> $DIR/issue-105330.rs:11:11
9896
|

0 commit comments

Comments
 (0)