Skip to content

Commit daf2e36

Browse files
committed
Rollup merge of rust-lang#24057 - nikomatsakis:lifetime-shadowing-hard-error, r=huon
2 parents 4faf0be + 49f2a56 commit daf2e36

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

src/librustc/middle/resolve_lifetime.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl<'a> LifetimeContext<'a> {
507507
EarlyScope(_, lifetimes, s) |
508508
LateScope(lifetimes, s) => {
509509
if let Some((_, lifetime_def)) = search_lifetimes(lifetimes, lifetime) {
510-
self.sess.span_warn(
510+
self.sess.span_err(
511511
lifetime.span,
512512
&format!("lifetime name `{}` shadows another \
513513
lifetime name that is already in scope",
@@ -516,10 +516,6 @@ impl<'a> LifetimeContext<'a> {
516516
lifetime_def.span,
517517
&format!("shadowed lifetime `{}` declared here",
518518
token::get_name(lifetime.name)));
519-
self.sess.span_note(
520-
lifetime.span,
521-
"shadowed lifetimes are deprecated \
522-
and will become a hard error before 1.0");
523519
return;
524520
}
525521

src/test/compile-fail/shadowed-lifetime.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ struct Foo<'a>(&'a isize);
1515
impl<'a> Foo<'a> {
1616
//~^ NOTE shadowed lifetime `'a` declared here
1717
fn shadow_in_method<'a>(&'a self) -> &'a isize {
18-
//~^ WARNING lifetime name `'a` shadows another lifetime name that is already in scope
19-
//~| NOTE deprecated
18+
//~^ ERROR lifetime name `'a` shadows another lifetime name that is already in scope
2019
self.0
2120
}
2221

2322
fn shadow_in_type<'b>(&'b self) -> &'b isize {
2423
//~^ NOTE shadowed lifetime `'b` declared here
2524
let x: for<'b> fn(&'b isize) = panic!();
26-
//~^ WARNING lifetime name `'b` shadows another lifetime name that is already in scope
27-
//~| NOTE deprecated
25+
//~^ ERROR lifetime name `'b` shadows another lifetime name that is already in scope
2826
self.0
2927
}
3028

@@ -35,9 +33,4 @@ impl<'a> Foo<'a> {
3533
}
3634

3735
fn main() {
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
41-
// not be needed.
42-
let x: isize = 3_usize; //~ ERROR mismatched types
4336
}

src/test/run-pass/overloaded-index-assoc-list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<K,V> AssociationList<K,V> {
3535
impl<'a, K: PartialEq + std::fmt::Debug, V:Clone> Index<&'a K> for AssociationList<K,V> {
3636
type Output = V;
3737

38-
fn index<'a>(&'a self, index: &K) -> &'a V {
38+
fn index(&self, index: &K) -> &V {
3939
for pair in &self.pairs {
4040
if pair.key == *index {
4141
return &pair.value

0 commit comments

Comments
 (0)