diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2024-04-02 00:26:10 +0200 |
|---|---|---|
| committer | Pietro Albini <pietro@pietroalbini.org> | 2024-04-14 18:45:28 +0200 |
| commit | f0f392781f2829aaf4368e28c2ba3e9bc0e6115f (patch) | |
| tree | f078c66e265afc5bf87bf79401fc5eb8f062f431 /clippy_lints | |
| parent | 2e989dc2809937fe33c17995e2147873977d2235 (diff) | |
| download | rust-f0f392781f2829aaf4368e28c2ba3e9bc0e6115f.tar.gz rust-f0f392781f2829aaf4368e28c2ba3e9bc0e6115f.zip | |
store the span of the nested part of the use tree in the ast
Diffstat (limited to 'clippy_lints')
| -rw-r--r-- | clippy_lints/src/single_component_path_imports.rs | 8 | ||||
| -rw-r--r-- | clippy_lints/src/unnecessary_self_imports.rs | 4 | ||||
| -rw-r--r-- | clippy_lints/src/unsafe_removed_from_name.rs | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/clippy_lints/src/single_component_path_imports.rs b/clippy_lints/src/single_component_path_imports.rs index 18fbbdb4079..acf44a9bb5a 100644 --- a/clippy_lints/src/single_component_path_imports.rs +++ b/clippy_lints/src/single_component_path_imports.rs @@ -201,8 +201,8 @@ impl SingleComponentPathImports { if segments.is_empty() { // keep track of `use {some_module, some_other_module};` usages - if let UseTreeKind::Nested(trees) = &use_tree.kind { - for tree in trees { + if let UseTreeKind::Nested { items, .. } = &use_tree.kind { + for tree in items { let segments = &tree.0.prefix.segments; if segments.len() == 1 { if let UseTreeKind::Simple(None) = tree.0.kind { @@ -229,8 +229,8 @@ impl SingleComponentPathImports { } // nested case such as `use self::{module1::Struct1, module2::Struct2}` - if let UseTreeKind::Nested(trees) = &use_tree.kind { - for tree in trees { + if let UseTreeKind::Nested { items, .. } = &use_tree.kind { + for tree in items { let segments = &tree.0.prefix.segments; if !segments.is_empty() { imports_reused_with_self.push(segments[0].ident.name); diff --git a/clippy_lints/src/unnecessary_self_imports.rs b/clippy_lints/src/unnecessary_self_imports.rs index ddee06b59ca..528a1dfcfc1 100644 --- a/clippy_lints/src/unnecessary_self_imports.rs +++ b/clippy_lints/src/unnecessary_self_imports.rs @@ -36,8 +36,8 @@ declare_lint_pass!(UnnecessarySelfImports => [UNNECESSARY_SELF_IMPORTS]); impl EarlyLintPass for UnnecessarySelfImports { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { if let ItemKind::Use(use_tree) = &item.kind - && let UseTreeKind::Nested(nodes) = &use_tree.kind - && let [(self_tree, _)] = &**nodes + && let UseTreeKind::Nested { items, .. } = &use_tree.kind + && let [(self_tree, _)] = &**items && let [self_seg] = &*self_tree.prefix.segments && self_seg.ident.name == kw::SelfLower && let Some(last_segment) = use_tree.prefix.segments.last() diff --git a/clippy_lints/src/unsafe_removed_from_name.rs b/clippy_lints/src/unsafe_removed_from_name.rs index 51b3ea93b6d..309eaedac8d 100644 --- a/clippy_lints/src/unsafe_removed_from_name.rs +++ b/clippy_lints/src/unsafe_removed_from_name.rs @@ -49,8 +49,8 @@ fn check_use_tree(use_tree: &UseTree, cx: &EarlyContext<'_>, span: Span) { unsafe_to_safe_check(old_name, new_name, cx, span); }, UseTreeKind::Simple(None) | UseTreeKind::Glob => {}, - UseTreeKind::Nested(ref nested_use_tree) => { - for (use_tree, _) in nested_use_tree { + UseTreeKind::Nested { ref items, .. } => { + for (use_tree, _) in items { check_use_tree(use_tree, cx, span); } }, |
