diff options
| author | bors <bors@rust-lang.org> | 2016-10-28 13:42:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-28 13:42:23 -0700 |
| commit | f0ab4a4f2abb778361bca645b07661cd07c702bb (patch) | |
| tree | 804721f606ed4ed9d30afd83b845eacd3ea0d8ba /src | |
| parent | 421b595f25e5dbab9c967afd03929d013f346322 (diff) | |
| parent | 4a9364868949a5390d85d26af4d6562bc4a18fb3 (diff) | |
| download | rust-f0ab4a4f2abb778361bca645b07661cd07c702bb.tar.gz rust-f0ab4a4f2abb778361bca645b07661cd07c702bb.zip | |
Auto merge of #37367 - jseyfried:import_crate_root, r=nrc
Support `use *;` and `use ::*;`. Fixes #31484. r? @nrc
Diffstat (limited to 'src')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 13 | ||||
| -rw-r--r-- | src/test/run-pass/import-glob-crate.rs | 12 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index da5d754b599..d52d73d70d3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6145,15 +6145,20 @@ impl<'a> Parser<'a> { /// MOD_SEP? LBRACE item_seq RBRACE fn parse_view_path(&mut self) -> PResult<'a, P<ViewPath>> { let lo = self.span.lo; - if self.check(&token::OpenDelim(token::Brace)) || self.is_import_coupler() { - // `{foo, bar}` or `::{foo, bar}` + if self.check(&token::OpenDelim(token::Brace)) || self.check(&token::BinOp(token::Star)) || + self.is_import_coupler() { + // `{foo, bar}`, `::{foo, bar}`, `*`, or `::*`. let prefix = ast::Path { global: self.eat(&token::ModSep), segments: Vec::new(), span: mk_sp(lo, self.span.hi), }; - let items = self.parse_path_list_items()?; - Ok(P(spanned(lo, self.span.hi, ViewPathList(prefix, items)))) + let view_path_kind = if self.eat(&token::BinOp(token::Star)) { + ViewPathGlob(prefix) + } else { + ViewPathList(prefix, self.parse_path_list_items()?) + }; + Ok(P(spanned(lo, self.span.hi, view_path_kind))) } else { let prefix = self.parse_path(PathStyle::Mod)?; if self.is_import_coupler() { diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs index b2a9b08b01b..fec46c7e1f8 100644 --- a/src/test/run-pass/import-glob-crate.rs +++ b/src/test/run-pass/import-glob-crate.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![allow(dead_assignment)] - use std::mem::*; pub fn main() { @@ -20,3 +17,12 @@ pub fn main() { assert_eq!(x, 2); assert_eq!(y, 1); } + +#[allow(unused)] +fn f() { + mod foo { pub use *; } + mod bar { pub use ::*; } + + foo::main(); + bar::main(); +} |
