Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't Create ParamCandidate When Obligation Contains Errors #122360

Merged
merged 1 commit into from Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -219,6 +219,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
) -> Result<(), SelectionError<'tcx>> {
debug!(?stack.obligation);

// An error type will unify with anything. So, avoid
// matching an error type with `ParamCandidate`.
// This helps us avoid spurious errors like issue #121941.
if stack.obligation.predicate.references_error() {
return Ok(());
}

let all_bounds = stack
.obligation
.param_env
Expand Down
@@ -0,0 +1,5 @@
fn function<T: PartialEq>() {
foo == 2; //~ ERROR cannot find value `foo` in this scope [E0425]
}

fn main() {}
@@ -0,0 +1,9 @@
error[E0425]: cannot find value `foo` in this scope
--> $DIR/dont-match-error-ty-with-calller-supplied-obligation-issue-121941.rs:2:5
|
LL | foo == 2;
| ^^^ not found in this scope

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0425`.