1 // Copyright 2013 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.
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.
11 // Test that shadowed lifetimes generate an error.
13 struct Foo<'a>(&'a isize);
16 //~^ HELP shadowed lifetime `'a` declared here
17 fn shadow_in_method<'a>(&'a self) -> &'a isize {
18 //~^ WARNING lifetime name `'a` shadows another lifetime name that is already in scope
23 fn shadow_in_type<'b>(&'b self) -> &'b isize {
24 //~^ HELP shadowed lifetime `'b` declared here
25 let x: for<'b> fn(&'b isize) = panic!();
26 //~^ WARNING lifetime name `'b` shadows another lifetime name that is already in scope
31 fn not_shadow_in_item<'b>(&'b self) {
32 struct Bar<'a, 'b>(&'a isize, &'b isize); // not a shadow, separate item
33 fn foo<'a, 'b>(x: &'a isize, y: &'b isize) { } // same
38 // intentional error that occurs after `resolve_lifetime` runs,
39 // just to ensure that this test fails to compile; when shadowed
40 // lifetimes become either an error or a proper lint, this will
42 let x: isize = 3us; //~ ERROR mismatched types