Skip to content

Commit 0828efd

Browse files
committed
Reject syntax like use foo::bar::; and use foo:: as bar; and keywords in view path idents
1 parent 76ce1ea commit 0828efd

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5912,9 +5912,9 @@ impl<'a> Parser<'a> {
59125912
self.bump();
59135913

59145914
match self.token {
5915-
token::Ident(i, _) => {
5916-
self.bump();
5917-
path.push(i);
5915+
token::Ident(..) => {
5916+
let ident = self.parse_ident();
5917+
path.push(ident);
59185918
}
59195919

59205920
// foo::bar::{a,b,c}
@@ -5954,6 +5954,11 @@ impl<'a> Parser<'a> {
59545954
return P(spanned(lo, self.span.hi, ViewPathGlob(path)));
59555955
}
59565956

5957+
// fall-through for case foo::bar::;
5958+
token::Semi => {
5959+
self.span_err(self.span, "expected identifier or `{` or `*`, found `;`");
5960+
}
5961+
59575962
_ => break
59585963
}
59595964
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2015 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.
4+
//
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.
10+
11+
use std::any:: as foo; //~ ERROR expected identifier or `{` or `*`, found `as`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2015 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.
4+
//
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.
10+
11+
use std::any::; //~ ERROR expected identifier or `{` or `*`, found `;`

0 commit comments

Comments
 (0)