mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +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
|
MSYS2_BITS: 64
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- set PATH=C:\Program Files\Git\mingw64\bin;%PATH%
|
||||||
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
|
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
|
||||||
- rustup-init.exe -y --default-host %TARGET% --default-toolchain nightly
|
- 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
|
- 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 {
|
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 MetaItemKind::List(ref items) = attr.value.node {
|
if let Some(ref items) = attr.meta_item_list() {
|
||||||
if items.is_empty() || attr.name() != "deprecated" {
|
if items.is_empty() || attr.name().map_or(true, |n| n != "deprecated") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for item in items {
|
for item in items {
|
||||||
|
@ -110,31 +110,33 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
|
||||||
ItemExternCrate(_) |
|
ItemExternCrate(_) |
|
||||||
ItemUse(_, _) => {
|
ItemUse(_, _) => {
|
||||||
for attr in &item.attrs {
|
for attr in &item.attrs {
|
||||||
if let MetaItemKind::List(ref lint_list) = attr.value.node {
|
if let Some(ref lint_list) = attr.meta_item_list() {
|
||||||
match &*attr.name().as_str() {
|
if let Some(name) = attr.name() {
|
||||||
"allow" | "warn" | "deny" | "forbid" => {
|
match &*name.as_str() {
|
||||||
// whitelist `unused_imports` and `deprecated`
|
"allow" | "warn" | "deny" | "forbid" => {
|
||||||
for lint in lint_list {
|
// whitelist `unused_imports` and `deprecated`
|
||||||
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
|
for lint in lint_list {
|
||||||
if let ItemUse(_, _) = item.node {
|
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
|
||||||
return;
|
if let ItemUse(_, _) = item.node {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if let Some(mut sugg) = snippet_opt(cx, attr.span) {
|
||||||
if let Some(mut sugg) = snippet_opt(cx, attr.span) {
|
if sugg.len() > 1 {
|
||||||
if sugg.len() > 1 {
|
span_lint_and_then(cx,
|
||||||
span_lint_and_then(cx,
|
USELESS_ATTRIBUTE,
|
||||||
USELESS_ATTRIBUTE,
|
attr.span,
|
||||||
attr.span,
|
"useless lint attribute",
|
||||||
"useless lint attribute",
|
|db| {
|
||||||
|db| {
|
sugg.insert(1, '!');
|
||||||
sugg.insert(1, '!');
|
db.span_suggestion(attr.span, "if you just forgot a `!`, use", sugg);
|
||||||
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 {
|
for attr in attrs {
|
||||||
if let MetaItemKind::List(ref values) = attr.value.node {
|
if let Some(ref values) = attr.meta_item_list() {
|
||||||
if values.len() != 1 || attr.name() != "inline" {
|
if values.len() != 1 || attr.name().map_or(true, |n| n != "inline") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if is_word(&values[0], "always") {
|
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 {
|
for attr in attrs {
|
||||||
if attr.is_sugared_doc {
|
if attr.is_sugared_doc {
|
||||||
if let ast::MetaItemKind::NameValue(ref doc) = attr.value.node {
|
if let Some(ref doc) = attr.value_str() {
|
||||||
if let ast::LitKind::Str(ref doc, _) = doc.node {
|
|
||||||
let doc = (*doc.as_str()).to_owned();
|
let doc = (*doc.as_str()).to_owned();
|
||||||
docs.extend_from_slice(&strip_doc_comment_decoration((doc, attr.span)));
|
docs.extend_from_slice(&strip_doc_comment_decoration((doc, attr.span)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#![feature(slice_patterns)]
|
#![feature(slice_patterns)]
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
#![feature(conservative_impl_trait)]
|
#![feature(conservative_impl_trait)]
|
||||||
#![feature(collections_bound)]
|
|
||||||
|
|
||||||
#![allow(indexing_slicing, shadow_reuse, unknown_lints, missing_docs_in_private_items)]
|
#![allow(indexing_slicing, shadow_reuse, unknown_lints, missing_docs_in_private_items)]
|
||||||
#![allow(needless_lifetimes)]
|
#![allow(needless_lifetimes)]
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl MissingDoc {
|
||||||
return;
|
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 {
|
if !has_doc {
|
||||||
cx.span_lint(MISSING_DOCS_IN_PRIVATE_ITEMS,
|
cx.span_lint(MISSING_DOCS_IN_PRIVATE_ITEMS,
|
||||||
sp,
|
sp,
|
||||||
|
|
|
@ -150,9 +150,5 @@ impl EarlyLintPass for ReturnPass {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn attr_is_cfg(attr: &ast::Attribute) -> bool {
|
fn attr_is_cfg(attr: &ast::Attribute) -> bool {
|
||||||
if let ast::MetaItemKind::List(_) = attr.value.node {
|
attr.meta_item_list().is_some() && attr.name().map_or(false, |n| n == "cfg")
|
||||||
attr.name() == "cfg"
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -678,17 +678,13 @@ fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'
|
||||||
if attr.is_sugared_doc {
|
if attr.is_sugared_doc {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let ast::MetaItemKind::NameValue(ref value) = attr.value.node {
|
if let Some(ref value) = attr.value_str() {
|
||||||
if attr.name() == name {
|
if attr.name().map_or(false, |n| n == name) {
|
||||||
if let LitKind::Str(ref s, _) = value.node {
|
if let Ok(value) = FromStr::from_str(&*value.as_str()) {
|
||||||
if let Ok(value) = FromStr::from_str(&*s.as_str()) {
|
attr::mark_used(attr);
|
||||||
attr::mark_used(attr);
|
f(value)
|
||||||
f(value)
|
|
||||||
} else {
|
|
||||||
sess.span_err(value.span, "not a number");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
sess.span_err(attr.span, "not a number");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![feature(collections_bound)]
|
|
||||||
|
|
||||||
extern crate clippy_lints;
|
extern crate clippy_lints;
|
||||||
extern crate syntax;
|
extern crate syntax;
|
||||||
|
|
Loading…
Reference in a new issue