Skip to content

Commit 47e7c9d

Browse files
committed
cargo fmt
1 parent 41abea0 commit 47e7c9d

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

clippy_lints/src/macro_use.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::utils::{in_macro, snippet, span_lint_and_sugg};
2+
use hir::def::{DefKind, Res};
23
use if_chain::if_chain;
4+
use rustc_ast::ast;
35
use rustc_data_structures::fx::FxHashMap;
46
use rustc_errors::Applicability;
57
use rustc_hir as hir;
6-
use hir::def::{Res, DefKind};
7-
use rustc_lint::{LintContext, LateLintPass, LateContext};
8+
use rustc_lint::{LateContext, LateLintPass, LintContext};
89
use rustc_session::{declare_tool_lint, impl_lint_pass};
910
use rustc_span::{edition::Edition, Span};
10-
use rustc_ast::ast;
1111

1212
declare_clippy_lint! {
1313
/// **What it does:** Checks for `#[macro_use] use...`.
@@ -133,7 +133,6 @@ impl<'l, 'txc> LateLintPass<'l, 'txc> for MacroUseImports {
133133
let name = snippet(lcx, lcx.sess().source_map().span_until_char(call_site, '!'), "_");
134134
if let Some(callee) = expr.span.source_callee() {
135135
if !self.collected.contains_key(&call_site) {
136-
137136
let name = if name.contains("::") {
138137
name.split("::").last().unwrap().to_string()
139138
} else {
@@ -153,7 +152,6 @@ impl<'l, 'txc> LateLintPass<'l, 'txc> for MacroUseImports {
153152
let name = snippet(lcx, lcx.sess().source_map().span_until_char(call_site, '!'), "_");
154153
if let Some(callee) = stmt.span.source_callee() {
155154
if !self.collected.contains_key(&call_site) {
156-
157155
let name = if name.contains("::") {
158156
name.split("::").last().unwrap().to_string()
159157
} else {
@@ -196,8 +194,11 @@ impl<'l, 'txc> LateLintPass<'l, 'txc> for MacroUseImports {
196194

197195
fn check_crate_post(&mut self, lcx: &LateContext<'_, '_>, _krate: &hir::Crate<'_>) {
198196
for (import, span) in self.imports.iter() {
199-
200-
let matched = self.mac_refs.iter().find(|(_span, mac)| import.ends_with(&mac.name)).is_some();
197+
let matched = self
198+
.mac_refs
199+
.iter()
200+
.find(|(_span, mac)| import.ends_with(&mac.name))
201+
.is_some();
201202

202203
if matched {
203204
self.mac_refs.retain(|(_span, mac)| !import.ends_with(&mac.name));
@@ -222,7 +223,6 @@ impl<'l, 'txc> LateLintPass<'l, 'txc> for MacroUseImports {
222223
}
223224
}
224225

225-
226226
const PRELUDE: &[&str] = &[
227227
"marker", "ops", "convert", "iter", "option", "result", "borrow", "boxed", "string", "vec", "macros",
228228
];
@@ -233,7 +233,10 @@ fn make_path(mac: &MacroRefData, use_path: &str) -> String {
233233
let segs = mac.path.split("::").filter(|s| *s != "").collect::<Vec<_>>();
234234

235235
if segs.starts_with(&["std"]) && PRELUDE.iter().any(|m| segs.contains(m)) {
236-
return format!("std::prelude::{} is imported by default, remove `use` statement", mac.name);
236+
return format!(
237+
"std::prelude::{} is imported by default, remove `use` statement",
238+
mac.name
239+
);
237240
}
238241

239242
if use_path.split("::").count() == 1 {

tests/ui/auxiliary/macro_use_helper.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ macro_rules! pub_macro {
88
};
99
}
1010

11-
1211
pub mod inner {
1312
pub use super::*;
14-
13+
1514
// RE-EXPORT
1615
// this will stick in `inner` module
1716
pub use macro_rules::try_err;
@@ -30,7 +29,9 @@ pub mod inner {
3029
#[macro_export]
3130
macro_rules! function {
3231
() => {
33-
if true {} else {}
32+
if true {
33+
} else {
34+
}
3435
};
3536
}
3637

0 commit comments

Comments
 (0)