Skip to content

Rustup to *rustc 1.15.0-nightly (7b3eeea22 2016-11-21)* and bump to 0.0.101 #1357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Change Log
All notable changes to this project will be documented in this file.

## 0.0.101 — 2016-11-23
* Update to *rustc 1.15.0-nightly (7b3eeea22 2016-11-21)*
* New lint: [`string_extend_chars`]

## 0.0.100 — 2016-11-20
* Update to *rustc 1.15.0-nightly (ac635aa95 2016-11-18)*

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

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

## 0.0.96 — 2016-10-22
* Rustup to *rustc 1.14.0-nightly (f09420685 2016-10-20)*
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.100"
version = "0.0.101"
authors = [
"Manish Goregaokar <[email protected]>",
"Andre Bogus <[email protected]>",
Expand All @@ -25,7 +25,7 @@ test = false

[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.100", path = "clippy_lints" }
clippy_lints = { version = "0.0.101", path = "clippy_lints" }
# end automatic update

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "clippy_lints"
# begin automatic update
version = "0.0.100"
version = "0.0.101"
# end automatic update
authors = [
"Manish Goregaokar <[email protected]>",
Expand Down
4 changes: 3 additions & 1 deletion clippy_lints/src/approx_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rustc::lint::*;
use rustc::hir::*;
use std::f64::consts as f64;
use syntax::ast::{Lit, LitKind, FloatTy};
use syntax::symbol;
use utils::span_lint;

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

fn check_known_consts(cx: &LateContext, e: &Expr, s: &str, module: &str) {
fn check_known_consts(cx: &LateContext, e: &Expr, s: &symbol::Symbol, module: &str) {
let s = &*s.as_str();
if s.parse::<f64>().is_ok() {
for &(constant, name, min_digits) in KNOWN_CONSTS {
if is_approx_const(constant, s, min_digits) {
Expand Down
26 changes: 12 additions & 14 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ impl LintPass for AttrPass {

impl LateLintPass for AttrPass {
fn check_attribute(&mut self, cx: &LateContext, attr: &Attribute) {
if let MetaItemKind::List(ref name, ref items) = attr.node.value.node {
if items.is_empty() || name != &"deprecated" {
if let MetaItemKind::List(ref items) = attr.value.node {
if items.is_empty() || attr.name() != "deprecated" {
return;
}
for item in items {
if_let_chain! {[
let NestedMetaItemKind::MetaItem(ref mi) = item.node,
let MetaItemKind::NameValue(ref name, ref lit) = mi.node,
name == &"since",
let MetaItemKind::NameValue(ref lit) = mi.node,
mi.name() == "since",
], {
check_semver(cx, item.span, lit);
}}
Expand All @@ -107,8 +107,8 @@ impl LateLintPass for AttrPass {
ItemExternCrate(_) |
ItemUse(_) => {
for attr in &item.attrs {
if let MetaItemKind::List(ref name, ref lint_list) = attr.node.value.node {
match &**name {
if let MetaItemKind::List(ref lint_list) = attr.value.node {
match &*attr.name().as_str() {
"allow" | "warn" | "deny" | "forbid" => {
// whitelist `unused_imports`
for lint in lint_list {
Expand Down Expand Up @@ -210,8 +210,8 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
}

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

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

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;
}
mi.is_word() && mi.name() == expected
} else {
false
}

false
}
2 changes: 1 addition & 1 deletion clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc::ty;
use rustc::hir::*;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use syntax::parse::token::InternedString;
use syntax::symbol::InternedString;
use syntax::util::small_vector::SmallVector;
use utils::{SpanlessEq, SpanlessHash};
use utils::{get_parent_expr, in_macro, span_lint_and_then, span_note_and_lint, snippet};
Expand Down
18 changes: 10 additions & 8 deletions clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ impl EarlyLintPass for Doc {
/// `syntax::parse::lexer::comments::strip_doc_comment_decoration` because we need to keep track of
/// the span but this function is inspired from the later.
#[allow(cast_possible_truncation)]
pub fn strip_doc_comment_decoration((comment, span): (&str, Span)) -> Vec<(&str, Span)> {
pub fn strip_doc_comment_decoration((comment, span): (String, Span)) -> Vec<(String, Span)> {
// one-line comments lose their prefix
const ONELINERS: &'static [&'static str] = &["///!", "///", "//!", "//"];
for prefix in ONELINERS {
if comment.starts_with(*prefix) {
return vec![(
&comment[prefix.len()..],
comment[prefix.len()..].to_owned(),
Span { lo: span.lo + BytePos(prefix.len() as u32), ..span }
)];
}
Expand All @@ -77,7 +77,7 @@ pub fn strip_doc_comment_decoration((comment, span): (&str, Span)) -> Vec<(&str,
debug_assert_eq!(offset as u32 as usize, offset);

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

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

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

fn line(&self) -> (&'a str, Span) {
self.docs[self.line]
let (ref doc, span) = self.docs[self.line];
(doc, span)
}

fn peek(&self) -> Option<char> {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn check_cond<'a, 'tcx, 'b>(cx: &'a LateContext<'a, 'tcx>, check: &'b Expr) -> O
if_let_chain! {[
let ExprMethodCall(ref name, _, ref params) = check.node,
params.len() >= 2,
name.node.as_str() == "contains_key",
&*name.node.as_str() == "contains_key",
let ExprAddrOf(_, ref key) = params[1].node
], {
let map = &params[0];
Expand Down Expand Up @@ -116,7 +116,7 @@ impl<'a, 'tcx, 'v, 'b> Visitor<'v> for InsertVisitor<'a, 'tcx, 'b> {
if_let_chain! {[
let ExprMethodCall(ref name, _, ref params) = expr.node,
params.len() == 3,
name.node.as_str() == "insert",
&*name.node.as_str() == "insert",
get_item_name(self.cx, self.map) == get_item_name(self.cx, &*params[0]),
SpanlessEq::new(self.cx).eq_expr(self.key, &params[1])
], {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use rustc::lint::*;
use syntax::ast::*;
use syntax::codemap::Span;
use syntax::parse::token::InternedString;
use syntax::symbol::InternedString;
use utils::{span_help_and_lint, span_lint};
use utils::{camel_case_from, camel_case_until, in_macro};

Expand Down
7 changes: 4 additions & 3 deletions clippy_lints/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use rustc::hir::map::Node::NodeItem;
use rustc::lint::*;
use rustc::ty::TypeVariants;
use syntax::ast::LitKind;
use syntax::symbol::InternedString;
use utils::paths;
use utils::{is_expn_of, match_def_path, match_type, resolve_node, span_lint, walk_ptrs_ty};

Expand Down Expand Up @@ -73,14 +74,14 @@ impl LateLintPass for Pass {
/// Returns the slice of format string parts in an `Arguments::new_v1` call.
/// Public because it's shared with a lint in print.rs.
pub fn get_argument_fmtstr_parts<'a, 'b>(cx: &LateContext<'a, 'b>, expr: &'a Expr)
-> Option<Vec<&'a str>> {
-> Option<Vec<InternedString>> {
if_let_chain! {[
let ExprBlock(ref block) = expr.node,
block.stmts.len() == 1,
let StmtDecl(ref decl, _) = block.stmts[0].node,
let DeclItem(ref decl) = decl.node,
let Some(NodeItem(decl)) = cx.tcx.map.find(decl.id),
decl.name.as_str() == "__STATIC_FMTSTR",
&*decl.name.as_str() == "__STATIC_FMTSTR",
let ItemStatic(_, _, ref expr) = decl.node,
let ExprAddrOf(_, ref expr) = expr.node, // &["…", "…", …]
let ExprArray(ref exprs) = expr.node,
Expand All @@ -89,7 +90,7 @@ pub fn get_argument_fmtstr_parts<'a, 'b>(cx: &LateContext<'a, 'b>, expr: &'a Exp
for expr in exprs {
if let ExprLit(ref lit) = expr.node {
if let LitKind::Str(ref lit, _) = lit.node {
result.push(&**lit);
result.push(lit.as_str());
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl LateLintPass for LenZero {

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

fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
fn is_named_self(cx: &LateContext, item: &ImplItemRef, name: &str) -> bool {
item.name.as_str() == name &&
&*item.name.as_str() == name &&
if let AssociatedItemKind::Method { has_self } = item.kind {
has_self && {
let did = cx.tcx.map.local_def_id(item.id.node_id);
Expand Down Expand Up @@ -157,7 +157,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str) {
// check if we are in an is_empty() method
if let Some(name) = get_item_name(cx, left) {
if name.as_str() == "is_empty" {
if &*name.as_str() == "is_empty" {
return;
}
}
Expand All @@ -172,7 +172,7 @@ fn check_cmp(cx: &LateContext, span: Span, left: &Expr, right: &Expr, op: &str)

fn check_len_zero(cx: &LateContext, span: Span, name: &Name, args: &[P<Expr>], lit: &Lit, op: &str) {
if let Spanned { node: LitKind::Int(0, _), .. } = *lit {
if name.as_str() == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
if &*name.as_str() == "len" && args.len() == 1 && has_is_empty(cx, &args[0]) {
span_lint_and_then(cx, LEN_ZERO, span, "length comparison to zero", |db| {
db.span_suggestion(span,
"consider using `is_empty`",
Expand All @@ -187,7 +187,7 @@ fn has_is_empty(cx: &LateContext, expr: &Expr) -> bool {
/// Get an `AssociatedItem` and return true if it matches `is_empty(self)`.
fn is_is_empty(cx: &LateContext, item: &ty::AssociatedItem) -> bool {
if let ty::AssociatedKind::Method = item.kind {
if item.name.as_str() == "is_empty" {
if &*item.name.as_str() == "is_empty" {
let ty = cx.tcx.item_type(item.def_id).fn_sig().skip_binder();
ty.inputs.len() == 1
} else {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ fn allowed_lts_from(named_lts: &[LifetimeDef]) -> HashSet<RefLt> {

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

fn record(&mut self, lifetime: &Option<Lifetime>) {
if let Some(ref lt) = *lifetime {
if lt.name.as_str() == "'static" {
if &*lt.name.as_str() == "'static" {
self.lts.push(RefLt::Static);
} else {
self.lts.push(RefLt::Named(lt.name));
Expand Down
16 changes: 8 additions & 8 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ impl LateLintPass for Pass {
&ExprMethodCall(method_name, _, ref method_args)) = (pat, &match_expr.node) {
let iter_expr = &method_args[0];
if let Some(lhs_constructor) = path.segments.last() {
if method_name.node.as_str() == "next" &&
if &*method_name.node.as_str() == "next" &&
match_trait_method(cx, match_expr, &paths::ITERATOR) &&
lhs_constructor.name.as_str() == "Some" &&
&*lhs_constructor.name.as_str() == "Some" &&
!is_refutable(cx, &pat_args[0]) &&
!is_iterator_used_after_while_let(cx, iter_expr) {
let iterator = snippet(cx, method_args[0].span, "_");
Expand All @@ -395,7 +395,7 @@ impl LateLintPass for Pass {
fn check_stmt(&mut self, cx: &LateContext, stmt: &Stmt) {
if let StmtSemi(ref expr, _) = stmt.node {
if let ExprMethodCall(ref method, _, ref args) = expr.node {
if args.len() == 1 && method.node.as_str() == "collect" &&
if args.len() == 1 && &*method.node.as_str() == "collect" &&
match_trait_method(cx, expr, &paths::ITERATOR) {
span_lint(cx,
UNUSED_COLLECT,
Expand Down Expand Up @@ -509,7 +509,7 @@ fn is_len_call(expr: &Expr, var: &Name) -> bool {
if_let_chain! {[
let ExprMethodCall(method, _, ref len_args) = expr.node,
len_args.len() == 1,
method.node.as_str() == "len",
&*method.node.as_str() == "len",
let ExprPath(_, ref path) = len_args[0].node,
path.segments.len() == 1,
&path.segments[0].name == var
Expand Down Expand Up @@ -580,14 +580,14 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
if args.len() == 1 {
let method_name = method.node;
// check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
if method_name.as_str() == "iter" || method_name.as_str() == "iter_mut" {
if &*method_name.as_str() == "iter" || &*method_name.as_str() == "iter_mut" {
if is_ref_iterable_type(cx, &args[0]) {
let object = snippet(cx, args[0].span, "_");
span_lint(cx,
EXPLICIT_ITER_LOOP,
expr.span,
&format!("it is more idiomatic to loop over `&{}{}` instead of `{}.{}()`",
if method_name.as_str() == "iter_mut" {
if &*method_name.as_str() == "iter_mut" {
"mut "
} else {
""
Expand All @@ -596,7 +596,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
object,
method_name));
}
} else if method_name.as_str() == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) {
} else if &*method_name.as_str() == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) {
let object = snippet(cx, args[0].span, "_");
span_lint(cx,
EXPLICIT_INTO_ITER_LOOP,
Expand All @@ -606,7 +606,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
object,
method_name));

} else if method_name.as_str() == "next" && match_trait_method(cx, arg, &paths::ITERATOR) {
} else if &*method_name.as_str() == "next" && match_trait_method(cx, arg, &paths::ITERATOR) {
span_lint(cx,
ITER_NEXT_LOOP,
expr.span,
Expand Down
Loading