Rollup merge of #65320 - memoryruins:const_err, r=oli-obk
Report `CONST_ERR` lint in external macros fixes #65300 fixes #61058 r? @oli-obk
This commit is contained in:
commit
643261aad4
4 changed files with 40 additions and 1 deletions
|
@ -21,7 +21,8 @@ declare_lint! {
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
pub CONST_ERR,
|
pub CONST_ERR,
|
||||||
Deny,
|
Deny,
|
||||||
"constant evaluation detected erroneous expression"
|
"constant evaluation detected erroneous expression",
|
||||||
|
report_in_external_macro: true
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
|
|
14
src/test/ui/consts/auxiliary/external_macro.rs
Normal file
14
src/test/ui/consts/auxiliary/external_macro.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#![feature(allow_internal_unstable)]
|
||||||
|
|
||||||
|
// Macro to help ensure CONST_ERR lint errors
|
||||||
|
// are not silenced in external macros.
|
||||||
|
// https://github.com/rust-lang/rust/issues/65300
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
#[allow_internal_unstable(type_ascription)]
|
||||||
|
macro_rules! static_assert {
|
||||||
|
($test:expr) => {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
const _: () = [()][!($test: bool) as usize];
|
||||||
|
}
|
||||||
|
}
|
13
src/test/ui/consts/const-external-macro-const-err.rs
Normal file
13
src/test/ui/consts/const-external-macro-const-err.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// edition:2018
|
||||||
|
// aux-build:external_macro.rs
|
||||||
|
|
||||||
|
// Ensure that CONST_ERR lint errors
|
||||||
|
// are not silenced in external macros.
|
||||||
|
// https://github.com/rust-lang/rust/issues/65300
|
||||||
|
|
||||||
|
extern crate external_macro;
|
||||||
|
use external_macro::static_assert;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
static_assert!(2 + 2 == 5); //~ ERROR
|
||||||
|
}
|
11
src/test/ui/consts/const-external-macro-const-err.stderr
Normal file
11
src/test/ui/consts/const-external-macro-const-err.stderr
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
error: any use of this value will cause an error
|
||||||
|
--> $DIR/const-external-macro-const-err.rs:12:5
|
||||||
|
|
|
||||||
|
LL | static_assert!(2 + 2 == 5);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
||||||
|
|
|
||||||
|
= note: `#[deny(const_err)]` on by default
|
||||||
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue