about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/lifetimes/elided-lifetime-in-const-param-type.rs12
-rw-r--r--tests/ui/lifetimes/elided-lifetime-in-const-param-type.stderr20
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/lifetimes/elided-lifetime-in-const-param-type.rs b/tests/ui/lifetimes/elided-lifetime-in-const-param-type.rs
new file mode 100644
index 00000000000..cdfd1327eae
--- /dev/null
+++ b/tests/ui/lifetimes/elided-lifetime-in-const-param-type.rs
@@ -0,0 +1,12 @@
+//! Regression test for <https://github.com/rust-lang/rust/issues/143413>
+//! The anonymous lifetime in `c(&())` is desugared by the resolver as an extra lifetime parameter
+//! at the end of the `for` binder. Verify that lowering creates the definition for that extra
+//! lifetime parameter before lowering `c(&())`.
+
+trait D {}
+
+type A = dyn for<const B: c(&())> D;
+//~^ ERROR cannot find type `c` in this scope
+//~| ERROR only lifetime parameters can be used in this context
+
+fn main() {}
diff --git a/tests/ui/lifetimes/elided-lifetime-in-const-param-type.stderr b/tests/ui/lifetimes/elided-lifetime-in-const-param-type.stderr
new file mode 100644
index 00000000000..c7f3c0cc0cd
--- /dev/null
+++ b/tests/ui/lifetimes/elided-lifetime-in-const-param-type.stderr
@@ -0,0 +1,20 @@
+error[E0412]: cannot find type `c` in this scope
+  --> $DIR/elided-lifetime-in-const-param-type.rs:8:27
+   |
+LL | type A = dyn for<const B: c(&())> D;
+   |                           ^ not found in this scope
+
+error[E0658]: only lifetime parameters can be used in this context
+  --> $DIR/elided-lifetime-in-const-param-type.rs:8:24
+   |
+LL | type A = dyn for<const B: c(&())> D;
+   |                        ^
+   |
+   = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
+   = help: add `#![feature(non_lifetime_binders)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0412, E0658.
+For more information about an error, try `rustc --explain E0412`.