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

Clippy subtree update #135297

Merged
merged 82 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
a5d5edc
Do not trigger trailing_empty_array in tests
alex-semenyuk Dec 17, 2024
639f405
Remove obsolete comment
samueltardieu Dec 17, 2024
15ab2ff
use the correct `ParamEnv` when checking future's return type in `mis…
y21 Dec 21, 2024
de86302
correct suggestion for manual_div_ceil lint
lapla-cogito Dec 22, 2024
71f1a87
remove known problems section from match_same_arms
lapla-cogito Dec 24, 2024
be09596
Examples fixes for regex
alex-semenyuk Dec 24, 2024
1cc5051
Merge commit '609cd310be44677ae31d452a17b0f8207e1abfe1' into clippy-s…
flip1995 Dec 26, 2024
8a38bcc
Make "all fields are shorthand" requirement configurable
smoelius Nov 26, 2024
553a381
Remove obsolete comment (#13850)
y21 Dec 27, 2024
4be0e62
correct suggestion for `manual_div_ceil` lint (#13864)
xFrednet Dec 27, 2024
363e61d
remove description of known problems in `match_same_arms` that have a…
xFrednet Dec 27, 2024
a8968e5
Make `inconsistent_struct_constructor` "all fields are shorthand" req…
y21 Dec 27, 2024
09022bb
fix arguments of ExprKind::MethodCall
lapla-cogito Dec 28, 2024
998c780
fix arguments of `ExprKind::MethodCall` (#13890)
flip1995 Dec 28, 2024
e582fcd
[`needless_continue`]: lint if the last stmt in for/while/loop is `co…
lengyijun Sep 20, 2023
d7cc6c4
borrow_interior_mutable_const ICE into FN
blyxyas Dec 25, 2024
786f090
Do not trigger `trailing_empty_array` in tests (#13844)
llogiq Dec 29, 2024
aef4772
Examples fixes for regex (#13874)
dswij Dec 29, 2024
c8ba3e1
use the correct `ParamEnv` when checking future's output type (#13863)
dswij Dec 29, 2024
eef47fc
Do not remove required parentheses in `borrow_as_ptr` suggestion
samueltardieu Dec 27, 2024
f5f1abd
`borrow_interior_mutable_const` ICE into FN (#13877)
xFrednet Dec 29, 2024
b57d98b
Do not remove required parentheses in `borrow_as_ptr` suggestion (#13…
blyxyas Dec 29, 2024
34b1765
Move more def paths into `clippy_utils::paths`
GuillaumeGomez Dec 29, 2024
a9fe043
Do not remove identity mapping if mandatory mutability would be lost
samueltardieu Dec 29, 2024
e4b11a7
Fix parentheses when replacing `matches!(…, None)` with `.is_none()`
samueltardieu Dec 29, 2024
a657fcc
Use the full lifetime name in suggestions
samueltardieu Dec 29, 2024
b515064
Correctly handle `char` paths
GuillaumeGomez Dec 30, 2024
be49f86
Move more def paths into `clippy_utils::paths` (#13903)
y21 Dec 30, 2024
2aea7a0
Fix parentheses when replacing `matches!(…, None)` with `.is_none()` …
y21 Dec 30, 2024
7a834b5
Use the full lifetime name in suggestions (#13907)
Manishearth Dec 30, 2024
4899333
better suggestion for slow_vector_initialization
lapla-cogito Dec 31, 2024
1e0b782
add test for ICE
matthiaskrgr Dec 31, 2024
2a4dadd
fix type suggestion for manual_is_ascii_check (#13913)
Otto-AA Dec 31, 2024
c52740c
add test for ICE (#13914)
dswij Dec 31, 2024
3bc089e
refactor manual_is_ascii_check to remove unused parameter
Otto-AA Dec 31, 2024
54e5116
cover guard patterns in clippy lints
max-niederman Oct 6, 2024
4c9c2cc
Check if deref target implements `is_empty` for `len_zero` lint
samueltardieu Dec 23, 2024
33a6590
Check if deref target implements `is_empty` for `len_zero` lint (#13871)
blyxyas Jan 1, 2025
707653f
Add lint for calling last() on DoubleEndedIterator
qsantos Jan 1, 2025
458c955
Fix conflicts with double_ended_iterator_last
qsantos Jan 1, 2025
09c5d34
Dogfood double_ended_iterator_last
qsantos Jan 1, 2025
034f3d2
Improve `slow_vector_initialization` suggestion (#13912)
blyxyas Jan 1, 2025
27acfd8
Prefer if chain to let-else
qsantos Jan 1, 2025
7331cc0
Only complain about default Iterator::last()
qsantos Jan 1, 2025
0d213aa
Revert "Dogfood double_ended_iterator_last"
qsantos Jan 1, 2025
d67c00f
Dogfood double_ended_iterator_last
qsantos Jan 1, 2025
f18399f
Emit redundant if when duplicated in `needless_continue`
profetia Dec 28, 2024
631d9a2
Add lint for calling `Iterator::last()` on `DoubleEndedIterator` (#13…
Manishearth Jan 2, 2025
9c46e11
Remove unneeded parentheses in `unnecessary_map_or` lint output
samueltardieu Jan 2, 2025
7ac1515
Make CI a little bit safer
blyxyas Jan 2, 2025
7a01033
Make CI a little bit safer (#13933)
blyxyas Jan 3, 2025
ad36f2b
turn rustc_box into an intrinsic
RalfJung Jan 2, 2025
4736004
Update version attribute for 1.84 clippy lints
xFrednet Jan 3, 2025
4e4a2d0
Changelog for Clippy 1.84 :firecracker:
xFrednet Jan 3, 2025
1b85ae3
Only emit `useless_vec` suggestion if the macro does not contain code…
GuillaumeGomez Dec 30, 2024
b76e042
Add regression test for `useless_vec` with code comments
GuillaumeGomez Dec 30, 2024
f416f26
turn hir::ItemKind::Fn into a named-field variant
RalfJung Jan 4, 2025
5262111
Rollup merge of #135046 - RalfJung:rustc_box_intrinsic, r=compiler-er…
workingjubilee Jan 4, 2025
622382b
Fix year in CHANGELOG.md
xFrednet Jan 4, 2025
54f88c3
[`needless_continue`]: lint if the last stmt in loop is `continue` re…
blyxyas Jan 4, 2025
12d3137
CI: be compatible with both Rustup pre-1.28.0 and 1.28.0
samueltardieu Jan 4, 2025
ad69c65
Only emit `useless_vec` suggestion if the macro does not contain code…
xFrednet Jan 4, 2025
ca55534
Do not trigger clippy::missing_const_for_fn triggering for tests
alex-semenyuk Jan 4, 2025
a9c0e22
Changelog for Clippy 1.84 🧨 (#13937)
Centri3 Jan 6, 2025
891e387
Don't emit machine applicable `map_flatten` lint if there are code co…
GuillaumeGomez Jan 4, 2025
78225cc
Add regression test for #8528
GuillaumeGomez Jan 4, 2025
0e2505b
Do not trigger `missing_const_for_fn` for tests (#13945)
Manishearth Jan 6, 2025
63487dd
`clippy::redundant_locals` is not a correctness lint
hrxi Nov 28, 2024
98b9a26
`clippy::redundant_locals` is not a correctness lint (#13747)
Centri3 Jan 7, 2025
d0d5b8a
Don't emit machine applicable `map_flatten` lint if there are code co…
xFrednet Jan 7, 2025
4ef9177
CI: be compatible with both Rustup pre-1.28.0 and 1.28.0 (#13944)
flip1995 Jan 7, 2025
b7b69b1
Remove unneeded parentheses in `unnecessary_map_or` lint output (#13932)
Alexendoo Jan 7, 2025
f5ca68f
Do not remove identity mapping if mandatory mutability would be lost …
Alexendoo Jan 7, 2025
11f38ad
Rollup merge of #134989 - max-niederman:guard-patterns-hir, r=oli-obk
matthiaskrgr Jan 7, 2025
8461d3f
Remove unnecessary string allocation
Otto-AA Jan 8, 2025
894e87c
Fix type suggestion for manual_is_ascii_check (#13916)
Alexendoo Jan 8, 2025
b5bf09e
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jan 9, 2025
bb4a259
Bump nightly version -> 2024-01-09
flip1995 Jan 9, 2025
663892b
Bump Clippy version -> 0.1.86
flip1995 Jan 9, 2025
19e305b
Rustup (#13970)
flip1995 Jan 9, 2025
573db1c
Merge commit '19e305bb57a7595f2a8d81f521c0dd8bf854e739' into clippy-s…
flip1995 Jan 9, 2025
43c3b30
Update Cargo.lock
flip1995 Jan 9, 2025
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
Prev Previous commit
Next Next commit
Make "all fields are shorthand" requirement configurable
Handle field attributes in suggestions

Fix adjacent code

Address review comments

rust-lang/rust-clippy#13737 (comment)

Address all review comments but one

This comment is not yet addressed: rust-lang/rust-clippy#13737 (comment)

`initializer_suggestions` -> `lint_inconsistent_struct_field_initializers`
  • Loading branch information
smoelius committed Dec 27, 2024
commit 8a38bcc39083a2c73c2b7f27870d6bef85756f52
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6250,6 +6250,7 @@ Released 2018-09-13
[`future-size-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#future-size-threshold
[`ignore-interior-mutability`]: https://doc.rust-lang.org/clippy/lint_configuration.html#ignore-interior-mutability
[`large-error-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#large-error-threshold
[`lint-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#lint-inconsistent-struct-field-initializers
[`literal-representation-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#literal-representation-threshold
[`matches-for-let-else`]: https://doc.rust-lang.org/clippy/lint_configuration.html#matches-for-let-else
[`max-fn-params-bools`]: https://doc.rust-lang.org/clippy/lint_configuration.html#max-fn-params-bools
Expand Down
27 changes: 27 additions & 0 deletions book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,33 @@ The maximum size of the `Err`-variant in a `Result` returned from a function
* [`result_large_err`](https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err)


## `lint-inconsistent-struct-field-initializers`
Whether to suggest reordering constructor fields when initializers are present.

Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
suggested code would compile, it can change semantics if the initializer expressions have side effects. The
following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:

```rust
struct MyStruct {
vector: Vec<u32>,
length: usize
}
fn main() {
let vector = vec![1,2,3];
MyStruct { length: vector.len(), vector};
}
```

[from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924

**Default Value:** `false`

---
**Affected lints:**
* [`inconsistent_struct_constructor`](https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor)


## `literal-representation-threshold`
The lower bound for linting decimal literals

Expand Down
2 changes: 2 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
avoid-breaking-exported-api = false

lint-inconsistent-struct-field-initializers = true

[[disallowed-methods]]
path = "rustc_lint::context::LintContext::lint"
reason = "this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead"
Expand Down
20 changes: 20 additions & 0 deletions clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,26 @@ define_Conf! {
/// The maximum size of the `Err`-variant in a `Result` returned from a function
#[lints(result_large_err)]
large_error_threshold: u64 = 128,
/// Whether to suggest reordering constructor fields when initializers are present.
///
/// Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
/// suggested code would compile, it can change semantics if the initializer expressions have side effects. The
/// following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
///
/// ```rust
/// struct MyStruct {
/// vector: Vec<u32>,
/// length: usize
/// }
/// fn main() {
/// let vector = vec![1,2,3];
/// MyStruct { length: vector.len(), vector};
/// }
/// ```
///
/// [from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
#[lints(inconsistent_struct_constructor)]
lint_inconsistent_struct_field_initializers: bool = false,
/// The lower bound for linting decimal literals
#[lints(decimal_literal_representation)]
literal_representation_threshold: u64 = 16384,
Expand Down
6 changes: 3 additions & 3 deletions clippy_dev/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ fn fmt_conf(check: bool) -> Result<(), Error> {
#[expect(clippy::drain_collect)]
fields.push(ClippyConf {
name,
lints: lints.drain(..).collect(),
attrs: &conf[attrs_start..attrs_end],
lints: lints.drain(..).collect(),
field: conf[field_start..i].trim_end(),
});
attrs_start = i;
Expand All @@ -191,8 +191,8 @@ fn fmt_conf(check: bool) -> Result<(), Error> {
#[expect(clippy::drain_collect)]
fields.push(ClippyConf {
name,
lints: lints.drain(..).collect(),
attrs: &conf[attrs_start..attrs_end],
lints: lints.drain(..).collect(),
field: conf[field_start..i].trim_end(),
});
attrs_start = i;
Expand Down Expand Up @@ -220,8 +220,8 @@ fn fmt_conf(check: bool) -> Result<(), Error> {
}
fields.push(ClippyConf {
name,
lints,
attrs: &conf[attrs_start..attrs_end],
lints,
field: conf[field_start..].trim_end(),
});

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/arbitrary_source_item_ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {

// Makes a note of the current item for comparison with the next.
cur_t = Some(CurItem {
order: module_level_order,
item,
order: module_level_order,
name: get_item_name(item),
});
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,8 +798,8 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
parser.into_offset_iter(),
&doc,
Fragments {
fragments: &fragments,
doc: &doc,
fragments: &fragments,
},
))
}
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 @@ -678,12 +678,12 @@ fn find_insert_calls<'tcx>(
map: contains_expr.map,
key: contains_expr.key,
ctxt: expr.span.ctxt(),
edits: Vec::new(),
is_map_used: false,
allow_insert_closure: true,
can_use_entry: true,
in_tail_pos: true,
is_single_insert: true,
is_map_used: false,
edits: Vec::new(),
loops: Vec::new(),
locals: HirIdSet::default(),
};
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/implied_bounds_in_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds
&& !predicates.is_empty()
{
Some(ImplTraitBound {
span: bound.span(),
predicates,
trait_def_id,
args: path.args.map_or([].as_slice(), |p| p.args),
constraints: path.args.map_or([].as_slice(), |p| p.constraints),
trait_def_id,
span: bound.span(),
})
} else {
None
Expand Down
127 changes: 90 additions & 37 deletions clippy_lints/src/inconsistent_struct_constructor.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_config::Conf;
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::fulfill_or_allowed;
use clippy_utils::source::snippet;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::Applicability;
use rustc_hir::{self as hir, ExprKind, StructTailExpr};
use rustc_hir::{self as hir, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::declare_lint_pass;
use rustc_middle::ty::TyCtxt;
use rustc_session::impl_lint_pass;
use rustc_span::Span;
use rustc_span::symbol::Symbol;
use std::fmt::{self, Write as _};

declare_clippy_lint! {
/// ### What it does
/// Checks for struct constructors where all fields are shorthand and
/// the order of the field init shorthand in the constructor is inconsistent
/// with the order in the struct definition.
/// Checks for struct constructors where the order of the field
/// init in the constructor is inconsistent with the order in the
/// struct definition.
///
/// ### Why is this bad?
/// Since the order of fields in a constructor doesn't affect the
Expand Down Expand Up @@ -59,16 +61,37 @@ declare_clippy_lint! {
#[clippy::version = "1.52.0"]
pub INCONSISTENT_STRUCT_CONSTRUCTOR,
pedantic,
"the order of the field init shorthand is inconsistent with the order in the struct definition"
"the order of the field init is inconsistent with the order in the struct definition"
}

declare_lint_pass!(InconsistentStructConstructor => [INCONSISTENT_STRUCT_CONSTRUCTOR]);
pub struct InconsistentStructConstructor {
lint_inconsistent_struct_field_initializers: bool,
}

impl InconsistentStructConstructor {
pub fn new(conf: &'static Conf) -> Self {
Self {
lint_inconsistent_struct_field_initializers: conf.lint_inconsistent_struct_field_initializers,
}
}
}

impl_lint_pass!(InconsistentStructConstructor => [INCONSISTENT_STRUCT_CONSTRUCTOR]);

impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
if let ExprKind::Struct(qpath, fields, base) = expr.kind
&& fields.iter().all(|f| f.is_shorthand)
&& !expr.span.from_expansion()
let ExprKind::Struct(_, fields, _) = expr.kind else {
return;
};
let all_fields_are_shorthand = fields.iter().all(|f| f.is_shorthand);
let applicability = if all_fields_are_shorthand {
Applicability::MachineApplicable
} else if self.lint_inconsistent_struct_field_initializers {
Applicability::MaybeIncorrect
} else {
return;
};
if !expr.span.from_expansion()
&& let ty = cx.typeck_results().expr_ty(expr)
&& let Some(adt_def) = ty.ty_adt_def()
&& adt_def.is_struct()
Expand All @@ -85,36 +108,24 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
return;
}

let mut ordered_fields: Vec<_> = fields.iter().map(|f| f.ident.name).collect();
ordered_fields.sort_unstable_by_key(|id| def_order_map[id]);

let mut fields_snippet = String::new();
let (last_ident, idents) = ordered_fields.split_last().unwrap();
for ident in idents {
let _: fmt::Result = write!(fields_snippet, "{ident}, ");
}
fields_snippet.push_str(&last_ident.to_string());

let base_snippet = if let StructTailExpr::Base(base) = base {
format!(", ..{}", snippet(cx, base.span, ".."))
} else {
String::new()
};

let sugg = format!(
"{} {{ {fields_snippet}{base_snippet} }}",
snippet(cx, qpath.span(), ".."),
);
let span = field_with_attrs_span(cx.tcx, fields.first().unwrap())
.with_hi(field_with_attrs_span(cx.tcx, fields.last().unwrap()).hi());

if !fulfill_or_allowed(cx, INCONSISTENT_STRUCT_CONSTRUCTOR, Some(ty_hir_id)) {
span_lint_and_sugg(
span_lint_and_then(
cx,
INCONSISTENT_STRUCT_CONSTRUCTOR,
expr.span,
span,
"struct constructor field order is inconsistent with struct definition field order",
"try",
sugg,
Applicability::MachineApplicable,
|diag| {
let msg = if all_fields_are_shorthand {
"try"
} else {
"if the field evaluation order doesn't matter, try"
};
let sugg = suggestion(cx, fields, &def_order_map);
diag.span_suggestion(span, msg, sugg, applicability);
},
);
}
}
Expand All @@ -135,3 +146,45 @@ fn is_consistent_order<'tcx>(fields: &'tcx [hir::ExprField<'tcx>], def_order_map

true
}

fn suggestion<'tcx>(
cx: &LateContext<'_>,
fields: &'tcx [hir::ExprField<'tcx>],
def_order_map: &FxHashMap<Symbol, usize>,
) -> String {
let ws = fields
.windows(2)
.map(|w| {
let w0_span = field_with_attrs_span(cx.tcx, &w[0]);
let w1_span = field_with_attrs_span(cx.tcx, &w[1]);
let span = w0_span.between(w1_span);
snippet(cx, span, " ")
})
.collect::<Vec<_>>();

let mut fields = fields.to_vec();
fields.sort_unstable_by_key(|field| def_order_map[&field.ident.name]);
let field_snippets = fields
.iter()
.map(|field| snippet(cx, field_with_attrs_span(cx.tcx, field), ".."))
.collect::<Vec<_>>();

assert_eq!(field_snippets.len(), ws.len() + 1);

let mut sugg = String::new();
for i in 0..field_snippets.len() {
sugg += &field_snippets[i];
if i < ws.len() {
sugg += &ws[i];
}
}
sugg
}

fn field_with_attrs_span(tcx: TyCtxt<'_>, field: &hir::ExprField<'_>) -> Span {
if let Some(attr) = tcx.hir().attrs(field.hir_id).first() {
field.span.with_lo(attr.span.lo())
} else {
field.span
}
}
6 changes: 5 additions & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,11 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
store.register_late_pass(|_| Box::new(implicit_return::ImplicitReturn));
store.register_late_pass(move |_| Box::new(implicit_saturating_sub::ImplicitSaturatingSub::new(conf)));
store.register_late_pass(|_| Box::new(default_numeric_fallback::DefaultNumericFallback));
store.register_late_pass(|_| Box::new(inconsistent_struct_constructor::InconsistentStructConstructor));
store.register_late_pass(move |_| {
Box::new(inconsistent_struct_constructor::InconsistentStructConstructor::new(
conf,
))
});
store.register_late_pass(|_| Box::new(non_octal_unix_permissions::NonOctalUnixPermissions));
store.register_early_pass(|| Box::new(unnecessary_self_imports::UnnecessarySelfImports));
store.register_late_pass(move |_| Box::new(approx_const::ApproxConstant::new(conf)));
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/loops/infinite_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub(super) fn check<'tcx>(
cx,
label,
inner_labels: label.into_iter().collect(),
is_finite: false,
loop_depth: 0,
is_finite: false,
};
loop_visitor.visit_block(loop_block);

Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/macro_metavars_in_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ impl<'tcx> LateLintPass<'tcx> for ExprMetavarsInUnsafe {
// `check_stmt_post` on `(Late)LintPass`, which we'd need to detect when we're leaving a macro span

let mut vis = BodyVisitor {
macro_unsafe_blocks: Vec::new(),
#[expect(clippy::bool_to_int_with_if)] // obfuscates the meaning
expn_depth: if body.value.span.from_expansion() { 1 } else { 0 },
macro_unsafe_blocks: Vec::new(),
lint: self,
cx
cx,
lint: self
};
vis.visit_body(body);
}
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/methods/needless_collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,14 @@ fn detect_iter_and_into_iters<'tcx: 'a, 'a>(
captured_ids: HirIdSet,
) -> Option<Vec<IterFunction>> {
let mut visitor = IterFunctionVisitor {
uses: Vec::new(),
target: id,
seen_other: false,
cx,
current_mutably_captured_ids: HirIdSet::default(),
illegal_mutable_capture_ids: captured_ids,
current_mutably_captured_ids: HirIdSet::default(),
cx,
uses: Vec::new(),
hir_id_uses_map: FxHashMap::default(),
current_statement_hir_id: None,
seen_other: false,
target: id,
};
visitor.visit_block(block);
if visitor.seen_other {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/str_splitn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ fn parse_iter_usage<'tcx>(
{
Some(IterUsage {
kind: IterUsageKind::NextTuple,
span: e.span,
unwrap_kind: None,
span: e.span,
})
} else {
None
Expand Down
Loading