Skip to content

Commit 670debf

Browse files
committed
Auto merge of #119627 - oli-obk:const_prop_lint_n̵o̵n̵sense, r=cjgillot
Remove all ConstPropNonsense We track all locals and projections on them ourselves within the const propagator and only use the InterpCx to actually do some low level operations or read from constants (via `OpTy` we get for said constants). This helps moving the const prop lint out from the normal pipeline and running it just based on borrowck information. This in turn allows us to make progress on rust-lang/rust#108730 (comment) there are various follow up cleanups that can be done after this PR (e.g. not matching on Rvalue twice and doing binop checks twice), but lets try landing this one first. r? `@RalfJung`
2 parents ff6e177 + a0fbb3b commit 670debf

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

tests/ui/modulo_one.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ fn main() {
3333
INT_MIN % NEG_ONE;
3434
//~^ ERROR: this operation will panic at runtime
3535
//~| ERROR: any number modulo -1 will panic/overflow or result in 0
36-
// ONLY caught by rustc
36+
// Not caught by lint, we don't look into static items, even if entirely immutable.
3737
INT_MIN % STATIC_NEG_ONE;
38-
//~^ ERROR: this operation will panic at runtime
3938
}

tests/ui/modulo_one.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ error: this operation will panic at runtime
1212
LL | INT_MIN % NEG_ONE;
1313
| ^^^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow
1414

15-
error: this operation will panic at runtime
16-
--> $DIR/modulo_one.rs:37:5
17-
|
18-
LL | INT_MIN % STATIC_NEG_ONE;
19-
| ^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow
20-
2115
error: any number modulo 1 will be 0
2216
--> $DIR/modulo_one.rs:8:5
2317
|
@@ -57,5 +51,5 @@ error: any number modulo -1 will panic/overflow or result in 0
5751
LL | INT_MIN % NEG_ONE;
5852
| ^^^^^^^^^^^^^^^^^
5953

60-
error: aborting due to 9 previous errors
54+
error: aborting due to 8 previous errors
6155

0 commit comments

Comments
 (0)