-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 impl candidates when obligation contains errors #73005
Conversation
Fixes rust-lang#72839 In PR rust-lang#72621, trait selection was modified to no longer bail out early when an error type was encountered. This allowed us treat `ty::Error` as `Sized`, causing us to avoid emitting a spurious "not sized" error after a type error had already occured. However, this means that we may now try to match an impl candidate against the error type. Since the error type will unify with almost anything, this can cause us to infinitely recurse (eventually triggering an overflow) when trying to verify certain `where` clauses. This commit causes us to skip generating any impl candidates when an error type is involved.
(rust_highfive has picked a reviewer for you, use r? to override) |
You'll need to re |
// emitting additional spurious errors, since we're guaranteed | ||
// to have emitted at least one. | ||
if stack.obligation.references_error() { | ||
debug!("no results for error type, treating as ambiguous"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a delay_span_bug
, just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With #70551, seeing an error type guarantees that delay_span_bug
has been called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me when CI is green then :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you want to wait for #70551, or can I r+ this now?
src/librustc_trait_selection/traits/select/candidate_assembly.rs
Outdated
Show resolved
Hide resolved
📌 Commit ae42c91 has been approved by |
Nominating for beta backport: while #72839 is 'only' a diagnostics issue, it's a very annoying one. When working on |
Rollup of 9 pull requests Successful merges: - rust-lang#72706 (Add windows group to triagebot) - rust-lang#72789 (resolve: Do not suggest imports from the same module in which we are resolving) - rust-lang#72890 (improper ctypes: normalize return types and transparent structs) - rust-lang#72897 (normalize adt fields during structural match checking) - rust-lang#73005 (Don't create impl candidates when obligation contains errors) - rust-lang#73023 (Remove noisy suggestion of hash_map ) - rust-lang#73070 (Add regression test for const generic ICE in rust-lang#72819) - rust-lang#73157 (Don't lose empty `where` clause when pretty-printing) - rust-lang#73184 (Reoder order in which MinGW libs are linked to fix recent breakage) Failed merges: r? @ghost
unilaterally accepting for beta-backport. |
@Aaron1011 -- on beta, it looks like src/librustc_trait_selection/traits/select/candidate_assembly.rs doesn't exist. Can you prepare a commit that backports this cleanly? (Or alternatively we can just not backport this as it's solely a diagnostics fix I guess?) |
@Mark-Simulacrum: I've created e461d2e |
Thanks, included. |
…ulacrum [beta] backports This PR backports the following: * Make novel structural match violations not a `bug` rust-lang#73446 * linker: Never pass `-no-pie` to non-gnu linkers rust-lang#73384 * Disable the `SimplifyArmIdentity` pass rust-lang#73262 * Allow inference regions when relating consts rust-lang#73225 * Fix link error with #[thread_local] introduced by rust-lang#71192 rust-lang#73065 * Ensure stack when building MIR for matches rust-lang#72941 * Don't create impl candidates when obligation contains errors rust-lang#73005 r? @ghost
…ompiler-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`.
…ompiler-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`.
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`.
Fixes #72839
In PR #72621, trait selection was modified to no longer bail out early
when an error type was encountered. This allowed us treat
ty::Error
asSized
, causing us to avoid emitting a spurious "not sized" error aftera type error had already occured.
However, this means that we may now try to match an impl candidate
against the error type. Since the error type will unify with almost
anything, this can cause us to infinitely recurse (eventually triggering
an overflow) when trying to verify certain
where
clauses.This commit causes us to skip generating any impl candidates when an
error type is involved.