diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
commit | a4b7ed7a42c716ab9f05e351f003d589124fd55d (patch) | |
tree | b620cd3f223850b28716e474e80c58059dca5dd4 /src/test/ui/regions/regions-name-undeclared.rs | |
parent | Adding upstream version 1.67.1+dfsg1. (diff) | |
download | rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip |
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/regions/regions-name-undeclared.rs')
-rw-r--r-- | src/test/ui/regions/regions-name-undeclared.rs | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/test/ui/regions/regions-name-undeclared.rs b/src/test/ui/regions/regions-name-undeclared.rs deleted file mode 100644 index 7b6ede193..000000000 --- a/src/test/ui/regions/regions-name-undeclared.rs +++ /dev/null @@ -1,58 +0,0 @@ -// edition:2018 -// Check that lifetime resolver enforces the lifetime name scoping -// rules correctly in various scenarios. - -struct Foo<'a> { - x: &'a isize -} - -impl<'a> Foo<'a> { - // &'a is inherited: - fn m1(&self, arg: &'a isize) { } - fn m2(&'a self) { } - fn m3(&self, arg: Foo<'a>) { } - - // &'b is not: - fn m4(&self, arg: &'b isize) { } //~ ERROR undeclared lifetime - fn m5(&'b self) { } //~ ERROR undeclared lifetime - fn m6(&self, arg: Foo<'b>) { } //~ ERROR undeclared lifetime -} - -fn bar<'a>(x: &'a isize) { - // &'a is visible to code: - let y: &'a isize = x; - - // &'a is not visible to *items*: - type X = Option<&'a isize>; //~ ERROR can't use generic parameters from outer item - enum E { - E1(&'a isize) //~ ERROR can't use generic parameters from outer item - } - struct S { - f: &'a isize //~ ERROR can't use generic parameters from outer item - } - fn f(a: &'a isize) { } //~ ERROR can't use generic parameters from outer item - - // &'a CAN be declared on functions and used then: - fn g<'a>(a: &'a isize) { } // OK - fn h(a: Box<dyn for<'a> FnOnce(&'a isize)>) { } // OK -} - -// Test nesting of lifetimes in fn type declarations -fn fn_types(a: &'a isize, //~ ERROR undeclared lifetime - b: Box<dyn for<'a> FnOnce(&'a isize, - &'b isize, //~ ERROR undeclared lifetime - Box<dyn for<'b> FnOnce(&'a isize, - &'b isize)>, - &'b isize)>, //~ ERROR undeclared lifetime - c: &'a isize) //~ ERROR undeclared lifetime -{ -} - -struct Bug {} -impl Bug { - async fn buggy(&self) -> &'a str { //~ ERROR use of undeclared lifetime name `'a` - todo!() - } -} - -pub fn main() {} |