diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/associated-types/bound-lifetime-constrained.rs | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/associated-types/bound-lifetime-constrained.rs')
-rw-r--r-- | src/test/ui/associated-types/bound-lifetime-constrained.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/test/ui/associated-types/bound-lifetime-constrained.rs b/src/test/ui/associated-types/bound-lifetime-constrained.rs new file mode 100644 index 000000000..4e6754c86 --- /dev/null +++ b/src/test/ui/associated-types/bound-lifetime-constrained.rs @@ -0,0 +1,48 @@ +// revisions: func object clause + +#![allow(dead_code)] +#![feature(rustc_attrs)] + +trait Foo<'a> { + type Item; +} + +impl<'a> Foo<'a> for() { + type Item = (); +} + +// Check that appearing in a projection input in the argument is not enough: +#[cfg(func)] +fn func1(_: for<'a> fn(<() as Foo<'a>>::Item) -> &'a i32) { + //[func]~^ ERROR E0581 +} + +// Check that appearing in a projection input in the return still +// causes an error: +#[cfg(func)] +fn func2(_: for<'a> fn() -> <() as Foo<'a>>::Item) { + //[func]~^ ERROR E0581 +} + +#[cfg(object)] +fn object1(_: Box<dyn for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32>) { + //[object]~^ ERROR E0582 +} + +#[cfg(object)] +fn object2(_: Box<dyn for<'a> Fn() -> <() as Foo<'a>>::Item>) { + //[object]~^ ERROR E0582 +} + +#[cfg(clause)] +fn clause1<T>() where T: for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32 { + //[clause]~^ ERROR `Output` references lifetime `'a` +} + +#[cfg(clause)] +fn clause2<T>() where T: for<'a> Fn() -> <() as Foo<'a>>::Item { + //[clause]~^ ERROR `Output` references lifetime `'a` +} + +#[rustc_error] +fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error] |