about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMaximilian Roos <5635139+max-sixty@users.noreply.github.com>2018-08-24 01:39:05 -0400
committerSeiichi Uchida <seuchida@gmail.com>2018-08-24 14:39:05 +0900
commit10512a59d00cd5b1f134d78a7ff4e2ce5abb9b12 (patch)
tree18857e37256c5502ede4f89ef55fa34b30f693bd /src
parentf009252a6a89e6e2ff1cc02984c260f61b8d5c16 (diff)
Impl only use (#2951)
Diffstat (limited to 'src')
-rw-r--r--src/config/file_lines.rs2
-rw-r--r--src/imports.rs28
2 files changed, 14 insertions, 16 deletions
diff --git a/src/config/file_lines.rs b/src/config/file_lines.rs
index ba317af8360..e113118c643 100644
--- a/src/config/file_lines.rs
+++ b/src/config/file_lines.rs
@@ -386,7 +386,7 @@ mod test {
         );
     }
 
-    use super::json::{self, json, json_internal};
+    use super::json::{self, json};
     use super::{FileLines, FileName};
     use std::{collections::HashMap, path::PathBuf};
 
diff --git a/src/imports.rs b/src/imports.rs
index a2d14c129d9..b3408bf7bf2 100644
--- a/src/imports.rs
+++ b/src/imports.rs
@@ -149,12 +149,10 @@ impl UseSegment {
         if name.is_empty() || name == "{{root}}" {
             return None;
         }
-        Some(if name == "self" {
-            UseSegment::Slf(None)
-        } else if name == "super" {
-            UseSegment::Super(None)
-        } else {
-            UseSegment::Ident((*name).to_owned(), None)
+        Some(match name {
+            "self" => UseSegment::Slf(None),
+            "super" => UseSegment::Super(None),
+            _ => UseSegment::Ident((*name).to_owned(), None),
         })
     }
 }
@@ -350,19 +348,19 @@ impl UseTree {
             UseTreeKind::Simple(ref rename, ..) => {
                 let name = rewrite_ident(context, path_to_imported_ident(&a.prefix)).to_owned();
                 let alias = rename.and_then(|ident| {
-                    if ident == path_to_imported_ident(&a.prefix) {
+                    if ident.name == "_" {
+                        // for impl-only-use
+                        Some("_".to_owned())
+                    } else if ident == path_to_imported_ident(&a.prefix) {
                         None
                     } else {
                         Some(rewrite_ident(context, ident).to_owned())
                     }
                 });
-
-                let segment = if &name == "self" {
-                    UseSegment::Slf(alias)
-                } else if &name == "super" {
-                    UseSegment::Super(alias)
-                } else {
-                    UseSegment::Ident(name, alias)
+                let segment = match name.as_ref() {
+                    "self" => UseSegment::Slf(alias),
+                    "super" => UseSegment::Super(alias),
+                    _ => UseSegment::Ident(name, alias),
                 };
 
                 // `name` is already in result.
@@ -746,7 +744,7 @@ fn rewrite_nested_use_tree(
 
 impl Rewrite for UseSegment {
     fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
-        Some(match *self {
+        Some(match self {
             UseSegment::Ident(ref ident, Some(ref rename)) => format!("{} as {}", ident, rename),
             UseSegment::Ident(ref ident, None) => ident.clone(),
             UseSegment::Slf(Some(ref rename)) => format!("self as {}", rename),