diff options
| author | mibac138 <5672750+mibac138@users.noreply.github.com> | 2020-04-28 16:07:50 +0200 |
|---|---|---|
| committer | mibac138 <5672750+mibac138@users.noreply.github.com> | 2020-05-03 02:42:11 +0200 |
| commit | a3ee28370fda2f956dc1c1d92858b18ddf55bf79 (patch) | |
| tree | ce90d2e0cd1febd9044406eba11ec3db57c93913 /src/test | |
| parent | 96f27c73cfb943e11afaff16dbe8415e6a3ae5a5 (diff) | |
Add more tests for cfg(version)
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-cfg-version.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-cfg-version.stderr | 43 |
2 files changed, 52 insertions, 3 deletions
diff --git a/src/test/ui/feature-gates/feature-gate-cfg-version.rs b/src/test/ui/feature-gates/feature-gate-cfg-version.rs index ffb08dedc8f..c29ef99945e 100644 --- a/src/test/ui/feature-gates/feature-gate-cfg-version.rs +++ b/src/test/ui/feature-gates/feature-gate-cfg-version.rs @@ -17,14 +17,24 @@ fn bar() -> bool { false } #[cfg(version("999"))] //~^ ERROR `cfg(version)` is experimental and subject to change fn bar() -> bool { false } -#[cfg(version("999"))] +#[cfg(version("-1"))] //~ ERROR: invalid version literal +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { false } +#[cfg(version("65536"))] //~ ERROR: invalid version literal //~^ ERROR `cfg(version)` is experimental and subject to change fn bar() -> bool { false } #[cfg(version("0"))] //~^ ERROR `cfg(version)` is experimental and subject to change fn bar() -> bool { true } +#[cfg(version("1.65536.2"))] +//~^ ERROR `cfg(version)` is experimental and subject to change +fn version_check_bug() {} + fn main() { + // This should fail but due to a bug in version_check `1.65536.2` is interpreted as `1.2`. + // See https://github.com/SergioBenitez/version_check/issues/11 + version_check_bug(); assert!(foo()); assert!(bar()); assert!(cfg!(version("1.42"))); //~ ERROR `cfg(version)` is experimental and subject to change diff --git a/src/test/ui/feature-gates/feature-gate-cfg-version.stderr b/src/test/ui/feature-gates/feature-gate-cfg-version.stderr index ffc0b4d4914..bdf160b5a02 100644 --- a/src/test/ui/feature-gates/feature-gate-cfg-version.stderr +++ b/src/test/ui/feature-gates/feature-gate-cfg-version.stderr @@ -73,6 +73,36 @@ LL | #[cfg(version("999"))] error[E0658]: `cfg(version)` is experimental and subject to change --> $DIR/feature-gate-cfg-version.rs:20:7 | +LL | #[cfg(version("-1"))] + | ^^^^^^^^^^^^^ + | + = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information + = help: add `#![feature(cfg_version)]` to the crate attributes to enable + +error: invalid version literal + --> $DIR/feature-gate-cfg-version.rs:20:15 + | +LL | #[cfg(version("-1"))] + | ^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:23:7 + | +LL | #[cfg(version("65536"))] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information + = help: add `#![feature(cfg_version)]` to the crate attributes to enable + +error: invalid version literal + --> $DIR/feature-gate-cfg-version.rs:23:15 + | +LL | #[cfg(version("65536"))] + | ^^^^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:26:7 + | LL | #[cfg(version("0"))] | ^^^^^^^^^^^^ | @@ -80,7 +110,16 @@ LL | #[cfg(version("0"))] = help: add `#![feature(cfg_version)]` to the crate attributes to enable error[E0658]: `cfg(version)` is experimental and subject to change - --> $DIR/feature-gate-cfg-version.rs:27:18 + --> $DIR/feature-gate-cfg-version.rs:30:7 + | +LL | #[cfg(version("1.65536.2"))] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information + = help: add `#![feature(cfg_version)]` to the crate attributes to enable + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:40:18 | LL | assert!(cfg!(version("1.42"))); | ^^^^^^^^^^^^^^^ @@ -88,6 +127,6 @@ LL | assert!(cfg!(version("1.42"))); = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information = help: add `#![feature(cfg_version)]` to the crate attributes to enable -error: aborting due to 11 previous errors +error: aborting due to 16 previous errors For more information about this error, try `rustc --explain E0658`. |
