dtolnay / rustversion

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

rustversion::before(date) matches stable version #26

Open glandium opened 3 years ago

glandium commented 3 years ago

Building the following:

#[rustversion::before(2020-01-01)]
fn main() {
    println!("Hello, world!");
}

fails as expected with recent nightlies (because of the missing main function in that case) but compiles just fine with 1.51.0.

since() is limited to nightlies. It seems before() should too.

wmmc88 commented 11 months ago

I think this is because #[rustversion::before(...) is defined as "Negative of #[rustversion::since(...)].", and #[rustversion::since(<some-nightly-version>)] is defined as "True on that nightly and all newer ones". That would mean that even newer stables than that nightly would not match.

If this is an intentional design decision by @dtolnay, what you want seems to be achieved by #[rustversion::all(nightly, before(2020-01-01))]