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

make_static!() does not work anymore since rustc nightly-2024-06-13 #16

Open
aurelj opened this issue Jun 19, 2024 · 3 comments
Open

make_static!() does not work anymore since rustc nightly-2024-06-13 #16

aurelj opened this issue Jun 19, 2024 · 3 comments

Comments

@aurelj
Copy link

aurelj commented Jun 19, 2024

make_static!() does not work anymore since rustc nightly-2024-06-13 or more precisely since this commit:
rust-lang/rust@02c7a59

Here is the detailed error I get when compiling with RUSTFLAGS="-Zmacro-backtrace":

error: item does not constrain `T::{opaque#0}`, but has it in its signature
   --> devel/embedded/static-cell/src/lib.rs:239:16
    |
234 | macro_rules! make_static {
    | ------------------------
    | |
    | in this expansion of `make_static!` (#1)
    | in this expansion of `$crate::make_static!` (#2)
235 |     ($val:expr) => ($crate::make_static!($val, ));
    |                     ---------------------------- in this macro invocation (#2)
...
239 |         static STATIC_CELL: $crate::StaticCell<T> = $crate::StaticCell::new();
    |                ^^^^^^^^^^^
    |
   ::: src/main.rs:133:24
    |
133 |     let merge_buffer = make_static!([0; 4096]);
    |                        ----------------------- in this macro invocation (#1)
    |
    = note: consider moving the opaque type's declaration and defining uses into a separate module
note: this opaque type is in the signature
   --> devel/embedded/static-cell/src/lib.rs:237:18
    |
234 | macro_rules! make_static {
    | ------------------------
    | |
    | in this expansion of `make_static!` (#1)
    | in this expansion of `$crate::make_static!` (#2)
235 |     ($val:expr) => ($crate::make_static!($val, ));
    |                     ---------------------------- in this macro invocation (#2)
236 |     ($val:expr, $(#[$m:meta])*) => {{
237 |         type T = impl ::core::marker::Sized;
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
   ::: src/main.rs:133:24
    |
133 |     let merge_buffer = make_static!([0; 4096]);
    |                        ----------------------- in this macro invocation (#1)

It seems the TAIT trick currently used in make_static!() is not allowed anymore. I tried to find an alternative without success.

@Dirbaio
Copy link
Member

Dirbaio commented Jun 19, 2024

yes, this is quite annoying. I've also failed to find an alternative! :(

kesyog added a commit to kesyog/hangman that referenced this issue Jul 6, 2024
static-cell's `make_static!` macro is broken in latest nightly:
embassy-rs/static-cell#16

Re-implement it by dropping the automatic type deduction magic.
@kesyog
Copy link

kesyog commented Jul 10, 2024

It's not as ergonomic, but I did the simple/naive thing in my project and fixed this by making a new version of the make_static! macro that adds an extra argument to pass in the type:

#[macro_export]
macro_rules! make_static {
    ($t:ty, $val:expr) => ($crate::make_static!($t, $val,));
    ($t:ty, $val:expr, $(#[$m:meta])*) => {{
        $(#[$m])*
        static STATIC_CELL: static_cell::StaticCell<$t> = static_cell::StaticCell::new();
        STATIC_CELL.init_with(|| $val)
    }};
}

@t-moe
Copy link

t-moe commented Aug 7, 2024

Is there any solution in sight?

Could we add this to the standard library? ( probably requires compiler intrinsics, but I'm no expert)

pmnxis added a commit to pmnxis/rusty-probe-firmware that referenced this issue Sep 11, 2024
Current rust embedded eco system has problem since rustc nightly 2024-06-13.
This would be related with this report embassy-rs/static-cell#16
Checked some of rust embedded project pass compile on 2024-06-12 include this repo.
lu-zero added a commit to wot-rust/wot-esp-hal-demo that referenced this issue Nov 19, 2024
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

4 participants