-
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
Deny capturing late-bound non-lifetime param in anon const #108553
Deny capturing late-bound non-lifetime param in anon const #108553
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
Here, we should only ban late-bound types and const params. That's |
I could move the logic to |
@rustbot ready Advice would be appreciated whether the current strategy in the PR, or something like 4b05b4ae7e2721cd6d265e8e2b858c745f97f957, is preferable. |
Ok, let's land this as is for now. |
🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. |
…in-anon-ct, r=petrochenkov Deny capturing late-bound non-lifetime param in anon const Introduce a new AnonConstBoundary so we can detect when we capture a late-bound non-lifetime param with `non_lifetime_binders` enabled. In the future, we could technically do something like introduce an early-bound parameter on the anon const, and stick the late-bound param in its substs (kinda like how we turn late-bound lifetimes in opaques into early-bound ones). But for now, just deny it so we don't ICE. Fixes rust-lang#108191
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#107981 (new solver: implement canonicalization and region constraints) - rust-lang#108553 (Deny capturing late-bound non-lifetime param in anon const) - rust-lang#108599 (Remove legacy PM leftovers) - rust-lang#108667 (Fix another ICE in `point_at_expr_source_of_inferred_type`) - rust-lang#108674 (Clippy Fix array-size-threshold config deserialization error) - rust-lang#108685 (Match unmatched backticks in compiler/) - rust-lang#108694 (Match unmatched backticks in compiler/ comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…s, r=cjgillot Correctly deny late-bound lifetimes from parent in anon consts and TAITs Reuse the `AnonConstBoundary` scope (introduced in rust-lang#108553, renamed in this PR to `LateBoundary`) to deny late-bound vars of *all* kinds (ty/const/lifetime) in anon consts and TAITs. Side-note, but I would like to consolidate this with the error reporting for RPITs (E0657): https://github.com/rust-lang/rust/blob/c4f25777a08cd64b710e8a9a6159e67cbb35e6f5/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs#L733-L754 but the semantics about what we're allowed to capture there are slightly different, so I'm leaving that untouched. Fixes rust-lang#115474
…s, r=cjgillot Correctly deny late-bound lifetimes from parent in anon consts and TAITs Reuse the `AnonConstBoundary` scope (introduced in rust-lang#108553, renamed in this PR to `LateBoundary`) to deny late-bound vars of *all* kinds (ty/const/lifetime) in anon consts and TAITs. Side-note, but I would like to consolidate this with the error reporting for RPITs (E0657): https://github.com/rust-lang/rust/blob/c4f25777a08cd64b710e8a9a6159e67cbb35e6f5/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs#L733-L754 but the semantics about what we're allowed to capture there are slightly different, so I'm leaving that untouched. Fixes rust-lang#115474
…s, r=cjgillot Correctly deny late-bound lifetimes from parent in anon consts and TAITs Reuse the `AnonConstBoundary` scope (introduced in rust-lang#108553, renamed in this PR to `LateBoundary`) to deny late-bound vars of *all* kinds (ty/const/lifetime) in anon consts and TAITs. Side-note, but I would like to consolidate this with the error reporting for RPITs (E0657): https://github.com/rust-lang/rust/blob/c4f25777a08cd64b710e8a9a6159e67cbb35e6f5/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs#L733-L754 but the semantics about what we're allowed to capture there are slightly different, so I'm leaving that untouched. Fixes rust-lang#115474
Introduce a new AnonConstBoundary so we can detect when we capture a late-bound non-lifetime param with
non_lifetime_binders
enabled.In the future, we could technically do something like introduce an early-bound parameter on the anon const, and stick the late-bound param in its substs (kinda like how we turn late-bound lifetimes in opaques into early-bound ones). But for now, just deny it so we don't ICE.
Fixes #108191