Skip to content

Commit e7f72a2

Browse files
authored
Unrolled build for rust-lang#122360
Rollup merge of rust-lang#122360 - veera-sivarajan:bugfix-121941, r=compiler-errors Don't Create `ParamCandidate` When Obligation Contains Errors Fixes rust-lang#121941 I'm not sure if I understand this correctly but this bug was caused by an error type incorrectly matching against `ParamCandidate`. This was introduced by the changes made in rust-lang#72621 (figured using cargo-bisect-rustc). This PR fixes it by skipping `ParamCandidate` generation when an error type is involved. Also, this is similar to rust-lang#73005 but addresses `ParamCandidate` instead of `ImplCandidate`.
2 parents 5a6c1aa + 96b8225 commit e7f72a2

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+7
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
219219
) -> Result<(), SelectionError<'tcx>> {
220220
debug!(?stack.obligation);
221221

222+
// An error type will unify with anything. So, avoid
223+
// matching an error type with `ParamCandidate`.
224+
// This helps us avoid spurious errors like issue #121941.
225+
if stack.obligation.predicate.references_error() {
226+
return Ok(());
227+
}
228+
222229
let all_bounds = stack
223230
.obligation
224231
.param_env
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn function<T: PartialEq>() {
2+
foo == 2; //~ ERROR cannot find value `foo` in this scope [E0425]
3+
}
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find value `foo` in this scope
2+
--> $DIR/dont-match-error-ty-with-calller-supplied-obligation-issue-121941.rs:2:5
3+
|
4+
LL | foo == 2;
5+
| ^^^ not found in this scope
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)