Skip to content

Commit 6cb0605

Browse files
committed
Cargo fmt
1 parent 664391c commit 6cb0605

File tree

3 files changed

+58
-60
lines changed

3 files changed

+58
-60
lines changed

clippy_lints/src/attrs.rs

+56-56
Original file line numberDiff line numberDiff line change
@@ -210,27 +210,27 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
210210
if let Some(items) = &attr.meta_item_list() {
211211
if let Some(ident) = attr.ident_str() {
212212
match ident {
213-
"allow" | "warn" | "deny" | "forbid" => {
214-
check_clippy_lint_names(cx, items);
215-
},
216-
_ => {},
217-
}
213+
"allow" | "warn" | "deny" | "forbid" => {
214+
check_clippy_lint_names(cx, items);
215+
},
216+
_ => {},
217+
}
218218
if items.is_empty() || !attr.check_name("deprecated") {
219-
return;
220-
}
221-
for item in items {
222-
if_chain! {
219+
return;
220+
}
221+
for item in items {
222+
if_chain! {
223223
if let NestedMetaItem::MetaItem(mi) = &item;
224-
if let MetaItemKind::NameValue(lit) = &mi.node;
224+
if let MetaItemKind::NameValue(lit) = &mi.node;
225225
if mi.check_name("since");
226-
then {
226+
then {
227227
check_semver(cx, item.span(), lit);
228+
}
228229
}
229230
}
230231
}
231232
}
232233
}
233-
}
234234

235235
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
236236
if is_relevant_item(cx.tcx, item) {
@@ -244,54 +244,54 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
244244
if let Some(lint_list) = &attr.meta_item_list() {
245245
if let Some(ident) = attr.ident_str() {
246246
match ident {
247-
"allow" | "warn" | "deny" | "forbid" => {
248-
// whitelist `unused_imports` and `deprecated` for `use` items
249-
// and `unused_imports` for `extern crate` items with `macro_use`
250-
for lint in lint_list {
251-
match item.node {
252-
ItemKind::Use(..) => {
253-
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
254-
return;
255-
}
256-
},
257-
ItemKind::ExternCrate(..) => {
258-
if is_word(lint, "unused_imports") && skip_unused_imports {
259-
return;
260-
}
261-
if is_word(lint, "unused_extern_crates") {
262-
return;
263-
}
264-
},
265-
_ => {},
266-
}
267-
}
268-
let line_span = last_line_of_span(cx, attr.span);
269-
270-
if let Some(mut sugg) = snippet_opt(cx, line_span) {
271-
if sugg.contains("#[") {
272-
span_lint_and_then(
273-
cx,
274-
USELESS_ATTRIBUTE,
275-
line_span,
276-
"useless lint attribute",
277-
|db| {
278-
sugg = sugg.replacen("#[", "#![", 1);
279-
db.span_suggestion(
280-
line_span,
281-
"if you just forgot a `!`, use",
282-
sugg,
283-
Applicability::MachineApplicable,
284-
);
247+
"allow" | "warn" | "deny" | "forbid" => {
248+
// whitelist `unused_imports` and `deprecated` for `use` items
249+
// and `unused_imports` for `extern crate` items with `macro_use`
250+
for lint in lint_list {
251+
match item.node {
252+
ItemKind::Use(..) => {
253+
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
254+
return;
255+
}
285256
},
286-
);
257+
ItemKind::ExternCrate(..) => {
258+
if is_word(lint, "unused_imports") && skip_unused_imports {
259+
return;
260+
}
261+
if is_word(lint, "unused_extern_crates") {
262+
return;
263+
}
264+
},
265+
_ => {},
266+
}
287267
}
288-
}
289-
},
290-
_ => {},
268+
let line_span = last_line_of_span(cx, attr.span);
269+
270+
if let Some(mut sugg) = snippet_opt(cx, line_span) {
271+
if sugg.contains("#[") {
272+
span_lint_and_then(
273+
cx,
274+
USELESS_ATTRIBUTE,
275+
line_span,
276+
"useless lint attribute",
277+
|db| {
278+
sugg = sugg.replacen("#[", "#![", 1);
279+
db.span_suggestion(
280+
line_span,
281+
"if you just forgot a `!`, use",
282+
sugg,
283+
Applicability::MachineApplicable,
284+
);
285+
},
286+
);
287+
}
288+
}
289+
},
290+
_ => {},
291+
}
291292
}
292293
}
293294
}
294-
}
295295
},
296296
_ => {},
297297
}
@@ -527,7 +527,7 @@ impl EarlyLintPass for CfgAttrPass {
527527
if feature_item.check_name("rustfmt");
528528
// check for `rustfmt_skip` and `rustfmt::skip`
529529
if let Some(skip_item) = &items[1].meta_item();
530-
if skip_item.check_name("rustfmt_skip") ||
530+
if skip_item.check_name("rustfmt_skip") ||
531531
skip_item.path.segments.last().expect("empty path in attribute").ident.name == "skip";
532532
// Only lint outer attributes, because custom inner attributes are unstable
533533
// Tracking issue: https://github.com/rust-lang/rust/issues/54726

clippy_lints/src/utils/conf.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ use syntax::{ast, source_map};
1111
use toml;
1212

1313
/// Gets the configuration file from arguments.
14-
pub fn file_from_args(
15-
args: &[ast::NestedMetaItem],
16-
) -> Result<Option<path::PathBuf>, (&'static str, source_map::Span)> {
14+
pub fn file_from_args(args: &[ast::NestedMetaItem]) -> Result<Option<path::PathBuf>, (&'static str, source_map::Span)> {
1715
for arg in args.iter().filter_map(syntax::ast::NestedMetaItem::meta_item) {
1816
if arg.check_name("conf_file") {
1917
return match arg.node {

clippy_lints/src/utils/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
146146
return self.print_def_path(def.did, substs);
147147
}
148148
}
149-
149+
150150
// This shouldn't ever be needed, but just in case:
151151
Ok(vec![match trait_ref {
152152
Some(trait_ref) => Symbol::intern(&format!("{:?}", trait_ref)).as_str(),

0 commit comments

Comments
 (0)