-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Deeply normalize obligations in BestObligation
folder
#139564
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
Conversation
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
@@ -1,17 +1,9 @@ | |||
error[E0271]: type mismatch resolving `<dyn Trait<A = A, B = B> as SuperTrait>::A == B` | |||
error[E0271]: type mismatch resolving `A == B` |
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.
AliasRelate
goals are negatively affected by this PR, which should make sense b/c we're normalizing the LHS and RHS; we probably should special-case ProjectionPredicate
s, since handling AliasRelate
predicates is already kinda weird:
rust/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
Lines 1422 to 1465 in d4f880f
ty::PredicateKind::AliasRelate(lhs, rhs, _) => { | |
let derive_better_type_error = | |
|alias_term: ty::AliasTerm<'tcx>, expected_term: ty::Term<'tcx>| { | |
let ocx = ObligationCtxt::new(self); | |
let Ok(normalized_term) = ocx.structurally_normalize_term( | |
&ObligationCause::dummy(), | |
obligation.param_env, | |
alias_term.to_term(self.tcx), | |
) else { | |
return None; | |
}; | |
if let Err(terr) = ocx.eq( | |
&ObligationCause::dummy(), | |
obligation.param_env, | |
expected_term, | |
normalized_term, | |
) { | |
Some((terr, self.resolve_vars_if_possible(normalized_term))) | |
} else { | |
None | |
} | |
}; | |
if let Some(lhs) = lhs.to_alias_term() | |
&& let Some((better_type_err, expected_term)) = | |
derive_better_type_error(lhs, rhs) | |
{ | |
( | |
Some((lhs, self.resolve_vars_if_possible(expected_term), rhs)), | |
better_type_err, | |
) | |
} else if let Some(rhs) = rhs.to_alias_term() | |
&& let Some((better_type_err, expected_term)) = | |
derive_better_type_error(rhs, lhs) | |
{ | |
( | |
Some((rhs, self.resolve_vars_if_possible(expected_term), lhs)), | |
better_type_err, | |
) | |
} else { | |
(None, error.err) | |
} |
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.
hmm yeah, I feel like we should do the "alias-relate -> normalization failure" transformation in the BestObligation
visitor instead maybe 🤔
This is definitely worse... also in the next-solver/async.rs#fail
test
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.
I'd rather defer this to a different PR. Right now the regression seems like a logical consequence of this implementation, and I'll play around with a fix for the AliasRelate
regression separately.
.unwrap_or_else(|_: Vec<ScrubbedTraitError<'tcx>>| ty.super_fold_with(self)) | ||
self.at | ||
.infcx | ||
.commit_if_ok(|_| { |
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.
commit_if_ok
b/c we shouldn't apply inference/opaque side-effects if the nested goals don't hold.
☔ The latest upstream changes (presumably #139555) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
so the idea is to deeply normalize the resulting obligations, but not deeply normalizing the goal we use to recur?
In that case, would it be easier to add a single deeply normalize call on the result of the visitor?
lol, I thought we didn't fold |
ae46b4e
to
4192cb6
Compare
@bors r+ rollup |
☔ The latest upstream changes (presumably #139595) made this pull request unmergeable. Please resolve the merge conflicts. |
4192cb6
to
decd7ec
Compare
@bors r=lcnr |
Rollup of 12 pull requests Successful merges: - rust-lang#137447 (add `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`) - rust-lang#138182 (rustc_target: update x86_win64 to match the documented calling convention for f128) - rust-lang#138682 (Allow drivers to supply a list of extra symbols to intern) - rust-lang#138904 (Test linking and running `no_std` binaries) - rust-lang#138998 (Don't suggest the use of `impl Trait` in closure parameter) - rust-lang#139447 (doc changes: debug assertions -> overflow checks) - rust-lang#139469 (Introduce a `//@ needs-crate-type` compiletest directive) - rust-lang#139564 (Deeply normalize obligations in `BestObligation` folder) - rust-lang#139574 (bootstrap: improve `channel` handling) - rust-lang#139600 (Update `compiler-builtins` to 0.1.153) - rust-lang#139641 (Allow parenthesis around inferred array lengths) - rust-lang#139654 (Improve `AssocItem::descr`.) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#139564 - compiler-errors:deeply-norm, r=lcnr Deeply normalize obligations in `BestObligation` folder Built on rust-lang#139513. This establishes a somewhat rough invariant that the `Obligation`'s predicate is always deeply normalized in the folder; when we construct a new obligation we normalize it. Putting this up for discussion since it does affect some goals. r? lcnr
Built on #139513.
This establishes a somewhat rough invariant that the
Obligation
's predicate is always deeply normalized in the folder; when we construct a new obligation we normalize it.Putting this up for discussion since it does affect some goals.
r? lcnr