Skip to content

Commit 1c0a61e

Browse files
committed
Auto merge of #8621 - Jarcho:eval_order_dependence_4637, r=Jarcho
Rename `eval_order_dependence` to `mixed_read_write_expression`, move to nursery As per the [reference](https://doc.rust-lang.org/1.51.0/reference/expressions.html#evaluation-order-of-operands) evaluation order is now defined. I'm pretty sure rust always compiled with this evaluation order anyways so there's no reason the put an msrv limit on the lint. changelog: Rename `eval_order_dependence` to `mixed_read_write_expression`, move to nursery
2 parents c10bfae + f7378da commit 1c0a61e

18 files changed

+112
-62
lines changed

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Large diffs are not rendered by default.

clippy_dev/src/update_lints.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,13 @@ fn generate_lint_files(
6666
|res| {
6767
for lint in usable_lints
6868
.iter()
69-
.map(|l| &l.name)
70-
.chain(deprecated_lints.iter().map(|l| &l.name))
69+
.map(|l| &*l.name)
70+
.chain(deprecated_lints.iter().map(|l| &*l.name))
71+
.chain(
72+
renamed_lints
73+
.iter()
74+
.map(|l| l.old_name.strip_prefix("clippy::").unwrap_or(&l.old_name)),
75+
)
7176
.sorted()
7277
{
7378
writeln!(res, "[`{}`]: {}#{}", lint, DOCS_LINK, lint).unwrap();

clippy_lints/src/lib.register_all.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
7171
LintId::of(erasing_op::ERASING_OP),
7272
LintId::of(escape::BOXED_LOCAL),
7373
LintId::of(eta_reduction::REDUNDANT_CLOSURE),
74-
LintId::of(eval_order_dependence::DIVERGING_SUB_EXPRESSION),
75-
LintId::of(eval_order_dependence::EVAL_ORDER_DEPENDENCE),
7674
LintId::of(explicit_write::EXPLICIT_WRITE),
7775
LintId::of(float_equality_without_abs::FLOAT_EQUALITY_WITHOUT_ABS),
7876
LintId::of(float_literal::EXCESSIVE_PRECISION),
@@ -230,6 +228,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
230228
LintId::of(misc_early::REDUNDANT_PATTERN),
231229
LintId::of(misc_early::UNNEEDED_WILDCARD_PATTERN),
232230
LintId::of(misc_early::ZERO_PREFIXED_LITERAL),
231+
LintId::of(mixed_read_write_in_expression::DIVERGING_SUB_EXPRESSION),
233232
LintId::of(mut_key::MUTABLE_KEY_TYPE),
234233
LintId::of(mut_mutex_lock::MUT_MUTEX_LOCK),
235234
LintId::of(mut_reference::UNNECESSARY_MUT_PASSED),

clippy_lints/src/lib.register_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec!
1212
LintId::of(double_comparison::DOUBLE_COMPARISONS),
1313
LintId::of(double_parens::DOUBLE_PARENS),
1414
LintId::of(duration_subsec::DURATION_SUBSEC),
15-
LintId::of(eval_order_dependence::DIVERGING_SUB_EXPRESSION),
1615
LintId::of(explicit_write::EXPLICIT_WRITE),
1716
LintId::of(format::USELESS_FORMAT),
1817
LintId::of(functions::TOO_MANY_ARGUMENTS),
@@ -59,6 +58,7 @@ store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec!
5958
LintId::of(misc::SHORT_CIRCUIT_STATEMENT),
6059
LintId::of(misc_early::UNNEEDED_WILDCARD_PATTERN),
6160
LintId::of(misc_early::ZERO_PREFIXED_LITERAL),
61+
LintId::of(mixed_read_write_in_expression::DIVERGING_SUB_EXPRESSION),
6262
LintId::of(needless_arbitrary_self_type::NEEDLESS_ARBITRARY_SELF_TYPE),
6363
LintId::of(needless_bool::BOOL_COMPARISON),
6464
LintId::of(needless_bool::NEEDLESS_BOOL),

clippy_lints/src/lib.register_lints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ store.register_lints(&[
151151
escape::BOXED_LOCAL,
152152
eta_reduction::REDUNDANT_CLOSURE,
153153
eta_reduction::REDUNDANT_CLOSURE_FOR_METHOD_CALLS,
154-
eval_order_dependence::DIVERGING_SUB_EXPRESSION,
155-
eval_order_dependence::EVAL_ORDER_DEPENDENCE,
156154
excessive_bools::FN_PARAMS_EXCESSIVE_BOOLS,
157155
excessive_bools::STRUCT_EXCESSIVE_BOOLS,
158156
exhaustive_items::EXHAUSTIVE_ENUMS,
@@ -383,6 +381,8 @@ store.register_lints(&[
383381
missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
384382
missing_enforced_import_rename::MISSING_ENFORCED_IMPORT_RENAMES,
385383
missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
384+
mixed_read_write_in_expression::DIVERGING_SUB_EXPRESSION,
385+
mixed_read_write_in_expression::MIXED_READ_WRITE_IN_EXPRESSION,
386386
module_style::MOD_MODULE_FILES,
387387
module_style::SELF_NAMED_MODULE_FILES,
388388
modulo_arithmetic::MODULO_ARITHMETIC,

clippy_lints/src/lib.register_restriction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ store.register_group(true, "clippy::restriction", Some("clippy_restriction"), ve
4646
LintId::of(missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS),
4747
LintId::of(missing_enforced_import_rename::MISSING_ENFORCED_IMPORT_RENAMES),
4848
LintId::of(missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS),
49+
LintId::of(mixed_read_write_in_expression::MIXED_READ_WRITE_IN_EXPRESSION),
4950
LintId::of(module_style::MOD_MODULE_FILES),
5051
LintId::of(module_style::SELF_NAMED_MODULE_FILES),
5152
LintId::of(modulo_arithmetic::MODULO_ARITHMETIC),

clippy_lints/src/lib.register_suspicious.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ store.register_group(true, "clippy::suspicious", Some("clippy_suspicious"), vec!
1515
LintId::of(drop_forget_ref::DROP_NON_DROP),
1616
LintId::of(drop_forget_ref::FORGET_NON_DROP),
1717
LintId::of(duplicate_mod::DUPLICATE_MOD),
18-
LintId::of(eval_order_dependence::EVAL_ORDER_DEPENDENCE),
1918
LintId::of(float_equality_without_abs::FLOAT_EQUALITY_WITHOUT_ABS),
2019
LintId::of(format_impl::PRINT_IN_FORMAT_IMPL),
2120
LintId::of(formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING),

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ mod equatable_if_let;
225225
mod erasing_op;
226226
mod escape;
227227
mod eta_reduction;
228-
mod eval_order_dependence;
229228
mod excessive_bools;
230229
mod exhaustive_items;
231230
mod exit;
@@ -301,6 +300,7 @@ mod missing_const_for_fn;
301300
mod missing_doc;
302301
mod missing_enforced_import_rename;
303302
mod missing_inline;
303+
mod mixed_read_write_in_expression;
304304
mod module_style;
305305
mod modulo_arithmetic;
306306
mod mut_key;
@@ -680,7 +680,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
680680
store.register_late_pass(|| Box::new(arithmetic::Arithmetic::default()));
681681
store.register_late_pass(|| Box::new(assign_ops::AssignOps));
682682
store.register_late_pass(|| Box::new(let_if_seq::LetIfSeq));
683-
store.register_late_pass(|| Box::new(eval_order_dependence::EvalOrderDependence));
683+
store.register_late_pass(|| Box::new(mixed_read_write_in_expression::EvalOrderDependence));
684684
store.register_late_pass(|| Box::new(missing_doc::MissingDoc::new()));
685685
store.register_late_pass(|| Box::new(missing_inline::MissingInline));
686686
store.register_late_pass(move || Box::new(exhaustive_items::ExhaustiveItems));

clippy_lints/src/eval_order_dependence.rs renamed to clippy_lints/src/mixed_read_write_in_expression.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ declare_clippy_lint! {
4040
/// let a = tmp + x;
4141
/// ```
4242
#[clippy::version = "pre 1.29.0"]
43-
pub EVAL_ORDER_DEPENDENCE,
44-
suspicious,
43+
pub MIXED_READ_WRITE_IN_EXPRESSION,
44+
restriction,
4545
"whether a variable read occurs before a write depends on sub-expression evaluation order"
4646
}
4747

@@ -73,7 +73,7 @@ declare_clippy_lint! {
7373
"whether an expression contains a diverging sub expression"
7474
}
7575

76-
declare_lint_pass!(EvalOrderDependence => [EVAL_ORDER_DEPENDENCE, DIVERGING_SUB_EXPRESSION]);
76+
declare_lint_pass!(EvalOrderDependence => [MIXED_READ_WRITE_IN_EXPRESSION, DIVERGING_SUB_EXPRESSION]);
7777

7878
impl<'tcx> LateLintPass<'tcx> for EvalOrderDependence {
7979
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
@@ -303,7 +303,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
303303
if !is_in_assignment_position(self.cx, expr) {
304304
span_lint_and_note(
305305
self.cx,
306-
EVAL_ORDER_DEPENDENCE,
306+
MIXED_READ_WRITE_IN_EXPRESSION,
307307
expr.span,
308308
&format!("unsequenced read of `{}`", self.cx.tcx.hir().name(self.var)),
309309
Some(self.write_expr.span),

clippy_lints/src/renamed_lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
99
("clippy::cyclomatic_complexity", "clippy::cognitive_complexity"),
1010
("clippy::disallowed_method", "clippy::disallowed_methods"),
1111
("clippy::disallowed_type", "clippy::disallowed_types"),
12+
("clippy::eval_order_dependence", "clippy::mixed_read_write_in_expression"),
1213
("clippy::for_loop_over_option", "clippy::for_loops_over_fallibles"),
1314
("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles"),
1415
("clippy::identity_conversion", "clippy::useless_conversion"),

tests/ui/branches_sharing_code/shared_at_top.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(dead_code, clippy::eval_order_dependence)]
1+
#![allow(dead_code, clippy::mixed_read_write_in_expression)]
22
#![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
33

44
// This tests the branches_sharing_code lint at the start of blocks

tests/ui/branches_sharing_code/valid_if_blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(dead_code, clippy::eval_order_dependence)]
1+
#![allow(dead_code, clippy::mixed_read_write_in_expression)]
22
#![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
33

44
// This tests valid if blocks that shouldn't trigger the lint

tests/ui/eval_order_dependence.rs renamed to tests/ui/mixed_read_write_in_expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[warn(clippy::eval_order_dependence)]
1+
#[warn(clippy::mixed_read_write_in_expression)]
22
#[allow(
33
unused_assignments,
44
unused_variables,

tests/ui/eval_order_dependence.stderr renamed to tests/ui/mixed_read_write_in_expression.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
error: unsequenced read of `x`
2-
--> $DIR/eval_order_dependence.rs:14:9
2+
--> $DIR/mixed_read_write_in_expression.rs:14:9
33
|
44
LL | } + x;
55
| ^
66
|
7-
= note: `-D clippy::eval-order-dependence` implied by `-D warnings`
7+
= note: `-D clippy::mixed-read-write-in-expression` implied by `-D warnings`
88
note: whether read occurs before this write depends on evaluation order
9-
--> $DIR/eval_order_dependence.rs:12:9
9+
--> $DIR/mixed_read_write_in_expression.rs:12:9
1010
|
1111
LL | x = 1;
1212
| ^^^^^
1313

1414
error: unsequenced read of `x`
15-
--> $DIR/eval_order_dependence.rs:17:5
15+
--> $DIR/mixed_read_write_in_expression.rs:17:5
1616
|
1717
LL | x += {
1818
| ^
1919
|
2020
note: whether read occurs before this write depends on evaluation order
21-
--> $DIR/eval_order_dependence.rs:18:9
21+
--> $DIR/mixed_read_write_in_expression.rs:18:9
2222
|
2323
LL | x = 20;
2424
| ^^^^^^
2525

2626
error: unsequenced read of `x`
27-
--> $DIR/eval_order_dependence.rs:30:12
27+
--> $DIR/mixed_read_write_in_expression.rs:30:12
2828
|
2929
LL | a: x,
3030
| ^
3131
|
3232
note: whether read occurs before this write depends on evaluation order
33-
--> $DIR/eval_order_dependence.rs:32:13
33+
--> $DIR/mixed_read_write_in_expression.rs:32:13
3434
|
3535
LL | x = 6;
3636
| ^^^^^
3737

3838
error: unsequenced read of `x`
39-
--> $DIR/eval_order_dependence.rs:39:9
39+
--> $DIR/mixed_read_write_in_expression.rs:39:9
4040
|
4141
LL | x += {
4242
| ^
4343
|
4444
note: whether read occurs before this write depends on evaluation order
45-
--> $DIR/eval_order_dependence.rs:40:13
45+
--> $DIR/mixed_read_write_in_expression.rs:40:13
4646
|
4747
LL | x = 20;
4848
| ^^^^^^

tests/ui/rename.fixed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![allow(clippy::cognitive_complexity)]
1111
#![allow(clippy::disallowed_methods)]
1212
#![allow(clippy::disallowed_types)]
13+
#![allow(clippy::mixed_read_write_in_expression)]
1314
#![allow(clippy::for_loops_over_fallibles)]
1415
#![allow(clippy::useless_conversion)]
1516
#![allow(clippy::match_result_ok)]
@@ -39,6 +40,7 @@
3940
#![warn(clippy::cognitive_complexity)]
4041
#![warn(clippy::disallowed_methods)]
4142
#![warn(clippy::disallowed_types)]
43+
#![warn(clippy::mixed_read_write_in_expression)]
4244
#![warn(clippy::for_loops_over_fallibles)]
4345
#![warn(clippy::for_loops_over_fallibles)]
4446
#![warn(clippy::useless_conversion)]

tests/ui/rename.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![allow(clippy::cognitive_complexity)]
1111
#![allow(clippy::disallowed_methods)]
1212
#![allow(clippy::disallowed_types)]
13+
#![allow(clippy::mixed_read_write_in_expression)]
1314
#![allow(clippy::for_loops_over_fallibles)]
1415
#![allow(clippy::useless_conversion)]
1516
#![allow(clippy::match_result_ok)]
@@ -39,6 +40,7 @@
3940
#![warn(clippy::cyclomatic_complexity)]
4041
#![warn(clippy::disallowed_method)]
4142
#![warn(clippy::disallowed_type)]
43+
#![warn(clippy::eval_order_dependence)]
4244
#![warn(clippy::for_loop_over_option)]
4345
#![warn(clippy::for_loop_over_result)]
4446
#![warn(clippy::identity_conversion)]

0 commit comments

Comments
 (0)