Skip to content

Conversation

@adamgreig
Copy link
Member

As per https://github.com/rust-embedded/wg/blob/master/ops/msrv.md we should have a defined MSRV for this crate. This PR proposes setting it to 1.31 to allow use of const-fn from bare-metal by default, and updates Cargo.toml accordingly. It also sets the edition to 2018, permitted by an MSRV of 1.31.

Since this PR introduces an MSRV I propose it not requiring a semver bump, and we instead would look to release this change as 0.6.1.

Closes #153.

@adamgreig adamgreig requested a review from a team as a code owner July 24, 2019 14:20
@rust-highfive
Copy link

r? @thejpster

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m labels Jul 24, 2019
@therealprof
Copy link
Contributor

@adamgreig
Copy link
Member Author

Weird. https://github.com/rust-embedded/wg/blob/master/ops/msrv.md claims const-fn requires Rust 1.34, but https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html#const-fn disagrees. ;)

I think this is just meant to be an example of a feature using a higher MSRV rather than specifically written to indicate const-fn needs 1.34.

@adamgreig
Copy link
Member Author

@therealprof I've updated this PR to remove the breaking edition-2018 stuff, which I'll do in another PR. This now passes CI.

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@therealprof
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Jul 28, 2019
159: Define MSRV to be 1.31.0 and unconditionally use const-fn r=therealprof a=adamgreig

As per https://github.com/rust-embedded/wg/blob/master/ops/msrv.md we should have a defined MSRV for this crate. This PR proposes setting it to 1.31 to allow use of `const-fn` from bare-metal by default, and updates `Cargo.toml` accordingly. It also sets the edition to 2018, permitted by an MSRV of 1.31.

Since this PR _introduces_ an MSRV I propose it not requiring a semver bump, and we instead would look to release this change as `0.6.1`.

Closes #153.

Co-authored-by: Adam Greig <adam@ael.co.uk>
Co-authored-by: Adam Greig <adam@adamgreig.com>
@bors
Copy link
Contributor

bors bot commented Jul 28, 2019

Build succeeded

@bors bors bot merged commit 548670a into master Jul 28, 2019
@bors bors bot deleted the const-fn branch July 28, 2019 00:55
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
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 <jorge@japaric.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cortex-m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make const-fn default

4 participants