From cc7d66aa9cae2fb9c97d534cb9244d98f5d67a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 27 Apr 2018 14:00:43 +0200 Subject: [PATCH] rustup --- CHANGELOG.md | 2 + README.md | 2 +- clippy_lints/src/functions.rs | 2 +- clippy_lints/src/lib.rs | 3 + clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/utils/mod.rs | 2 +- mini-macro/src/lib.rs | 2 +- tests/ui/infallible_destructuring_match.rs | 2 +- tests/ui/result_map_unit_fn.rs | 1 + tests/ui/result_map_unit_fn.stderr | 98 +++++++++++----------- 10 files changed, 61 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27420e47238..650c2a9d893 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -615,6 +615,7 @@ All notable changes to this project will be documented in this file. [`eq_op`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#eq_op [`erasing_op`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#erasing_op [`eval_order_dependence`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#eval_order_dependence +[`excessive_precision`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#excessive_precision [`expl_impl_clone_on_copy`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#expl_impl_clone_on_copy [`explicit_counter_loop`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#explicit_counter_loop [`explicit_into_iter_loop`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#explicit_into_iter_loop @@ -644,6 +645,7 @@ All notable changes to this project will be documented in this file. [`inconsistent_digit_grouping`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#inconsistent_digit_grouping [`indexing_slicing`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#indexing_slicing [`ineffective_bit_mask`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#ineffective_bit_mask +[`infallible_destructuring_match`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#infallible_destructuring_match [`infinite_iter`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#infinite_iter [`inline_always`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#inline_always [`inline_fn_without_body`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#inline_fn_without_body diff --git a/README.md b/README.md index d0ba8b0948a..208aa550882 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code. -[There are 255 lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html) +[There are 257 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: diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index cb359daba44..83c9c0f1d1a 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -5,7 +5,7 @@ use rustc::ty; use rustc::hir::def::Def; use std::collections::HashSet; use syntax::ast; -use syntax::abi::Abi; +use rustc_target::spec::abi::Abi; use syntax::codemap::Span; use utils::{iter_input_pats, span_lint, type_is_unsafe_function}; diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index c2b0895942f..a952f5081f4 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -19,6 +19,7 @@ #[macro_use] extern crate rustc; extern crate rustc_typeck; +extern crate rustc_target; extern crate syntax; extern crate syntax_pos; @@ -516,6 +517,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { eta_reduction::REDUNDANT_CLOSURE, eval_order_dependence::DIVERGING_SUB_EXPRESSION, eval_order_dependence::EVAL_ORDER_DEPENDENCE, + excessive_precision::EXCESSIVE_PRECISION, explicit_write::EXPLICIT_WRITE, format::USELESS_FORMAT, formatting::POSSIBLE_MISSING_COMMA, @@ -692,6 +694,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) { enum_variants::MODULE_INCEPTION, eq_op::OP_REF, eta_reduction::REDUNDANT_CLOSURE, + excessive_precision::EXCESSIVE_PRECISION, formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING, formatting::SUSPICIOUS_ELSE_FORMATTING, if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING, diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index 02048c39265..944f20fe99d 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -6,7 +6,7 @@ use rustc::ty::{self, RegionKind, TypeFoldable}; use rustc::traits; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; -use syntax::abi::Abi; +use rustc_target::spec::abi::Abi; use syntax::ast::NodeId; use syntax_pos::Span; use syntax::errors::DiagnosticBuilder; diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index bfb6160d3cd..39df3698064 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -8,7 +8,7 @@ use rustc::hir::map::Node; use rustc::lint::{LateContext, Level, Lint, LintContext}; use rustc::session::Session; use rustc::traits; -use rustc::ty::{self, Ty, TyCtxt, layout}; +use rustc::ty::{self, Ty, TyCtxt, layout::{self, IntegerExt}}; use rustc_errors; use std::borrow::Cow; use std::env; diff --git a/mini-macro/src/lib.rs b/mini-macro/src/lib.rs index 3caf85103b5..9f88de62677 100644 --- a/mini-macro/src/lib.rs +++ b/mini-macro/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro)] +#![feature(proc_macro, proc_macro_non_items)] extern crate proc_macro; use proc_macro::{TokenStream, quote}; diff --git a/tests/ui/infallible_destructuring_match.rs b/tests/ui/infallible_destructuring_match.rs index 270272261b5..6f3d7a3ff2b 100644 --- a/tests/ui/infallible_destructuring_match.rs +++ b/tests/ui/infallible_destructuring_match.rs @@ -1,4 +1,4 @@ -#![feature(exhaustive_patterns)] +#![feature(exhaustive_patterns, never_type)] #![allow(let_and_return)] enum SingleVariantEnum { diff --git a/tests/ui/result_map_unit_fn.rs b/tests/ui/result_map_unit_fn.rs index 8f3c1579987..dd163439d78 100644 --- a/tests/ui/result_map_unit_fn.rs +++ b/tests/ui/result_map_unit_fn.rs @@ -1,3 +1,4 @@ +#![feature(never_type)] #![warn(result_map_unit_fn)] #![allow(unused)] diff --git a/tests/ui/result_map_unit_fn.stderr b/tests/ui/result_map_unit_fn.stderr index 199f5e7cf97..9ec24a7e97b 100644 --- a/tests/ui/result_map_unit_fn.stderr +++ b/tests/ui/result_map_unit_fn.stderr @@ -1,7 +1,7 @@ error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:32:5 + --> $DIR/result_map_unit_fn.rs:33:5 | -32 | x.field.map(do_nothing); +33 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` @@ -9,183 +9,183 @@ error: called `map(f)` on an Result value where `f` is a unit function = note: `-D result-map-unit-fn` implied by `-D warnings` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:34:5 + --> $DIR/result_map_unit_fn.rs:35:5 | -34 | x.field.map(do_nothing); +35 | x.field.map(do_nothing); | ^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { do_nothing(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:36:5 + --> $DIR/result_map_unit_fn.rs:37:5 | -36 | x.field.map(diverge); +37 | x.field.map(diverge); | ^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(x_field) = x.field { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:42:5 + --> $DIR/result_map_unit_fn.rs:43:5 | -42 | x.field.map(|value| x.do_result_nothing(value + captured)); +43 | x.field.map(|value| x.do_result_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { x.do_result_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:44:5 + --> $DIR/result_map_unit_fn.rs:45:5 | -44 | x.field.map(|value| { x.do_result_plus_one(value + captured); }); +45 | x.field.map(|value| { x.do_result_plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { x.do_result_plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:47:5 + --> $DIR/result_map_unit_fn.rs:48:5 | -47 | x.field.map(|value| do_nothing(value + captured)); +48 | x.field.map(|value| do_nothing(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:49:5 + --> $DIR/result_map_unit_fn.rs:50:5 | -49 | x.field.map(|value| { do_nothing(value + captured) }); +50 | x.field.map(|value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:51:5 + --> $DIR/result_map_unit_fn.rs:52:5 | -51 | x.field.map(|value| { do_nothing(value + captured); }); +52 | x.field.map(|value| { do_nothing(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:53:5 + --> $DIR/result_map_unit_fn.rs:54:5 | -53 | x.field.map(|value| { { do_nothing(value + captured); } }); +54 | x.field.map(|value| { { do_nothing(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { do_nothing(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:56:5 + --> $DIR/result_map_unit_fn.rs:57:5 | -56 | x.field.map(|value| diverge(value + captured)); +57 | x.field.map(|value| diverge(value + captured)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:58:5 + --> $DIR/result_map_unit_fn.rs:59:5 | -58 | x.field.map(|value| { diverge(value + captured) }); +59 | x.field.map(|value| { diverge(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:60:5 + --> $DIR/result_map_unit_fn.rs:61:5 | -60 | x.field.map(|value| { diverge(value + captured); }); +61 | x.field.map(|value| { diverge(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:62:5 + --> $DIR/result_map_unit_fn.rs:63:5 | -62 | x.field.map(|value| { { diverge(value + captured); } }); +63 | x.field.map(|value| { { diverge(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { diverge(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:67:5 + --> $DIR/result_map_unit_fn.rs:68:5 | -67 | x.field.map(|value| { let y = plus_one(value + captured); }); +68 | x.field.map(|value| { let y = plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { let y = plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:69:5 + --> $DIR/result_map_unit_fn.rs:70:5 | -69 | x.field.map(|value| { plus_one(value + captured); }); +70 | x.field.map(|value| { plus_one(value + captured); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:71:5 + --> $DIR/result_map_unit_fn.rs:72:5 | -71 | x.field.map(|value| { { plus_one(value + captured); } }); +72 | x.field.map(|value| { { plus_one(value + captured); } }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { plus_one(value + captured); }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:74:5 + --> $DIR/result_map_unit_fn.rs:75:5 | -74 | x.field.map(|ref value| { do_nothing(value + captured) }); +75 | x.field.map(|ref value| { do_nothing(value + captured) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(ref value) = x.field { do_nothing(value + captured) }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:77:5 + --> $DIR/result_map_unit_fn.rs:78:5 | -77 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); +78 | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:79:5 + --> $DIR/result_map_unit_fn.rs:80:5 | -79 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); +80 | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:83:5 + --> $DIR/result_map_unit_fn.rs:84:5 | -83 | x.field.map(|value| { +84 | x.field.map(|value| { | _____^ | |_____| | || -84 | || do_nothing(value); -85 | || do_nothing(value) -86 | || }); +85 | || do_nothing(value); +86 | || do_nothing(value) +87 | || }); | ||______^- help: try this: `if let Ok(value) = x.field { ... }` | |_______| | error: called `map(f)` on an Result value where `f` is a unit closure - --> $DIR/result_map_unit_fn.rs:87:5 + --> $DIR/result_map_unit_fn.rs:88:5 | -87 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); +88 | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(value) = x.field { ... }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:91:5 + --> $DIR/result_map_unit_fn.rs:92:5 | -91 | "12".parse::().map(diverge); +92 | "12".parse::().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(_) = "12".parse::() { diverge(...) }` error: called `map(f)` on an Result value where `f` is a unit function - --> $DIR/result_map_unit_fn.rs:97:5 + --> $DIR/result_map_unit_fn.rs:98:5 | -97 | y.map(do_nothing); +98 | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^- | | | help: try this: `if let Ok(_y) = y { do_nothing(...) }`