Skip to content

Commit f701b4c

Browse files
committed
Added test to make sure that undeclared lifetimes are in fact detected
1 parent b90e9c9 commit f701b4c

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(generic_associated_types)]
12+
13+
use std::ops::Deref;
14+
15+
//FIXME(#44265): "lifetime parameters are not allowed on this type" errors will be addressed in a
16+
//follow-up PR
17+
18+
trait Iterable {
19+
type Item<'a>;
20+
type Iter<'a>: Iterator<Item = Self::Item<'a>>
21+
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
22+
+ Deref<Target = Self::Item<'b>>;
23+
//~^ ERROR undeclared lifetime
24+
//~| ERROR lifetime parameters are not allowed on this type [E0110]
25+
26+
fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
27+
//~^ ERROR undeclared lifetime
28+
//~| ERROR lifetime parameters are not allowed on this type [E0110]
29+
}
30+
31+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error[E0261]: use of undeclared lifetime name `'b`
2+
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37
3+
|
4+
22 | + Deref<Target = Self::Item<'b>>;
5+
| ^^ undeclared lifetime
6+
7+
error[E0261]: use of undeclared lifetime name `'undeclared`
8+
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:26:41
9+
|
10+
26 | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
11+
| ^^^^^^^^^^^ undeclared lifetime
12+
13+
error[E0110]: lifetime parameters are not allowed on this type
14+
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:20:47
15+
|
16+
20 | type Iter<'a>: Iterator<Item = Self::Item<'a>>
17+
| ^^ lifetime parameter not allowed on this type
18+
19+
error[E0110]: lifetime parameters are not allowed on this type
20+
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37
21+
|
22+
22 | + Deref<Target = Self::Item<'b>>;
23+
| ^^ lifetime parameter not allowed on this type
24+
25+
error[E0110]: lifetime parameters are not allowed on this type
26+
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:26:41
27+
|
28+
26 | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
29+
| ^^^^^^^^^^^ lifetime parameter not allowed on this type
30+
31+
error: aborting due to 5 previous errors
32+

0 commit comments

Comments
 (0)