]> git.lizzy.rs Git - rust.git/commitdiff
Rustup to rustc 1.24.0-nightly (bb42071f6 2017-12-01)
authorSeiichi Uchida <seuchida@gmail.com>
Sat, 2 Dec 2017 09:23:32 +0000 (18:23 +0900)
committerSeiichi Uchida <seuchida@gmail.com>
Sat, 2 Dec 2017 09:23:32 +0000 (18:23 +0900)
clippy_lints/src/unsafe_removed_from_name.rs

index 1c9bf70429d9232e45db6bd8fc3d42c601e9ebe0..637df96180a565261140538fb633bb580433e484 100644 (file)
@@ -35,26 +35,27 @@ fn get_lints(&self) -> LintArray {
 
 impl EarlyLintPass for UnsafeNameRemoval {
     fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
-        if let ItemKind::Use(ref item_use) = item.node {
-            match item_use.node {
-                ViewPath_::ViewPathSimple(ref name, ref path) => {
-                    unsafe_to_safe_check(
-                        path.segments
-                            .last()
-                            .expect("use paths cannot be empty")
-                            .identifier,
-                        *name,
-                        cx,
-                        &item.span,
-                    );
-                },
-                ViewPath_::ViewPathList(_, ref path_list_items) => for path_list_item in path_list_items.iter() {
-                    let plid = path_list_item.node;
-                    if let Some(rename) = plid.rename {
-                        unsafe_to_safe_check(plid.name, rename, cx, &item.span);
-                    };
-                },
-                ViewPath_::ViewPathGlob(_) => {},
+        if let ItemKind::Use(ref use_tree) = item.node {
+            check_use_tree(use_tree, cx, &item.span);
+        }
+    }
+}
+
+fn check_use_tree(use_tree: &UseTree, cx: &EarlyContext, span: &Span) {
+    match use_tree.kind {
+        UseTreeKind::Simple(new_name) => {
+            let old_name = use_tree
+                .prefix
+                .segments
+                .last()
+                .expect("use paths cannot be empty")
+                .identifier;
+            unsafe_to_safe_check(old_name, new_name, cx, span);
+        }
+        UseTreeKind::Glob => {},
+        UseTreeKind::Nested(ref nested_use_tree) => {
+            for &(ref use_tree, _) in nested_use_tree {
+                check_use_tree(use_tree, cx, span);
             }
         }
     }