Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta / 2018 Edition compatibility complications #11

Closed
therealprof opened this issue Sep 21, 2018 · 2 comments
Closed

Beta / 2018 Edition compatibility complications #11

therealprof opened this issue Sep 21, 2018 · 2 comments

Comments

@therealprof
Copy link
Contributor

I was just checking how well my crates would play with the 2018 edition and I was able to work around most quirks except for a few with the most major probably being that it seems to be impossible to share peripherals via the good old Mutex<RefCell<Option<_>>> static mechanism due to the inavailability of const_fn:

error[E0015]: calls in statics are limited to tuple structs and tuple variants
  --> examples/i2c_haldriver_printmagserial.rs:31:62
   |
31 | static MAG3110: Mutex<RefCell<Option<Mag3110<I2c<TWI1>>>>> = Mutex::new(RefCell::new(None));
   |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: a limited form of compile-time function evaluation is available on a nightly compiler via `const fn`
  --> examples/i2c_haldriver_printmagserial.rs:31:62
   |
31 | static MAG3110: Mutex<RefCell<Option<Mag3110<I2c<TWI1>>>>> = Mutex::new(RefCell::new(None));
   |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Is there any good workaround we can use here? Not being able to pass around peripherals and data safely into/out of interrupt handlers would be pretty bad, IMHO.

@TeXitoi
Copy link

TeXitoi commented Dec 10, 2018

In your Cargo.toml, you can just

bare-metal = { version = "0.2.4", features = ["const-fn"] }

It works on stable.

Maybe it should be the default now?

bors bot added a commit that referenced this issue Jan 29, 2020
25: Remove const-fn feature r=jonas-schievink a=rubberduck203

Per #22, as of Rust v1.31 const-fn was stablized.
Removing the feature in preparation of a 1.0 release.

Related to #11

Co-authored-by: Christopher J. McClellan <chris.mcclellan203@gmail.com>
@adamgreig
Copy link
Member

@therealprof we can close this now, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants