Don't trigger const_is_empty for inline const assertions

This commit is contained in:
Alexey Semenyuk 2024-10-17 22:36:26 +05:00
parent dae1be90ee
commit 8555922351
3 changed files with 33 additions and 2 deletions

View file

@ -171,3 +171,17 @@ fn constant_from_external_crate() {
let _ = std::env::consts::EXE_EXTENSION.is_empty();
// Do not lint, `exe_ext` comes from the `std` crate
}
fn issue_13106() {
const {
assert!(!NON_EMPTY_STR.is_empty());
}
const {
assert!(EMPTY_STR.is_empty());
}
const {
EMPTY_STR.is_empty();
}
}

View file

@ -157,5 +157,11 @@ error: this expression always evaluates to true
LL | let _ = val.is_empty();
| ^^^^^^^^^^^^^^
error: aborting due to 26 previous errors
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:185:9
|
LL | EMPTY_STR.is_empty();
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 27 previous errors