-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #115486 - compiler-errors:dont-capture-late-pls, r=cjgi…
…llot Correctly deny late-bound lifetimes from parent in anon consts and TAITs Reuse the `AnonConstBoundary` scope (introduced in #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 #115474
- Loading branch information
Showing
22 changed files
with
268 additions
and
150 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
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
30 changes: 20 additions & 10 deletions
30
tests/ui/const-generics/late-bound-vars/in_closure.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 |
---|---|---|
@@ -1,10 +1,20 @@ | ||
#0 [mir_borrowck] borrow-checking `test::{closure#0}::{constant#1}` | ||
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{closure#0}::{constant#1}` | ||
#2 [mir_for_ctfe] caching mir of `test::{closure#0}::{constant#1}` for CTFE | ||
#3 [eval_to_allocation_raw] const-evaluating + checking `test::{closure#0}::{constant#1}` | ||
#4 [eval_to_allocation_raw] const-evaluating + checking `test::{closure#0}::{constant#1}` | ||
#5 [eval_to_valtree] evaluating type-level constant | ||
#6 [typeck] type-checking `test` | ||
#7 [analysis] running analysis passes on this crate | ||
end of query stack | ||
error: aborting due to previous error | ||
error: cannot capture late-bound lifetime in constant | ||
--> $DIR/in_closure.rs:16:29 | ||
| | ||
LL | fn test<'a>() { | ||
| -- lifetime defined here | ||
LL | let _ = || { | ||
LL | let _: [u8; inner::<'a>()]; | ||
| ^^ | ||
|
||
error: cannot capture late-bound lifetime in constant | ||
--> $DIR/in_closure.rs:17:29 | ||
| | ||
LL | fn test<'a>() { | ||
| -- lifetime defined here | ||
... | ||
LL | let _ = [0; inner::<'a>()]; | ||
| ^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
13 changes: 13 additions & 0 deletions
13
tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.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,13 @@ | ||
// known-bug: unknown | ||
// see comment on `tests/ui/const-generics/late-bound-vars/simple.rs` | ||
|
||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
trait MyTrait<T> {} | ||
|
||
fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> { | ||
todo!() | ||
} | ||
|
||
fn main() {} |
8 changes: 8 additions & 0 deletions
8
tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.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,8 @@ | ||
error: cannot capture late-bound lifetime in constant | ||
--> $DIR/late-bound-in-return-issue-77357.rs:9:53 | ||
| | ||
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> { | ||
| -- lifetime defined here ^^ | ||
|
||
error: aborting due to previous error | ||
|
15 changes: 15 additions & 0 deletions
15
tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.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,15 @@ | ||
// known-bug: unknown | ||
// see comment on `tests/ui/const-generics/late-bound-vars/simple.rs` | ||
|
||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
fn bug<'a>() | ||
where | ||
for<'b> [(); { | ||
let x: &'b (); | ||
0 | ||
}]: | ||
{} | ||
|
||
fn main() {} |
10 changes: 10 additions & 0 deletions
10
tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.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,10 @@ | ||
error: cannot capture late-bound lifetime in constant | ||
--> $DIR/late-bound-in-where-issue-83993.rs:10:17 | ||
| | ||
LL | for<'b> [(); { | ||
| -- lifetime defined here | ||
LL | let x: &'b (); | ||
| ^^ | ||
|
||
error: aborting due to previous error | ||
|
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
Oops, something went wrong.