Skip to content

Commit 3ef2df9

Browse files
committed
rollup merge of #21845: Potpourri/import-syntax
syntax like `use foo::bar::;` and `use foo:: as bar;` should be rejected, see issue #21629
2 parents 99b2bd4 + 0828efd commit 3ef2df9

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
@@ -5917,9 +5917,9 @@ impl<'a> Parser<'a> {
59175917
self.bump();
59185918

59195919
match self.token {
5920-
token::Ident(i, _) => {
5921-
self.bump();
5922-
path.push(i);
5920+
token::Ident(..) => {
5921+
let ident = self.parse_ident();
5922+
path.push(ident);
59235923
}
59245924

59255925
// foo::bar::{a,b,c}
@@ -5959,6 +5959,11 @@ impl<'a> Parser<'a> {
59595959
return P(spanned(lo, self.span.hi, ViewPathGlob(path)));
59605960
}
59615961

5962+
// fall-through for case foo::bar::;
5963+
token::Semi => {
5964+
self.span_err(self.span, "expected identifier or `{` or `*`, found `;`");
5965+
}
5966+
59625967
_ => break
59635968
}
59645969
}
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)