]> git.lizzy.rs Git - rust.git/blob - tests/ui/extern/extern-const.rs
Rollup merge of #106113 - krasimirgg:llvm-16-ext-tyid, r=nikic
[rust.git] / tests / ui / extern / extern-const.rs
1 // Check extern items cannot be const + `rustfix` suggests using
2 // extern static.
3 //
4 // #54388: an unused reference to an undefined static may or may not
5 // compile. To sidestep this by using one that *is* defined.
6
7 // run-rustfix
8 // ignore-wasm32-bare no external library to link to.
9 // ignore-asmjs wasm2js does not support source maps yet
10 // compile-flags: -g
11 #![feature(rustc_private)]
12 extern crate libc;
13
14 #[link(name = "rust_test_helpers", kind = "static")]
15 extern "C" {
16     const rust_dbg_static_mut: libc::c_int; //~ ERROR extern items cannot be `const`
17 }
18
19 fn main() {
20     // We suggest turning the (illegal) extern `const` into an extern `static`,
21     // but this also requires `unsafe` (a deny-by-default lint at comment time,
22     // future error; Issue #36247)
23     unsafe {
24         let _x = rust_dbg_static_mut;
25     }
26 }