Skip to content

Commit b0d490e

Browse files
committed
rustc_ast_lowering: Stop lowering imports into multiple items
Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
1 parent 9314e5b commit b0d490e

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

clippy_lints/src/single_component_path_imports.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl SingleComponentPathImports {
149149

150150
// keep track of `use some_module;` usages
151151
if segments.len() == 1 {
152-
if let UseTreeKind::Simple(None, _, _) = use_tree.kind {
152+
if let UseTreeKind::Simple(None) = use_tree.kind {
153153
let name = segments[0].ident.name;
154154
if !macros.contains(&name) {
155155
single_use_usages.push(SingleUse {
@@ -169,7 +169,7 @@ impl SingleComponentPathImports {
169169
for tree in trees {
170170
let segments = &tree.0.prefix.segments;
171171
if segments.len() == 1 {
172-
if let UseTreeKind::Simple(None, _, _) = tree.0.kind {
172+
if let UseTreeKind::Simple(None) = tree.0.kind {
173173
let name = segments[0].ident.name;
174174
if !macros.contains(&name) {
175175
single_use_usages.push(SingleUse {

clippy_lints/src/unnecessary_self_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl EarlyLintPass for UnnecessarySelfImports {
5757
format!(
5858
"{}{};",
5959
last_segment.ident,
60-
if let UseTreeKind::Simple(Some(alias), ..) = self_tree.kind { format!(" as {alias}") } else { String::new() },
60+
if let UseTreeKind::Simple(Some(alias)) = self_tree.kind { format!(" as {alias}") } else { String::new() },
6161
),
6262
Applicability::MaybeIncorrect,
6363
);

clippy_lints/src/unsafe_removed_from_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl EarlyLintPass for UnsafeNameRemoval {
3939

4040
fn check_use_tree(use_tree: &UseTree, cx: &EarlyContext<'_>, span: Span) {
4141
match use_tree.kind {
42-
UseTreeKind::Simple(Some(new_name), ..) => {
42+
UseTreeKind::Simple(Some(new_name)) => {
4343
let old_name = use_tree
4444
.prefix
4545
.segments
@@ -48,7 +48,7 @@ fn check_use_tree(use_tree: &UseTree, cx: &EarlyContext<'_>, span: Span) {
4848
.ident;
4949
unsafe_to_safe_check(old_name, new_name, cx, span);
5050
},
51-
UseTreeKind::Simple(None, ..) | UseTreeKind::Glob => {},
51+
UseTreeKind::Simple(None) | UseTreeKind::Glob => {},
5252
UseTreeKind::Nested(ref nested_use_tree) => {
5353
for (use_tree, _) in nested_use_tree {
5454
check_use_tree(use_tree, cx, span);

clippy_utils/src/ast_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ pub fn eq_use_tree_kind(l: &UseTreeKind, r: &UseTreeKind) -> bool {
566566
use UseTreeKind::*;
567567
match (l, r) {
568568
(Glob, Glob) => true,
569-
(Simple(l, _, _), Simple(r, _, _)) => both(l, r, |l, r| eq_id(*l, *r)),
569+
(Simple(l), Simple(r)) => both(l, r, |l, r| eq_id(*l, *r)),
570570
(Nested(l), Nested(r)) => over(l, r, |(l, _), (r, _)| eq_use_tree(l, r)),
571571
_ => false,
572572
}

tests/ui/macro_use_imports.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
2-
--> $DIR/macro_use_imports.rs:23:5
2+
--> $DIR/macro_use_imports.rs:25:5
33
|
44
LL | #[macro_use]
5-
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::foofoo, inner::try_err};`
5+
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;`
66
|
77
= note: `-D clippy::macro-use-imports` implied by `-D warnings`
88

@@ -13,10 +13,10 @@ LL | #[macro_use]
1313
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;`
1414

1515
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
16-
--> $DIR/macro_use_imports.rs:25:5
16+
--> $DIR/macro_use_imports.rs:23:5
1717
|
1818
LL | #[macro_use]
19-
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;`
19+
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::foofoo, inner::try_err};`
2020

2121
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
2222
--> $DIR/macro_use_imports.rs:19:5

0 commit comments

Comments
 (0)