about summary refs log tree commit diff
path: root/src/libsyntax/print/pprust.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-03-09 18:58:44 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-03-17 22:12:21 +0300
commitb057c554ab9c7615ebdb3c920010a164ec5bf3ed (patch)
tree3fcc7c2945653152d55af9c48a498b9bb5384c94 /src/libsyntax/print/pprust.rs
parentc6c6cf9515b330551b04f36025bc72e1288a96d9 (diff)
downloadrust-b057c554ab9c7615ebdb3c920010a164ec5bf3ed.tar.gz
rust-b057c554ab9c7615ebdb3c920010a164ec5bf3ed.zip
AST: Make renames in imports closer to the source
Fix `unused_import_braces` lint false positive on `use prefix::{self as rename}`
Diffstat (limited to 'src/libsyntax/print/pprust.rs')
-rw-r--r--src/libsyntax/print/pprust.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 097c0fd16d0..18a758ba968 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -2949,13 +2949,12 @@ impl<'a> State<'a> {
 
     pub fn print_use_tree(&mut self, tree: &ast::UseTree) -> io::Result<()> {
         match tree.kind {
-            ast::UseTreeKind::Simple(ref ident) => {
+            ast::UseTreeKind::Simple(rename) => {
                 self.print_path(&tree.prefix, false, 0, true)?;
-
-                if tree.prefix.segments.last().unwrap().identifier.name != ident.name {
+                if let Some(rename) = rename {
                     self.s.space()?;
                     self.word_space("as")?;
-                    self.print_ident(*ident)?;
+                    self.print_ident(rename)?;
                 }
             }
             ast::UseTreeKind::Glob => {