Skip to content
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

Update Clippy #101140

Merged
merged 163 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
171d082
Compare where predicates to trait bounds.
aldhsu Jul 12, 2022
b96842d
Split unfixable lints.
aldhsu Jul 13, 2022
3ddc04f
Add extra test cases from #8771, #8757, #9076.
aldhsu Jul 13, 2022
b426bd5
Don't lint `transmute_undefined_repr` when the the first field of a `…
Jarcho Aug 3, 2022
80f0f28
Extend `if_then_some_else_none` to also suggest `bool::then_some`
mkrasnitski Aug 4, 2022
99e77d0
Allow type erasure using `*const/mut int_type` in `transmute_undefine…
Jarcho Aug 7, 2022
73cd954
Add iter_once and iter_empty lints
sgued Jul 16, 2022
332e031
Fix the lint in clippy itself
sgued Jul 16, 2022
f3f86d8
Move iter_once and iter_empty to methods as a late pass
sgued Jul 16, 2022
f30d7c2
Improve suggestions
sgued Jul 19, 2022
b247594
Prevent some false positives
sgued Jul 28, 2022
af4885c
Rename new lints to iter_on_empty_collections and iter_on_single_items
sgued Jul 30, 2022
9ffddf5
Add new lint [`positional_named_format_parameters`]
miam-miam Jun 23, 2022
cf3f71d
Do not consider method call receiver as an argument in AST.
cjgillot Aug 7, 2022
6a73a45
Fix if_let_mutex not checking Mutexes behind refs
lukaslueg Aug 10, 2022
0428f0d
Add labels to if_let_mutex
lukaslueg Aug 10, 2022
eb68895
Simplify `rustc_ast::visit::Visitor::visit_poly_trait_ref`.
nnethercote Aug 11, 2022
459821b
fix
tamaroning Jul 2, 2022
45084ee
give up when gurad has side effects
tamaroning Aug 11, 2022
dc29cfb
Merge commit '2b2190cb5667cdd276a24ef8b9f3692209c54a89' into clippyup
flip1995 Aug 11, 2022
4d8b6d4
Rollup merge of #100392 - nnethercote:simplify-visitors, r=cjgillot
matthiaskrgr Aug 11, 2022
9ac237d
Auto merge of #100419 - flip1995:clippyup, r=Manishearth
bors Aug 12, 2022
f7f60b8
Adjust lint description for better clarity
mkrasnitski Aug 12, 2022
8bae517
Lint trait duplication in one pass.
Aug 12, 2022
3c4aec5
Update clippy for introduction of Node::ExprField
ehuss Jul 31, 2022
05fc1c7
Auto merge of #9289 - mkrasnitski:9094, r=xFrednet
bors Aug 12, 2022
1a3192a
Adjust cfgs
Mark-Simulacrum Aug 9, 2022
35486cb
Update Changelog to 1.63
flip1995 Aug 8, 2022
dfa780e
Auto merge of #9324 - flip1995:changelog, r=xFrednet
bors Aug 12, 2022
f18cd27
Update lint versions for 1.63 release
flip1995 Aug 12, 2022
4d5d191
Auto merge of #9326 - flip1995:version-update, r=xFrednet
bors Aug 13, 2022
84df61c
Auto merge of #9167 - aldhsu:fix-trait-duplication-false-pos, r=flip1995
bors Aug 14, 2022
679fa9f
Auto merge of #9187 - sgued:iter-once, r=flip1995
bors Aug 14, 2022
80826c3
Implement clippy::manual_empty_string_creations lint
Guilherme-Vasconcelos Jul 18, 2022
1bf8841
Update all tests to comply with clippy::manual_empty_string_creations
Guilherme-Vasconcelos Aug 5, 2022
1a2aaf6
Skip `unnecessary_to_owned` when `t != t.to_string()`
xphoniex Aug 14, 2022
86a0a18
Auto merge of #96745 - ehuss:even-more-attribute-validation, r=cjgillot
bors Aug 15, 2022
8c9040c
Auto merge of #9329 - xphoniex:fix-#9317, r=flip1995
bors Aug 15, 2022
6de4bdf
Fix label not starting with lcase-letter
lukaslueg Aug 15, 2022
7727c30
Simplify the borrow_deref_ref lint example
stanislav-tkach Aug 13, 2022
0fc95e8
Auto merge of #9318 - lukaslueg:ifletmutexref, r=xFrednet
bors Aug 15, 2022
a427b12
Auto merge of #9328 - stanislav-tkach:borrow_deref_ref-remove-extra-d…
bors Aug 16, 2022
6e5f90a
Shrink `ast::Attribute`.
nnethercote Aug 11, 2022
e92183c
Rename some things related to literals.
nnethercote Aug 1, 2022
9e9b3dd
Fix example
alex-semenyuk Aug 16, 2022
86ac6e8
Auto merge of #9040 - miam-miam100:unused_named_parameter, r=dswij
bors Aug 16, 2022
048e4d0
Auto merge of #9340 - alex-semenyuk:box_t, r=dswij
bors Aug 16, 2022
c1e0435
unwrap_used and expect_used: trigger on uses of their _err variants
sgued Aug 15, 2022
bd121ef
Fix [`non_ascii_literal`] in tests
Serial-ATA Aug 13, 2022
bfeaae8
suggest map_or in case_sensitive_file_extension_comparisons
Aug 16, 2022
f4f5bb4
Auto merge of #9327 - Serial-ATA:non_ascii_literal_macro, r=Alexendoo
bors Aug 16, 2022
343476d
Use `CARGO_TARGET_DIR` in compile-test
Serial-ATA Aug 16, 2022
a331766
Auto merge of #9343 - Serial-ATA:compiletest-target-env, r=Manishearth
bors Aug 16, 2022
a05cb74
Enhance `needless_borrow` to consider trait implementations
smoelius Jul 8, 2022
032f112
Fix adjacent code
smoelius Jul 8, 2022
18c6818
Auto merge of #9341 - bmc-msft:suggest-map_or-instead-of-unwrap_or, r…
bors Aug 17, 2022
48cb816
Handle `CARGO_TARGET_DIR` not being set in compile-test
Jarcho Aug 17, 2022
aadd014
Fix typo in as_undescore docs
cherryblossom000 Aug 17, 2022
4235b64
Auto merge of #9344 - Jarcho:opt_target_dir, r=flip1995
bors Aug 17, 2022
dc497c8
Auto merge of #9345 - cherryblossom000:patch-1, r=flip1995
bors Aug 17, 2022
37eeed7
Rollup merge of #100018 - nnethercote:clean-up-LitKind, r=petrochenkov
matthiaskrgr Aug 17, 2022
84fb7e0
Auto merge of #9287 - Jarcho:trans_undefined, r=xFrednet
bors Aug 17, 2022
ab91d5a
unwrap_used: Fix error message for unwrap_err when expect_used is all…
sgued Aug 17, 2022
849c1c0
Auto merge of #9338 - sgued:9331-unwrap-err-used, r=giraffate
bors Aug 17, 2022
c419d0a
Auto merge of #9136 - smoelius:enhance-needless-borrow, r=Jarcho
bors Aug 18, 2022
e87a5a1
Dont lint on match pattern-binding
lukaslueg Aug 18, 2022
eeaaba3
Auto merge of #9348 - lukaslueg:issue9347, r=Alexendoo
bors Aug 18, 2022
868dba9
Auto merge of #9295 - Guilherme-Vasconcelos:manual-empty-string-creat…
bors Aug 19, 2022
2666c38
Add [`unused_peekable`] lint
Serial-ATA Jul 29, 2022
0efafa4
Better handle method/function calls
Serial-ATA Aug 5, 2022
8ab2f88
Move `AsUnderscore` into `Casts` lint pass
Jarcho Jun 5, 2022
21f5954
Move `BorrowAsPtr` into `Casts` lint pass
Jarcho Jun 5, 2022
2502898
Move `ByteCount` into `Methods` lint pass
Jarcho Jun 5, 2022
ba6a459
Move `BytesCountToLen` into `Methods` lint pass
Jarcho Jun 5, 2022
e3b7797
Move `CaseSensitiveFileExtensionComparisons` into `Methods` lint pass
Jarcho Jun 5, 2022
a8d80d5
Move `GetFirst` into `Methods` lint pass
Jarcho Jun 5, 2022
5bc8813
Move `ManualOkOr` into `Methods` lint pass
Jarcho Jun 5, 2022
4523954
Move `MapClone` into `Methods` lint pass
Jarcho Jun 5, 2022
2f0ed0a
Move `MapErrIgnore` into `Methods` lint pass
Jarcho Jun 5, 2022
508cf6b
Move `MutMutexLock` into `Methods` lint pass
Jarcho Jun 5, 2022
0cc01ce
Move `OpenOptions` into `Methods` lint pass
Jarcho Jun 6, 2022
226f135
Move `PathBufPushOverwrite` into `Methods` lint group
Jarcho Jun 6, 2022
fd53761
Move `range_zip_with_len` into `Methods` lint pass
Jarcho Jun 6, 2022
06d752e
Move `RepeatOnce` into `Methods` lint pass
Jarcho Jun 6, 2022
e834855
Move `StableSortPrimitive` to `Methods` lint pass
Jarcho Jun 6, 2022
e213b6e
Move `TransmutingNull` into `Transmute` lint pass
Jarcho Jun 6, 2022
bb0584d
Move `UnitHash` into `Methods` lint pass
Jarcho Jun 6, 2022
d8d4a13
Move `UnnecessarySortBy` into `Methods` lint pass
Jarcho Jun 6, 2022
8acc4d2
Move `VecResizeToZero` into `Methods` lint pass
Jarcho Jun 6, 2022
d8808db
Move `VerboseFileReads` into `Methods` lint pass
Jarcho Jun 6, 2022
477c16d
Auto merge of #8957 - Jarcho:more_pass_merges, r=flip1995
bors Aug 19, 2022
4f049f5
Refactor `FormatArgsExpn`
Alexendoo Aug 18, 2022
d95b675
Rework `only_used_in_recursion`
Jarcho May 8, 2022
39f4bee
Move `only_used_in_recursion` back into `complexity`
Jarcho May 16, 2022
3e594de
Auto merge of #9349 - Alexendoo:format-args-expn, r=flip1995
bors Aug 19, 2022
3a54117
Auto merge of #8804 - Jarcho:in_recursion, r=Alexendoo
bors Aug 19, 2022
a4413f7
Register new lint collapsible_str_replace to methods
nahuakang Aug 2, 2022
89698b9
Extend and improve initial test cases for collapsible_str_replace
nahuakang Aug 4, 2022
6e86687
Handle replace calls with char slices
nahuakang Aug 5, 2022
a9bd0bd
Handle repeated str::replace calls with single char kind to str
nahuakang Aug 7, 2022
c989746
Remove checks on char slice; improve lint suggestion
nahuakang Aug 8, 2022
fb30b64
Adjust test cases; run cargo dev bless
nahuakang Aug 8, 2022
2091142
Auto merge of #9258 - Serial-ATA:unused-peekable, r=Alexendoo
bors Aug 19, 2022
2781ad0
Fix typos
alex-semenyuk Aug 20, 2022
b070b40
Simplify lint logic and address code review comments
nahuakang Aug 14, 2022
0dfec01
Auto merge of #9355 - alex-semenyuk:fixed_typos, r=giraffate
bors Aug 20, 2022
5820add
Auto merge of #9269 - nahuakang:collapsible_str_replace, r=flip1995
bors Aug 20, 2022
6f3d398
Add test for #8855
smoelius May 20, 2022
41309df
Auto merge of #8857 - smoelius:fix-8855, r=flip1995
bors Aug 20, 2022
5d403c0
allow check for `match` in lint [`option_if_let_else`]
J-ZhengLi Apr 16, 2022
ffe7125
and check for `Result`
J-ZhengLi Apr 16, 2022
f7a376e
Update needless_match.stderr
tamaroning Aug 21, 2022
1f75845
Reduce indentation and add comment about lint name
flip1995 Aug 21, 2022
87b3afc
Auto merge of #8696 - J-ZhengLi:issue8492, r=flip1995
bors Aug 21, 2022
5048af7
feat(fix): Do not lint if the target code is inside a loop
kyoto7250 Jun 13, 2022
318ed05
Reduce code duplication
flip1995 Aug 21, 2022
070b035
Improve error if rustfix coverage test spuriously fails
flip1995 Aug 21, 2022
e19a05c
Auto merge of #8992 - kyoto7250:fix_8753, r=flip1995
bors Aug 21, 2022
cc637ba
Auto merge of #9092 - tamaroning:fix-needless-match, r=llogiq
bors Aug 21, 2022
687fcf1
Fix `to_string_in_format_args` false positive
smoelius Jul 29, 2022
0bc26c8
`needed_ref` -> `needs_ref`
smoelius Jul 29, 2022
5735a3b
Auto merge of #9259 - smoelius:fix-9256, r=llogiq
bors Aug 22, 2022
06d7119
Remove the symbol from `ast::LitKind::Err`.
nnethercote Aug 22, 2022
2cb5318
Rename `manual_empty_string_creation` and move to pedantic
Alexendoo Aug 23, 2022
b33002d
Auto merge of #9366 - Alexendoo:manual_string_new, r=xFrednet
bors Aug 23, 2022
345c42a
Stabilize `#![feature(label_break_value)]`
jyn514 Jul 14, 2022
a0afbdf
Replace `contains_ty(..)` with `Ty::contains(..)`
Aug 24, 2022
79a439a
Auto merge of #9370 - mikerite:20220824_ty_contains, r=Jarcho
bors Aug 24, 2022
2cdc54d
Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petroc…
JohnTitor Aug 24, 2022
61aa4ef
uninit_vec: Vec::spare_capacity_mut is stable
sk1p Aug 25, 2022
fb7dffe
add `multi_assignments` lint
roynrishingha Aug 26, 2022
21f103a
Auto merge of #9379 - royrustdev:multi_assignments, r=llogiq
bors Aug 26, 2022
602bec2
Auto merge of #9374 - sk1p:patch-1, r=Jarcho
bors Aug 26, 2022
fe93b8d
Don't lint `needless_return` if `return` has attrs
lukaslueg Aug 26, 2022
de028e2
Implemented suspicious_to_owned lint to check if `to_owned` is called…
xanathar Jun 10, 2022
be8bd60
Auto merge of #9381 - lukaslueg:issue9361, r=dswij
bors Aug 27, 2022
90fe3be
remove parenthesis from unnecessary_cast suggestion
llogiq Aug 27, 2022
51e9113
Add `span_contains_comments` util
dswij Aug 1, 2022
b07d72b
Ignore when there is comment
dswij Aug 27, 2022
2d4d8e1
Auto merge of #8984 - xanathar:pr/suspicious_to_owned, r=llogiq
bors Aug 27, 2022
8d9da4d
Auto merge of #9276 - dswij:9164, r=flip1995
bors Aug 28, 2022
c542f1f
Don't lint literal None from expansion
lukaslueg Aug 28, 2022
3ad398d
Merge branch 'master' into rustup
Jarcho Aug 28, 2022
278b092
Bump nightly version -> 2022-08-27
Jarcho Aug 28, 2022
9790a32
Fixes for latest nightly
Jarcho Aug 28, 2022
4e31c8c
Auto merge of #9389 - lukaslueg:penmacro, r=llogiq
bors Aug 28, 2022
e550739
Disable incremental compilation on CI
Jarcho Aug 28, 2022
28ec27b
Auto merge of #9388 - Jarcho:rustup, r=Jarcho
bors Aug 29, 2022
58bbb1a
Auto merge of #9385 - rust-lang:unnecessary-cast-remove-parens, r=Ale…
bors Aug 29, 2022
26a6891
Fix missing parens in `suboptimal_flops` sugg
lukaslueg Aug 29, 2022
c5a8230
Fix `suspicious_to_owned` test when `c_char` is `u8`
Alexendoo Aug 29, 2022
30979bf
Add lint `cast_slice_from_raw_parts`
clubby789 Jul 26, 2022
cc9f203
Update clippy_lints/src/casts/mod.rs
clubby789 Aug 29, 2022
e9f7ce1
Auto merge of #9247 - clubby789:raw_slice_pointer_cast, r=Alexendoo
bors Aug 29, 2022
e1ecdb6
Auto merge of #9395 - Alexendoo:suspicious-to-owned-test, r=Manishearth
bors Aug 29, 2022
9ffc5a5
Fix more parens for `suboptimal_flops` suggs
lukaslueg Aug 29, 2022
4df6032
Auto merge of #9394 - lukaslueg:issue9391, r=Jarcho
bors Aug 30, 2022
19ef04f
Fix the order of `trait_duplication_in_bounds`
Jarcho Aug 30, 2022
66a9705
Initial implementation of `result_large_err`
lukaslueg Aug 24, 2022
09e4659
Auto merge of #9373 - lukaslueg:result_large_err, r=Alexendoo
bors Aug 30, 2022
f51aade
Auto merge of #9397 - Jarcho:trait_dup_order, r=dswij
bors Aug 31, 2022
9a67767
Merge commit 'f51aade56f93175dde89177a92e3669ebd8e7592' into clippyup
Jarcho Aug 31, 2022
7ed1333
Use `CountIsStart` in clippy
Jarcho Aug 31, 2022
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
1 change: 1 addition & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ env:
RUST_BACKTRACE: 1
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
NO_FMT_TEST: 1
CARGO_INCREMENTAL: 0

