Fixed build for latest nightly (again)
This commit is contained in:
parent
c7ce6c07b1
commit
00b549ad40
@ -125,14 +125,14 @@ impl LintPass for AttrPass {
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|
||||
fn check_attribute(&mut self, cx: &LateContext<'a, 'tcx>, attr: &'tcx Attribute) {
|
||||
if let Some(ref items) = attr.meta_item_list() {
|
||||
if items.is_empty() || attr.name().map_or(true, |n| n != "deprecated") {
|
||||
if items.is_empty() || attr.name() != "deprecated" {
|
||||
return;
|
||||
}
|
||||
for item in items {
|
||||
if_chain! {
|
||||
if let NestedMetaItemKind::MetaItem(ref mi) = item.node;
|
||||
if let MetaItemKind::NameValue(ref lit) = mi.node;
|
||||
if mi.ident.name == "since";
|
||||
if mi.name() == "since";
|
||||
then {
|
||||
check_semver(cx, item.span, lit);
|
||||
}
|
||||
@ -149,40 +149,38 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|
||||
ItemExternCrate(_) | ItemUse(_, _) => {
|
||||
for attr in &item.attrs {
|
||||
if let Some(ref lint_list) = attr.meta_item_list() {
|
||||
if let Some(name) = attr.name() {
|
||||
match &*name.as_str() {
|
||||
"allow" | "warn" | "deny" | "forbid" => {
|
||||
// whitelist `unused_imports` and `deprecated`
|
||||
for lint in lint_list {
|
||||
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
|
||||
if let ItemUse(_, _) = item.node {
|
||||
return;
|
||||
}
|
||||
match &*attr.name().as_str() {
|
||||
"allow" | "warn" | "deny" | "forbid" => {
|
||||
// whitelist `unused_imports` and `deprecated`
|
||||
for lint in lint_list {
|
||||
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
|
||||
if let ItemUse(_, _) = item.node {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let line_span = last_line_of_span(cx, attr.span);
|
||||
}
|
||||
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,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
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,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -294,7 +292,7 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
|
||||
}
|
||||
|
||||
if let Some(ref values) = attr.meta_item_list() {
|
||||
if values.len() != 1 || attr.name().map_or(true, |n| n != "inline") {
|
||||
if values.len() != 1 || attr.name() != "inline" {
|
||||
continue;
|
||||
}
|
||||
if is_word(&values[0], "always") {
|
||||
@ -328,7 +326,7 @@ fn check_semver(cx: &LateContext, span: Span, lit: &Lit) {
|
||||
|
||||
fn is_word(nmi: &NestedMetaItem, expected: &str) -> bool {
|
||||
if let NestedMetaItemKind::MetaItem(ref mi) = nmi.node {
|
||||
mi.is_word() && mi.ident.name == expected
|
||||
mi.is_word() && mi.name() == expected
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -150,9 +150,9 @@ pub fn check_attrs<'a>(cx: &EarlyContext, valid_idents: &[String], attrs: &'a [a
|
||||
spans.extend_from_slice(¤t_spans);
|
||||
doc.push_str(¤t);
|
||||
}
|
||||
} else if let Some(name) = attr.name() {
|
||||
} else {
|
||||
// ignore mix of sugared and non-sugared doc
|
||||
if name == "doc" {
|
||||
if attr.name() == "doc" {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
|
||||
fn check_attrs(cx: &LateContext, name: &Name, attrs: &[Attribute]) {
|
||||
for attr in attrs {
|
||||
if attr.name().map_or(true, |n| n != "inline") {
|
||||
if attr.name() == "inline" {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ impl MissingDoc {
|
||||
|
||||
let has_doc = attrs
|
||||
.iter()
|
||||
.any(|a| a.is_value_str() && a.name().map_or(false, |n| n == "doc"));
|
||||
.any(|a| a.is_value_str() && a.name() == "doc");
|
||||
if !has_doc {
|
||||
cx.span_lint(
|
||||
MISSING_DOCS_IN_PRIVATE_ITEMS,
|
||||
|
@ -77,13 +77,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
||||
return;
|
||||
}
|
||||
for a in attrs {
|
||||
if_chain! {
|
||||
if a.meta_item_list().is_some();
|
||||
if let Some(name) = a.name();
|
||||
if name == "proc_macro_derive";
|
||||
then {
|
||||
return;
|
||||
}
|
||||
if a.meta_item_list().is_some() && a.name() == "proc_macro_derive" {
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -149,5 +149,5 @@ impl EarlyLintPass for ReturnPass {
|
||||
}
|
||||
|
||||
fn attr_is_cfg(attr: &ast::Attribute) -> bool {
|
||||
attr.meta_item_list().is_some() && attr.name().map_or(false, |n| n == "cfg")
|
||||
attr.meta_item_list().is_some() && attr.name() == "cfg"
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ fn has_attr(attrs: &[Attribute]) -> bool {
|
||||
attrs.iter().any(|attr| {
|
||||
attr.check_name("clippy") && attr.meta_item_list().map_or(false, |list| {
|
||||
list.len() == 1 && match list[0].node {
|
||||
ast::NestedMetaItemKind::MetaItem(ref it) => it.ident.name == "author",
|
||||
ast::NestedMetaItemKind::MetaItem(ref it) => it.name() == "author",
|
||||
ast::NestedMetaItemKind::Literal(_) => false,
|
||||
}
|
||||
})
|
||||
|
@ -13,7 +13,7 @@ pub fn file_from_args(
|
||||
args: &[codemap::Spanned<ast::NestedMetaItemKind>],
|
||||
) -> Result<Option<path::PathBuf>, (&'static str, codemap::Span)> {
|
||||
for arg in args.iter().filter_map(|a| a.meta_item()) {
|
||||
if arg.ident.name == "conf_file" {
|
||||
if arg.name() == "conf_file" {
|
||||
return match arg.node {
|
||||
ast::MetaItemKind::Word | ast::MetaItemKind::List(_) => {
|
||||
Err(("`conf_file` must be a named value", arg.span))
|
||||
|
@ -743,7 +743,7 @@ fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'
|
||||
continue;
|
||||
}
|
||||
if let Some(ref value) = attr.value_str() {
|
||||
if attr.name().map_or(false, |n| n == name) {
|
||||
if attr.name() == name {
|
||||
if let Ok(value) = FromStr::from_str(&value.as_str()) {
|
||||
attr::mark_used(attr);
|
||||
f(value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user