Auto merge of #46497 - AgustinCB:issue-46311, r=petrochenkov

Modify message for keyword as identifier name

This is a temporary solution to #46311.

The message is generic enough to cover both cases and is probably a fine enough solution to the specific problem described in the task. However, the underlying reason for this to be wrong is that `next_token_inner` returns `Lifetime` even if the token is a label. That's not simple, as the syntax for both can be quite similar and it may need to take a look to the next token to make a decision. I'm not sure I have enough knowledge about the project to be able to solve that (yet!), so I thought I'll fix the immediate problem first.
This commit is contained in:
bors 2017-12-07 21:05:49 +00:00
commit c8ddf28527
6 changed files with 46 additions and 23 deletions

View file

@ -8,16 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: -Z parse-only -Z continue-parse-after-error
trait Serializable<'self, T> { //~ ERROR lifetimes cannot use keyword names
fn serialize(val : &'self T) -> Vec<u8> ; //~ ERROR lifetimes cannot use keyword names
fn serialize(val : &'self T) -> Vec<u8>; //~ ERROR lifetimes cannot use keyword names
fn deserialize(repr : &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names
}
impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names
//~^ ERROR lifetimes cannot use keyword names
//~| ERROR missing lifetime specifier
fn serialize(val : &'self str) -> Vec<u8> { //~ ERROR lifetimes cannot use keyword names
vec![1]
}

View file

@ -0,0 +1,14 @@
// Copyright 2012-2014 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.
fn main() {
'break: loop { //~ ERROR invalid label name `'break`
}
}

View file

@ -8,11 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: -Z parse-only -Z continue-parse-after-error
fn foo<'a>(a: &'a isize) { }
fn bar(a: &'static isize) { }
fn baz(a: &'let isize) { } //~ ERROR lifetimes cannot use keyword names
fn zab(a: &'self isize) { } //~ ERROR lifetimes cannot use keyword names
fn baz<'let>(a: &'let isize) { } //~ ERROR lifetimes cannot use keyword names
//~^ ERROR lifetimes cannot use keyword names
fn zab<'self>(a: &'self isize) { } //~ ERROR lifetimes cannot use keyword names
//~^ ERROR lifetimes cannot use keyword names
fn main() { }