From f479a7aa8d17dd3abab4f84fe9fe3e248e362eaf Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 2 Sep 2023 22:53:59 +0000 Subject: [PATCH] Restore some removed tests --- .../const-generics/late-bound-vars/in_closure.rs | 10 +--------- .../late-bound-vars/in_closure.stderr | 4 ++-- .../late-bound-in-return-issue-77357.rs | 13 +++++++++++++ .../late-bound-in-return-issue-77357.stderr | 8 ++++++++ .../late-bound-in-where-issue-83993.rs | 15 +++++++++++++++ .../late-bound-in-where-issue-83993.stderr | 10 ++++++++++ tests/ui/const-generics/late-bound-vars/simple.rs | 2 +- 7 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.rs create mode 100644 tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.stderr create mode 100644 tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.rs create mode 100644 tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.stderr diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.rs b/tests/ui/const-generics/late-bound-vars/in_closure.rs index 349e82fa45a..443c755c601 100644 --- a/tests/ui/const-generics/late-bound-vars/in_closure.rs +++ b/tests/ui/const-generics/late-bound-vars/in_closure.rs @@ -1,13 +1,5 @@ // known-bug: unknown - -// If we want this to compile, then we'd need to do something like RPITs do, -// where nested associated constants have early-bound versions of their captured -// late-bound vars inserted into their generics. This gives us substitutable -// lifetimes to actually use when borrow-checking the associated const, which is -// lowered as a totally separate body from its parent. Since this doesn't exist, -// so we should just error rather than resolving this late-bound var with no -// binder to actually attach it to, or worse, as a free region that can't even be -// substituted correctly, and ICEing. - @compiler-errors +// see comment on `tests/ui/const-generics/late-bound-vars/simple.rs` #![feature(generic_const_exprs)] #![allow(incomplete_features)] diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.stderr b/tests/ui/const-generics/late-bound-vars/in_closure.stderr index 275dd742ebd..e15496454a0 100644 --- a/tests/ui/const-generics/late-bound-vars/in_closure.stderr +++ b/tests/ui/const-generics/late-bound-vars/in_closure.stderr @@ -1,5 +1,5 @@ error: cannot capture late-bound lifetime in constant - --> $DIR/in_closure.rs:24:29 + --> $DIR/in_closure.rs:16:29 | LL | fn test<'a>() { | -- lifetime defined here @@ -8,7 +8,7 @@ LL | let _: [u8; inner::<'a>()]; | ^^ error: cannot capture late-bound lifetime in constant - --> $DIR/in_closure.rs:25:29 + --> $DIR/in_closure.rs:17:29 | LL | fn test<'a>() { | -- lifetime defined here diff --git a/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.rs b/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.rs new file mode 100644 index 00000000000..b81aa50d9a9 --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.rs @@ -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 {} + +fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> { + todo!() +} + +fn main() {} diff --git a/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.stderr b/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.stderr new file mode 100644 index 00000000000..21c8fe6865c --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.stderr @@ -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 + diff --git a/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.rs b/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.rs new file mode 100644 index 00000000000..89f01748fc9 --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.rs @@ -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() {} diff --git a/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.stderr b/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.stderr new file mode 100644 index 00000000000..a66dc8db914 --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.stderr @@ -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 + diff --git a/tests/ui/const-generics/late-bound-vars/simple.rs b/tests/ui/const-generics/late-bound-vars/simple.rs index c459419115a..a562bd8cb41 100644 --- a/tests/ui/const-generics/late-bound-vars/simple.rs +++ b/tests/ui/const-generics/late-bound-vars/simple.rs @@ -5,7 +5,7 @@ // late-bound vars inserted into their generics. This gives us substitutable // lifetimes to actually use when borrow-checking the associated const, which is // lowered as a totally separate body from its parent. Since this doesn't exist, -// so we should just error rather than resolving this late-bound var with no +// we should just error rather than resolving this late-bound var with no // binder to actually attach it to, or worse, as a free region that can't even be // substituted correctly, and ICEing. - @compiler-errors