You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
159: static mut transform: forward `#[cfg]` r=therealprof a=japaric
as reported in japaric/cortex-m-rtfm#110 the following code fails to compile
``` rust
#[entry]
fn main() -> ! {
#[cfg(something)]
static mut FOO: u32 = 0; //~ ERROR cannot find value `FOO` in this scope
}
```
the issue is that the expansion of the static looks like this:
``` rust
let FOO = unsafe {
#[cfg(never)]
static mut FOO: u32 = 0;
&mut FOO
};
```
so when the `#[cfg]` evals to false the static is gone but the `let FOO` is not
removed.
this PR forwards `#[cfg]` attributes to the `let` expression and fixes the error
``` rust
#[cfg(never)] // <- added
let FOO = unsafe {
#[cfg(never)]
static mut FOO: u32 = 0;
&mut FOO
};
```
Co-authored-by: Jorge Aparicio <[email protected]>
0 commit comments