Implement RFC 2128 (use_nested_groups)

This commit adds support for nested groups inside `use` declarations,
such as `use foo::{bar, sub::{baz::Foo, *}};`.
This commit is contained in:
Pietro Albini
2017-09-26 23:04:00 +02:00
parent d6b010f98b
commit 91ba8b42fc
29 changed files with 960 additions and 589 deletions

View File

@@ -13,7 +13,7 @@ use attr;
use ext::hygiene::{Mark, SyntaxContext};
use symbol::{Symbol, keywords};
use syntax_pos::{DUMMY_SP, Span};
use codemap::{self, ExpnInfo, NameAndSpan, MacroAttribute};
use codemap::{ExpnInfo, NameAndSpan, MacroAttribute};
use ptr::P;
use tokenstream::TokenStream;
@@ -75,12 +75,16 @@ pub fn maybe_inject_crates_ref(mut krate: ast::Crate, alt_std_name: Option<Strin
span,
}],
vis: ast::Visibility::Inherited,
node: ast::ItemKind::Use(P(codemap::dummy_spanned(ast::ViewPathGlob(ast::Path {
segments: ["{{root}}", name, "prelude", "v1"].into_iter().map(|name| {
ast::PathSegment::from_ident(ast::Ident::from_str(name), DUMMY_SP)
}).collect(),
node: ast::ItemKind::Use(P(ast::UseTree {
prefix: ast::Path {
segments: ["{{root}}", name, "prelude", "v1"].into_iter().map(|name| {
ast::PathSegment::from_ident(ast::Ident::from_str(name), DUMMY_SP)
}).collect(),
span,
},
kind: ast::UseTreeKind::Glob,
span,
})))),
})),
id: ast::DUMMY_NODE_ID,
ident: keywords::Invalid.ident(),
span,