Closed
Description
STR
fn main() {}
pub struct Peripherals {}
static mut PERIPHERALS: bool = false;
impl Peripherals {
pub fn all() {
foo(|| unsafe {
if PERIPHERALS {
loop {}
} else {
PERIPHERALS = true;
}
})
}
}
fn foo<F>(_f: F)
where
F: FnOnce(),
{
}
$ cargo check && echo OK
OK
$ rustfmt src/main.rs
$ cargo check
error[E0133]: use of mutable static requires unsafe function or block
(..)
$ cat src/main.rs
fn main() {}
pub struct Peripherals {}
static mut PERIPHERALS: bool = false;
impl Peripherals {
pub fn all() {
foo(|| {
if PERIPHERALS {
loop {}
} else {
PERIPHERALS = true;
}
})
}
}
fn foo<F>(_f: F)
where
F: FnOnce(),
{
}
Meta
$ rustfmt -V
0.2.15-nightly (f987946 2017-11-20)