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