From e5fb13897d947e13a1322a055b71632e30357eff Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 10 Mar 2018 02:02:39 +0300 Subject: AST: Keep distinction between `path` and `::path` in imports and visibilities Add the root segment for name resolution purposes only --- src/libsyntax/ext/build.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 97f784dd617..ee646dc9174 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -329,9 +329,13 @@ impl<'a> AstBuilder for ExtCtxt<'a> { None }; segments.push(ast::PathSegment { identifier: last_identifier, span, parameters }); - let path = ast::Path { span, segments }; - - if global { path.default_to_global() } else { path } + let mut path = ast::Path { span, segments }; + if global { + if let Some(seg) = path.make_root() { + path.segments.insert(0, seg); + } + } + path } /// Constructs a qualified path. -- cgit 1.4.1-3-g733a5