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

Apply assure and forward directly to expressions #37

Open
ErichDonGubler opened this issue Aug 7, 2020 · 3 comments
Open

Apply assure and forward directly to expressions #37

ErichDonGubler opened this issue Aug 7, 2020 · 3 comments

Comments

@ErichDonGubler
Copy link

ErichDonGubler commented Aug 7, 2020

Rust 1.45 lifts the restriction that proc-macros cannot be invoked in expression and statement position, which is the restriction referred to as the reason for needing a #[pre] macro on items using #[assure(...)] in the latest (0.2.0) crate docs:

Doing this is currently necessary, because the current (1.44.1) stable rust compiler does not support attribute macros being applied to statements or expressions directly.

What are plans for this crate now that this restriction has been lifted? Is any help needed to, say, lift the constraint that #[pre] needs to be applied to items?

The premise of the question is invalid, but @aticu has left this issue open and renamed it appropriately.

@aticu
Copy link
Owner

aticu commented Aug 7, 2020

Unfortunately this restriction has only been lifted for function-like proc-macros. pre uses attribute proc-macros, where this restriction still applies.

The following code still fails on 1.45

fn main() {
    unsafe {
        #[test_macro]
        foo()
    }
}

with this error message

error[E0658]: attributes on expressions are experimental
 --> src/main.rs:7:9
  |
7 |         #[test_macro]
  |         ^^^^^^^^^^^^^
  |
  = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information

error[E0658]: custom attributes cannot be applied to expressions
 --> src/main.rs:7:9
  |
7 |         #[test_macro]
  |         ^^^^^^^^^^^^^
  |
  = note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information

error: aborting due to 2 previous errors

I guess this issue could be left open though, until that limitation can be lifted.

@aticu aticu changed the title Plans for proc-macros now that they're available in Rust 1.45? Apply assure and forward directly to expressions Aug 7, 2020
@ErichDonGubler
Copy link
Author

Ergh, I obviously misunderstood the situation. Thanks for the patient response. :)

@aticu
Copy link
Owner

aticu commented Aug 7, 2020

Ergh, I obviously misunderstood the situation.

No worries, I had to double check as well, when I read the patch notes.

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

2 participants