Rustup to *rustc 1.15.0-nightly (7b3eeea22 2016-11-21)*

This commit is contained in:
mcarton
2016-11-23 21:19:03 +01:00
parent 530083c3b9
commit c35f82b823
28 changed files with 111 additions and 105 deletions

View File

@@ -10,22 +10,20 @@ use toml;
/// Get the configuration file from arguments.
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()) {
match arg.node {
ast::MetaItemKind::Word(ref name) |
ast::MetaItemKind::List(ref name, _) => {
if name == &"conf_file" {
return Err(("`conf_file` must be a named value", arg.span));
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))
}
}
ast::MetaItemKind::NameValue(ref name, ref value) => {
if name == &"conf_file" {
return if let ast::LitKind::Str(ref file, _) = value.node {
ast::MetaItemKind::NameValue(ref value) => {
if let ast::LitKind::Str(ref file, _) = value.node {
Ok(Some(file.to_string().into()))
} else {
Err(("`conf_file` value must be a string", value.span))
};
}
}
}
};
}
}

View File

@@ -61,7 +61,7 @@ pub fn range(expr: &hir::Expr) -> Option<Range> {
/// Find the field named `name` in the field. Always return `Some` for convenience.
fn get_field<'a>(name: &str, fields: &'a [hir::Field]) -> Option<&'a hir::Expr> {
let expr = &fields.iter()
.find(|field| field.name.node.as_str() == name)
.find(|field| field.name.node == name)
.unwrap_or_else(|| panic!("missing {} field for range", name))
.expr;

View File

@@ -2,7 +2,7 @@ use rustc::lint::*;
use rustc::hir::*;
use rustc::hir::intravisit::{Visitor, walk_expr};
use utils::{paths, match_path, span_lint};
use syntax::parse::token::InternedString;
use syntax::symbol::InternedString;
use syntax::ast::{Name, NodeId, ItemKind, Crate as AstCrate};
use syntax::codemap::Span;
use std::collections::{HashSet, HashMap};
@@ -63,9 +63,9 @@ impl LintPass for Clippy {
impl EarlyLintPass for Clippy {
fn check_crate(&mut self, cx: &EarlyContext, krate: &AstCrate) {
if let Some(utils) = krate.module.items.iter().find(|item| item.ident.name.as_str() == "utils") {
if let Some(utils) = krate.module.items.iter().find(|item| item.ident.name == "utils") {
if let ItemKind::Mod(ref utils_mod) = utils.node {
if let Some(paths) = utils_mod.items.iter().find(|item| item.ident.name.as_str() == "paths") {
if let Some(paths) = utils_mod.items.iter().find(|item| item.ident.name == "paths") {
if let ItemKind::Mod(ref paths_mod) = paths.node {
let mut last_name: Option<InternedString> = None;
for item in &paths_mod.items {
@@ -109,7 +109,7 @@ impl LateLintPass for LintWithoutLintPass {
if let ItemStatic(ref ty, MutImmutable, ref expr) = item.node {
if is_lint_ref_type(ty) {
self.declared_lints.insert(item.name, item.span);
} else if is_lint_array_type(ty) && item.vis == Visibility::Inherited && item.name.as_str() == "ARRAY" {
} else if is_lint_array_type(ty) && item.vis == Visibility::Inherited && item.name == "ARRAY" {
let mut collector = LintCollector { output: &mut self.registered_lints };
collector.visit_expr(expr);
}

View File

@@ -129,10 +129,10 @@ pub fn in_external_macro<T: LintContext>(cx: &T, span: Span) -> bool {
///
/// See also the `paths` module.
pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
use syntax::parse::token;
use syntax::symbol;
struct AbsolutePathBuffer {
names: Vec<token::InternedString>,
names: Vec<symbol::InternedString>,
}
impl ty::item_path::ItemPathBuffer for AbsolutePathBuffer {
@@ -142,7 +142,7 @@ pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
}
fn push(&mut self, text: &str) {
self.names.push(token::intern(text).as_str());
self.names.push(symbol::Symbol::intern(text).as_str());
}
}
@@ -150,7 +150,8 @@ pub fn match_def_path(cx: &LateContext, def_id: DefId, path: &[&str]) -> bool {
cx.tcx.push_item_path(&mut apb, def_id);
apb.names == path
apb.names.len() == path.len() &&
apb.names.iter().zip(path.iter()).all(|(a, &b)| &**a == b)
}
/// Check if type is struct, enum or union type with given def path.
@@ -202,7 +203,7 @@ pub fn match_trait_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool
/// match_path(path, &["std", "rt", "begin_unwind"])
/// ```
pub fn match_path(path: &Path, segments: &[&str]) -> bool {
path.segments.iter().rev().zip(segments.iter().rev()).all(|(a, b)| a.name.as_str() == *b)
path.segments.iter().rev().zip(segments.iter().rev()).all(|(a, b)| a.name == *b)
}
/// Match a `Path` against a slice of segment string literals, e.g.
@@ -212,7 +213,7 @@ pub fn match_path(path: &Path, segments: &[&str]) -> bool {
/// match_path(path, &["std", "rt", "begin_unwind"])
/// ```
pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
path.segments.iter().rev().zip(segments.iter().rev()).all(|(a, b)| a.identifier.name.as_str() == *b)
path.segments.iter().rev().zip(segments.iter().rev()).all(|(a, b)| a.identifier.name == *b)
}
/// Get the definition associated to a path.
@@ -234,7 +235,7 @@ pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
};
for item in &mem::replace(&mut items, vec![]) {
if item.name.as_str() == *segment {
if item.name == *segment {
if path_it.peek().is_none() {
return Some(item.def);
}
@@ -297,7 +298,7 @@ pub fn method_chain_args<'a>(expr: &'a Expr, methods: &[&str]) -> Option<Vec<&'a
for method_name in methods.iter().rev() {
// method chains are stored last -> first
if let ExprMethodCall(ref name, _, ref args) = current.node {
if name.node.as_str() == *method_name {
if name.node == *method_name {
matched.push(args); // build up `matched` backwards
current = &args[0] // go to parent expression
} else {
@@ -580,13 +581,13 @@ impl LimitStack {
fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'static str, mut f: F) {
for attr in attrs {
if attr.node.is_sugared_doc {
if attr.is_sugared_doc {
continue;
}
if let ast::MetaItemKind::NameValue(ref key, ref value) = attr.node.value.node {
if *key == name {
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) {
if let Ok(value) = FromStr::from_str(&*s.as_str()) {
attr::mark_used(attr);
f(value)
} else {
@@ -610,7 +611,7 @@ pub fn is_expn_of(cx: &LateContext, mut span: Span, name: &str) -> Option<Span>
.with_expn_info(span.expn_id, |expn| expn.map(|ei| (ei.callee.name(), ei.call_site)));
match span_name_span {
Some((mac_name, new_span)) if mac_name.as_str() == name => return Some(new_span),
Some((mac_name, new_span)) if mac_name == name => return Some(new_span),
None => return None,
Some((_, new_span)) => span = new_span,
}
@@ -631,7 +632,7 @@ pub fn is_direct_expn_of(cx: &LateContext, span: Span, name: &str) -> Option<Spa
.with_expn_info(span.expn_id, |expn| expn.map(|ei| (ei.callee.name(), ei.call_site)));
match span_name_span {
Some((mac_name, new_span)) if mac_name.as_str() == name => Some(new_span),
Some((mac_name, new_span)) if mac_name == name => Some(new_span),
_ => None,
}
}