ignore assertions-on-constants in const contexts

This commit is contained in:
Lzu Tao 2024-05-24 10:51:15 +07:00
parent e18b27aa2a
commit ac600282a0
3 changed files with 6 additions and 26 deletions

View file

@ -47,7 +47,6 @@ fn main() {
assert!(!CFG_FLAG);
const _: () = assert!(true);
//~^ ERROR: `assert!(true)` will be optimized out by the compiler
// Don't lint if the value is dependent on a defined constant:
const N: usize = 1024;

View file

@ -72,29 +72,5 @@ LL | debug_assert!(true);
|
= help: remove it
error: `assert!(true)` will be optimized out by the compiler
--> tests/ui/assertions_on_constants.rs:49:19
|
LL | const _: () = assert!(true);
| ^^^^^^^^^^^^^
|
= help: remove it
error: `assert!(true)` will be optimized out by the compiler
--> tests/ui/assertions_on_constants.rs:59:5
|
LL | assert!(true);
| ^^^^^^^^^^^^^
|
= help: remove it
error: `assert!(true)` will be optimized out by the compiler
--> tests/ui/assertions_on_constants.rs:60:5
|
LL | assert!(8 == (7 + 1));
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: remove it
error: aborting due to 12 previous errors
error: aborting due to 9 previous errors