Auto merge of #37367 - jseyfried:import_crate_root, r=nrc
Support `use *;` and `use ::*;`. Fixes #31484. r? @nrc
This commit is contained in:
commit
f0ab4a4f2a
|
@ -6145,15 +6145,20 @@ impl<'a> Parser<'a> {
|
||||||
/// MOD_SEP? LBRACE item_seq RBRACE
|
/// MOD_SEP? LBRACE item_seq RBRACE
|
||||||
fn parse_view_path(&mut self) -> PResult<'a, P<ViewPath>> {
|
fn parse_view_path(&mut self) -> PResult<'a, P<ViewPath>> {
|
||||||
let lo = self.span.lo;
|
let lo = self.span.lo;
|
||||||
if self.check(&token::OpenDelim(token::Brace)) || self.is_import_coupler() {
|
if self.check(&token::OpenDelim(token::Brace)) || self.check(&token::BinOp(token::Star)) ||
|
||||||
// `{foo, bar}` or `::{foo, bar}`
|
self.is_import_coupler() {
|
||||||
|
// `{foo, bar}`, `::{foo, bar}`, `*`, or `::*`.
|
||||||
let prefix = ast::Path {
|
let prefix = ast::Path {
|
||||||
global: self.eat(&token::ModSep),
|
global: self.eat(&token::ModSep),
|
||||||
segments: Vec::new(),
|
segments: Vec::new(),
|
||||||
span: mk_sp(lo, self.span.hi),
|
span: mk_sp(lo, self.span.hi),
|
||||||
};
|
};
|
||||||
let items = self.parse_path_list_items()?;
|
let view_path_kind = if self.eat(&token::BinOp(token::Star)) {
|
||||||
Ok(P(spanned(lo, self.span.hi, ViewPathList(prefix, items))))
|
ViewPathGlob(prefix)
|
||||||
|
} else {
|
||||||
|
ViewPathList(prefix, self.parse_path_list_items()?)
|
||||||
|
};
|
||||||
|
Ok(P(spanned(lo, self.span.hi, view_path_kind)))
|
||||||
} else {
|
} else {
|
||||||
let prefix = self.parse_path(PathStyle::Mod)?;
|
let prefix = self.parse_path(PathStyle::Mod)?;
|
||||||
if self.is_import_coupler() {
|
if self.is_import_coupler() {
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#![allow(dead_assignment)]
|
|
||||||
|
|
||||||
use std::mem::*;
|
use std::mem::*;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
@ -20,3 +17,12 @@ pub fn main() {
|
||||||
assert_eq!(x, 2);
|
assert_eq!(x, 2);
|
||||||
assert_eq!(y, 1);
|
assert_eq!(y, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
fn f() {
|
||||||
|
mod foo { pub use *; }
|
||||||
|
mod bar { pub use ::*; }
|
||||||
|
|
||||||
|
foo::main();
|
||||||
|
bar::main();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue