-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #108553 - compiler-errors:non-lt-late-bound-in-anon-c…
…t, 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 #108191
- Loading branch information
Showing
5 changed files
with
121 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![feature(non_lifetime_binders, generic_const_exprs)] | ||
//~^ WARN the feature `non_lifetime_binders` is incomplete | ||
//~| WARN the feature `generic_const_exprs` is incomplete | ||
|
||
fn foo() -> usize | ||
where | ||
for<T> [i32; { let _: T = todo!(); 0 }]:, | ||
//~^ ERROR cannot capture late-bound type parameter in a constant | ||
{} | ||
|
||
fn main() {} |
27 changes: 27 additions & 0 deletions
27
tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/late-bound-in-anon-ct.rs:1:12 | ||
| | ||
LL | #![feature(non_lifetime_binders, generic_const_exprs)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/late-bound-in-anon-ct.rs:1:34 | ||
| | ||
LL | #![feature(non_lifetime_binders, generic_const_exprs)] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information | ||
|
||
error: cannot capture late-bound type parameter in a constant | ||
--> $DIR/late-bound-in-anon-ct.rs:7:27 | ||
| | ||
LL | for<T> [i32; { let _: T = todo!(); 0 }]:, | ||
| - ^ | ||
| | | ||
| parameter defined here | ||
|
||
error: aborting due to previous error; 2 warnings emitted | ||
|