Rustup to *1.13.0-nightly (eac41469d 2016-08-30)*
This commit is contained in:
@@ -4,7 +4,7 @@ use reexport::*;
|
|||||||
use rustc::lint::*;
|
use rustc::lint::*;
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
use syntax::ast::{Attribute, Lit, LitKind, MetaItemKind};
|
use syntax::ast::{Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem, NestedMetaItemKind};
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use utils::{in_macro, match_path, span_lint, span_lint_and_then, snippet_opt};
|
use utils::{in_macro, match_path, span_lint, span_lint_and_then, snippet_opt};
|
||||||
use utils::paths;
|
use utils::paths;
|
||||||
@@ -89,11 +89,13 @@ impl LateLintPass for AttrPass {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for item in items {
|
for item in items {
|
||||||
if let MetaItemKind::NameValue(ref name, ref lit) = item.node {
|
if_let_chain! {[
|
||||||
if name == &"since" {
|
let NestedMetaItemKind::MetaItem(ref mi) = item.node,
|
||||||
|
let MetaItemKind::NameValue(ref name, ref lit) = mi.node,
|
||||||
|
name == &"since",
|
||||||
|
], {
|
||||||
check_semver(cx, item.span, lit);
|
check_semver(cx, item.span, lit);
|
||||||
}
|
}}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,14 +113,12 @@ impl LateLintPass for AttrPass {
|
|||||||
"allow" | "warn" | "deny" | "forbid" => {
|
"allow" | "warn" | "deny" | "forbid" => {
|
||||||
// whitelist `unused_imports`
|
// whitelist `unused_imports`
|
||||||
for lint in lint_list {
|
for lint in lint_list {
|
||||||
if let MetaItemKind::Word(ref word) = lint.node {
|
if is_word(lint, "unused_imports") {
|
||||||
if word == "unused_imports" {
|
|
||||||
if let ItemUse(_) = item.node {
|
if let ItemUse(_) = item.node {
|
||||||
return;
|
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, USELESS_ATTRIBUTE, attr.span,
|
span_lint_and_then(cx, USELESS_ATTRIBUTE, attr.span,
|
||||||
@@ -214,10 +214,7 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
|
|||||||
if values.len() != 1 || inline != &"inline" {
|
if values.len() != 1 || inline != &"inline" {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let MetaItemKind::Word(ref always) = values[0].node {
|
if is_word(&values[0], "always") {
|
||||||
if always != &"always" {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
span_lint(cx,
|
span_lint(cx,
|
||||||
INLINE_ALWAYS,
|
INLINE_ALWAYS,
|
||||||
attr.span,
|
attr.span,
|
||||||
@@ -239,3 +236,13 @@ fn check_semver(cx: &LateContext, span: Span, lit: &Lit) {
|
|||||||
span,
|
span,
|
||||||
"the since field must contain a semver-compliant version");
|
"the since field must contain a semver-compliant version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_word(nmi: &NestedMetaItem, expected: &str) -> bool {
|
||||||
|
if let NestedMetaItemKind::MetaItem(ref mi) = nmi.node {
|
||||||
|
if let MetaItemKind::Word(ref word) = mi.node {
|
||||||
|
return word == expected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use rustc::hir;
|
|||||||
use rustc::lint::*;
|
use rustc::lint::*;
|
||||||
use rustc::ty;
|
use rustc::ty;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr::{self, AttrMetaMethods};
|
use syntax::attr;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use utils::in_macro;
|
use utils::in_macro;
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ impl LateLintPass for MissingDoc {
|
|||||||
let doc_hidden = self.doc_hidden() || attrs.iter().any(|attr| {
|
let doc_hidden = self.doc_hidden() || attrs.iter().any(|attr| {
|
||||||
attr.check_name("doc") && match attr.meta_item_list() {
|
attr.check_name("doc") && match attr.meta_item_list() {
|
||||||
None => false,
|
None => false,
|
||||||
Some(l) => attr::contains_name(&l[..], "hidden"),
|
Some(l) => attr::list_contains_name(&l[..], "hidden"),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
self.doc_hidden_stack.push(doc_hidden);
|
self.doc_hidden_stack.push(doc_hidden);
|
||||||
@@ -123,6 +123,7 @@ impl LateLintPass for MissingDoc {
|
|||||||
hir::ItemStruct(..) => "a struct",
|
hir::ItemStruct(..) => "a struct",
|
||||||
hir::ItemTrait(..) => "a trait",
|
hir::ItemTrait(..) => "a trait",
|
||||||
hir::ItemTy(..) => "a type alias",
|
hir::ItemTy(..) => "a type alias",
|
||||||
|
hir::ItemUnion(..) => "a union",
|
||||||
hir::ItemDefaultImpl(..) |
|
hir::ItemDefaultImpl(..) |
|
||||||
hir::ItemExternCrate(..) |
|
hir::ItemExternCrate(..) |
|
||||||
hir::ItemForeignMod(..) |
|
hir::ItemForeignMod(..) |
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ impl LateLintPass for UnsafeNameRemoval {
|
|||||||
ViewPath_::ViewPathList(_, ref path_list_items) => {
|
ViewPath_::ViewPathList(_, ref path_list_items) => {
|
||||||
for path_list_item in path_list_items.iter() {
|
for path_list_item in path_list_items.iter() {
|
||||||
let plid = path_list_item.node;
|
let plid = path_list_item.node;
|
||||||
if let (Some(name), Some(rename)) = (plid.name(), plid.rename()) {
|
if let Some(rename) = plid.rename {
|
||||||
unsafe_to_safe_check(name, rename, cx, &item.span);
|
unsafe_to_safe_check(plid.name, rename, cx, &item.span);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
use std::{fmt, fs, io};
|
use std::{fmt, fs, io};
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use syntax::{ast, codemap, ptr};
|
use syntax::{ast, codemap};
|
||||||
use syntax::parse::token;
|
use syntax::parse::token;
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
/// Get the configuration file from arguments.
|
/// Get the configuration file from arguments.
|
||||||
pub fn file(args: &[ptr::P<ast::MetaItem>]) -> Result<Option<token::InternedString>, (&'static str, codemap::Span)> {
|
pub fn file(args: &[codemap::Spanned<ast::NestedMetaItemKind>]) -> Result<Option<token::InternedString>, (&'static str, codemap::Span)> {
|
||||||
for arg in args {
|
for arg in args.iter().filter_map(|a| a.meta_item()) {
|
||||||
match arg.node {
|
match arg.node {
|
||||||
ast::MetaItemKind::Word(ref name) |
|
ast::MetaItemKind::Word(ref name) |
|
||||||
ast::MetaItemKind::List(ref name, _) => {
|
ast::MetaItemKind::List(ref name, _) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user