-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test for CONST_ERR lints in extern macros
- Loading branch information
1 parent
05db5a2
commit 95a65cd
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|