Cargo fmt
This commit is contained in:
parent
664391c5f8
commit
6cb0605600
@ -210,27 +210,27 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|
||||
if let Some(items) = &attr.meta_item_list() {
|
||||
if let Some(ident) = attr.ident_str() {
|
||||
match ident {
|
||||
"allow" | "warn" | "deny" | "forbid" => {
|
||||
check_clippy_lint_names(cx, items);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
"allow" | "warn" | "deny" | "forbid" => {
|
||||
check_clippy_lint_names(cx, items);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
if items.is_empty() || !attr.check_name("deprecated") {
|
||||
return;
|
||||
}
|
||||
for item in items {
|
||||
if_chain! {
|
||||
return;
|
||||
}
|
||||
for item in items {
|
||||
if_chain! {
|
||||
if let NestedMetaItem::MetaItem(mi) = &item;
|
||||
if let MetaItemKind::NameValue(lit) = &mi.node;
|
||||
if let MetaItemKind::NameValue(lit) = &mi.node;
|
||||
if mi.check_name("since");
|
||||
then {
|
||||
then {
|
||||
check_semver(cx, item.span(), lit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
|
||||
if is_relevant_item(cx.tcx, item) {
|
||||
@ -244,54 +244,54 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|
||||
if let Some(lint_list) = &attr.meta_item_list() {
|
||||
if let Some(ident) = attr.ident_str() {
|
||||
match ident {
|
||||
"allow" | "warn" | "deny" | "forbid" => {
|
||||
// whitelist `unused_imports` and `deprecated` for `use` items
|
||||
// and `unused_imports` for `extern crate` items with `macro_use`
|
||||
for lint in lint_list {
|
||||
match item.node {
|
||||
ItemKind::Use(..) => {
|
||||
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
|
||||
return;
|
||||
}
|
||||
},
|
||||
ItemKind::ExternCrate(..) => {
|
||||
if is_word(lint, "unused_imports") && skip_unused_imports {
|
||||
return;
|
||||
}
|
||||
if is_word(lint, "unused_extern_crates") {
|
||||
return;
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
let line_span = last_line_of_span(cx, attr.span);
|
||||
|
||||
if let Some(mut sugg) = snippet_opt(cx, line_span) {
|
||||
if sugg.contains("#[") {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
USELESS_ATTRIBUTE,
|
||||
line_span,
|
||||
"useless lint attribute",
|
||||
|db| {
|
||||
sugg = sugg.replacen("#[", "#![", 1);
|
||||
db.span_suggestion(
|
||||
line_span,
|
||||
"if you just forgot a `!`, use",
|
||||
sugg,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
"allow" | "warn" | "deny" | "forbid" => {
|
||||
// whitelist `unused_imports` and `deprecated` for `use` items
|
||||
// and `unused_imports` for `extern crate` items with `macro_use`
|
||||
for lint in lint_list {
|
||||
match item.node {
|
||||
ItemKind::Use(..) => {
|
||||
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
|
||||
return;
|
||||
}
|
||||
},
|
||||
);
|
||||
ItemKind::ExternCrate(..) => {
|
||||
if is_word(lint, "unused_imports") && skip_unused_imports {
|
||||
return;
|
||||
}
|
||||
if is_word(lint, "unused_extern_crates") {
|
||||
return;
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
let line_span = last_line_of_span(cx, attr.span);
|
||||
|
||||
if let Some(mut sugg) = snippet_opt(cx, line_span) {
|
||||
if sugg.contains("#[") {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
USELESS_ATTRIBUTE,
|
||||
line_span,
|
||||
"useless lint attribute",
|
||||
|db| {
|
||||
sugg = sugg.replacen("#[", "#![", 1);
|
||||
db.span_suggestion(
|
||||
line_span,
|
||||
"if you just forgot a `!`, use",
|
||||
sugg,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
@ -527,7 +527,7 @@ impl EarlyLintPass for CfgAttrPass {
|
||||
if feature_item.check_name("rustfmt");
|
||||
// check for `rustfmt_skip` and `rustfmt::skip`
|
||||
if let Some(skip_item) = &items[1].meta_item();
|
||||
if skip_item.check_name("rustfmt_skip") ||
|
||||
if skip_item.check_name("rustfmt_skip") ||
|
||||
skip_item.path.segments.last().expect("empty path in attribute").ident.name == "skip";
|
||||
// Only lint outer attributes, because custom inner attributes are unstable
|
||||
// Tracking issue: https://github.com/rust-lang/rust/issues/54726
|
||||
|
@ -11,9 +11,7 @@ use syntax::{ast, source_map};
|
||||
use toml;
|
||||
|
||||
/// Gets the configuration file from arguments.
|
||||
pub fn file_from_args(
|
||||
args: &[ast::NestedMetaItem],
|
||||
) -> Result<Option<path::PathBuf>, (&'static str, source_map::Span)> {
|
||||
pub fn file_from_args(args: &[ast::NestedMetaItem]) -> Result<Option<path::PathBuf>, (&'static str, source_map::Span)> {
|
||||
for arg in args.iter().filter_map(syntax::ast::NestedMetaItem::meta_item) {
|
||||
if arg.check_name("conf_file") {
|
||||
return match arg.node {
|
||||
|
@ -146,7 +146,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
|
||||
return self.print_def_path(def.did, substs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This shouldn't ever be needed, but just in case:
|
||||
Ok(vec![match trait_ref {
|
||||
Some(trait_ref) => Symbol::intern(&format!("{:?}", trait_ref)).as_str(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user