jobs:
base:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/clippy_bors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ env:
RUST_BACKTRACE: 1
CARGO_TARGET_DIR: '${{ github.workspace }}/target'
NO_FMT_TEST: 1
CARGO_INCREMENTAL: 0

defaults:
run:
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/crate_in_macro_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ impl EarlyLintPass for CrateInMacroDef {

fn is_macro_export(attr: &Attribute) -> bool {
if_chain! {
if let AttrKind::Normal(attr_item, _) = &attr.kind;
if let [segment] = attr_item.path.segments.as_slice();
if let AttrKind::Normal(normal) = &attr.kind;
if let [segment] = normal.item.path.segments.as_slice();
then {
segment.ident.name == sym::macro_export
} else {
Expand Down
29 changes: 17 additions & 12 deletions clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then};
use clippy_utils::source::{snippet_with_applicability, snippet_with_context};
use clippy_utils::sugg::has_enclosing_paren;
use clippy_utils::ty::{expr_sig, is_copy, peel_mid_ty_refs, ty_sig, variant_of_res};
use clippy_utils::{fn_def_id, get_parent_expr, is_lint_allowed, meets_msrv, msrvs, path_to_local, walk_to_expr_usage};
use clippy_utils::{
fn_def_id, get_parent_expr, get_parent_expr_for_hir, is_lint_allowed, meets_msrv, msrvs, path_to_local,
walk_to_expr_usage,
};
use rustc_ast::util::parser::{PREC_POSTFIX, PREC_PREFIX};
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::Applicability;
Expand Down Expand Up @@ -732,6 +735,19 @@ fn walk_parents<'tcx>(
Some(ty_auto_deref_stability(cx, output, precedence).position_for_result(cx))
},

Node::ExprField(field) if field.span.ctxt() == ctxt => match get_parent_expr_for_hir(cx, field.hir_id) {
Some(Expr {
hir_id,
kind: ExprKind::Struct(path, ..),
..
}) => variant_of_res(cx, cx.qpath_res(path, *hir_id))
.and_then(|variant| variant.fields.iter().find(|f| f.name == field.ident.name))
.map(|field_def| {
ty_auto_deref_stability(cx, cx.tcx.type_of(field_def.did), precedence).position_for_arg()
}),
_ => None,
},

Node::Expr(parent) if parent.span.ctxt() == ctxt => match parent.kind {
ExprKind::Ret(_) => {
let owner_id = cx.tcx.hir().body_owner(cx.enclosing_body.unwrap());
Expand Down Expand Up @@ -833,17 +849,6 @@ fn walk_parents<'tcx>(
}
})
},
ExprKind::Struct(path, fields, _) => {
let variant = variant_of_res(cx, cx.qpath_res(path, parent.hir_id));
fields
.iter()
.find(|f| f.expr.hir_id == child_id)
.zip(variant)
.and_then(|(field, variant)| variant.fields.iter().find(|f| f.name == field.ident.name))
.map(|field| {
ty_auto_deref_stability(cx, cx.tcx.type_of(field.did), precedence).position_for_arg()
})
},
ExprKind::Field(child, name) if child.hir_id == e.hir_id => Some(Position::FieldAccess(name.name)),
ExprKind::Unary(UnOp::Deref, child) if child.hir_id == e.hir_id => Some(Position::Deref),
ExprKind::Match(child, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar)
Expand Down
5 changes: 2 additions & 3 deletions clippy_lints/src/double_parens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ impl EarlyLintPass for DoubleParens {
}
}
},
ExprKind::MethodCall(_, ref params, _) => {
if params.len() == 2 {
let param = &params[1];
ExprKind::MethodCall(_, _, ref params, _) => {
if let [ref param] = params[..] {
if let ExprKind::Paren(_) = param.kind {
span_lint(cx, DOUBLE_PARENS, param.span, msg);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/matches/match_same_arms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl<'a> NormalizedPat<'a> {
LitKind::Char(val) => Self::LitInt(val.into()),
LitKind::Int(val, _) => Self::LitInt(val),
LitKind::Bool(val) => Self::LitBool(val),
LitKind::Float(..) | LitKind::Err(_) => Self::Wild,
LitKind::Float(..) | LitKind::Err => Self::Wild,
},
_ => Self::Wild,
},
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/octal_escapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ impl EarlyLintPass for OctalEscapes {
}

if let ExprKind::Lit(lit) = &expr.kind {
if matches!(lit.token.kind, LitKind::Str) {
check_lit(cx, &lit.token, lit.span, true);
} else if matches!(lit.token.kind, LitKind::ByteStr) {
check_lit(cx, &lit.token, lit.span, false);
if matches!(lit.token_lit.kind, LitKind::Str) {
check_lit(cx, &lit.token_lit, lit.span, true);
} else if matches!(lit.token_lit.kind, LitKind::ByteStr) {
check_lit(cx, &lit.token_lit, lit.span, false);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/option_env_unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ declare_lint_pass!(OptionEnvUnwrap => [OPTION_ENV_UNWRAP]);
impl EarlyLintPass for OptionEnvUnwrap {
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
if_chain! {
if let ExprKind::MethodCall(path_segment, args, _) = &expr.kind;
if let ExprKind::MethodCall(path_segment, receiver, _, _) = &expr.kind;
if matches!(path_segment.ident.name, sym::expect | sym::unwrap);
if let ExprKind::Call(caller, _) = &args[0].kind;
if let ExprKind::Call(caller, _) = &receiver.kind;
if is_direct_expn_of(caller.span, "option_env").is_some();
then {
span_lint_and_help(
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/precedence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ impl EarlyLintPass for Precedence {
let mut arg = operand;

let mut all_odd = true;
while let ExprKind::MethodCall(path_segment, args, _) = &arg.kind {
while let ExprKind::MethodCall(path_segment, receiver, _, _) = &arg.kind {
let path_segment_str = path_segment.ident.name.as_str();
all_odd &= ALLOWED_ODD_FUNCTIONS
.iter()
.any(|odd_function| **odd_function == *path_segment_str);
arg = args.first().expect("A method always has a receiver.");
arg = receiver;
}

if_chain! {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/suspicious_operation_groupings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ fn ident_difference_expr_with_base_location(
| (Unary(_, _), Unary(_, _))
| (Binary(_, _, _), Binary(_, _, _))
| (Tup(_), Tup(_))
| (MethodCall(_, _, _), MethodCall(_, _, _))
| (MethodCall(_, _, _, _), MethodCall(_, _, _, _))
| (Call(_, _), Call(_, _))
| (ConstBlock(_), ConstBlock(_))
| (Array(_), Array(_))
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unused_peekable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl<'tcx> Visitor<'_> for PeekableVisitor<'_, 'tcx> {
return;
},
},
Node::Block(_) => {},
Node::Block(_) | Node::ExprField(_) => {},
_ => {
break;
},
Expand Down
5 changes: 2 additions & 3 deletions clippy_lints/src/unused_rounding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ declare_clippy_lint! {
declare_lint_pass!(UnusedRounding => [UNUSED_ROUNDING]);

fn is_useless_rounding(expr: &Expr) -> Option<(&str, String)> {
if let ExprKind::MethodCall(name_ident, args, _) = &expr.kind
if let ExprKind::MethodCall(name_ident, receiver, _, _) = &expr.kind
&& let method_name = name_ident.ident.name.as_str()
&& (method_name == "ceil" || method_name == "round" || method_name == "floor")
&& !args.is_empty()
&& let ExprKind::Lit(spanned) = &args[0].kind
&& let ExprKind::Lit(spanned) = &receiver.kind
&& let LitKind::Float(symbol, ty) = spanned.kind {
let f = symbol.as_str().parse::<f64>().unwrap();
let f_str = symbol.to_string() + if let LitFloatType::Suffixed(ty) = ty {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unused_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl EarlyLintPass for UnusedUnit {
}
}

fn check_poly_trait_ref(&mut self, cx: &EarlyContext<'_>, poly: &ast::PolyTraitRef, _: &ast::TraitBoundModifier) {
fn check_poly_trait_ref(&mut self, cx: &EarlyContext<'_>, poly: &ast::PolyTraitRef) {
let segments = &poly.trait_ref.path.segments;

if_chain! {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
match lit.value.node {
LitKind::Bool(val) => kind!("Bool({val:?})"),
LitKind::Char(c) => kind!("Char({c:?})"),
LitKind::Err(val) => kind!("Err({val})"),
LitKind::Err => kind!("Err"),
LitKind::Byte(b) => kind!("Byte({b})"),
LitKind::Int(i, suffix) => {
let int_ty = match suffix {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/internal_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@ fn extract_clippy_version_value(cx: &LateContext<'_>, item: &'_ Item<'_>) -> Opt
attrs.iter().find_map(|attr| {
if_chain! {
// Identify attribute
if let ast::AttrKind::Normal(ref attr_kind, _) = &attr.kind;
if let [tool_name, attr_name] = &attr_kind.path.segments[..];
if let ast::AttrKind::Normal(ref attr_kind) = &attr.kind;
if let [tool_name, attr_name] = &attr_kind.item.path.segments[..];
if tool_name.ident.name == sym::clippy;
if attr_name.ident.name == sym::version;
if let Some(version) = attr.value_str();
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,12 +683,12 @@ impl Write {
},
};

let replacement: String = match lit.token.kind {
let replacement: String = match lit.token_lit.kind {
LitKind::StrRaw(_) | LitKind::ByteStrRaw(_) if matches!(fmtstr.style, StrStyle::Raw(_)) => {
lit.token.symbol.as_str().replace('{', "{{").replace('}', "}}")
lit.token_lit.symbol.as_str().replace('{', "{{").replace('}', "}}")
},
LitKind::Str | LitKind::ByteStr if matches!(fmtstr.style, StrStyle::Cooked) => {
lit.token.symbol.as_str().replace('{', "{{").replace('}', "}}")
lit.token_lit.symbol.as_str().replace('{', "{{").replace('}', "}}")
},
LitKind::StrRaw(_)
| LitKind::Str
Expand All @@ -697,7 +697,7 @@ impl Write {
| LitKind::Integer
| LitKind::Float
| LitKind::Err => continue,
LitKind::Byte | LitKind::Char => match lit.token.symbol.as_str() {
LitKind::Byte | LitKind::Char => match lit.token_lit.symbol.as_str() {
"\"" if matches!(fmtstr.style, StrStyle::Cooked) => "\\\"",
"\"" if matches!(fmtstr.style, StrStyle::Raw(0)) => continue,
"\\\\" if matches!(fmtstr.style, StrStyle::Raw(_)) => "\\",
Expand All @@ -708,7 +708,7 @@ impl Write {
x => x,
}
.into(),
LitKind::Bool => lit.token.symbol.as_str().deref().into(),
LitKind::Bool => lit.token_lit.symbol.as_str().deref().into(),
};

if !fmt_spans.is_empty() {
Expand Down
6 changes: 4 additions & 2 deletions clippy_utils/src/ast_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
(Array(l), Array(r)) | (Tup(l), Tup(r)) => over(l, r, |l, r| eq_expr(l, r)),
(Repeat(le, ls), Repeat(re, rs)) => eq_expr(le, re) && eq_expr(&ls.value, &rs.value),
(Call(lc, la), Call(rc, ra)) => eq_expr(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
(MethodCall(lc, la, _), MethodCall(rc, ra, _)) => eq_path_seg(lc, rc) && over(la, ra, |l, r| eq_expr(l, r)),
(MethodCall(lc, ls, la, _), MethodCall(rc, rs, ra, _)) => {
eq_path_seg(lc, rc) && eq_expr(ls, rs) && over(la, ra, |l, r| eq_expr(l, r))
},
(Binary(lo, ll, lr), Binary(ro, rl, rr)) => lo.node == ro.node && eq_expr(ll, rl) && eq_expr(lr, rr),
(Unary(lo, l), Unary(ro, r)) => mem::discriminant(lo) == mem::discriminant(ro) && eq_expr(l, r),
(Lit(l), Lit(r)) => l.kind == r.kind,
Expand Down Expand Up @@ -693,7 +695,7 @@ pub fn eq_attr(l: &Attribute, r: &Attribute) -> bool {
l.style == r.style
&& match (&l.kind, &r.kind) {
(DocComment(l1, l2), DocComment(r1, r2)) => l1 == r1 && l2 == r2,
(Normal(l, _), Normal(r, _)) => eq_path(&l.path, &r.path) && eq_mac_args(&l.args, &r.args),
(Normal(l), Normal(r)) => eq_path(&l.item.path, &r.item.path) && eq_mac_args(&l.item.args, &r.item.args),
_ => false,
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_utils/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ pub fn get_attr<'a>(
name: &'static str,
) -> impl Iterator<Item = &'a ast::Attribute> {
attrs.iter().filter(move |attr| {
let attr = if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
attr
let attr = if let ast::AttrKind::Normal(ref normal) = attr.kind {
&normal.item
} else {
return false;
};
Expand Down
8 changes: 3 additions & 5 deletions clippy_utils/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub enum Constant {
/// A reference
Ref(Box<Constant>),
/// A literal with syntax error.
Err(Symbol),
Err,
}

impl PartialEq for Constant {
Expand Down Expand Up @@ -118,9 +118,7 @@ impl Hash for Constant {
Self::Ref(ref r) => {
r.hash(state);
},
Self::Err(ref s) => {
s.hash(state);
},
Self::Err => {},
}
}
}
Expand Down Expand Up @@ -194,7 +192,7 @@ pub fn lit_to_mir_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
_ => bug!(),
},
LitKind::Bool(b) => Constant::Bool(b),
LitKind::Err(s) => Constant::Err(s),
LitKind::Err => Constant::Err,
}
}

Expand Down
8 changes: 4 additions & 4 deletions clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1900,8 +1900,8 @@ pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> {

pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
attr.path == sym::no_std
if let ast::AttrKind::Normal(ref normal) = attr.kind {
normal.item.path == sym::no_std
} else {
false
}
Expand All @@ -1910,8 +1910,8 @@ pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {

pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
attr.path == sym::no_core
if let ast::AttrKind::Normal(ref normal) = attr.kind {
normal.item.path == sym::no_core
} else {
false
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2022-08-11"
channel = "nightly-2022-08-27"
components = ["cargo", "llvm-tools-preview", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
2 changes: 1 addition & 1 deletion src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ struct ClippyCallbacks {

impl rustc_driver::Callbacks for ClippyCallbacks {
// JUSTIFICATION: necessary in clippy driver to set `mir_opt_level`
#[cfg_attr(not(bootstrap), allow(rustc::bad_opt_access))]
#[allow(rustc::bad_opt_access)]
fn config(&mut self, config: &mut interface::Config) {
let previous = config.register_lints.take();
let clippy_args_var = self.clippy_args_var.take();
Expand Down
1 change: 0 additions & 1 deletion tests/ui/semicolon_if_nothing_returned.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![warn(clippy::semicolon_if_nothing_returned)]
#![allow(clippy::redundant_closure)]
#![feature(label_break_value)]
#![feature(let_else)]

fn get_unit() {}
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/semicolon_if_nothing_returned.stderr
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
error: consider adding a `;` to the last statement for consistent formatting
--> $DIR/semicolon_if_nothing_returned.rs:10:5
--> $DIR/semicolon_if_nothing_returned.rs:9:5
|
LL | println!("Hello")
| ^^^^^^^^^^^^^^^^^ help: add a `;` here: `println!("Hello");`
|
= note: `-D clippy::semicolon-if-nothing-returned` implied by `-D warnings`

error: consider adding a `;` to the last statement for consistent formatting
--> $DIR/semicolon_if_nothing_returned.rs:14:5
--> $DIR/semicolon_if_nothing_returned.rs:13:5
|
LL | get_unit()
| ^^^^^^^^^^ help: add a `;` here: `get_unit();`

error: consider adding a `;` to the last statement for consistent formatting
--> $DIR/semicolon_if_nothing_returned.rs:19:5
--> $DIR/semicolon_if_nothing_returned.rs:18:5
|
LL | y = x + 1
| ^^^^^^^^^ help: add a `;` here: `y = x + 1;`

error: consider adding a `;` to the last statement for consistent formatting
--> $DIR/semicolon_if_nothing_returned.rs:25:9
--> $DIR/semicolon_if_nothing_returned.rs:24:9
|
LL | hello()
| ^^^^^^^ help: add a `;` here: `hello();`

error: consider adding a `;` to the last statement for consistent formatting
--> $DIR/semicolon_if_nothing_returned.rs:36:9
--> $DIR/semicolon_if_nothing_returned.rs:35:9
|
LL | ptr::drop_in_place(s.as_mut_ptr())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add a `;` here: `ptr::drop_in_place(s.as_mut_ptr());`
Expand Down