Skip to content

Commit

Permalink
Added test to make sure that undeclared lifetimes are in fact detected
Browse files Browse the repository at this point in the history
  • Loading branch information
sunjay committed Dec 13, 2017
1 parent b90e9c9 commit f701b4c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(generic_associated_types)]

use std::ops::Deref;

//FIXME(#44265): "lifetime parameters are not allowed on this type" errors will be addressed in a
//follow-up PR

trait Iterable {
type Item<'a>;
type Iter<'a>: Iterator<Item = Self::Item<'a>>
//~^ ERROR lifetime parameters are not allowed on this type [E0110]
+ Deref<Target = Self::Item<'b>>;
//~^ ERROR undeclared lifetime
//~| ERROR lifetime parameters are not allowed on this type [E0110]

fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
//~^ ERROR undeclared lifetime
//~| ERROR lifetime parameters are not allowed on this type [E0110]
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37
|
22 | + Deref<Target = Self::Item<'b>>;
| ^^ undeclared lifetime

error[E0261]: use of undeclared lifetime name `'undeclared`
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:26:41
|
26 | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
| ^^^^^^^^^^^ undeclared lifetime

error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:20:47
|
20 | type Iter<'a>: Iterator<Item = Self::Item<'a>>
| ^^ lifetime parameter not allowed on this type

error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37
|
22 | + Deref<Target = Self::Item<'b>>;
| ^^ lifetime parameter not allowed on this type

error[E0110]: lifetime parameters are not allowed on this type
--> $DIR/generic_associated_type_undeclared_lifetimes.rs:26:41
|
26 | fn iter<'a>(&'a self) -> Self::Iter<'undeclared>;
| ^^^^^^^^^^^ lifetime parameter not allowed on this type

error: aborting due to 5 previous errors

0 comments on commit f701b4c

Please sign in to comment.