diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-02 11:01:17 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-02 11:01:17 -0800 |
| commit | 3ef2df9e88ea20b661a8e313cf0e661595c516c9 (patch) | |
| tree | a39e4b2b6a64627cbe89f49381f391ebabd4fcbb | |
| parent | 99b2bd4bfa332c5a723114d09e8bb74d5a0c7376 (diff) | |
| parent | 0828efd72f0c1a1823426f327cddfbced535117a (diff) | |
rollup merge of #21845: Potpourri/import-syntax
syntax like `use foo::bar::;` and `use foo:: as bar;` should be rejected, see issue #21629
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 11 | ||||
| -rw-r--r-- | src/test/compile-fail/use-as-where-use-ends-with-mod-sep.rs | 11 | ||||
| -rw-r--r-- | src/test/compile-fail/use-ends-with-mod-sep.rs | 11 |
3 files changed, 30 insertions, 3 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c56734439eb..c3182602a4b 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5917,9 +5917,9 @@ impl<'a> Parser<'a> { self.bump(); match self.token { - token::Ident(i, _) => { - self.bump(); - path.push(i); + token::Ident(..) => { + let ident = self.parse_ident(); + path.push(ident); } // foo::bar::{a,b,c} @@ -5959,6 +5959,11 @@ impl<'a> Parser<'a> { return P(spanned(lo, self.span.hi, ViewPathGlob(path))); } + // fall-through for case foo::bar::; + token::Semi => { + self.span_err(self.span, "expected identifier or `{` or `*`, found `;`"); + } + _ => break } } diff --git a/src/test/compile-fail/use-as-where-use-ends-with-mod-sep.rs b/src/test/compile-fail/use-as-where-use-ends-with-mod-sep.rs new file mode 100644 index 00000000000..ef443fc125d --- /dev/null +++ b/src/test/compile-fail/use-as-where-use-ends-with-mod-sep.rs @@ -0,0 +1,11 @@ +// Copyright 2015 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. + +use std::any:: as foo; //~ ERROR expected identifier or `{` or `*`, found `as` diff --git a/src/test/compile-fail/use-ends-with-mod-sep.rs b/src/test/compile-fail/use-ends-with-mod-sep.rs new file mode 100644 index 00000000000..a375a5962a5 --- /dev/null +++ b/src/test/compile-fail/use-ends-with-mod-sep.rs @@ -0,0 +1,11 @@ +// Copyright 2015 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. + +use std::any::; //~ ERROR expected identifier or `{` or `*`, found `;` |
