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
No known key found for this signature in database
GPG key ID: E8C1042DD1624519
29 changed files with 960 additions and 589 deletions

View file

@ -455,9 +455,11 @@ fn mk_std(cx: &TestCtxt) -> P<ast::Item> {
let id_test = Ident::from_str("test");
let sp = ignored_span(cx, DUMMY_SP);
let (vi, vis, ident) = if cx.is_libtest {
(ast::ItemKind::Use(
P(nospan(ast::ViewPathSimple(id_test,
path_node(vec![id_test]))))),
(ast::ItemKind::Use(P(ast::UseTree {
span: DUMMY_SP,
prefix: path_node(vec![id_test]),
kind: ast::UseTreeKind::Simple(id_test),
})),
ast::Visibility::Public, keywords::Invalid.ident())
} else {
(ast::ItemKind::ExternCrate(None), ast::Visibility::Inherited, id_test)
@ -547,9 +549,11 @@ fn mk_test_module(cx: &mut TestCtxt) -> (P<ast::Item>, Option<P<ast::Item>>) {
// building `use <ident> = __test::main`
let reexport_ident = Ident::with_empty_ctxt(s);
let use_path =
nospan(ast::ViewPathSimple(reexport_ident,
path_node(vec![mod_ident, Ident::from_str("main")])));
let use_path = ast::UseTree {
span: DUMMY_SP,
prefix: path_node(vec![mod_ident, Ident::from_str("main")]),
kind: ast::UseTreeKind::Simple(reexport_ident),
};
expander.fold_item(P(ast::Item {
id: ast::DUMMY_NODE_ID,