From f701b4cca07d740d4d17c906ff982d40101ec09e Mon Sep 17 00:00:00 2001 From: Sunjay Varma Date: Wed, 13 Dec 2017 18:50:45 -0500 Subject: [PATCH] Added test to make sure that undeclared lifetimes are in fact detected --- ...ic_associated_type_undeclared_lifetimes.rs | 31 ++++++++++++++++++ ...ssociated_type_undeclared_lifetimes.stderr | 32 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs create mode 100644 src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr diff --git a/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs new file mode 100644 index 000000000000..263b3cb42eb4 --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.rs @@ -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 or the MIT license +// , 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> + //~^ ERROR lifetime parameters are not allowed on this type [E0110] + + Deref>; + //~^ 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() {} diff --git a/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr new file mode 100644 index 000000000000..587be7113cec --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/generic_associated_type_undeclared_lifetimes.stderr @@ -0,0 +1,32 @@ +error[E0261]: use of undeclared lifetime name `'b` + --> $DIR/generic_associated_type_undeclared_lifetimes.rs:22:37 + | +22 | + Deref>; + | ^^ 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> + | ^^ 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>; + | ^^ 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 +