Skip to content

Rustup #2880

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 3 commits into from
Jun 29, 2018
Merged

Rustup #2880

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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ All notable changes to this project will be documented in this file.
[`block_in_if_condition_expr`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#block_in_if_condition_expr
[`block_in_if_condition_stmt`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#block_in_if_condition_stmt
[`bool_comparison`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#bool_comparison
[`borrow_interior_mutable_const`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#borrow_interior_mutable_const
[`borrowed_box`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#borrowed_box
[`box_vec`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#box_vec
[`boxed_local`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#boxed_local
Expand All @@ -641,6 +642,7 @@ All notable changes to this project will be documented in this file.
[`crosspointer_transmute`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#crosspointer_transmute
[`cyclomatic_complexity`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#cyclomatic_complexity
[`decimal_literal_representation`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#decimal_literal_representation
[`declare_interior_mutable_const`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
[`default_trait_access`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#default_trait_access
[`deprecated_semver`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#deprecated_semver
[`deref_addrof`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#deref_addrof
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ We are currently in the process of discussing Clippy 1.0 via the RFC process in

A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.

[There are 270 lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html)
[There are 272 lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html)

We have a bunch of lint categories to allow you to choose how much clippy is supposed to ~~annoy~~ help you:

Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {

fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
if is_relevant_impl(cx.tcx, item) {
check_attrs(cx, item.span, item.name, &item.attrs)
check_attrs(cx, item.span, item.ident.name, &item.attrs)
}
}

fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
if is_relevant_trait(cx.tcx, item) {
check_attrs(cx, item.span, item.name, &item.attrs)
check_attrs(cx, item.span, item.ident.name, &item.attrs)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/blacklisted_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ impl LintPass for BlackListedName {

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
if let PatKind::Binding(_, _, ref ident, _) = pat.node {
if self.blacklist.iter().any(|s| ident.node == *s) {
if let PatKind::Binding(_, _, ident, _) = pat.node {
if self.blacklist.iter().any(|s| ident.name == *s) {
span_lint(
cx,
BLACKLISTED_NAME,
ident.span,
&format!("use of a blacklisted/placeholder name `{}`", ident.node),
&format!("use of a blacklisted/placeholder name `{}`", ident.name),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
METHODS_WITH_NEGATION
.iter().cloned()
.flat_map(|(a, b)| vec![(a, b), (b, a)])
.find(|&(a, _)| a == path.name.as_str())
.find(|&(a, _)| a == path.ident.as_str())
.and_then(|(_, neg_method)| Some(format!("{}.{}()", self.snip(&args[0])?, neg_method)))
},
_ => None,
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
if_chain! {
if let ExprMethodCall(ref count, _, ref count_args) = expr.node;
if count.name == "count";
if count.ident.name == "count";
if count_args.len() == 1;
if let ExprMethodCall(ref filter, _, ref filter_args) = count_args[0].node;
if filter.name == "filter";
if filter.ident.name == "filter";
if filter_args.len() == 2;
if let ExprClosure(_, _, body_id, _, _) = filter_args[1].node;
then {
Expand All @@ -68,7 +68,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ByteCount {
}
let haystack = if let ExprMethodCall(ref path, _, ref args) =
filter_args[0].node {
let p = path.name;
let p = path.ident.name;
if (p == "iter" || p == "iter_mut") && args.len() == 1 {
&args[0]
} else {
Expand Down Expand Up @@ -104,7 +104,7 @@ fn get_path_name(expr: &Expr) -> Option<Name> {
} else {
None
},
ExprPath(ref qpath) => single_segment_path(qpath).map(|ps| ps.name),
ExprPath(ref qpath) => single_segment_path(qpath).map(|ps| ps.ident.name),
_ => None,
}
}
4 changes: 2 additions & 2 deletions clippy_lints/src/copies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<LocalInt
PatKind::TupleStruct(_, ref pats, _) => for pat in pats {
bindings_impl(cx, pat, map);
},
PatKind::Binding(_, _, ref ident, ref as_pat) => {
if let Entry::Vacant(v) = map.entry(ident.node.as_str()) {
PatKind::Binding(_, _, ident, ref as_pat) => {
if let Entry::Vacant(v) = map.entry(ident.as_str()) {
v.insert(cx.tables.pat_ty(pat));
}
if let Some(ref as_pat) = *as_pat {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/duration_subsec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DurationSubsec {
if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&args[0])), &paths::DURATION);
if let Some((Constant::Int(divisor), _)) = constant(cx, cx.tables, right);
then {
let suggested_fn = match (method_path.name.as_str().as_ref(), divisor) {
let suggested_fn = match (method_path.ident.as_str().as_ref(), divisor) {
("subsec_micros", 1_000) => "subsec_millis",
("subsec_nanos", 1_000) => "subsec_micros",
("subsec_nanos", 1_000_000) => "subsec_millis",
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 @@ -90,7 +90,7 @@ fn check_cond<'a, 'tcx, 'b>(
if_chain! {
if let ExprMethodCall(ref path, _, ref params) = check.node;
if params.len() >= 2;
if path.name == "contains_key";
if path.ident.name == "contains_key";
if let ExprAddrOf(_, ref key) = params[1].node;
then {
let map = &params[0];
Expand Down Expand Up @@ -125,7 +125,7 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
if_chain! {
if let ExprMethodCall(ref path, _, ref params) = expr.node;
if params.len() == 3;
if path.name == "insert";
if path.ident.name == "insert";
if get_item_name(self.cx, self.map) == get_item_name(self.cx, &params[0]);
if SpanlessEq::new(self.cx).eq_expr(self.key, &params[1]);
then {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/enum_variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl LintPass for EnumVariantNames {
}

fn var2str(var: &Variant) -> LocalInternedString {
var.node.ident.name.as_str()
var.node.ident.as_str()
}

/// Returns the number of chars that match from the start
Expand Down Expand Up @@ -245,7 +245,7 @@ impl EarlyLintPass for EnumVariantNames {
}

fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
let item_name = item.ident.name.as_str();
let item_name = item.ident.as_str();
let item_name_chars = item_name.chars().count();
let item_camel = to_camel_case(&item_name);
if !in_macro(item.span) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn check_closure(cx: &LateContext, expr: &Expr) {
// If it's a proper path, it can't be a local variable
return;
}
if p.segments[0].name != ident.node {
if p.segments[0].ident.name != ident.name {
// The two idents should be the same
return;
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/explicit_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
if_chain! {
// match call to unwrap
if let ExprMethodCall(ref unwrap_fun, _, ref unwrap_args) = expr.node;
if unwrap_fun.name == "unwrap";
if unwrap_fun.ident.name == "unwrap";
// match call to write_fmt
if unwrap_args.len() > 0;
if let ExprMethodCall(ref write_fun, _, ref write_args) =
unwrap_args[0].node;
if write_fun.name == "write_fmt";
if write_fun.ident.name == "write_fmt";
// match calls to std::io::stdout() / std::io::stderr ()
if write_args.len() > 0;
if let ExprCall(ref dest_fun, _) = write_args[0].node;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/fallible_impl_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it

for impl_item in impl_items {
if_chain! {
if impl_item.name == "from";
if impl_item.ident.name == "from";
if let ImplItemKind::Method(_, body_id) =
cx.tcx.hir.impl_item(impl_item.id).node;
then {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn check_unformatted(expr: &Expr) -> bool {
if let ExprStruct(_, ref fields, _) = format_field.expr.node;
if let Some(align_field) = fields.iter().find(|f| f.ident.name == "width");
if let ExprPath(ref qpath) = align_field.expr.node;
if last_path_segment(qpath).name == "Implied";
if last_path_segment(qpath).ident.name == "Implied";
then {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/identity_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
},

ExprMethodCall(ref name, .., ref args) => {
if match_trait_method(cx, e, &paths::INTO[..]) && &*name.name.as_str() == "into" {
if match_trait_method(cx, e, &paths::INTO[..]) && &*name.ident.as_str() == "into" {
let a = cx.tables.expr_ty(e);
let b = cx.tables.expr_ty(&args[0]);
if same_tys(cx, a, b) {
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/infinite_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
match expr.node {
ExprMethodCall(ref method, _, ref args) => {
for &(name, len, heuristic, cap) in HEURISTICS.iter() {
if method.name == name && args.len() == len {
if method.ident.name == name && args.len() == len {
return (match heuristic {
Always => Infinite,
First => is_infinite(cx, &args[0]),
Expand All @@ -152,7 +152,7 @@ fn is_infinite(cx: &LateContext, expr: &Expr) -> Finiteness {
}).and(cap);
}
}
if method.name == "flat_map" && args.len() == 2 {
if method.ident.name == "flat_map" && args.len() == 2 {
if let ExprClosure(_, _, body_id, _, _) = args[1].node {
let body = cx.tcx.hir.body(body_id);
return is_infinite(cx, &body.value);
Expand Down Expand Up @@ -207,16 +207,16 @@ fn complete_infinite_iter(cx: &LateContext, expr: &Expr) -> Finiteness {
match expr.node {
ExprMethodCall(ref method, _, ref args) => {
for &(name, len) in COMPLETING_METHODS.iter() {
if method.name == name && args.len() == len {
if method.ident.name == name && args.len() == len {
return is_infinite(cx, &args[0]);
}
}
for &(name, len) in POSSIBLY_COMPLETING_METHODS.iter() {
if method.name == name && args.len() == len {
if method.ident.name == name && args.len() == len {
return MaybeInfinite.and(is_infinite(cx, &args[0]));
}
}
if method.name == "last" && args.len() == 1 {
if method.ident.name == "last" && args.len() == 1 {
let not_double_ended = get_trait_def_id(cx, &paths::DOUBLE_ENDED_ITERATOR)
.map_or(false, |id| !implements_trait(cx, cx.tables.expr_ty(&args[0]), id, &[]));
if not_double_ended {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/inline_fn_without_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl LintPass for Pass {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
if let TraitItemKind::Method(_, TraitMethod::Required(_)) = item.node {
check_attrs(cx, item.name, &item.attrs);
check_attrs(cx, item.ident.name, &item.attrs);
}
}
}
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 @@ -107,7 +107,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {

fn check_trait_items(cx: &LateContext, visited_trait: &Item, trait_items: &[TraitItemRef]) {
fn is_named_self(cx: &LateContext, item: &TraitItemRef, name: &str) -> bool {
item.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
item.ident.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
has_self && {
let did = cx.tcx.hir.local_def_id(item.id.node_id);
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
Expand Down Expand Up @@ -135,7 +135,7 @@ fn check_trait_items(cx: &LateContext, visited_trait: &Item, trait_items: &[Trai
.iter()
.flat_map(|&i| cx.tcx.associated_items(i))
.any(|i| {
i.kind == ty::AssociatedKind::Method && i.method_has_self_argument && i.name == "is_empty"
i.kind == ty::AssociatedKind::Method && i.method_has_self_argument && i.ident.name == "is_empty"
&& cx.tcx.fn_sig(i.def_id).inputs().skip_binder().len() == 1
});

Expand All @@ -155,7 +155,7 @@ fn check_trait_items(cx: &LateContext, visited_trait: &Item, trait_items: &[Trai

fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
fn is_named_self(cx: &LateContext, item: &ImplItemRef, name: &str) -> bool {
item.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
item.ident.name == name && if let AssociatedItemKind::Method { has_self } = item.kind {
has_self && {
let did = cx.tcx.hir.local_def_id(item.id.node_id);
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
Expand Down Expand Up @@ -202,7 +202,7 @@ fn check_cmp(cx: &LateContext, span: Span, method: &Expr, lit: &Expr, op: &str,
}
}

check_len(cx, span, method_path.name, args, lit, op, compare_to)
check_len(cx, span, method_path.ident.name, args, lit, op, compare_to)
}
}

Expand Down Expand Up @@ -235,7 +235,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 == "is_empty" {
if item.ident.name == "is_empty" {
let sig = cx.tcx.fn_sig(item.def_id);
let ty = sig.skip_binder();
ty.inputs().len() == 1
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/let_if_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
if let Some(expr) = it.peek();
if let hir::StmtDecl(ref decl, _) = stmt.node;
if let hir::DeclLocal(ref decl) = decl.node;
if let hir::PatKind::Binding(mode, canonical_id, ref name, None) = decl.pat.node;
if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node;
if let hir::StmtExpr(ref if_, _) = expr.node;
if let hir::ExprIf(ref cond, ref then, ref else_) = if_.node;
if !used_in_expr(cx, canonical_id, cond);
Expand Down Expand Up @@ -106,7 +106,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
let sug = format!(
"let {mut}{name} = if {cond} {{{then} {value} }} else {{{else} {default} }};",
mut=mutability,
name=name.node,
name=ident.name,
cond=snippet(cx, cond.span, "_"),
then=if then.stmts.len() > 1 { " ..;" } else { "" },
else=if default_multi_stmts { " ..;" } else { "" },
Expand Down
3 changes: 1 addition & 2 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
reg.register_lint_group("clippy_pedantic", vec![
attrs::INLINE_ALWAYS,
copies::MATCH_SAME_ARMS,
default_trait_access::DEFAULT_TRAIT_ACCESS,
derive::EXPL_IMPL_CLONE_ON_COPY,
doc::DOC_MARKDOWN,
empty_enum::EMPTY_ENUM,
Expand Down Expand Up @@ -492,7 +493,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
copies::IF_SAME_THEN_ELSE,
copies::IFS_SAME_COND,
cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
default_trait_access::DEFAULT_TRAIT_ACCESS,
derive::DERIVE_HASH_XOR_EQ,
double_comparison::DOUBLE_COMPARISONS,
double_parens::DOUBLE_PARENS,
Expand Down Expand Up @@ -694,7 +694,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
collapsible_if::COLLAPSIBLE_IF,
const_static_lifetime::CONST_STATIC_LIFETIME,
default_trait_access::DEFAULT_TRAIT_ACCESS,
enum_variants::ENUM_VARIANT_NAMES,
enum_variants::MODULE_INCEPTION,
eq_op::OP_REF,
Expand Down
Loading