dtolnay / rustversion

Conditional compilation according to rustc compiler version
Apache License 2.0
334 stars 15 forks source link

Ability to enable unstable feature in tests #18

Closed Frago9876543210 closed 2 years ago

Frago9876543210 commented 4 years ago

tests.rs

#[rustversion::attr(nightly, feature(arbitrary_enum_discriminant))]

mod something;
error[E0658]: discriminants on non-unit variants are experimental
 --> tests/derive/enums/regular_enum.rs:9:9
  |
9 |     } = 0xde,
  |         ^^^^
  |
  = note: see issue #60553 <https://github.com/rust-lang/rust/issues/60553> for more information
  = help: add `#![feature(arbitrary_enum_discriminant)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
error: could not compile `endiannezz`.

To learn more, run the command again with --verbose.
taiki-e commented 4 years ago

inner attribute (#![...]) is needed to enable unstable features. and the ability to use user-defined attributes as inner attributes is not yet stable and probably does not work at this time.

I'd recommend using a build script instead: https://github.com/dtolnay/rustversion/issues/8#issuecomment-555233586

dtolnay commented 2 years ago

I'll close this in favor of https://github.com/rust-lang/rust/issues/54726, since the required work here is in rustc, not this crate.

If there end up being changes required based on how that issue plays out, we can reopen an issue.

peter-lyons-kehl commented 1 year ago

See also #8.

wmmc88 commented 1 year ago

I'll close this in favor of rust-lang/rust#60553, since the required work here is in rustc, not this crate.

If there end up being changes required based on how that issue plays out, we can reopen an issue.

The linked issue is closed, but is that the right one? Seems like this would be blocked on https://github.com/rust-lang/rust/issues/54726

dtolnay commented 1 year ago

You're right. Fixed.