Skip to content

Commit 6201d17

Browse files
committed
Rustup to *rustc 1.15.0-nightly (7b3eeea 2016-11-21)*
1 parent 530083c commit 6201d17

27 files changed

+109
-103
lines changed

clippy_lints/src/approx_const.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use rustc::lint::*;
22
use rustc::hir::*;
33
use std::f64::consts as f64;
44
use syntax::ast::{Lit, LitKind, FloatTy};
5+
use syntax::symbol;
56
use utils::span_lint;
67

78
/// **What it does:** Checks for floating point literals that approximate
@@ -75,7 +76,8 @@ fn check_lit(cx: &LateContext, lit: &Lit, e: &Expr) {
7576
}
7677
}
7778

78-
fn check_known_consts(cx: &LateContext, e: &Expr, s: &str, module: &str) {
79+
fn check_known_consts(cx: &LateContext, e: &Expr, s: &symbol::Symbol, module: &str) {
80+
let s = &*s.as_str();
7981
if s.parse::<f64>().is_ok() {
8082
for &(constant, name, min_digits) in KNOWN_CONSTS {
8183
if is_approx_const(constant, s, min_digits) {

clippy_lints/src/attrs.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ impl LintPass for AttrPass {
8383

8484
impl LateLintPass for AttrPass {
8585
fn check_attribute(&mut self, cx: &LateContext, attr: &Attribute) {
86-
if let MetaItemKind::List(ref name, ref items) = attr.node.value.node {
87-
if items.is_empty() || name != &"deprecated" {
86+
if let MetaItemKind::List(ref items) = attr.value.node {
87+
if items.is_empty() || attr.name() != "deprecated" {
8888
return;
8989
}
9090
for item in items {
9191
if_let_chain! {[
9292
let NestedMetaItemKind::MetaItem(ref mi) = item.node,
93-
let MetaItemKind::NameValue(ref name, ref lit) = mi.node,
94-
name == &"since",
93+
let MetaItemKind::NameValue(ref lit) = mi.node,
94+
mi.name() == "since",
9595
], {
9696
check_semver(cx, item.span, lit);
9797
}}
@@ -107,8 +107,8 @@ impl LateLintPass for AttrPass {
107107
ItemExternCrate(_) |
108108
ItemUse(_) => {
109109
for attr in &item.attrs {
110-
if let MetaItemKind::List(ref name, ref lint_list) = attr.node.value.node {
111-
match &**name {
110+
if let MetaItemKind::List(ref lint_list) = attr.value.node {
111+
match &*attr.name().as_str() {
112112
"allow" | "warn" | "deny" | "forbid" => {
113113
// whitelist `unused_imports`
114114
for lint in lint_list {
@@ -210,8 +210,8 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
210210
}
211211

212212
for attr in attrs {
213-
if let MetaItemKind::List(ref inline, ref values) = attr.node.value.node {
214-
if values.len() != 1 || inline != &"inline" {
213+
if let MetaItemKind::List(ref values) = attr.value.node {
214+
if values.len() != 1 || attr.name() != "inline" {
215215
continue;
216216
}
217217
if is_word(&values[0], "always") {
@@ -227,7 +227,7 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
227227

228228
fn check_semver(cx: &LateContext, span: Span, lit: &Lit) {
229229
if let LitKind::Str(ref is, _) = lit.node {
230-
if Version::parse(&*is).is_ok() {
230+
if Version::parse(&*is.as_str()).is_ok() {
231231
return;
232232
}
233233
}
@@ -239,10 +239,8 @@ fn check_semver(cx: &LateContext, span: Span, lit: &Lit) {
239239

240240
fn is_word(nmi: &NestedMetaItem, expected: &str) -> bool {
241241
if let NestedMetaItemKind::MetaItem(ref mi) = nmi.node {
242-
if let MetaItemKind::Word(ref word) = mi.node {
243-
return word == expected;
244-
}
242+
mi.is_word() && mi.name() == expected
243+
} else {
244+
false
245245
}
246-
247-
false
248246
}

clippy_lints/src/copies.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc::ty;
33
use rustc::hir::*;
44
use std::collections::HashMap;
55
use std::collections::hash_map::Entry;
6-
use syntax::parse::token::InternedString;
6+
use syntax::symbol::InternedString;
77
use syntax::util::small_vector::SmallVector;
88
use utils::{SpanlessEq, SpanlessHash};
99
use utils::{get_parent_expr, in_macro, span_lint_and_then, span_note_and_lint, snippet};

clippy_lints/src/doc.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ impl EarlyLintPass for Doc {
5959
/// `syntax::parse::lexer::comments::strip_doc_comment_decoration` because we need to keep track of
6060
/// the span but this function is inspired from the later.
6161
#[allow(cast_possible_truncation)]
62-
pub fn strip_doc_comment_decoration((comment, span): (&str, Span)) -> Vec<(&str, Span)> {
62+
pub fn strip_doc_comment_decoration((comment, span): (String, Span)) -> Vec<(String, Span)> {
6363
// one-line comments lose their prefix
6464
const ONELINERS: &'static [&'static str] = &["///!", "///", "//!", "//"];
6565
for prefix in ONELINERS {
6666
if comment.starts_with(*prefix) {
6767
return vec![(
68-
&comment[prefix.len()..],
68+
comment[prefix.len()..].to_owned(),
6969
Span { lo: span.lo + BytePos(prefix.len() as u32), ..span }
7070
)];
7171
}
@@ -77,7 +77,7 @@ pub fn strip_doc_comment_decoration((comment, span): (&str, Span)) -> Vec<(&str,
7777
debug_assert_eq!(offset as u32 as usize, offset);
7878

7979
(
80-
line,
80+
line.to_owned(),
8181
Span {
8282
lo: span.lo + BytePos(offset as u32),
8383
..span
@@ -93,9 +93,10 @@ pub fn check_attrs<'a>(cx: &EarlyContext, valid_idents: &[String], attrs: &'a [a
9393
let mut docs = vec![];
9494

9595
for attr in attrs {
96-
if attr.node.is_sugared_doc {
97-
if let ast::MetaItemKind::NameValue(_, ref doc) = attr.node.value.node {
96+
if attr.is_sugared_doc {
97+
if let ast::MetaItemKind::NameValue(ref doc) = attr.value.node {
9898
if let ast::LitKind::Str(ref doc, _) = doc.node {
99+
let doc = (*doc.as_str()).to_owned();
99100
docs.extend_from_slice(&strip_doc_comment_decoration((doc, attr.span)));
100101
}
101102
}
@@ -108,7 +109,7 @@ pub fn check_attrs<'a>(cx: &EarlyContext, valid_idents: &[String], attrs: &'a [a
108109
}
109110

110111
#[allow(while_let_loop)] // #362
111-
fn check_doc(cx: &EarlyContext, valid_idents: &[String], docs: &[(&str, Span)]) -> Result<(), ()> {
112+
fn check_doc(cx: &EarlyContext, valid_idents: &[String], docs: &[(String, Span)]) -> Result<(), ()> {
112113
// In markdown, `_` can be used to emphasize something, or, is a raw `_` depending on context.
113114
// There really is no markdown specification that would disambiguate this properly. This is
114115
// what GitHub and Rustdoc do:
@@ -136,7 +137,7 @@ fn check_doc(cx: &EarlyContext, valid_idents: &[String], docs: &[(&str, Span)])
136137
/// First byte of the current potential match
137138
current_word_begin: usize,
138139
/// List of lines and their associated span
139-
docs: &'a [(&'a str, Span)],
140+
docs: &'a [(String, Span)],
140141
/// Index of the current line we are parsing
141142
line: usize,
142143
/// Whether we are in a link
@@ -155,7 +156,8 @@ fn check_doc(cx: &EarlyContext, valid_idents: &[String], docs: &[(&str, Span)])
155156
}
156157

157158
fn line(&self) -> (&'a str, Span) {
158-
self.docs[self.line]
159+
let (ref doc, span) = self.docs[self.line];
160+
(doc, span)
159161
}
160162

161163
fn peek(&self) -> Option<char> {

clippy_lints/src/entry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ fn check_cond<'a, 'tcx, 'b>(cx: &'a LateContext<'a, 'tcx>, check: &'b Expr) -> O
8282
if_let_chain! {[
8383
let ExprMethodCall(ref name, _, ref params) = check.node,
8484
params.len() >= 2,
85-
name.node.as_str() == "contains_key",
85+
&*name.node.as_str() == "contains_key",
8686
let ExprAddrOf(_, ref key) = params[1].node
8787
], {
8888
let map = &params[0];
@@ -116,7 +116,7 @@ impl<'a, 'tcx, 'v, 'b> Visitor<'v> for InsertVisitor<'a, 'tcx, 'b> {
116116
if_let_chain! {[
117117
let ExprMethodCall(ref name, _, ref params) = expr.node,
118118
params.len() == 3,
119-
name.node.as_str() == "insert",
119+
&*name.node.as_str() == "insert",
120120
get_item_name(self.cx, self.map) == get_item_name(self.cx, &*params[0]),
121121
SpanlessEq::new(self.cx).eq_expr(self.key, &params[1])
122122
], {

clippy_lints/src/enum_variants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use rustc::lint::*;
44
use syntax::ast::*;
55
use syntax::codemap::Span;
6-
use syntax::parse::token::InternedString;
6+
use syntax::symbol::InternedString;
77
use utils::{span_help_and_lint, span_lint};
88
use utils::{camel_case_from, camel_case_until, in_macro};
99

clippy_lints/src/format.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use rustc::hir::map::Node::NodeItem;
33
use rustc::lint::*;
44
use rustc::ty::TypeVariants;
55
use syntax::ast::LitKind;
6+
use syntax::symbol::InternedString;
67
use utils::paths;
78
use utils::{is_expn_of, match_def_path, match_type, resolve_node, span_lint, walk_ptrs_ty};
89

@@ -73,14 +74,14 @@ impl LateLintPass for Pass {
7374
/// Returns the slice of format string parts in an `Arguments::new_v1` call.
7475
/// Public because it's shared with a lint in print.rs.
7576
pub fn get_argument_fmtstr_parts<'a, 'b>(cx: &LateContext<'a, 'b>, expr: &'a Expr)
76-
-> Option<Vec<&'a str>> {
77+
-> Option<Vec<InternedString>> {
7778
if_let_chain! {[
7879
let ExprBlock(ref block) = expr.node,
7980
block.stmts.len() == 1,
8081
let StmtDecl(ref decl, _) = block.stmts[0].node,
8182
let DeclItem(ref decl) = decl.node,
8283
let Some(NodeItem(decl)) = cx.tcx.map.find(decl.id),
83-
decl.name.as_str() == "__STATIC_FMTSTR",
84+
&*decl.name.as_str() == "__STATIC_FMTSTR",
8485
let ItemStatic(_, _, ref expr) = decl.node,
8586
let ExprAddrOf(_, ref expr) = expr.node, // &["…", "…", …]
8687
let ExprArray(ref exprs) = expr.node,
@@ -89,7 +90,7 @@ pub fn get_argument_fmtstr_parts<'a, 'b>(cx: &LateContext<'a, 'b>, expr: &'a Exp
8990
for expr in exprs {
9091
if let ExprLit(ref lit) = expr.node {
9192
if let LitKind::Str(ref lit, _) = lit.node {
92-
result.push(&**lit);
93+
result.push(lit.as_str());
9394
}
9495
}
9596
}

clippy_lints/src/len_zero.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl LateLintPass for LenZero {
9090

9191
fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItem]) {
9292
fn is_named_self(item: &TraitItem, name: &str) -> bool {
93-
item.name.as_str() == name &&
93+
&*item.name.as_str() == name &&
9494
if let MethodTraitItem(ref sig, _) = item.node {
9595
if sig.decl.has_self() {
9696
sig.decl.inputs.len() == 1
@@ -117,7 +117,7 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItem]) {
117117

118118
fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
119119
fn is_named_self(cx: &LateContext, item: &ImplItemRef, name: &str) -> bool {
120-
item.name.as_str() == name &&
120+
&*item.name.as_str() == name &&
121121
if let AssociatedItemKind::Method { has_self } = item.kind {
122122
has_self && {
123123
let did = cx.tcx.map.local_def_id(item.id.node_id);
@@ -157,7 +157,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
157157
fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str) {
158158
// check if we are in an is_empty() method
159159
if let Some(name) = get_item_name(cx, left) {
160-
if name.as_str() == "is_empty" {
160+
if &*name.as_str() == "is_empty" {
161161
return;
162162
}
163163
}
@@ -172,7 +172,7 @@ fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str)
172172

173173
fn check_len_zero(cx: &LateContext, span: Span, name: &Name, args: &[P<Expr>], lit: &Lit, op: &str) {
174174
if let Spanned { node: LitKind::Int(0, _), .. } = *lit {
175-
if name.as_str() == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
175+
if &*name.as_str() == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
176176
span_lint_and_then(cx, LEN_ZERO, span, "length comparison to zero", |db| {
177177
db.span_suggestion(span,
178178
"consider using `is_empty`",
@@ -187,7 +187,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
187187
/// Get an `AssociatedItem` and return true if it matches `is_empty(self)`.
188188
fn is_is_empty(cx: &LateContext, item: &ty::AssociatedItem) -> bool {
189189
if let ty::AssociatedKind::Method = item.kind {
190-
if item.name.as_str() == "is_empty" {
190+
if &*item.name.as_str() == "is_empty" {
191191
let ty = cx.tcx.item_type(item.def_id).fn_sig().skip_binder();
192192
ty.inputs.len() == 1
193193
} else {

clippy_lints/src/lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ fn allowed_lts_from(named_lts: &[LifetimeDef]) -> HashSet<RefLt> {
196196

197197
fn lts_from_bounds<'a, T: Iterator<Item = &'a Lifetime>>(mut vec: Vec<RefLt>, bounds_lts: T) -> Vec<RefLt> {
198198
for lt in bounds_lts {
199-
if lt.name.as_str() != "'static" {
199+
if &*lt.name.as_str() != "'static" {
200200
vec.push(RefLt::Named(lt.name));
201201
}
202202
}
@@ -225,7 +225,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
225225

226226
fn record(&mut self, lifetime: &Option<Lifetime>) {
227227
if let Some(ref lt) = *lifetime {
228-
if lt.name.as_str() == "'static" {
228+
if &*lt.name.as_str() == "'static" {
229229
self.lts.push(RefLt::Static);
230230
} else {
231231
self.lts.push(RefLt::Named(lt.name));

clippy_lints/src/loops.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ impl LateLintPass for Pass {
370370
&ExprMethodCall(method_name, _, ref method_args)) = (pat, &match_expr.node) {
371371
let iter_expr = &method_args[0];
372372
if let Some(lhs_constructor) = path.segments.last() {
373-
if method_name.node.as_str() == "next" &&
373+
if &*method_name.node.as_str() == "next" &&
374374
match_trait_method(cx, match_expr, &paths::ITERATOR) &&
375-
lhs_constructor.name.as_str() == "Some" &&
375+
&*lhs_constructor.name.as_str() == "Some" &&
376376
!is_refutable(cx, &pat_args[0]) &&
377377
!is_iterator_used_after_while_let(cx, iter_expr) {
378378
let iterator = snippet(cx, method_args[0].span, "_");
@@ -395,7 +395,7 @@ impl LateLintPass for Pass {
395395
fn check_stmt(&mut self, cx: &LateContext, stmt: &Stmt) {
396396
if let StmtSemi(ref expr, _) = stmt.node {
397397
if let ExprMethodCall(ref method, _, ref args) = expr.node {
398-
if args.len() == 1 && method.node.as_str() == "collect" &&
398+
if args.len() == 1 && &*method.node.as_str() == "collect" &&
399399
match_trait_method(cx, expr, &paths::ITERATOR) {
400400
span_lint(cx,
401401
UNUSED_COLLECT,
@@ -509,7 +509,7 @@ fn is_len_call(expr: &Expr, var: &Name) -> bool {
509509
if_let_chain! {[
510510
let ExprMethodCall(method, _, ref len_args) = expr.node,
511511
len_args.len() == 1,
512-
method.node.as_str() == "len",
512+
&*method.node.as_str() == "len",
513513
let ExprPath(_, ref path) = len_args[0].node,
514514
path.segments.len() == 1,
515515
&path.segments[0].name == var
@@ -580,14 +580,14 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
580580
if args.len() == 1 {
581581
let method_name = method.node;
582582
// check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
583-
if method_name.as_str() == "iter" || method_name.as_str() == "iter_mut" {
583+
if &*method_name.as_str() == "iter" || &*method_name.as_str() == "iter_mut" {
584584
if is_ref_iterable_type(cx, &args[0]) {
585585
let object = snippet(cx, args[0].span, "_");
586586
span_lint(cx,
587587
EXPLICIT_ITER_LOOP,
588588
expr.span,
589589
&format!("it is more idiomatic to loop over `&{}{}` instead of `{}.{}()`",
590-
if method_name.as_str() == "iter_mut" {
590+
if &*method_name.as_str() == "iter_mut" {
591591
"mut "
592592
} else {
593593
""
@@ -596,7 +596,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
596596
object,
597597
method_name));
598598
}
599-
} else if method_name.as_str() == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) {
599+
} else if &*method_name.as_str() == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) {
600600
let object = snippet(cx, args[0].span, "_");
601601
span_lint(cx,
602602
EXPLICIT_INTO_ITER_LOOP,
@@ -606,7 +606,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
606606
object,
607607
method_name));
608608

609-
} else if method_name.as_str() == "next" && match_trait_method(cx, arg, &paths::ITERATOR) {
609+
} else if &*method_name.as_str() == "next" && match_trait_method(cx, arg, &paths::ITERATOR) {
610610
span_lint(cx,
611611
ITER_NEXT_LOOP,
612612
expr.span,

clippy_lints/src/map_clone.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl LateLintPass for Pass {
2828
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
2929
// call to .map()
3030
if let ExprMethodCall(name, _, ref args) = expr.node {
31-
if name.node.as_str() == "map" && args.len() == 2 {
31+
if &*name.node.as_str() == "map" && args.len() == 2 {
3232
match args[1].node {
3333
ExprClosure(_, ref decl, ref closure_expr, _) => {
3434
let closure_expr = remove_blocks(closure_expr);
@@ -51,7 +51,7 @@ impl LateLintPass for Pass {
5151
}
5252
// explicit clone() calls ( .map(|x| x.clone()) )
5353
else if let ExprMethodCall(clone_call, _, ref clone_args) = closure_expr.node {
54-
if clone_call.node.as_str() == "clone" &&
54+
if &*clone_call.node.as_str() == "clone" &&
5555
clone_args.len() == 1 &&
5656
match_trait_method(cx, closure_expr, &paths::CLONE_TRAIT) &&
5757
expr_eq_name(&clone_args[0], arg_ident)

0 commit comments

Comments
 (0)