fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #66089 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4560ea788cb

1.39.0
770 B25 linesraw
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 no external library to link to.
9// compile-flags: -g
10#![feature(rustc_private)]
11extern crate libc;
12
13#[link(name = "rust_test_helpers", kind = "static")]
14extern "C" {
15    static rust_dbg_static_mut: libc::c_int; //~ ERROR extern items cannot be `const`
16}
17
18fn main() {
19    // We suggest turning the (illegal) extern `const` into an extern `static`,
20    // but this also requires `unsafe` (a deny-by-default lint at comment time,
21    // future error; Issue #36247)
22    unsafe {
23        let _x = rust_dbg_static_mut;
24    }
25}