Skip to content

Commit eaeac1a

Browse files
committed
submodules: update clippy from fc24fce to f7bdf50
Fixes clippy toolstate Changes: ```` Match on ast/hir::ExprKind::Err Update *.stderr files Use -Zui-testing flag Mention S-inactive-closed PRs in the CONTRIBUTING.md tests: fix formatting and update test output base tests: make sure to fail CI if tests need formatting base tests: switch to nightly toolchain before checking formatting of tests with rustfmt rustup rust-lang/rust#57069 Rustfmt. fix breakage from rust-lang/rust#57088 fix a couple of ftrivial typos (NFC). update CARGO_CLIPPY_HELP string to suggest tool lints. rustc_tools_util: add readme rustc_tool_utils: expand Cargo.toml with a few keywords in preparation for crates.io release Fix macro detection in `empty_loop`. Changed `macro_backtrace()` to `in_macro()`. Fix lint detection on macro expansion. ````
1 parent aca8f94 commit eaeac1a

File tree

247 files changed

+4864
-4759
lines changed

Some content is hidden

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

247 files changed

+4864
-4759
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ Some issues are easier than others. The [`good first issue`](https://github.com/
4242
label can be used to find the easy issues. If you want to work on an issue, please leave a comment
4343
so that we can assign it to you!
4444

45+
There are also some abandoned PRs, marked with
46+
[`S-inactive-closed`](https://github.com/rust-lang/rust-clippy/pulls?q=is%3Aclosed+label%3AS-inactive-closed).
47+
Pretty often these PRs are nearly completed and just need some extra steps
48+
(formatting, addressing review comments, ...) to be merged. If you want to
49+
complete such a PR, please leave a comment in the PR and open a new one based
50+
on it.
51+
4552
Issues marked [`T-AST`](https://github.com/rust-lang/rust-clippy/labels/T-AST) involve simple
4653
matching of the syntax tree structure, and are generally easier than
4754
[`T-middle`](https://github.com/rust-lang/rust-clippy/labels/T-middle) issues, which involve types

ci/base-tests.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,29 @@ cd ..
3535
./util/dev update_lints --check
3636
cargo +nightly fmt --all -- --check
3737

38-
39-
#avoid loop spam
40-
set +x
4138
# make sure tests are formatted
4239

4340
# some lints are sensitive to formatting, exclude some files
44-
needs_formatting=false
41+
tests_need_reformatting="false"
42+
# switch to nightly
43+
rustup default nightly
44+
# avoid loop spam and allow cmds with exit status != 0
45+
set +ex
46+
4547
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
46-
rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true
48+
rustfmt ${file} --check
49+
if [ $? -ne 0 ]; then
50+
echo "${file} needs reformatting!"
51+
tests_need_reformatting="true"
52+
fi
4753
done
4854

49-
if [ "${needs_reformatting}" = true ] ; then
55+
set -ex # reset
56+
57+
if [ "${tests_need_reformatting}" == "true" ] ; then
5058
echo "Tests need reformatting!"
5159
exit 2
5260
fi
53-
set -x
61+
62+
# switch back to master
63+
rustup default master

clippy_dev/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ fn test_gen_deprecated() {
432432
"should_assert_eq",
433433
"group1",
434434
"abc",
435-
Some("has been superseeded by should_assert_eq2"),
435+
Some("has been superseded by should_assert_eq2"),
436436
"module_name",
437437
),
438438
Lint::new(
@@ -447,7 +447,7 @@ fn test_gen_deprecated() {
447447
let expected: Vec<String> = vec![
448448
" store.register_removed(",
449449
" \"should_assert_eq\",",
450-
" \"has been superseeded by should_assert_eq2\",",
450+
" \"has been superseded by should_assert_eq2\",",
451451
" );",
452452
" store.register_removed(",
453453
" \"another_deprecated\",",

clippy_lints/src/double_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::syntax::source_map::Span;
1717

1818
use crate::utils::{snippet_with_applicability, span_lint_and_sugg, SpanlessEq};
1919

20-
/// **What it does:** Checks for double comparions that could be simpified to a single expression.
20+
/// **What it does:** Checks for double comparions that could be simplified to a single expression.
2121
///
2222
///
2323
/// **Why is this bad?** Readability.

clippy_lints/src/implicit_return.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
1212
use crate::rustc::{declare_tool_lint, lint_array};
1313
use crate::rustc_errors::Applicability;
1414
use crate::syntax::{ast::NodeId, source_map::Span};
15-
use crate::utils::{snippet_opt, span_lint_and_then};
15+
use crate::utils::{in_macro, snippet_opt, span_lint_and_then};
1616

1717
/// **What it does:** Checks for missing return statements at the end of a block.
1818
///
@@ -116,14 +116,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
116116
_: FnKind<'tcx>,
117117
_: &'tcx FnDecl,
118118
body: &'tcx Body,
119-
_: Span,
119+
span: Span,
120120
_: NodeId,
121121
) {
122122
let def_id = cx.tcx.hir().body_owner_def_id(body.id());
123123
let mir = cx.tcx.optimized_mir(def_id);
124124

125125
// checking return type through MIR, HIR is not able to determine inferred closure return types
126-
if !mir.return_ty().is_unit() {
126+
// make sure it's not a macro
127+
if !mir.return_ty().is_unit() && !in_macro(span) {
127128
Self::expr_match(cx, &body.value);
128129
}
129130
}

clippy_lints/src/loops.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ impl LintPass for Pass {
478478

479479
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
480480
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
481+
// we don't want to check expanded macros
482+
if in_macro(expr.span) {
483+
return;
484+
}
485+
481486
if let Some((pat, arg, body)) = higher::for_loop(expr) {
482487
check_for_loop(cx, pat, arg, body, expr);
483488
}
@@ -751,7 +756,8 @@ fn never_loop_expr(expr: &Expr, main_loop_id: NodeId) -> NeverLoopResult {
751756
| ExprKind::Closure(_, _, _, _, _)
752757
| ExprKind::InlineAsm(_, _, _)
753758
| ExprKind::Path(_)
754-
| ExprKind::Lit(_) => NeverLoopResult::Otherwise,
759+
| ExprKind::Lit(_)
760+
| ExprKind::Err => NeverLoopResult::Otherwise,
755761
}
756762
}
757763

clippy_lints/src/utils/author.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
504504
self.current = value_pat;
505505
self.visit_expr(value);
506506
},
507+
ExprKind::Err => {
508+
println!("Err = {}", current);
509+
},
507510
}
508511
}
509512

clippy_lints/src/utils/hir_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
615615
self.hash_name(l.ident.name);
616616
}
617617
},
618+
ExprKind::Err => {},
618619
}
619620
}
620621

