Skip to content

Commit 99d8509

Browse files
committed
Merge branch 'master' of github.com:rust-lang/rust-clippy
2 parents 98ecce7 + cfdf47e commit 99d8509

File tree

117 files changed

+2882
-1597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2882
-1597
lines changed

CHANGELOG.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,38 @@ All notable changes to this project will be documented in this file.
44

55
## Unreleased / In Rust Beta or Nightly
66

7-
[b2601be...master](https://github.com/rust-lang/rust-clippy/compare/b2601be...master)
7+
[1b89724...master](https://github.com/rust-lang/rust-clippy/compare/1b89724...master)
8+
9+
## Rust 1.33 (2019-02-26)
10+
11+
[b2601be...1b89724](https://github.com/rust-lang/rust-clippy/compare/b2601be...1b89724)
12+
13+
* New lints: [`implicit_return`], [`vec_box`], [`cast_ref_to_mut`]
14+
* The `rust-clippy` repository is now part of the `rust-lang` org.
15+
* Rename `stutter` to `module_name_repetitions`
16+
* Merge `new_without_default_derive` into `new_without_default` lint
17+
* Move `large_digit_groups` from `style` group to `pedantic`
18+
* Expand `bool_comparison` to check for `<`, `<=`, `>`, `>=`, and `!=`
19+
comparisons against booleans
20+
* Expand `no_effect` to detect writes to constants such as `A_CONST.field = 2`
21+
* Expand `redundant_clone` to work on struct fields
22+
* Expand `suspicious_else_formatting` to detect `if .. {..} {..}`
23+
* Expand `use_self` to work on tuple structs and also in local macros
24+
* Fix ICE in `result_map_unit_fn` and `option_map_unit_fn`
25+
* Fix false positives in `implicit_return`
26+
* Fix false positives in `use_self`
27+
* Fix false negative in `clone_on_copy`
28+
* Fix false positive in `doc_markdown`
29+
* Fix false positive in `empty_loop`
30+
* Fix false positive in `if_same_then_else`
31+
* Fix false positive in `infinite_iter`
32+
* Fix false positive in `question_mark`
33+
* Fix false positive in `useless_asref`
34+
* Fix false positive in `wildcard_dependencies`
35+
* Fix false positive in `write_with_newline`
36+
* Add suggestion to `explicit_write`
37+
* Improve suggestions for `question_mark` lint
38+
* Fix incorrect suggestion for `get_unwrap`
839

940
## Rust 1.32 (2019-01-17)
1041

@@ -785,6 +816,7 @@ All notable changes to this project will be documented in this file.
785816
[`double_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_comparisons
786817
[`double_neg`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_neg
787818
[`double_parens`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_parens
819+
[`drop_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_bounds
788820
[`drop_copy`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_copy
789821
[`drop_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#drop_ref
790822
[`duplicate_underscore_argument`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicate_underscore_argument

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ A collection of lints to catch common mistakes and improve your [Rust](https://g
1111

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

14-
* `clippy::all` (everything that has no false positives)
15-
* `clippy::pedantic` (everything)
16-
* `clippy::nursery` (new lints that aren't quite ready yet)
14+
* `clippy::all` (everything that is on by default: all the categories below except for `nursery`, `pedantic`, and `cargo`)
15+
* **`clippy::correctness`** (code that is just outright wrong or very very useless, causes hard errors by default)
1716
* `clippy::style` (code that should be written in a more idiomatic way)
1817
* `clippy::complexity` (code that does something simple but in a complex way)
1918
* `clippy::perf` (code that can be written in a faster way)
20-
* `clippy::cargo` (checks against the cargo manifest)
21-
* **`clippy::correctness`** (code that is just outright wrong or very very useless)
19+
* `clippy::pedantic` (lints which are rather strict, off by default)
20+
* `clippy::nursery` (new lints that aren't quite ready yet, off by default)
21+
* `clippy::cargo` (checks against the cargo manifest, off by default)
2222

2323
More to come, please [file an issue](https://github.com/rust-lang/rust-clippy/issues) if you have ideas!
2424

@@ -31,6 +31,8 @@ Only the following of those categories are enabled by default:
3131

3232
Other categories need to be enabled in order for their lints to be executed.
3333

34+
The [lint list](https://rust-lang.github.io/rust-clippy/master/index.html) also contains "restriction lints", which are for things which are usually not considered "bad", but may be useful to turn on in specific cases. These should be used very selectively, if at all.
35+
3436
Table of contents:
3537

3638
* [Usage instructions](#usage)

ci/base-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ rustup override set nightly
5959
# avoid loop spam and allow cmds with exit status != 0
6060
set +ex
6161

62-
for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/formatting.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do
62+
for file in `find tests -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do
6363
rustfmt ${file} --check
6464
if [ $? -ne 0 ]; then
6565
echo "${file} needs reformatting!"

clippy_dev/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Lint {
4747
name: name.to_lowercase(),
4848
group: group.to_string(),
4949
desc: NL_ESCAPE_RE.replace(&desc.replace("\\\"", "\""), "").to_string(),
50-
deprecation: deprecation.map(|d| d.to_string()),
50+
deprecation: deprecation.map(std::string::ToString::to_string),
5151
module: module.to_string(),
5252
}
5353
}
@@ -178,7 +178,7 @@ fn lint_files() -> impl Iterator<Item = walkdir::DirEntry> {
178178
// Otherwise we would not collect all the lints, for example in `clippy_lints/src/methods/`.
179179
WalkDir::new("../clippy_lints/src")
180180
.into_iter()
181-
.filter_map(|f| f.ok())
181+
.filter_map(std::result::Result::ok)
182182
.filter(|f| f.path().extension() == Some(OsStr::new("rs")))
183183
}
184184

clippy_lints/src/assertions_on_constants.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::rustc::hir::{Expr, ExprKind};
33
use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
44
use crate::rustc::{declare_tool_lint, lint_array};
55
use crate::syntax::ast::LitKind;
6-
use crate::utils::{is_direct_expn_of, span_help_and_lint};
6+
use crate::utils::{in_macro, is_direct_expn_of, span_help_and_lint};
77
use if_chain::if_chain;
88

99
/// **What it does:** Check to call assert!(true/false)
@@ -43,7 +43,9 @@ impl LintPass for AssertionsOnConstants {
4343
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
4444
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
4545
if_chain! {
46-
if is_direct_expn_of(e.span, "assert").is_some();
46+
if let Some(assert_span) = is_direct_expn_of(e.span, "assert");
47+
if !in_macro(assert_span)
48+
|| is_direct_expn_of(assert_span, "debug_assert").map_or(false, |span| !in_macro(span));
4749
if let ExprKind::Unary(_, ref lit) = e.node;
4850
then {
4951
if let ExprKind::Lit(ref inner) = lit.node {

clippy_lints/src/assign_ops.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
66
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
77
use rustc::{declare_tool_lint, lint_array};
88
use rustc_errors::Applicability;
9-
use syntax::ast;
109

1110
/// **What it does:** Checks for `a = a op b` or `a = b commutative_op a`
1211
/// patterns.
@@ -140,12 +139,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
140139
return; // useless if the trait doesn't exist
141140
};
142141
// check that we are not inside an `impl AssignOp` of this exact operation
143-
let parent_fn = cx.tcx.hir().get_parent(e.id);
144-
let parent_impl = cx.tcx.hir().get_parent(parent_fn);
142+
let parent_fn = cx.tcx.hir().get_parent_item(e.hir_id);
143+
let parent_impl = cx.tcx.hir().get_parent_item(parent_fn);
145144
// the crate node is the only one that is not in the map
146145
if_chain! {
147-
if parent_impl != ast::CRATE_NODE_ID;
148-
if let hir::Node::Item(item) = cx.tcx.hir().get(parent_impl);
146+
if parent_impl != hir::CRATE_HIR_ID;
147+
if let hir::Node::Item(item) = cx.tcx.hir().get_by_hir_id(parent_impl);
149148
if let hir::ItemKind::Impl(_, _, _, _, Some(trait_ref), _, _) =
150149
&item.node;
151150
if trait_ref.path.def.def_id() == trait_id;

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
326326
lint.span,
327327
&format!("unknown clippy lint: clippy::{}", name),
328328
|db| {
329-
if name.as_str().chars().any(|c| c.is_uppercase()) {
329+
if name.as_str().chars().any(char::is_uppercase) {
330330
let name_lower = name.as_str().to_lowercase();
331331
match lint_store.check_lint_name(
332332
&name_lower,

clippy_lints/src/booleans.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
77
use rustc::{declare_tool_lint, lint_array};
88
use rustc_data_structures::thin_vec::ThinVec;
99
use rustc_errors::Applicability;
10-
use syntax::ast::{LitKind, NodeId, DUMMY_NODE_ID};
10+
use syntax::ast::LitKind;
1111
use syntax::source_map::{dummy_spanned, Span, DUMMY_SP};
1212

1313
/// **What it does:** Checks for boolean expressions that can be written more
@@ -72,7 +72,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonminimalBool {
7272
_: &'tcx FnDecl,
7373
body: &'tcx Body,
7474
_: Span,
75-
_: NodeId,
75+
_: HirId,
7676
) {
7777
NonminimalBoolVisitor { cx }.visit_body(body)
7878
}
@@ -132,7 +132,6 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
132132
}
133133

134134
let mk_expr = |op| Expr {
135-
id: DUMMY_NODE_ID,
136135
hir_id: DUMMY_HIR_ID,
137136
span: DUMMY_SP,
138137
attrs: ThinVec::new(),

clippy_lints/src/cargo_common_metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn is_empty_str(value: &Option<String>) -> bool {
5353

5454
fn is_empty_vec(value: &[String]) -> bool {
5555
// This works because empty iterators return true
56-
value.iter().all(|v| v.is_empty())
56+
value.iter().all(std::string::String::is_empty)
5757
}
5858

5959
pub struct Pass;

clippy_lints/src/consts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use if_chain::if_chain;
55
use rustc::hir::def::Def;
66
use rustc::hir::*;
77
use rustc::lint::LateContext;
8-
use rustc::ty::subst::{Subst, Substs};
8+
use rustc::ty::subst::{Subst, SubstsRef};
99
use rustc::ty::{self, Instance, Ty, TyCtxt};
1010
use rustc::{bug, span_bug};
1111
use rustc_data_structures::sync::Lrc;
@@ -209,7 +209,7 @@ pub struct ConstEvalLateContext<'a, 'tcx: 'a> {
209209
tables: &'a ty::TypeckTables<'tcx>,
210210
param_env: ty::ParamEnv<'tcx>,
211211
needed_resolution: bool,
212-
substs: &'tcx Substs<'tcx>,
212+
substs: SubstsRef<'tcx>,
213213
}
214214

215215
impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {

0 commit comments

Comments
 (0)