Add enough attrs to the test file so the fix compiles with no errors, fmt/clippy

This commit is contained in:
Devin R 2020-06-07 16:25:21 -04:00
parent 288df59b25
commit e521a4ed38
4 changed files with 28 additions and 21 deletions

View File

@ -164,34 +164,37 @@ impl<'l, 'txc> LateLintPass<'l, 'txc> for MacroUseImports {
let seg = import.split("::").collect::<Vec<_>>(); let seg = import.split("::").collect::<Vec<_>>();
match seg.as_slice() { match seg.as_slice() {
[] => unreachable!("this should never be empty"), // an empty path is impossible
[_] => unreachable!("path must have two segments ?"), // a path should always consist of 2 or more segments
[] | [_] => return,
[root, item] => { [root, item] => {
if !check_dup.contains(&(*item).to_string()) { if !check_dup.contains(&(*item).to_string()) {
used.entry((root.to_string(), span)) used.entry(((*root).to_string(), span))
.or_insert_with(|| vec![]) .or_insert_with(Vec::new)
.push(item.to_string()); .push((*item).to_string());
check_dup.push(item.to_string()); check_dup.push((*item).to_string());
} }
}, },
[root, rest @ ..] => { [root, rest @ ..] => {
if rest.iter().all(|item| !check_dup.contains(&(*item).to_string())) { if rest.iter().all(|item| !check_dup.contains(&(*item).to_string())) {
let filtered = rest let filtered = rest
.iter() .iter()
.filter_map(|item| if check_dup.contains(&(*item).to_string()) { .filter_map(|item| {
None if check_dup.contains(&(*item).to_string()) {
} else { None
Some(item.to_string()) } else {
Some((*item).to_string())
}
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
used.entry(((*root).to_string(), span)) used.entry(((*root).to_string(), span))
.or_insert_with(|| vec![]) .or_insert_with(Vec::new)
.push(filtered.join("::")); .push(filtered.join("::"));
check_dup.extend(filtered); check_dup.extend(filtered);
} else { } else {
let rest = rest.to_vec(); let rest = rest.to_vec();
used.entry((root.to_string(), span)) used.entry(((*root).to_string(), span))
.or_insert_with(|| vec![]) .or_insert_with(Vec::new)
.push(rest.join("::")); .push(rest.join("::"));
check_dup.extend(rest.iter().map(ToString::to_string)); check_dup.extend(rest.iter().map(ToString::to_string));
} }

View File

@ -2,7 +2,9 @@
// aux-build:macro_rules.rs // aux-build:macro_rules.rs
// aux-build:macro_use_helper.rs // aux-build:macro_use_helper.rs
// run-rustfix // run-rustfix
// ignore-32bit
#![allow(unused_imports, unreachable_code, unused_variables, dead_code)]
#![allow(clippy::single_component_path_imports)] #![allow(clippy::single_component_path_imports)]
#![warn(clippy::macro_use_imports)] #![warn(clippy::macro_use_imports)]

View File

@ -2,7 +2,9 @@
// aux-build:macro_rules.rs // aux-build:macro_rules.rs
// aux-build:macro_use_helper.rs // aux-build:macro_use_helper.rs
// run-rustfix // run-rustfix
// ignore-32bit
#![allow(unused_imports, unreachable_code, unused_variables, dead_code)]
#![allow(clippy::single_component_path_imports)] #![allow(clippy::single_component_path_imports)]
#![warn(clippy::macro_use_imports)] #![warn(clippy::macro_use_imports)]

View File

@ -2,7 +2,7 @@ error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:18:5 --> $DIR/macro_use_imports.rs:18:5
| |
LL | #[macro_use] LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;` | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{pub_macro, inner_mod_macro, function_macro, ty_macro, pub_in_private_macro};`
| |
= note: `-D clippy::macro-use-imports` implied by `-D warnings` = note: `-D clippy::macro-use-imports` implied by `-D warnings`
@ -10,17 +10,17 @@ error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:20:5 --> $DIR/macro_use_imports.rs:20:5
| |
LL | #[macro_use] LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::foofoo, inner::try_err};` | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:16:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{pub_macro, inner_mod_macro, function_macro, ty_macro, pub_in_private_macro};`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:22:5 --> $DIR/macro_use_imports.rs:22:5
| |
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::foofoo, inner::try_err};`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:24:5
|
LL | #[macro_use] LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;` | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;`