clippy_lints/src/utils/inspector.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr, indent: usize) {
347347
println!("{}repeat count:", ind);
348348
print_expr(cx, &cx.tcx.hir().body(anon_const.body).value, indent + 1);
349349
},
350+
hir::ExprKind::Err => {
351+
println!("{}Err", ind);
352+
},
350353
}
351354
}
352355

clippy_lints/src/utils/sugg.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ impl<'a> Sugg<'a> {
7979
| hir::ExprKind::Ret(..)
8080
| hir::ExprKind::Struct(..)
8181
| hir::ExprKind::Tup(..)
82-
| hir::ExprKind::While(..) => Sugg::NonParen(snippet),
82+
| hir::ExprKind::While(..)
83+
| hir::ExprKind::Err => Sugg::NonParen(snippet),
8384
hir::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet),
8485
hir::ExprKind::AssignOp(op, ..) => Sugg::BinOp(hirbinop2assignop(op), snippet),
8586
hir::ExprKind::Binary(op, ..) => Sugg::BinOp(AssocOp::from_ast_binop(higher::binop(op.node)), snippet),
@@ -158,7 +159,8 @@ impl<'a> Sugg<'a> {
158159
| ast::ExprKind::Tup(..)
159160
| ast::ExprKind::Array(..)
160161
| ast::ExprKind::While(..)
161-
| ast::ExprKind::WhileLet(..) => Sugg::NonParen(snippet),
162+
| ast::ExprKind::WhileLet(..)
163+
| ast::ExprKind::Err => Sugg::NonParen(snippet),
162164
ast::ExprKind::Range(.., RangeLimits::HalfOpen) => Sugg::BinOp(AssocOp::DotDot, snippet),
163165
ast::ExprKind::Range(.., RangeLimits::Closed) => Sugg::BinOp(AssocOp::DotDotEq, snippet),
164166
ast::ExprKind::Assign(..) => Sugg::BinOp(AssocOp::Assign, snippet),

0 commit comments

Comments
 (0)