-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Normalize type outlives obligations in NLL for new solver #120513
Normalize type outlives obligations in NLL for new solver #120513
Conversation
); | ||
let category = origin.to_constraint_category(); | ||
outlives.type_must_outlive(origin, sup_type, sub_region, category); | ||
// Must loop since the process of normalizing may itself register region obligations. |
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 don't know whether this is purely theoretical or if it could be used for unsoundness, actually.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…r-nll, r=<try> Normalize type outlives obligations in NLL for new solver Normalize the type outlives assumptions and obligations in MIR borrowck. This should fix any of the lazy-norm-related MIR borrowck problems. Also some cleanups from last PR: 1. Normalize obligations in a loop in lexical region resolution 2. Use `deeply_normalize_with_skipped_universes` in lexical resolution since we may have, e.g. `for<'a> Alias<'a>: 'b`. r? lcnr
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (78d5ab6): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 660.046s -> 659.99s (-0.01%) |
@@ -24,12 +24,13 @@ impl<'tcx> InferCtxtRegionExt<'tcx> for InferCtxt<'tcx> { | |||
let ty = self.resolve_vars_if_possible(ty); | |||
|
|||
if self.next_trait_solver() { | |||
crate::solve::deeply_normalize( | |||
crate::solve::deeply_normalize_with_skipped_universes( |
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.
probably nicer to change process_registered_region_obligations
to first rebind and then normalize instead of accepting skipped universes here?
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.
This is somewhat annoying, since then the deeply_normalize
predicate needs to take a PolyTypeOutlivesPredicate
here. When processing region obligations, these type outlives obligations are not bound, so we'd need to bind them up, and then skip their binder again. It just feels redundant :/
I'd rather do something like pass the outermost exclusive binder as part of normalize so we ICE if we find bound vars further than ty::INNERMOST
, and only when normalizing the param-envs.
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.
When processing region obligations, these type outlives obligations are not bound, so we'd need to bind them up, and then skip their binder again. It just feels redundant :/
I would prefer doing so and using ty::Binder::dummy(sup_type)
when normalizing region obligations 🤔 we can talk about this in sync, but I strongly dislike having escaping bound vars anywhere. And believe that having to think about escaping bound vars adds unnecessary mental complexity. While this is mostly vibe based, I do feel fairly strongly about this.
compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
Outdated
Show resolved
Hide resolved
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.
can you add a FIXME(-Znext-solver)
to both loops that its likely they'll have to handle infinite recursion somehow? can imagine this to cause hangs
870f77c
to
2c3e238
Compare
|
||
// In the new solver, normalize the type-outlives obligation assumptions. | ||
if self.infcx.next_trait_solver() { | ||
match deeply_normalize_with_skipped_universes( |
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.
this can definitely use deeply_normalize
by moving the rebind
eagerly :<
@@ -24,12 +24,13 @@ impl<'tcx> InferCtxtRegionExt<'tcx> for InferCtxt<'tcx> { | |||
let ty = self.resolve_vars_if_possible(ty); | |||
|
|||
if self.next_trait_solver() { | |||
crate::solve::deeply_normalize( | |||
crate::solve::deeply_normalize_with_skipped_universes( |
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.
When processing region obligations, these type outlives obligations are not bound, so we'd need to bind them up, and then skip their binder again. It just feels redundant :/
I would prefer doing so and using ty::Binder::dummy(sup_type)
when normalizing region obligations 🤔 we can talk about this in sync, but I strongly dislike having escaping bound vars anywhere. And believe that having to think about escaping bound vars adds unnecessary mental complexity. While this is mostly vibe based, I do feel fairly strongly about this.
2c3e238
to
e951bcf
Compare
@bors r+ rollup |
🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. |
@bors rollup=never |
@bors rollup=maybe |
…for-nll, r=lcnr Normalize type outlives obligations in NLL for new solver Normalize the type outlives assumptions and obligations in MIR borrowck. This should fix any of the lazy-norm-related MIR borrowck problems. Also some cleanups from last PR: 1. Normalize obligations in a loop in lexical region resolution 2. Use `deeply_normalize_with_skipped_universes` in lexical resolution since we may have, e.g. `for<'a> Alias<'a>: 'b`. r? lcnr
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#119614 (unstably allow constants to refer to statics and read from immutable statics) - rust-lang#119939 (Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items) - rust-lang#120206 (hir: Make sure all `HirId`s have corresponding HIR `Node`s) - rust-lang#120331 (pattern_analysis: use a plain `Vec` in `DeconstructedPat`) - rust-lang#120396 (Account for unbounded type param receiver in suggestions) - rust-lang#120423 (update indirect structural match lints to match RFC and to show up for dependencies) - rust-lang#120435 (Suggest name value cfg when only value is used for check-cfg) - rust-lang#120502 (Remove `ffi_returns_twice` feature) - rust-lang#120507 (Account for non-overlapping unmet trait bounds in suggestion) - rust-lang#120513 (Normalize type outlives obligations in NLL for new solver) r? `@ghost` `@rustbot` modify labels: rollup
…for-nll, r=lcnr Normalize type outlives obligations in NLL for new solver Normalize the type outlives assumptions and obligations in MIR borrowck. This should fix any of the lazy-norm-related MIR borrowck problems. Also some cleanups from last PR: 1. Normalize obligations in a loop in lexical region resolution 2. Use `deeply_normalize_with_skipped_universes` in lexical resolution since we may have, e.g. `for<'a> Alias<'a>: 'b`. r? lcnr
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#119939 (Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items) - rust-lang#120206 (hir: Make sure all `HirId`s have corresponding HIR `Node`s) - rust-lang#120331 (pattern_analysis: use a plain `Vec` in `DeconstructedPat`) - rust-lang#120396 (Account for unbounded type param receiver in suggestions) - rust-lang#120423 (update indirect structural match lints to match RFC and to show up for dependencies) - rust-lang#120435 (Suggest name value cfg when only value is used for check-cfg) - rust-lang#120502 (Remove `ffi_returns_twice` feature) - rust-lang#120507 (Account for non-overlapping unmet trait bounds in suggestion) - rust-lang#120513 (Normalize type outlives obligations in NLL for new solver) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#119939 (Improve 'generic param from outer item' error for `Self` and inside `static`/`const` items) - rust-lang#120331 (pattern_analysis: use a plain `Vec` in `DeconstructedPat`) - rust-lang#120396 (Account for unbounded type param receiver in suggestions) - rust-lang#120423 (update indirect structural match lints to match RFC and to show up for dependencies) - rust-lang#120435 (Suggest name value cfg when only value is used for check-cfg) - rust-lang#120502 (Remove `ffi_returns_twice` feature) - rust-lang#120507 (Account for non-overlapping unmet trait bounds in suggestion) - rust-lang#120513 (Normalize type outlives obligations in NLL for new solver) - rust-lang#120707 (Don't expect early-bound region to be local when reporting errors in RPITIT well-formedness) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120513 - compiler-errors:normalize-regions-for-nll, r=lcnr Normalize type outlives obligations in NLL for new solver Normalize the type outlives assumptions and obligations in MIR borrowck. This should fix any of the lazy-norm-related MIR borrowck problems. Also some cleanups from last PR: 1. Normalize obligations in a loop in lexical region resolution 2. Use `deeply_normalize_with_skipped_universes` in lexical resolution since we may have, e.g. `for<'a> Alias<'a>: 'b`. r? lcnr
Normalize the type outlives assumptions and obligations in MIR borrowck. This should fix any of the lazy-norm-related MIR borrowck problems.
Also some cleanups from last PR:
deeply_normalize_with_skipped_universes
in lexical resolution since we may have, e.g.for<'a> Alias<'a>: 'b
.r? lcnr