Rollup merge of #138886 - samueltardieu:push-xxkzmupznoky, r=jieyouxu
Fix autofix for `self` and `self as …` in `unused_imports` lint This fixes two problems with the autofixes for the `unused_imports` lint: - `use std::collections::{HashMap, self as coll};` would suggest, when `HashMap` is unused, the incorrect `use std::collections::self as coll;` which does not compile. - `use std::borrow::{self, Cow};` would suggest, when `self` is unused, `use std::borrow::{Cow};`, which contains unnecessary brackets. The first problem was reported in rust-lang/rust-clippy#14450, the second found while fixing the first one. Fix #133750 (thanks to `@richardsamuels` for spotting the duplicate)
This commit is contained in:
commit
946192b25a
4 changed files with 105 additions and 1 deletions
|
@ -337,7 +337,8 @@ fn calc_unused_spans(
|
|||
}
|
||||
}
|
||||
contains_self |= use_tree.prefix == kw::SelfLower
|
||||
&& matches!(use_tree.kind, ast::UseTreeKind::Simple(None));
|
||||
&& matches!(use_tree.kind, ast::UseTreeKind::Simple(_))
|
||||
&& !unused_import.unused.contains(&use_tree_id);
|
||||
previous_unused = remove.is_some();
|
||||
}
|
||||
if unused_spans.is_empty() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue