mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
Merge pull request #1634 from ensch/master
Fix for rustc 1.17.0-nightly (6eb9960d3 2017-03-19)
This commit is contained in:
commit
b7bc8d923b
8 changed files with 38 additions and 47 deletions
|
@ -12,6 +12,7 @@ environment:
|
|||
MSYS2_BITS: 64
|
||||
|
||||
install:
|
||||
- set PATH=C:\Program Files\Git\mingw64\bin;%PATH%
|
||||
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
|
||||
- rustup-init.exe -y --default-host %TARGET% --default-toolchain nightly
|
||||
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin;C:\Users\appveyor\.rustup\toolchains\nightly-%TARGET%\bin
|
||||
|
|
|
@ -86,8 +86,8 @@ 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 MetaItemKind::List(ref items) = attr.value.node {
|
||||
if items.is_empty() || attr.name() != "deprecated" {
|
||||
if let Some(ref items) = attr.meta_item_list() {
|
||||
if items.is_empty() || attr.name().map_or(true, |n| n != "deprecated") {
|
||||
return;
|
||||
}
|
||||
for item in items {
|
||||
|
@ -110,31 +110,33 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|
|||
ItemExternCrate(_) |
|
||||
ItemUse(_, _) => {
|
||||
for attr in &item.attrs {
|
||||
if let MetaItemKind::List(ref lint_list) = attr.value.node {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(mut sugg) = snippet_opt(cx, attr.span) {
|
||||
if sugg.len() > 1 {
|
||||
span_lint_and_then(cx,
|
||||
USELESS_ATTRIBUTE,
|
||||
attr.span,
|
||||
"useless lint attribute",
|
||||
|db| {
|
||||
sugg.insert(1, '!');
|
||||
db.span_suggestion(attr.span, "if you just forgot a `!`, use", sugg);
|
||||
});
|
||||
if let Some(mut sugg) = snippet_opt(cx, attr.span) {
|
||||
if sugg.len() > 1 {
|
||||
span_lint_and_then(cx,
|
||||
USELESS_ATTRIBUTE,
|
||||
attr.span,
|
||||
"useless lint attribute",
|
||||
|db| {
|
||||
sugg.insert(1, '!');
|
||||
db.span_suggestion(attr.span, "if you just forgot a `!`, use", sugg);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,8 +220,8 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
|
|||
}
|
||||
|
||||
for attr in attrs {
|
||||
if let MetaItemKind::List(ref values) = attr.value.node {
|
||||
if values.len() != 1 || attr.name() != "inline" {
|
||||
if let Some(ref values) = attr.meta_item_list() {
|
||||
if values.len() != 1 || attr.name().map_or(true, |n| n != "inline") {
|
||||
continue;
|
||||
}
|
||||
if is_word(&values[0], "always") {
|
||||
|
|
|
@ -89,11 +89,9 @@ pub fn check_attrs<'a>(cx: &EarlyContext, valid_idents: &[String], attrs: &'a [a
|
|||
|
||||
for attr in attrs {
|
||||
if attr.is_sugared_doc {
|
||||
if let ast::MetaItemKind::NameValue(ref doc) = attr.value.node {
|
||||
if let ast::LitKind::Str(ref doc, _) = doc.node {
|
||||
if let Some(ref doc) = attr.value_str() {
|
||||
let doc = (*doc.as_str()).to_owned();
|
||||
docs.extend_from_slice(&strip_doc_comment_decoration((doc, attr.span)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#![feature(slice_patterns)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(conservative_impl_trait)]
|
||||
#![feature(collections_bound)]
|
||||
|
||||
#![allow(indexing_slicing, shadow_reuse, unknown_lints, missing_docs_in_private_items)]
|
||||
#![allow(needless_lifetimes)]
|
||||
|
|
|
@ -77,7 +77,7 @@ impl MissingDoc {
|
|||
return;
|
||||
}
|
||||
|
||||
let has_doc = attrs.iter().any(|a| a.is_value_str() && a.name() == "doc");
|
||||
let has_doc = attrs.iter().any(|a| a.is_value_str() && a.name().map_or(false, |n| n == "doc"));
|
||||
if !has_doc {
|
||||
cx.span_lint(MISSING_DOCS_IN_PRIVATE_ITEMS,
|
||||
sp,
|
||||
|
|
|
@ -150,9 +150,5 @@ impl EarlyLintPass for ReturnPass {
|
|||
}
|
||||
|
||||
fn attr_is_cfg(attr: &ast::Attribute) -> bool {
|
||||
if let ast::MetaItemKind::List(_) = attr.value.node {
|
||||
attr.name() == "cfg"
|
||||
} else {
|
||||
false
|
||||
}
|
||||
attr.meta_item_list().is_some() && attr.name().map_or(false, |n| n == "cfg")
|
||||
}
|
||||
|
|
|
@ -678,17 +678,13 @@ fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'
|
|||
if attr.is_sugared_doc {
|
||||
continue;
|
||||
}
|
||||
if let ast::MetaItemKind::NameValue(ref value) = attr.value.node {
|
||||
if attr.name() == name {
|
||||
if let LitKind::Str(ref s, _) = value.node {
|
||||
if let Ok(value) = FromStr::from_str(&*s.as_str()) {
|
||||
attr::mark_used(attr);
|
||||
f(value)
|
||||
} else {
|
||||
sess.span_err(value.span, "not a number");
|
||||
}
|
||||
if let Some(ref value) = attr.value_str() {
|
||||
if attr.name().map_or(false, |n| n == name) {
|
||||
if let Ok(value) = FromStr::from_str(&*value.as_str()) {
|
||||
attr::mark_used(attr);
|
||||
f(value)
|
||||
} else {
|
||||
unreachable!()
|
||||
sess.span_err(attr.span, "not a number");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#![feature(rustc_private)]
|
||||
#![feature(collections_bound)]
|
||||
|
||||
extern crate clippy_lints;
|
||||
extern crate syntax;
|
||||
|
|
Loading…
Reference in a new issue