Skip to content

Commit 0b7de0d

Browse files
authored
Merge pull request #1357 from Manishearth/rustup
Rustup to *rustc 1.15.0-nightly (7b3eeea 2016-11-21)* and bump to 0.0.101
2 parents 530083c + 338690b commit 0b7de0d

31 files changed

+120
-108
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 0.0.101 — 2016-11-23
5+
* Update to *rustc 1.15.0-nightly (7b3eeea22 2016-11-21)*
6+
* New lint: [`string_extend_chars`]
7+
48
## 0.0.100 — 2016-11-20
59
* Update to *rustc 1.15.0-nightly (ac635aa95 2016-11-18)*
610

711
## 0.0.99 — 2016-11-18
812
* Update to rustc 1.15.0-nightly (0ed951993 2016-11-14)
13+
* New lint: [`get_unwrap`]
914

1015
## 0.0.98 — 2016-11-08
1116
* Fixes a an issue due to a change in how cargo handles `--sysroot`, which broke `cargo clippy`
@@ -16,6 +21,7 @@ All notable changes to this project will be documented in this file.
1621
compatibility.
1722
* `cargo clippy --help` is more helping (and less helpful :smile:)
1823
* Rustup to *rustc 1.14.0-nightly (5665bdf3e 2016-11-02)*
24+
* New lints: [`if_let_redundant_pattern_matching`], [`partialeq_ne_impl`]
1925

2026
## 0.0.96 — 2016-10-22
2127
* Rustup to *rustc 1.14.0-nightly (f09420685 2016-10-20)*

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.100"
3+
version = "0.0.101"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -25,7 +25,7 @@ test = false
2525

2626
[dependencies]
2727
# begin automatic update
28-
clippy_lints = { version = "0.0.100", path = "clippy_lints" }
28+
clippy_lints = { version = "0.0.101", path = "clippy_lints" }
2929
# end automatic update
3030

3131
[dev-dependencies]

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin automatic update
4-
version = "0.0.100"
4+
version = "0.0.101"
55
# end automatic update
66
authors = [
77
"Manish Goregaokar <[email protected]>",

clippy_lints/src/approx_const.rs

Lines changed: 3 additions & 1 deletion
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

Lines changed: 12 additions & 14 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 8 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 3 deletions
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
}

0 commit comments

Comments
 (0)