Skip to content

Commit 95a65cd

Browse files
committed
Add regression test for CONST_ERR lints in extern macros
1 parent 05db5a2 commit 95a65cd

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

Diff for: src/test/ui/consts/auxiliary/external_macro.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(allow_internal_unstable)]
2+
3+
// Macro to help ensure CONST_ERR lint errors
4+
// are not silenced in external macros.
5+
// https://github.com/rust-lang/rust/issues/65300
6+
7+
#[macro_export]
8+
#[allow_internal_unstable(type_ascription)]
9+
macro_rules! static_assert {
10+
($test:expr) => {
11+
#[allow(dead_code)]
12+
const _: () = [()][!($test: bool) as usize];
13+
}
14+
}

Diff for: src/test/ui/consts/const-external-macro-const-err.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// edition:2018
2+
// aux-build:external_macro.rs
3+
4+
// Ensure that CONST_ERR lint errors
5+
// are not silenced in external macros.
6+
// https://github.com/rust-lang/rust/issues/65300
7+
8+
extern crate external_macro;
9+
use external_macro::static_assert;
10+
11+
fn main() {
12+
static_assert!(2 + 2 == 5); //~ ERROR
13+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: any use of this value will cause an error
2+
--> $DIR/const-external-macro-const-err.rs:12:5
3+
|
4+
LL | static_assert!(2 + 2 == 5);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1
6+
|
7+
= note: `#[deny(const_err)]` on by default
8+
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
9+
10+
error: aborting due to previous error
11+

0 commit comments

Comments
 (0)