diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/feature-gates | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/feature-gates')
358 files changed, 9706 insertions, 0 deletions
diff --git a/tests/ui/feature-gates/allow-features-empty.rs b/tests/ui/feature-gates/allow-features-empty.rs new file mode 100644 index 000000000..88a609349 --- /dev/null +++ b/tests/ui/feature-gates/allow-features-empty.rs @@ -0,0 +1,8 @@ +// compile-flags: -Z allow_features= +// Note: This test uses rustc internal flags because they will never stabilize. + +#![feature(lang_items)] //~ ERROR + +#![feature(unknown_stdlib_feature)] //~ ERROR + +fn main() {} diff --git a/tests/ui/feature-gates/allow-features-empty.stderr b/tests/ui/feature-gates/allow-features-empty.stderr new file mode 100644 index 000000000..f88b3ea0a --- /dev/null +++ b/tests/ui/feature-gates/allow-features-empty.stderr @@ -0,0 +1,15 @@ +error[E0725]: the feature `lang_items` is not in the list of allowed features + --> $DIR/allow-features-empty.rs:4:12 + | +LL | #![feature(lang_items)] + | ^^^^^^^^^^ + +error[E0725]: the feature `unknown_stdlib_feature` is not in the list of allowed features + --> $DIR/allow-features-empty.rs:6:12 + | +LL | #![feature(unknown_stdlib_feature)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0725`. diff --git a/tests/ui/feature-gates/allow-features.rs b/tests/ui/feature-gates/allow-features.rs new file mode 100644 index 000000000..2ce4701a8 --- /dev/null +++ b/tests/ui/feature-gates/allow-features.rs @@ -0,0 +1,8 @@ +// compile-flags: -Z allow_features=lang_items +// Note: This test uses rustc internal flags because they will never stabilize. + +#![feature(lang_items)] + +#![feature(unknown_stdlib_feature)] //~ ERROR + +fn main() {} diff --git a/tests/ui/feature-gates/allow-features.stderr b/tests/ui/feature-gates/allow-features.stderr new file mode 100644 index 000000000..9caf48dd1 --- /dev/null +++ b/tests/ui/feature-gates/allow-features.stderr @@ -0,0 +1,9 @@ +error[E0725]: the feature `unknown_stdlib_feature` is not in the list of allowed features + --> $DIR/allow-features.rs:6:12 + | +LL | #![feature(unknown_stdlib_feature)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0725`. diff --git a/tests/ui/feature-gates/auxiliary/cfg-target-thread-local.rs b/tests/ui/feature-gates/auxiliary/cfg-target-thread-local.rs new file mode 100644 index 000000000..bd5c8f81c --- /dev/null +++ b/tests/ui/feature-gates/auxiliary/cfg-target-thread-local.rs @@ -0,0 +1,7 @@ +#![feature(thread_local)] +#![feature(cfg_target_thread_local)] +#![crate_type = "lib"] + +#[no_mangle] +#[cfg_attr(target_thread_local, thread_local)] +pub static FOO: u32 = 3; diff --git a/tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis b/tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis new file mode 100644 index 000000000..6eb47e3d8 --- /dev/null +++ b/tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="utf-8"?> +<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> +</AutoVisualizer> diff --git a/tests/ui/feature-gates/auxiliary/pub_dep.rs b/tests/ui/feature-gates/auxiliary/pub_dep.rs new file mode 100644 index 000000000..3ebafd953 --- /dev/null +++ b/tests/ui/feature-gates/auxiliary/pub_dep.rs @@ -0,0 +1 @@ +pub struct PubType; diff --git a/tests/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs b/tests/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs new file mode 100644 index 000000000..41b9d64d5 --- /dev/null +++ b/tests/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs @@ -0,0 +1,22 @@ +pub trait Backend {} +pub trait SupportsDefaultKeyword {} + +impl SupportsDefaultKeyword for Postgres {} + +pub struct Postgres; + +impl Backend for Postgres {} + +pub struct AstPass<DB>(::std::marker::PhantomData<DB>); + +pub trait QueryFragment<DB: Backend> {} + + +#[derive(Debug, Clone, Copy)] +pub struct BatchInsert<'a, T: 'a, Tab> { + _marker: ::std::marker::PhantomData<(&'a T, Tab)>, +} + +impl<'a, T:'a, Tab, DB> QueryFragment<DB> for BatchInsert<'a, T, Tab> +where DB: SupportsDefaultKeyword + Backend, +{} diff --git a/tests/ui/feature-gates/bench.rs b/tests/ui/feature-gates/bench.rs new file mode 100644 index 000000000..8de390bec --- /dev/null +++ b/tests/ui/feature-gates/bench.rs @@ -0,0 +1,9 @@ +// edition:2018 + +#[bench] //~ ERROR use of unstable library feature 'test' + //~| WARN this was previously accepted +fn bench() {} + +use bench as _; //~ ERROR use of unstable library feature 'test' + //~| WARN this was previously accepted +fn main() {} diff --git a/tests/ui/feature-gates/bench.stderr b/tests/ui/feature-gates/bench.stderr new file mode 100644 index 000000000..5f0aaf925 --- /dev/null +++ b/tests/ui/feature-gates/bench.stderr @@ -0,0 +1,21 @@ +error: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable + --> $DIR/bench.rs:3:3 + | +LL | #[bench] + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266> + = note: `#[deny(soft_unstable)]` on by default + +error: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable + --> $DIR/bench.rs:7:5 + | +LL | use bench as _; + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266> + +error: aborting due to 2 previous errors + diff --git a/tests/ui/feature-gates/duplicate-features.rs b/tests/ui/feature-gates/duplicate-features.rs new file mode 100644 index 000000000..d8f781805 --- /dev/null +++ b/tests/ui/feature-gates/duplicate-features.rs @@ -0,0 +1,9 @@ +#![allow(stable_features)] + +#![feature(rust1)] +#![feature(rust1)] //~ ERROR the feature `rust1` has already been declared + +#![feature(if_let)] +#![feature(if_let)] //~ ERROR the feature `if_let` has already been declared + +fn main() {} diff --git a/tests/ui/feature-gates/duplicate-features.stderr b/tests/ui/feature-gates/duplicate-features.stderr new file mode 100644 index 000000000..dbde806f6 --- /dev/null +++ b/tests/ui/feature-gates/duplicate-features.stderr @@ -0,0 +1,15 @@ +error[E0636]: the feature `if_let` has already been declared + --> $DIR/duplicate-features.rs:7:12 + | +LL | #![feature(if_let)] + | ^^^^^^ + +error[E0636]: the feature `rust1` has already been declared + --> $DIR/duplicate-features.rs:4:12 + | +LL | #![feature(rust1)] + | ^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0636`. diff --git a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs new file mode 100644 index 000000000..05461297a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs @@ -0,0 +1,51 @@ +// needs-llvm-components: avr +// compile-flags: --target=avr-unknown-gnu-atmega328 --crate-type=rlib +#![no_core] +#![feature(no_core, lang_items)] +#[lang="sized"] +trait Sized { } + +// Test that the AVR interrupt ABI cannot be used when avr_interrupt +// feature gate is not used. + +extern "avr-non-blocking-interrupt" fn fu() {} +//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +extern "avr-interrupt" fn f() {} +//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + +trait T { + extern "avr-interrupt" fn m(); + //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + extern "avr-non-blocking-interrupt" fn mu(); + //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + + extern "avr-interrupt" fn dm() {} + //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + extern "avr-non-blocking-interrupt" fn dmu() {} + //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +} + +struct S; +impl T for S { + extern "avr-interrupt" fn m() {} + //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + extern "avr-non-blocking-interrupt" fn mu() {} + //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +} + +impl S { + extern "avr-interrupt" fn im() {} + //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + extern "avr-non-blocking-interrupt" fn imu() {} + //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +} + +type TA = extern "avr-interrupt" fn(); +//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +type TAU = extern "avr-non-blocking-interrupt" fn(); +//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + +extern "avr-interrupt" {} +//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +extern "avr-non-blocking-interrupt" {} +//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental diff --git a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr new file mode 100644 index 000000000..d017d03a3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr @@ -0,0 +1,129 @@ +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:11:8 + | +LL | extern "avr-non-blocking-interrupt" fn fu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:13:8 + | +LL | extern "avr-interrupt" fn f() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:17:12 + | +LL | extern "avr-interrupt" fn m(); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:19:12 + | +LL | extern "avr-non-blocking-interrupt" fn mu(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:22:12 + | +LL | extern "avr-interrupt" fn dm() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:24:12 + | +LL | extern "avr-non-blocking-interrupt" fn dmu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:30:12 + | +LL | extern "avr-interrupt" fn m() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:32:12 + | +LL | extern "avr-non-blocking-interrupt" fn mu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:37:12 + | +LL | extern "avr-interrupt" fn im() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:39:12 + | +LL | extern "avr-non-blocking-interrupt" fn imu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:43:18 + | +LL | type TA = extern "avr-interrupt" fn(); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:45:19 + | +LL | type TAU = extern "avr-non-blocking-interrupt" fn(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:48:8 + | +LL | extern "avr-interrupt" {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:50:8 + | +LL | extern "avr-non-blocking-interrupt" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information + = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs new file mode 100644 index 000000000..8b7d8066a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs @@ -0,0 +1,34 @@ +// needs-llvm-components: msp430 +// compile-flags: --target=msp430-none-elf --crate-type=rlib +#![no_core] +#![feature(no_core, lang_items)] +#[lang="sized"] +trait Sized { } + +extern "msp430-interrupt" fn f() {} +//~^ ERROR msp430-interrupt ABI is experimental + +trait T { + extern "msp430-interrupt" fn m(); + //~^ ERROR msp430-interrupt ABI is experimental + + extern "msp430-interrupt" fn dm() {} + //~^ ERROR msp430-interrupt ABI is experimental +} + +struct S; +impl T for S { + extern "msp430-interrupt" fn m() {} + //~^ ERROR msp430-interrupt ABI is experimental +} + +impl S { + extern "msp430-interrupt" fn im() {} + //~^ ERROR msp430-interrupt ABI is experimental +} + +type TA = extern "msp430-interrupt" fn(); +//~^ ERROR msp430-interrupt ABI is experimental + +extern "msp430-interrupt" {} +//~^ ERROR msp430-interrupt ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr new file mode 100644 index 000000000..c19ec9789 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr @@ -0,0 +1,66 @@ +error[E0658]: msp430-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-msp430-interrupt.rs:8:8 + | +LL | extern "msp430-interrupt" fn f() {} + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information + = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable + +error[E0658]: msp430-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-msp430-interrupt.rs:12:12 + | +LL | extern "msp430-interrupt" fn m(); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information + = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable + +error[E0658]: msp430-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-msp430-interrupt.rs:15:12 + | +LL | extern "msp430-interrupt" fn dm() {} + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information + = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable + +error[E0658]: msp430-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-msp430-interrupt.rs:21:12 + | +LL | extern "msp430-interrupt" fn m() {} + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information + = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable + +error[E0658]: msp430-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-msp430-interrupt.rs:26:12 + | +LL | extern "msp430-interrupt" fn im() {} + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information + = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable + +error[E0658]: msp430-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-msp430-interrupt.rs:30:18 + | +LL | type TA = extern "msp430-interrupt" fn(); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information + = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable + +error[E0658]: msp430-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-msp430-interrupt.rs:33:8 + | +LL | extern "msp430-interrupt" {} + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information + = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs new file mode 100644 index 000000000..7c3e4d10d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs @@ -0,0 +1,28 @@ +// needs-llvm-components: x86 +// compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib +#![no_core] +#![feature(no_core, lang_items)] +#[lang="sized"] +trait Sized { } + +extern "x86-interrupt" fn f7() {} //~ ERROR x86-interrupt ABI is experimental +trait Tr { + extern "x86-interrupt" fn m7(); //~ ERROR x86-interrupt ABI is experimental + extern "x86-interrupt" fn dm7() {} //~ ERROR x86-interrupt ABI is experimental +} + +struct S; + +// Methods in trait impl +impl Tr for S { + extern "x86-interrupt" fn m7() {} //~ ERROR x86-interrupt ABI is experimental +} + +// Methods in inherent impl +impl S { + extern "x86-interrupt" fn im7() {} //~ ERROR x86-interrupt ABI is experimental +} + +type A7 = extern "x86-interrupt" fn(); //~ ERROR x86-interrupt ABI is experimental + +extern "x86-interrupt" {} //~ ERROR x86-interrupt ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr new file mode 100644 index 000000000..3b727a745 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr @@ -0,0 +1,66 @@ +error[E0658]: x86-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-x86-interrupt.rs:8:8 + | +LL | extern "x86-interrupt" fn f7() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #40180 <https://github.com/rust-lang/rust/issues/40180> for more information + = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable + +error[E0658]: x86-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-x86-interrupt.rs:10:12 + | +LL | extern "x86-interrupt" fn m7(); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #40180 <https://github.com/rust-lang/rust/issues/40180> for more information + = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable + +error[E0658]: x86-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-x86-interrupt.rs:11:12 + | +LL | extern "x86-interrupt" fn dm7() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #40180 <https://github.com/rust-lang/rust/issues/40180> for more information + = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable + +error[E0658]: x86-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-x86-interrupt.rs:18:12 + | +LL | extern "x86-interrupt" fn m7() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #40180 <https://github.com/rust-lang/rust/issues/40180> for more information + = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable + +error[E0658]: x86-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-x86-interrupt.rs:23:12 + | +LL | extern "x86-interrupt" fn im7() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #40180 <https://github.com/rust-lang/rust/issues/40180> for more information + = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable + +error[E0658]: x86-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-x86-interrupt.rs:26:18 + | +LL | type A7 = extern "x86-interrupt" fn(); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #40180 <https://github.com/rust-lang/rust/issues/40180> for more information + = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable + +error[E0658]: x86-interrupt ABI is experimental and subject to change + --> $DIR/feature-gate-abi-x86-interrupt.rs:28:8 + | +LL | extern "x86-interrupt" {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #40180 <https://github.com/rust-lang/rust/issues/40180> for more information + = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-abi.rs b/tests/ui/feature-gates/feature-gate-abi.rs new file mode 100644 index 000000000..712655f97 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi.rs @@ -0,0 +1,60 @@ +// gate-test-intrinsics +// gate-test-platform_intrinsics +// compile-flags: --crate-type=rlib + +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized { } + +#[lang="tuple_trait"] +trait Tuple { } + +// Functions +extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change + //~^ ERROR intrinsic must be in +extern "platform-intrinsic" fn f2() {} //~ ERROR platform intrinsics are experimental + //~^ ERROR intrinsic must be in +extern "rust-call" fn f4(_: ()) {} //~ ERROR rust-call ABI is subject to change + +// Methods in trait definition +trait Tr { + extern "rust-intrinsic" fn m1(); //~ ERROR intrinsics are subject to change + //~^ ERROR intrinsic must be in + extern "platform-intrinsic" fn m2(); //~ ERROR platform intrinsics are experimental + //~^ ERROR intrinsic must be in + extern "rust-call" fn m4(_: ()); //~ ERROR rust-call ABI is subject to change + + extern "rust-call" fn dm4(_: ()) {} //~ ERROR rust-call ABI is subject to change +} + +struct S; + +// Methods in trait impl +impl Tr for S { + extern "rust-intrinsic" fn m1() {} //~ ERROR intrinsics are subject to change + //~^ ERROR intrinsic must be in + extern "platform-intrinsic" fn m2() {} //~ ERROR platform intrinsics are experimental + //~^ ERROR intrinsic must be in + extern "rust-call" fn m4(_: ()) {} //~ ERROR rust-call ABI is subject to change +} + +// Methods in inherent impl +impl S { + extern "rust-intrinsic" fn im1() {} //~ ERROR intrinsics are subject to change + //~^ ERROR intrinsic must be in + extern "platform-intrinsic" fn im2() {} //~ ERROR platform intrinsics are experimental + //~^ ERROR intrinsic must be in + extern "rust-call" fn im4(_: ()) {} //~ ERROR rust-call ABI is subject to change +} + +// Function pointer types +type A1 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change +type A2 = extern "platform-intrinsic" fn(); //~ ERROR platform intrinsics are experimental +type A4 = extern "rust-call" fn(_: ()); //~ ERROR rust-call ABI is subject to change + +// Foreign modules +extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change +extern "platform-intrinsic" {} //~ ERROR platform intrinsics are experimental +extern "rust-call" {} //~ ERROR rust-call ABI is subject to change diff --git a/tests/ui/feature-gates/feature-gate-abi.stderr b/tests/ui/feature-gates/feature-gate-abi.stderr new file mode 100644 index 000000000..e9791b951 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi.stderr @@ -0,0 +1,216 @@ +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:15:8 + | +LL | extern "rust-intrinsic" fn f1() {} + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(intrinsics)]` to the crate attributes to enable + +error[E0658]: platform intrinsics are experimental and possibly buggy + --> $DIR/feature-gate-abi.rs:17:8 + | +LL | extern "platform-intrinsic" fn f2() {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-abi.rs:19:8 + | +LL | extern "rust-call" fn f4(_: ()) {} + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:23:12 + | +LL | extern "rust-intrinsic" fn m1(); + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(intrinsics)]` to the crate attributes to enable + +error[E0658]: platform intrinsics are experimental and possibly buggy + --> $DIR/feature-gate-abi.rs:25:12 + | +LL | extern "platform-intrinsic" fn m2(); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-abi.rs:27:12 + | +LL | extern "rust-call" fn m4(_: ()); + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-abi.rs:29:12 + | +LL | extern "rust-call" fn dm4(_: ()) {} + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:36:12 + | +LL | extern "rust-intrinsic" fn m1() {} + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(intrinsics)]` to the crate attributes to enable + +error[E0658]: platform intrinsics are experimental and possibly buggy + --> $DIR/feature-gate-abi.rs:38:12 + | +LL | extern "platform-intrinsic" fn m2() {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-abi.rs:40:12 + | +LL | extern "rust-call" fn m4(_: ()) {} + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:45:12 + | +LL | extern "rust-intrinsic" fn im1() {} + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(intrinsics)]` to the crate attributes to enable + +error[E0658]: platform intrinsics are experimental and possibly buggy + --> $DIR/feature-gate-abi.rs:47:12 + | +LL | extern "platform-intrinsic" fn im2() {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-abi.rs:49:12 + | +LL | extern "rust-call" fn im4(_: ()) {} + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:53:18 + | +LL | type A1 = extern "rust-intrinsic" fn(); + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(intrinsics)]` to the crate attributes to enable + +error[E0658]: platform intrinsics are experimental and possibly buggy + --> $DIR/feature-gate-abi.rs:54:18 + | +LL | type A2 = extern "platform-intrinsic" fn(); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-abi.rs:55:18 + | +LL | type A4 = extern "rust-call" fn(_: ()); + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-abi.rs:58:8 + | +LL | extern "rust-intrinsic" {} + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(intrinsics)]` to the crate attributes to enable + +error[E0658]: platform intrinsics are experimental and possibly buggy + --> $DIR/feature-gate-abi.rs:59:8 + | +LL | extern "platform-intrinsic" {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-abi.rs:60:8 + | +LL | extern "rust-call" {} + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error: intrinsic must be in `extern "rust-intrinsic" { ... }` block + --> $DIR/feature-gate-abi.rs:23:32 + | +LL | extern "rust-intrinsic" fn m1(); + | ^^ + +error: intrinsic must be in `extern "rust-intrinsic" { ... }` block + --> $DIR/feature-gate-abi.rs:25:36 + | +LL | extern "platform-intrinsic" fn m2(); + | ^^ + +error: intrinsic must be in `extern "rust-intrinsic" { ... }` block + --> $DIR/feature-gate-abi.rs:15:33 + | +LL | extern "rust-intrinsic" fn f1() {} + | ^^ + +error: intrinsic must be in `extern "rust-intrinsic" { ... }` block + --> $DIR/feature-gate-abi.rs:17:37 + | +LL | extern "platform-intrinsic" fn f2() {} + | ^^ + +error: intrinsic must be in `extern "rust-intrinsic" { ... }` block + --> $DIR/feature-gate-abi.rs:36:37 + | +LL | extern "rust-intrinsic" fn m1() {} + | ^^ + +error: intrinsic must be in `extern "rust-intrinsic" { ... }` block + --> $DIR/feature-gate-abi.rs:38:41 + | +LL | extern "platform-intrinsic" fn m2() {} + | ^^ + +error: intrinsic must be in `extern "rust-intrinsic" { ... }` block + --> $DIR/feature-gate-abi.rs:45:38 + | +LL | extern "rust-intrinsic" fn im1() {} + | ^^ + +error: intrinsic must be in `extern "rust-intrinsic" { ... }` block + --> $DIR/feature-gate-abi.rs:47:42 + | +LL | extern "platform-intrinsic" fn im2() {} + | ^^ + +error: aborting due to 27 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-abi_amdgpu_kernel.rs b/tests/ui/feature-gates/feature-gate-abi_amdgpu_kernel.rs new file mode 100644 index 000000000..465b81d7f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi_amdgpu_kernel.rs @@ -0,0 +1,30 @@ +// compile-flags: --crate-type=rlib +#![no_core] +#![feature(no_core, lang_items)] +#[lang="sized"] +trait Sized { } + +extern "amdgpu-kernel" fn fu() {} //~ ERROR amdgpu-kernel ABI is experimental +//~^ ERROR is not a supported ABI + +trait T { + extern "amdgpu-kernel" fn mu(); //~ ERROR amdgpu-kernel ABI is experimental + extern "amdgpu-kernel" fn dmu() {} //~ ERROR amdgpu-kernel ABI is experimental + //~^ ERROR is not a supported ABI +} + +struct S; +impl T for S { + extern "amdgpu-kernel" fn mu() {} //~ ERROR amdgpu-kernel ABI is experimental + //~^ ERROR is not a supported ABI +} + +impl S { + extern "amdgpu-kernel" fn imu() {} //~ ERROR amdgpu-kernel ABI is experimental + //~^ ERROR is not a supported ABI +} + +type TAU = extern "amdgpu-kernel" fn(); //~ ERROR amdgpu-kernel ABI is experimental + +extern "amdgpu-kernel" {} //~ ERROR amdgpu-kernel ABI is experimental +//~^ ERROR is not a supported ABI diff --git a/tests/ui/feature-gates/feature-gate-abi_amdgpu_kernel.stderr b/tests/ui/feature-gates/feature-gate-abi_amdgpu_kernel.stderr new file mode 100644 index 000000000..c89ab7bae --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi_amdgpu_kernel.stderr @@ -0,0 +1,97 @@ +error[E0658]: amdgpu-kernel ABI is experimental and subject to change + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:7:8 + | +LL | extern "amdgpu-kernel" fn fu() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #51575 <https://github.com/rust-lang/rust/issues/51575> for more information + = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable + +error[E0658]: amdgpu-kernel ABI is experimental and subject to change + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:11:12 + | +LL | extern "amdgpu-kernel" fn mu(); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #51575 <https://github.com/rust-lang/rust/issues/51575> for more information + = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable + +error[E0658]: amdgpu-kernel ABI is experimental and subject to change + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:12:12 + | +LL | extern "amdgpu-kernel" fn dmu() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #51575 <https://github.com/rust-lang/rust/issues/51575> for more information + = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable + +error[E0658]: amdgpu-kernel ABI is experimental and subject to change + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:18:12 + | +LL | extern "amdgpu-kernel" fn mu() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #51575 <https://github.com/rust-lang/rust/issues/51575> for more information + = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable + +error[E0658]: amdgpu-kernel ABI is experimental and subject to change + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:23:12 + | +LL | extern "amdgpu-kernel" fn imu() {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #51575 <https://github.com/rust-lang/rust/issues/51575> for more information + = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable + +error[E0658]: amdgpu-kernel ABI is experimental and subject to change + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:27:19 + | +LL | type TAU = extern "amdgpu-kernel" fn(); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #51575 <https://github.com/rust-lang/rust/issues/51575> for more information + = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable + +error[E0658]: amdgpu-kernel ABI is experimental and subject to change + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:29:8 + | +LL | extern "amdgpu-kernel" {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #51575 <https://github.com/rust-lang/rust/issues/51575> for more information + = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable + +error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:29:1 + | +LL | extern "amdgpu-kernel" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:7:1 + | +LL | extern "amdgpu-kernel" fn fu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:12:5 + | +LL | extern "amdgpu-kernel" fn dmu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:18:5 + | +LL | extern "amdgpu-kernel" fn mu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target + --> $DIR/feature-gate-abi_amdgpu_kernel.rs:23:5 + | +LL | extern "amdgpu-kernel" fn imu() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors + +Some errors have detailed explanations: E0570, E0658. +For more information about an error, try `rustc --explain E0570`. diff --git a/tests/ui/feature-gates/feature-gate-abi_ptx.rs b/tests/ui/feature-gates/feature-gate-abi_ptx.rs new file mode 100644 index 000000000..e3405641e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi_ptx.rs @@ -0,0 +1,26 @@ +// needs-llvm-components: nvptx +// compile-flags: --target=nvptx64-nvidia-cuda --crate-type=rlib +#![no_core] +#![feature(no_core, lang_items)] +#[lang="sized"] +trait Sized { } + +extern "ptx-kernel" fn fu() {} //~ ERROR PTX ABIs are experimental + +trait T { + extern "ptx-kernel" fn mu(); //~ ERROR PTX ABIs are experimental + extern "ptx-kernel" fn dmu() {} //~ ERROR PTX ABIs are experimental +} + +struct S; +impl T for S { + extern "ptx-kernel" fn mu() {} //~ ERROR PTX ABIs are experimental +} + +impl S { + extern "ptx-kernel" fn imu() {} //~ ERROR PTX ABIs are experimental +} + +type TAU = extern "ptx-kernel" fn(); //~ ERROR PTX ABIs are experimental + +extern "ptx-kernel" {} //~ ERROR PTX ABIs are experimental diff --git a/tests/ui/feature-gates/feature-gate-abi_ptx.stderr b/tests/ui/feature-gates/feature-gate-abi_ptx.stderr new file mode 100644 index 000000000..40782d361 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi_ptx.stderr @@ -0,0 +1,66 @@ +error[E0658]: PTX ABIs are experimental and subject to change + --> $DIR/feature-gate-abi_ptx.rs:8:8 + | +LL | extern "ptx-kernel" fn fu() {} + | ^^^^^^^^^^^^ + | + = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information + = help: add `#![feature(abi_ptx)]` to the crate attributes to enable + +error[E0658]: PTX ABIs are experimental and subject to change + --> $DIR/feature-gate-abi_ptx.rs:11:12 + | +LL | extern "ptx-kernel" fn mu(); + | ^^^^^^^^^^^^ + | + = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information + = help: add `#![feature(abi_ptx)]` to the crate attributes to enable + +error[E0658]: PTX ABIs are experimental and subject to change + --> $DIR/feature-gate-abi_ptx.rs:12:12 + | +LL | extern "ptx-kernel" fn dmu() {} + | ^^^^^^^^^^^^ + | + = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information + = help: add `#![feature(abi_ptx)]` to the crate attributes to enable + +error[E0658]: PTX ABIs are experimental and subject to change + --> $DIR/feature-gate-abi_ptx.rs:17:12 + | +LL | extern "ptx-kernel" fn mu() {} + | ^^^^^^^^^^^^ + | + = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information + = help: add `#![feature(abi_ptx)]` to the crate attributes to enable + +error[E0658]: PTX ABIs are experimental and subject to change + --> $DIR/feature-gate-abi_ptx.rs:21:12 + | +LL | extern "ptx-kernel" fn imu() {} + | ^^^^^^^^^^^^ + | + = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information + = help: add `#![feature(abi_ptx)]` to the crate attributes to enable + +error[E0658]: PTX ABIs are experimental and subject to change + --> $DIR/feature-gate-abi_ptx.rs:24:19 + | +LL | type TAU = extern "ptx-kernel" fn(); + | ^^^^^^^^^^^^ + | + = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information + = help: add `#![feature(abi_ptx)]` to the crate attributes to enable + +error[E0658]: PTX ABIs are experimental and subject to change + --> $DIR/feature-gate-abi_ptx.rs:26:8 + | +LL | extern "ptx-kernel" {} + | ^^^^^^^^^^^^ + | + = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information + = help: add `#![feature(abi_ptx)]` to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-abi_unadjusted.rs b/tests/ui/feature-gates/feature-gate-abi_unadjusted.rs new file mode 100644 index 000000000..35a7d7328 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi_unadjusted.rs @@ -0,0 +1,7 @@ +extern "unadjusted" fn foo() { +//~^ ERROR: unadjusted ABI is an implementation detail and perma-unstable +} + +fn main() { + foo(); +} diff --git a/tests/ui/feature-gates/feature-gate-abi_unadjusted.stderr b/tests/ui/feature-gates/feature-gate-abi_unadjusted.stderr new file mode 100644 index 000000000..1757befec --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-abi_unadjusted.stderr @@ -0,0 +1,11 @@ +error[E0658]: unadjusted ABI is an implementation detail and perma-unstable + --> $DIR/feature-gate-abi_unadjusted.rs:1:8 + | +LL | extern "unadjusted" fn foo() { + | ^^^^^^^^^^^^ + | + = help: add `#![feature(abi_unadjusted)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-adt_const_params.rs b/tests/ui/feature-gates/feature-gate-adt_const_params.rs new file mode 100644 index 000000000..8a3bcf259 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-adt_const_params.rs @@ -0,0 +1,2 @@ +struct Foo<const NAME: &'static str>; //~ ERROR `&'static str` is forbidden +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-adt_const_params.stderr b/tests/ui/feature-gates/feature-gate-adt_const_params.stderr new file mode 100644 index 000000000..d8f089a28 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-adt_const_params.stderr @@ -0,0 +1,11 @@ +error: `&'static str` is forbidden as the type of a const generic parameter + --> $DIR/feature-gate-adt_const_params.rs:1:24 + | +LL | struct Foo<const NAME: &'static str>; + | ^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to previous error + diff --git a/tests/ui/feature-gates/feature-gate-alloc-error-handler.rs b/tests/ui/feature-gates/feature-gate-alloc-error-handler.rs new file mode 100644 index 000000000..78d189d20 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-alloc-error-handler.rs @@ -0,0 +1,16 @@ +// compile-flags:-C panic=abort + +#![no_std] +#![no_main] + +use core::alloc::Layout; + +#[alloc_error_handler] //~ ERROR use of unstable library feature 'alloc_error_handler' +fn oom(info: Layout) -> ! { + loop {} +} + +#[panic_handler] +fn panic(_: &core::panic::PanicInfo) -> ! { + loop {} +} diff --git a/tests/ui/feature-gates/feature-gate-alloc-error-handler.stderr b/tests/ui/feature-gates/feature-gate-alloc-error-handler.stderr new file mode 100644 index 000000000..f414eb463 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-alloc-error-handler.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature 'alloc_error_handler' + --> $DIR/feature-gate-alloc-error-handler.rs:8:3 + | +LL | #[alloc_error_handler] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #51540 <https://github.com/rust-lang/rust/issues/51540> for more information + = help: add `#![feature(alloc_error_handler)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-allocator_internals.rs b/tests/ui/feature-gates/feature-gate-allocator_internals.rs new file mode 100644 index 000000000..a17d17da6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allocator_internals.rs @@ -0,0 +1,3 @@ +#![default_lib_allocator] //~ ERROR: attribute is an experimental feature + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-allocator_internals.stderr b/tests/ui/feature-gates/feature-gate-allocator_internals.stderr new file mode 100644 index 000000000..6e276f7bc --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allocator_internals.stderr @@ -0,0 +1,11 @@ +error[E0658]: the `#[default_lib_allocator]` attribute is an experimental feature + --> $DIR/feature-gate-allocator_internals.rs:1:1 + | +LL | #![default_lib_allocator] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(allocator_internals)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unsafe-nested-macro.rs b/tests/ui/feature-gates/feature-gate-allow-internal-unsafe-nested-macro.rs new file mode 100644 index 000000000..9f604aafd --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unsafe-nested-macro.rs @@ -0,0 +1,17 @@ +// gate-test-allow_internal_unsafe + +#![allow(unused_macros)] + +macro_rules! bar { + () => { + // more layers don't help: + #[allow_internal_unsafe] //~ ERROR allow_internal_unsafe side-steps + macro_rules! baz { + () => {} + } + } +} + +bar!(); + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unsafe-nested-macro.stderr b/tests/ui/feature-gates/feature-gate-allow-internal-unsafe-nested-macro.stderr new file mode 100644 index 000000000..4621bc0b3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unsafe-nested-macro.stderr @@ -0,0 +1,15 @@ +error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint + --> $DIR/feature-gate-allow-internal-unsafe-nested-macro.rs:8:9 + | +LL | #[allow_internal_unsafe] + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | bar!(); + | ------ in this macro invocation + | + = help: add `#![feature(allow_internal_unsafe)]` to the crate attributes to enable + = note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.rs b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.rs new file mode 100644 index 000000000..ee48f9516 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.rs @@ -0,0 +1,17 @@ +// gate-test-allow_internal_unstable + +#![allow(unused_macros)] + +macro_rules! bar { + () => { + // more layers don't help: + #[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps + macro_rules! baz { + () => {} + } + } +} + +bar!(); + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.stderr b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.stderr new file mode 100644 index 000000000..1232d13a4 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.stderr @@ -0,0 +1,15 @@ +error[E0658]: allow_internal_unstable side-steps feature gating and stability checks + --> $DIR/feature-gate-allow-internal-unstable-nested-macro.rs:8:9 + | +LL | #[allow_internal_unstable()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | bar!(); + | ------ in this macro invocation + | + = help: add `#![feature(allow_internal_unstable)]` to the crate attributes to enable + = note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs new file mode 100644 index 000000000..8b13f1bf2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs @@ -0,0 +1,8 @@ +// checks that this attribute is caught on non-macro items. +// this needs a different test since this is done after expansion + +#[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps +//~| ERROR attribute should +struct S; + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr new file mode 100644 index 000000000..df7773ba4 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr @@ -0,0 +1,20 @@ +error[E0658]: allow_internal_unstable side-steps feature gating and stability checks + --> $DIR/feature-gate-allow-internal-unstable-struct.rs:4:1 + | +LL | #[allow_internal_unstable()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(allow_internal_unstable)]` to the crate attributes to enable + +error: attribute should be applied to a macro + --> $DIR/feature-gate-allow-internal-unstable-struct.rs:4:1 + | +LL | #[allow_internal_unstable()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | struct S; + | --------- not a macro + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable.rs b/tests/ui/feature-gates/feature-gate-allow-internal-unstable.rs new file mode 100644 index 000000000..0a1b6acd9 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable.rs @@ -0,0 +1,8 @@ +#![allow(unused_macros)] + +#[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps +macro_rules! foo { + () => {} +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable.stderr b/tests/ui/feature-gates/feature-gate-allow-internal-unstable.stderr new file mode 100644 index 000000000..3c1a4bfc7 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable.stderr @@ -0,0 +1,11 @@ +error[E0658]: allow_internal_unstable side-steps feature gating and stability checks + --> $DIR/feature-gate-allow-internal-unstable.rs:3:1 + | +LL | #[allow_internal_unstable()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(allow_internal_unstable)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-arbitrary-self-types.rs b/tests/ui/feature-gates/feature-gate-arbitrary-self-types.rs new file mode 100644 index 000000000..47ca7e349 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-arbitrary-self-types.rs @@ -0,0 +1,29 @@ +use std::{ + ops::Deref, +}; + +struct Ptr<T: ?Sized>(Box<T>); + +impl<T: ?Sized> Deref for Ptr<T> { + type Target = T; + + fn deref(&self) -> &T { + &*self.0 + } +} + +trait Foo { + fn foo(self: Ptr<Self>); //~ ERROR `Ptr<Self>` cannot be used as the type of `self` without +} + +struct Bar; + +impl Foo for Bar { + fn foo(self: Ptr<Self>) {} //~ ERROR `Ptr<Bar>` cannot be used as the type of `self` without +} + +impl Bar { + fn bar(self: Box<Ptr<Self>>) {} //~ ERROR `Box<Ptr<Bar>>` cannot be used as the +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-arbitrary-self-types.stderr b/tests/ui/feature-gates/feature-gate-arbitrary-self-types.stderr new file mode 100644 index 000000000..a1c69a5af --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-arbitrary-self-types.stderr @@ -0,0 +1,33 @@ +error[E0658]: `Ptr<Bar>` cannot be used as the type of `self` without the `arbitrary_self_types` feature + --> $DIR/feature-gate-arbitrary-self-types.rs:22:18 + | +LL | fn foo(self: Ptr<Self>) {} + | ^^^^^^^^^ + | + = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information + = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable + = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) + +error[E0658]: `Box<Ptr<Bar>>` cannot be used as the type of `self` without the `arbitrary_self_types` feature + --> $DIR/feature-gate-arbitrary-self-types.rs:26:18 + | +LL | fn bar(self: Box<Ptr<Self>>) {} + | ^^^^^^^^^^^^^^ + | + = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information + = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable + = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) + +error[E0658]: `Ptr<Self>` cannot be used as the type of `self` without the `arbitrary_self_types` feature + --> $DIR/feature-gate-arbitrary-self-types.rs:16:18 + | +LL | fn foo(self: Ptr<Self>); + | ^^^^^^^^^ + | + = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information + = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable + = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.rs b/tests/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.rs new file mode 100644 index 000000000..f7e94117e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.rs @@ -0,0 +1,18 @@ +struct Foo; + +impl Foo { + fn foo(self: *const Self) {} + //~^ ERROR `*const Foo` cannot be used as the type of `self` without +} + +trait Bar { + fn bar(self: *const Self); + //~^ ERROR `*const Self` cannot be used as the type of `self` without +} + +impl Bar for () { + fn bar(self: *const Self) {} + //~^ ERROR `*const ()` cannot be used as the type of `self` without +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.stderr b/tests/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.stderr new file mode 100644 index 000000000..a9f611b87 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-arbitrary_self_types-raw-pointer.stderr @@ -0,0 +1,33 @@ +error[E0658]: `*const Foo` cannot be used as the type of `self` without the `arbitrary_self_types` feature + --> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:4:18 + | +LL | fn foo(self: *const Self) {} + | ^^^^^^^^^^^ + | + = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information + = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable + = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) + +error[E0658]: `*const ()` cannot be used as the type of `self` without the `arbitrary_self_types` feature + --> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:14:18 + | +LL | fn bar(self: *const Self) {} + | ^^^^^^^^^^^ + | + = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information + = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable + = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) + +error[E0658]: `*const Self` cannot be used as the type of `self` without the `arbitrary_self_types` feature + --> $DIR/feature-gate-arbitrary_self_types-raw-pointer.rs:9:18 + | +LL | fn bar(self: *const Self); + | ^^^^^^^^^^^ + | + = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information + = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable + = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-asm_const.rs b/tests/ui/feature-gates/feature-gate-asm_const.rs new file mode 100644 index 000000000..936918a3c --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-asm_const.rs @@ -0,0 +1,16 @@ +// only-x86_64 + +use std::arch::asm; + +unsafe fn foo<const N: usize>() { + asm!("mov eax, {}", const N + 1); + //~^ ERROR const operands for inline assembly are unstable +} + +fn main() { + unsafe { + foo::<0>(); + asm!("mov eax, {}", const 123); + //~^ ERROR const operands for inline assembly are unstable + } +} diff --git a/tests/ui/feature-gates/feature-gate-asm_const.stderr b/tests/ui/feature-gates/feature-gate-asm_const.stderr new file mode 100644 index 000000000..c248374ec --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-asm_const.stderr @@ -0,0 +1,21 @@ +error[E0658]: const operands for inline assembly are unstable + --> $DIR/feature-gate-asm_const.rs:6:25 + | +LL | asm!("mov eax, {}", const N + 1); + | ^^^^^^^^^^^ + | + = note: see issue #93332 <https://github.com/rust-lang/rust/issues/93332> for more information + = help: add `#![feature(asm_const)]` to the crate attributes to enable + +error[E0658]: const operands for inline assembly are unstable + --> $DIR/feature-gate-asm_const.rs:13:29 + | +LL | asm!("mov eax, {}", const 123); + | ^^^^^^^^^ + | + = note: see issue #93332 <https://github.com/rust-lang/rust/issues/93332> for more information + = help: add `#![feature(asm_const)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-asm_experimental_arch.rs b/tests/ui/feature-gates/feature-gate-asm_experimental_arch.rs new file mode 100644 index 000000000..53e2a4d13 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-asm_experimental_arch.rs @@ -0,0 +1,21 @@ +// compile-flags: --target mips-unknown-linux-gnu +// needs-llvm-components: mips + +#![feature(no_core, lang_items, rustc_attrs)] +#![crate_type = "rlib"] +#![no_core] + +#[rustc_builtin_macro] +macro_rules! asm { + () => {}; +} + +#[lang = "sized"] +trait Sized {} +#[lang = "copy"] +trait Copy {} + +unsafe fn main() { + asm!(""); + //~^ ERROR inline assembly is not stable yet on this architecture +} diff --git a/tests/ui/feature-gates/feature-gate-asm_experimental_arch.stderr b/tests/ui/feature-gates/feature-gate-asm_experimental_arch.stderr new file mode 100644 index 000000000..4a859430e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-asm_experimental_arch.stderr @@ -0,0 +1,12 @@ +error[E0658]: inline assembly is not stable yet on this architecture + --> $DIR/feature-gate-asm_experimental_arch.rs:19:5 + | +LL | asm!(""); + | ^^^^^^^^ + | + = note: see issue #93335 <https://github.com/rust-lang/rust/issues/93335> for more information + = help: add `#![feature(asm_experimental_arch)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-asm_unwind.rs b/tests/ui/feature-gates/feature-gate-asm_unwind.rs new file mode 100644 index 000000000..df161b600 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-asm_unwind.rs @@ -0,0 +1,10 @@ +// only-x86_64 + +use std::arch::asm; + +fn main() { + unsafe { + asm!("", options(may_unwind)); + //~^ ERROR the `may_unwind` option is unstable + } +} diff --git a/tests/ui/feature-gates/feature-gate-asm_unwind.stderr b/tests/ui/feature-gates/feature-gate-asm_unwind.stderr new file mode 100644 index 000000000..05e66acb5 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-asm_unwind.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `may_unwind` option is unstable + --> $DIR/feature-gate-asm_unwind.rs:7:9 + | +LL | asm!("", options(may_unwind)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #93334 <https://github.com/rust-lang/rust/issues/93334> for more information + = help: add `#![feature(asm_unwind)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-assoc-type-defaults.rs b/tests/ui/feature-gates/feature-gate-assoc-type-defaults.rs new file mode 100644 index 000000000..d7c6a9f97 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-assoc-type-defaults.rs @@ -0,0 +1,7 @@ +// gate-test-associated_type_defaults + +trait Foo { + type Bar = u8; //~ ERROR associated type defaults are unstable +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-assoc-type-defaults.stderr b/tests/ui/feature-gates/feature-gate-assoc-type-defaults.stderr new file mode 100644 index 000000000..9edad6153 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-assoc-type-defaults.stderr @@ -0,0 +1,12 @@ +error[E0658]: associated type defaults are unstable + --> $DIR/feature-gate-assoc-type-defaults.rs:4:5 + | +LL | type Bar = u8; + | ^^^^^^^^^^^^^^ + | + = note: see issue #29661 <https://github.com/rust-lang/rust/issues/29661> for more information + = help: add `#![feature(associated_type_defaults)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-associated_const_equality.rs b/tests/ui/feature-gates/feature-gate-associated_const_equality.rs new file mode 100644 index 000000000..2534c527b --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-associated_const_equality.rs @@ -0,0 +1,15 @@ +pub trait TraitWAssocConst { + const A: usize; +} +pub struct Demo {} + +impl TraitWAssocConst for Demo { + const A: usize = 32; +} + +fn foo<A: TraitWAssocConst<A=32>>() {} +//~^ ERROR associated const equality + +fn main() { + foo::<Demo>(); +} diff --git a/tests/ui/feature-gates/feature-gate-associated_const_equality.stderr b/tests/ui/feature-gates/feature-gate-associated_const_equality.stderr new file mode 100644 index 000000000..6563fbcba --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-associated_const_equality.stderr @@ -0,0 +1,12 @@ +error[E0658]: associated const equality is incomplete + --> $DIR/feature-gate-associated_const_equality.rs:10:28 + | +LL | fn foo<A: TraitWAssocConst<A=32>>() {} + | ^^^^ + | + = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs b/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs new file mode 100644 index 000000000..4e0203274 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs @@ -0,0 +1,76 @@ +// compile-flags: -Zsave-analysis +// This is also a regression test for #69415 and the above flag is needed. + +use std::mem::ManuallyDrop; + +trait Tr1 { type As1: Copy; } +trait Tr2 { type As2: Copy; } + +struct S1; +#[derive(Copy, Clone)] +struct S2; +impl Tr1 for S1 { type As1 = S2; } + +trait _Tr3 { + type A: Iterator<Item: Copy>; + //~^ ERROR associated type bounds are unstable + //~| ERROR the trait bound `<<Self as _Tr3>::A as Iterator>::Item: Copy` is not satisfied + + type B: Iterator<Item: 'static>; + //~^ ERROR associated type bounds are unstable +} + +struct _St1<T: Tr1<As1: Tr2>> { +//~^ ERROR associated type bounds are unstable + outest: T, + outer: T::As1, + inner: <T::As1 as Tr2>::As2, +} + +enum _En1<T: Tr1<As1: Tr2>> { +//~^ ERROR associated type bounds are unstable + Outest(T), + Outer(T::As1), + Inner(<T::As1 as Tr2>::As2), +} + +union _Un1<T: Tr1<As1: Tr2>> { +//~^ ERROR associated type bounds are unstable + outest: ManuallyDrop<T>, + outer: ManuallyDrop<T::As1>, + inner: ManuallyDrop<<T::As1 as Tr2>::As2>, +} + +type _TaWhere1<T> where T: Iterator<Item: Copy> = T; +//~^ ERROR associated type bounds are unstable + +fn _apit(_: impl Tr1<As1: Copy>) {} +//~^ ERROR associated type bounds are unstable +fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {} +//~^ ERROR associated type bounds are unstable + +fn _rpit() -> impl Tr1<As1: Copy> { S1 } +//~^ ERROR associated type bounds are unstable + +fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) } +//~^ ERROR associated type bounds are unstable + +const _cdef: impl Tr1<As1: Copy> = S1; +//~^ ERROR associated type bounds are unstable +//~| ERROR `impl Trait` only allowed in function and inherent method return types +// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. +// const _cdef_dyn: &dyn Tr1<As1: Copy> = &S1; + +static _sdef: impl Tr1<As1: Copy> = S1; +//~^ ERROR associated type bounds are unstable +//~| ERROR `impl Trait` only allowed in function and inherent method return types +// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. +// static _sdef_dyn: &dyn Tr1<As1: Copy> = &S1; + +fn main() { + let _: impl Tr1<As1: Copy> = S1; + //~^ ERROR associated type bounds are unstable + //~| ERROR `impl Trait` only allowed in function and inherent method return types + // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. + // let _: &dyn Tr1<As1: Copy> = &S1; +} diff --git a/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr new file mode 100644 index 000000000..5be1d97a0 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -0,0 +1,150 @@ +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:15:22 + | +LL | type A: Iterator<Item: Copy>; + | ^^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:19:22 + | +LL | type B: Iterator<Item: 'static>; + | ^^^^^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:23:20 + | +LL | struct _St1<T: Tr1<As1: Tr2>> { + | ^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:30:18 + | +LL | enum _En1<T: Tr1<As1: Tr2>> { + | ^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:37:19 + | +LL | union _Un1<T: Tr1<As1: Tr2>> { + | ^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:44:37 + | +LL | type _TaWhere1<T> where T: Iterator<Item: Copy> = T; + | ^^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:47:22 + | +LL | fn _apit(_: impl Tr1<As1: Copy>) {} + | ^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:49:26 + | +LL | fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {} + | ^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:52:24 + | +LL | fn _rpit() -> impl Tr1<As1: Copy> { S1 } + | ^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:55:31 + | +LL | fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) } + | ^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:58:23 + | +LL | const _cdef: impl Tr1<As1: Copy> = S1; + | ^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:64:24 + | +LL | static _sdef: impl Tr1<As1: Copy> = S1; + | ^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/feature-gate-associated_type_bounds.rs:71:21 + | +LL | let _: impl Tr1<As1: Copy> = S1; + | ^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type + --> $DIR/feature-gate-associated_type_bounds.rs:58:14 + | +LL | const _cdef: impl Tr1<As1: Copy> = S1; + | ^^^^^^^^^^^^^^^^^^^ + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in type + --> $DIR/feature-gate-associated_type_bounds.rs:64:15 + | +LL | static _sdef: impl Tr1<As1: Copy> = S1; + | ^^^^^^^^^^^^^^^^^^^ + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding + --> $DIR/feature-gate-associated_type_bounds.rs:71:12 + | +LL | let _: impl Tr1<As1: Copy> = S1; + | ^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `<<Self as _Tr3>::A as Iterator>::Item: Copy` is not satisfied + --> $DIR/feature-gate-associated_type_bounds.rs:15:28 + | +LL | type A: Iterator<Item: Copy>; + | ^^^^ the trait `Copy` is not implemented for `<<Self as _Tr3>::A as Iterator>::Item` + | +help: consider further restricting the associated type + | +LL | trait _Tr3 where <<Self as _Tr3>::A as Iterator>::Item: Copy { + | +++++++++++++++++++++++++++++++++++++++++++++++++ + +error: aborting due to 17 previous errors + +Some errors have detailed explanations: E0277, E0562, E0658. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/feature-gates/feature-gate-auto-traits.rs b/tests/ui/feature-gates/feature-gate-auto-traits.rs new file mode 100644 index 000000000..80cfa9cee --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-auto-traits.rs @@ -0,0 +1,12 @@ +// Test that default and negative trait implementations are gated by +// `auto_traits` feature gate + +struct DummyStruct; + +auto trait AutoDummyTrait {} +//~^ ERROR auto traits are experimental and possibly buggy + +impl !AutoDummyTrait for DummyStruct {} +//~^ ERROR negative trait bounds are not yet fully implemented; use marker types for now + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-auto-traits.stderr b/tests/ui/feature-gates/feature-gate-auto-traits.stderr new file mode 100644 index 000000000..e01541816 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-auto-traits.stderr @@ -0,0 +1,21 @@ +error[E0658]: auto traits are experimental and possibly buggy + --> $DIR/feature-gate-auto-traits.rs:6:1 + | +LL | auto trait AutoDummyTrait {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information + = help: add `#![feature(auto_traits)]` to the crate attributes to enable + +error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now + --> $DIR/feature-gate-auto-traits.rs:9:6 + | +LL | impl !AutoDummyTrait for DummyStruct {} + | ^^^^^^^^^^^^^^^ + | + = note: see issue #68318 <https://github.com/rust-lang/rust/issues/68318> for more information + = help: add `#![feature(negative_impls)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-box-expr.rs b/tests/ui/feature-gates/feature-gate-box-expr.rs new file mode 100644 index 000000000..870253d2f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-box-expr.rs @@ -0,0 +1,14 @@ +// gate-test-box_syntax + +// Check that `box EXPR` is feature-gated. +// +// See also feature-gate-placement-expr.rs +// +// (Note that the two tests are separated since the checks appear to +// be performed at distinct phases, with an abort_if_errors call +// separating them.) + +fn main() { + let x = box 'c'; //~ ERROR box expression syntax is experimental + println!("x: {}", x); +} diff --git a/tests/ui/feature-gates/feature-gate-box-expr.stderr b/tests/ui/feature-gates/feature-gate-box-expr.stderr new file mode 100644 index 000000000..af864b25f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-box-expr.stderr @@ -0,0 +1,12 @@ +error[E0658]: box expression syntax is experimental; you can call `Box::new` instead + --> $DIR/feature-gate-box-expr.rs:12:13 + | +LL | let x = box 'c'; + | ^^^^^^^ + | + = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information + = help: add `#![feature(box_syntax)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-box_patterns.rs b/tests/ui/feature-gates/feature-gate-box_patterns.rs new file mode 100644 index 000000000..8bec16a97 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-box_patterns.rs @@ -0,0 +1,4 @@ +fn main() { + let box x = Box::new('c'); //~ ERROR box pattern syntax is experimental + println!("x: {}", x); +} diff --git a/tests/ui/feature-gates/feature-gate-box_patterns.stderr b/tests/ui/feature-gates/feature-gate-box_patterns.stderr new file mode 100644 index 000000000..601ec46a4 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-box_patterns.stderr @@ -0,0 +1,12 @@ +error[E0658]: box pattern syntax is experimental + --> $DIR/feature-gate-box_patterns.rs:2:9 + | +LL | let box x = Box::new('c'); + | ^^^^^ + | + = note: see issue #29641 <https://github.com/rust-lang/rust/issues/29641> for more information + = help: add `#![feature(box_patterns)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-box_syntax.rs b/tests/ui/feature-gates/feature-gate-box_syntax.rs new file mode 100644 index 000000000..778660cc0 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-box_syntax.rs @@ -0,0 +1,6 @@ +// Test that the use of the box syntax is gated by `box_syntax` feature gate. + +fn main() { + let x = box 3; + //~^ ERROR box expression syntax is experimental; you can call `Box::new` instead +} diff --git a/tests/ui/feature-gates/feature-gate-box_syntax.stderr b/tests/ui/feature-gates/feature-gate-box_syntax.stderr new file mode 100644 index 000000000..dcf8eeed7 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-box_syntax.stderr @@ -0,0 +1,12 @@ +error[E0658]: box expression syntax is experimental; you can call `Box::new` instead + --> $DIR/feature-gate-box_syntax.rs:4:13 + | +LL | let x = box 3; + | ^^^^^ + | + = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information + = help: add `#![feature(box_syntax)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-c_variadic.rs b/tests/ui/feature-gates/feature-gate-c_variadic.rs new file mode 100644 index 000000000..8b40c36c7 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-c_variadic.rs @@ -0,0 +1,4 @@ +#![crate_type="lib"] + +pub unsafe extern "C" fn test(_: i32, ap: ...) { } +//~^ C-variadic functions are unstable diff --git a/tests/ui/feature-gates/feature-gate-c_variadic.stderr b/tests/ui/feature-gates/feature-gate-c_variadic.stderr new file mode 100644 index 000000000..7b3af8d99 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-c_variadic.stderr @@ -0,0 +1,12 @@ +error[E0658]: C-variadic functions are unstable + --> $DIR/feature-gate-c_variadic.rs:3:1 + | +LL | pub unsafe extern "C" fn test(_: i32, ap: ...) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #44930 <https://github.com/rust-lang/rust/issues/44930> for more information + = help: add `#![feature(c_variadic)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-abi.rs b/tests/ui/feature-gates/feature-gate-cfg-target-abi.rs new file mode 100644 index 000000000..d005dc3ad --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-abi.rs @@ -0,0 +1,13 @@ +#[cfg(target_abi = "x")] //~ ERROR `cfg(target_abi)` is experimental +struct Foo(u64, u64); + +#[cfg_attr(target_abi = "x", x)] //~ ERROR `cfg(target_abi)` is experimental +struct Bar(u64, u64); + +#[cfg(not(any(all(target_abi = "x"))))] //~ ERROR `cfg(target_abi)` is experimental +fn foo() {} + +fn main() { + cfg!(target_abi = "x"); + //~^ ERROR `cfg(target_abi)` is experimental and subject to change +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-abi.stderr b/tests/ui/feature-gates/feature-gate-cfg-target-abi.stderr new file mode 100644 index 000000000..013705d48 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-abi.stderr @@ -0,0 +1,39 @@ +error[E0658]: `cfg(target_abi)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-abi.rs:1:7 + | +LL | #[cfg(target_abi = "x")] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #80970 <https://github.com/rust-lang/rust/issues/80970> for more information + = help: add `#![feature(cfg_target_abi)]` to the crate attributes to enable + +error[E0658]: `cfg(target_abi)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-abi.rs:4:12 + | +LL | #[cfg_attr(target_abi = "x", x)] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #80970 <https://github.com/rust-lang/rust/issues/80970> for more information + = help: add `#![feature(cfg_target_abi)]` to the crate attributes to enable + +error[E0658]: `cfg(target_abi)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-abi.rs:7:19 + | +LL | #[cfg(not(any(all(target_abi = "x"))))] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #80970 <https://github.com/rust-lang/rust/issues/80970> for more information + = help: add `#![feature(cfg_target_abi)]` to the crate attributes to enable + +error[E0658]: `cfg(target_abi)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-abi.rs:11:10 + | +LL | cfg!(target_abi = "x"); + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #80970 <https://github.com/rust-lang/rust/issues/80970> for more information + = help: add `#![feature(cfg_target_abi)]` to the crate attributes to enable + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-compact.rs b/tests/ui/feature-gates/feature-gate-cfg-target-compact.rs new file mode 100644 index 000000000..df81b7d22 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-compact.rs @@ -0,0 +1,13 @@ +#[cfg(target(os = "x"))] //~ ERROR compact `cfg(target(..))` is experimental +struct Foo(u64, u64); + +#[cfg_attr(target(os = "x"), x)] //~ ERROR compact `cfg(target(..))` is experimental +struct Bar(u64, u64); + +#[cfg(not(any(all(target(os = "x")))))] //~ ERROR compact `cfg(target(..))` is experimental +fn foo() {} + +fn main() { + cfg!(target(os = "x")); + //~^ ERROR compact `cfg(target(..))` is experimental and subject to change +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-compact.stderr b/tests/ui/feature-gates/feature-gate-cfg-target-compact.stderr new file mode 100644 index 000000000..be6fe23de --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-compact.stderr @@ -0,0 +1,39 @@ +error[E0658]: compact `cfg(target(..))` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-compact.rs:1:7 + | +LL | #[cfg(target(os = "x"))] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information + = help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable + +error[E0658]: compact `cfg(target(..))` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-compact.rs:4:12 + | +LL | #[cfg_attr(target(os = "x"), x)] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information + = help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable + +error[E0658]: compact `cfg(target(..))` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-compact.rs:7:19 + | +LL | #[cfg(not(any(all(target(os = "x")))))] + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information + = help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable + +error[E0658]: compact `cfg(target(..))` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-compact.rs:11:10 + | +LL | cfg!(target(os = "x")); + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information + = help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic-equal-alignment.rs b/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic-equal-alignment.rs new file mode 100644 index 000000000..3d692a070 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic-equal-alignment.rs @@ -0,0 +1,14 @@ +fn main() { + cfg!(target_has_atomic_equal_alignment = "8"); + //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + cfg!(target_has_atomic_equal_alignment = "16"); + //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + cfg!(target_has_atomic_equal_alignment = "32"); + //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + cfg!(target_has_atomic_equal_alignment = "64"); + //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + cfg!(target_has_atomic_equal_alignment = "128"); + //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + cfg!(target_has_atomic_equal_alignment = "ptr"); + //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic-equal-alignment.stderr b/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic-equal-alignment.stderr new file mode 100644 index 000000000..8ad3b034a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic-equal-alignment.stderr @@ -0,0 +1,57 @@ +error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic-equal-alignment.rs:2:10 + | +LL | cfg!(target_has_atomic_equal_alignment = "8"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #93822 <https://github.com/rust-lang/rust/issues/93822> for more information + = help: add `#![feature(cfg_target_has_atomic_equal_alignment)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic-equal-alignment.rs:4:10 + | +LL | cfg!(target_has_atomic_equal_alignment = "16"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #93822 <https://github.com/rust-lang/rust/issues/93822> for more information + = help: add `#![feature(cfg_target_has_atomic_equal_alignment)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic-equal-alignment.rs:6:10 + | +LL | cfg!(target_has_atomic_equal_alignment = "32"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #93822 <https://github.com/rust-lang/rust/issues/93822> for more information + = help: add `#![feature(cfg_target_has_atomic_equal_alignment)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic-equal-alignment.rs:8:10 + | +LL | cfg!(target_has_atomic_equal_alignment = "64"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #93822 <https://github.com/rust-lang/rust/issues/93822> for more information + = help: add `#![feature(cfg_target_has_atomic_equal_alignment)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic-equal-alignment.rs:10:10 + | +LL | cfg!(target_has_atomic_equal_alignment = "128"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #93822 <https://github.com/rust-lang/rust/issues/93822> for more information + = help: add `#![feature(cfg_target_has_atomic_equal_alignment)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic-equal-alignment.rs:12:10 + | +LL | cfg!(target_has_atomic_equal_alignment = "ptr"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #93822 <https://github.com/rust-lang/rust/issues/93822> for more information + = help: add `#![feature(cfg_target_has_atomic_equal_alignment)]` to the crate attributes to enable + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs b/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs new file mode 100644 index 000000000..df9c51cb1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs @@ -0,0 +1,14 @@ +fn main() { + cfg!(target_has_atomic_load_store = "8"); + //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change + cfg!(target_has_atomic_load_store = "16"); + //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change + cfg!(target_has_atomic_load_store = "32"); + //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change + cfg!(target_has_atomic_load_store = "64"); + //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change + cfg!(target_has_atomic_load_store = "128"); + //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change + cfg!(target_has_atomic_load_store = "ptr"); + //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr b/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr new file mode 100644 index 000000000..b9e6830a9 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr @@ -0,0 +1,57 @@ +error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic.rs:2:10 + | +LL | cfg!(target_has_atomic_load_store = "8"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #94039 <https://github.com/rust-lang/rust/issues/94039> for more information + = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic.rs:4:10 + | +LL | cfg!(target_has_atomic_load_store = "16"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #94039 <https://github.com/rust-lang/rust/issues/94039> for more information + = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic.rs:6:10 + | +LL | cfg!(target_has_atomic_load_store = "32"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #94039 <https://github.com/rust-lang/rust/issues/94039> for more information + = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic.rs:8:10 + | +LL | cfg!(target_has_atomic_load_store = "64"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #94039 <https://github.com/rust-lang/rust/issues/94039> for more information + = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic.rs:10:10 + | +LL | cfg!(target_has_atomic_load_store = "128"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #94039 <https://github.com/rust-lang/rust/issues/94039> for more information + = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable + +error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-atomic.rs:12:10 + | +LL | cfg!(target_has_atomic_load_store = "ptr"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #94039 <https://github.com/rust-lang/rust/issues/94039> for more information + = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs b/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs new file mode 100644 index 000000000..b600ad23e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs @@ -0,0 +1,16 @@ +// ignore-windows +// aux-build:cfg-target-thread-local.rs + +#![feature(thread_local)] + +extern crate cfg_target_thread_local; + +extern "C" { + #[cfg_attr(target_thread_local, thread_local)] + //~^ `cfg(target_thread_local)` is experimental and subject to change + static FOO: u32; +} + +fn main() { + assert_eq!(FOO, 3); +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.stderr b/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.stderr new file mode 100644 index 000000000..af59c7141 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.stderr @@ -0,0 +1,12 @@ +error[E0658]: `cfg(target_thread_local)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-thread-local.rs:9:16 + | +LL | #[cfg_attr(target_thread_local, thread_local)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #29594 <https://github.com/rust-lang/rust/issues/29594> for more information + = help: add `#![feature(cfg_target_thread_local)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg-version.rs b/tests/ui/feature-gates/feature-gate-cfg-version.rs new file mode 100644 index 000000000..e35784a68 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-version.rs @@ -0,0 +1,49 @@ +#[cfg(version(42))] //~ ERROR: expected a version literal +//~^ ERROR `cfg(version)` is experimental and subject to change +fn foo() {} +#[cfg(version(1.20))] //~ ERROR: expected a version literal +//~^ ERROR `cfg(version)` is experimental and subject to change +fn foo() -> bool { true } +#[cfg(version("1.44"))] +//~^ ERROR `cfg(version)` is experimental and subject to change +fn foo() -> bool { true } +#[cfg(not(version("1.44")))] +//~^ ERROR `cfg(version)` is experimental and subject to change +fn foo() -> bool { false } + +#[cfg(version("1.43", "1.44", "1.45"))] //~ ERROR: expected single version literal +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { false } +#[cfg(version(false))] //~ ERROR: expected a version literal +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { false } +#[cfg(version("foo"))] //~ WARNING: unknown version literal format +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { false } +#[cfg(version("999"))] //~ WARNING: unknown version literal format +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { false } +#[cfg(version("-1"))] //~ WARNING: unknown version literal format +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { false } +#[cfg(version("65536"))] //~ WARNING: unknown version literal format +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { false } +#[cfg(version("0"))] //~ WARNING: unknown version literal format +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { true } +#[cfg(version("1.0"))] +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { true } +#[cfg(version("1.65536.2"))] //~ WARNING: unknown version literal format +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() -> bool { false } +#[cfg(version("1.20.0-stable"))] //~ WARNING: unknown version literal format +//~^ ERROR `cfg(version)` is experimental and subject to change +fn bar() {} + +fn main() { + assert!(foo()); + assert!(bar()); + assert!(cfg!(version("1.42"))); //~ ERROR `cfg(version)` is experimental and subject to change +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-version.stderr b/tests/ui/feature-gates/feature-gate-cfg-version.stderr new file mode 100644 index 000000000..ae899d409 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-version.stderr @@ -0,0 +1,204 @@ +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:1:7 + | +LL | #[cfg(version(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: expected a version literal + --> $DIR/feature-gate-cfg-version.rs:1:15 + | +LL | #[cfg(version(42))] + | ^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:4:7 + | +LL | #[cfg(version(1.20))] + | ^^^^^^^^^^^^^ + | + = 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: expected a version literal + --> $DIR/feature-gate-cfg-version.rs:4:15 + | +LL | #[cfg(version(1.20))] + | ^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:7:7 + | +LL | #[cfg(version("1.44"))] + | ^^^^^^^^^^^^^^^ + | + = 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:10:11 + | +LL | #[cfg(not(version("1.44")))] + | ^^^^^^^^^^^^^^^ + | + = 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:14:7 + | +LL | #[cfg(version("1.43", "1.44", "1.45"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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: expected single version literal + --> $DIR/feature-gate-cfg-version.rs:14:7 + | +LL | #[cfg(version("1.43", "1.44", "1.45"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:17:7 + | +LL | #[cfg(version(false))] + | ^^^^^^^^^^^^^^ + | + = 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: expected a version literal + --> $DIR/feature-gate-cfg-version.rs:17:15 + | +LL | #[cfg(version(false))] + | ^^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:20:7 + | +LL | #[cfg(version("foo"))] + | ^^^^^^^^^^^^^^ + | + = 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 + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/feature-gate-cfg-version.rs:20:15 + | +LL | #[cfg(version("foo"))] + | ^^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:23:7 + | +LL | #[cfg(version("999"))] + | ^^^^^^^^^^^^^^ + | + = 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 + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/feature-gate-cfg-version.rs:23:15 + | +LL | #[cfg(version("999"))] + | ^^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:26: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 + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/feature-gate-cfg-version.rs:26:15 + | +LL | #[cfg(version("-1"))] + | ^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:29: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 + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/feature-gate-cfg-version.rs:29:15 + | +LL | #[cfg(version("65536"))] + | ^^^^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:32:7 + | +LL | #[cfg(version("0"))] + | ^^^^^^^^^^^^ + | + = 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 + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/feature-gate-cfg-version.rs:32:15 + | +LL | #[cfg(version("0"))] + | ^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:35:7 + | +LL | #[cfg(version("1.0"))] + | ^^^^^^^^^^^^^^ + | + = 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:38: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 + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/feature-gate-cfg-version.rs:38:15 + | +LL | #[cfg(version("1.65536.2"))] + | ^^^^^^^^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:41:7 + | +LL | #[cfg(version("1.20.0-stable"))] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 + +warning: unknown version literal format, assuming it refers to a future version + --> $DIR/feature-gate-cfg-version.rs:41:15 + | +LL | #[cfg(version("1.20.0-stable"))] + | ^^^^^^^^^^^^^^^ + +error[E0658]: `cfg(version)` is experimental and subject to change + --> $DIR/feature-gate-cfg-version.rs:48:18 + | +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 19 previous errors; 7 warnings emitted + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-cfg_sanitize.rs b/tests/ui/feature-gates/feature-gate-cfg_sanitize.rs new file mode 100644 index 000000000..c3e7cc9ed --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg_sanitize.rs @@ -0,0 +1,3 @@ +#[cfg(not(sanitize = "thread"))] +//~^ `cfg(sanitize)` is experimental +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-cfg_sanitize.stderr b/tests/ui/feature-gates/feature-gate-cfg_sanitize.stderr new file mode 100644 index 000000000..8088585da --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg_sanitize.stderr @@ -0,0 +1,12 @@ +error[E0658]: `cfg(sanitize)` is experimental and subject to change + --> $DIR/feature-gate-cfg_sanitize.rs:1:11 + | +LL | #[cfg(not(sanitize = "thread"))] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #39699 <https://github.com/rust-lang/rust/issues/39699> for more information + = help: add `#![feature(cfg_sanitize)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-check-cfg.rs b/tests/ui/feature-gates/feature-gate-check-cfg.rs new file mode 100644 index 000000000..4012a3b04 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-check-cfg.rs @@ -0,0 +1,3 @@ +// compile-flags: --check-cfg "names()" + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-check-cfg.stderr b/tests/ui/feature-gates/feature-gate-check-cfg.stderr new file mode 100644 index 000000000..9b27c2bc0 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-check-cfg.stderr @@ -0,0 +1,2 @@ +error: the `-Z unstable-options` flag must also be passed to enable the flag `check-cfg` + diff --git a/tests/ui/feature-gates/feature-gate-closure_lifetime_binder.rs b/tests/ui/feature-gates/feature-gate-closure_lifetime_binder.rs new file mode 100644 index 000000000..b0b494fa3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-closure_lifetime_binder.rs @@ -0,0 +1,8 @@ +fn main() { + for<> || -> () {}; + //~^ ERROR `for<...>` binders for closures are experimental + for<'a> || -> () {}; + //~^ ERROR `for<...>` binders for closures are experimental + for<'a, 'b> |_: &'a ()| -> () {}; + //~^ ERROR `for<...>` binders for closures are experimental +} diff --git a/tests/ui/feature-gates/feature-gate-closure_lifetime_binder.stderr b/tests/ui/feature-gates/feature-gate-closure_lifetime_binder.stderr new file mode 100644 index 000000000..aea5cfeed --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-closure_lifetime_binder.stderr @@ -0,0 +1,33 @@ +error[E0658]: `for<...>` binders for closures are experimental + --> $DIR/feature-gate-closure_lifetime_binder.rs:2:5 + | +LL | for<> || -> () {}; + | ^^^^^ + | + = note: see issue #97362 <https://github.com/rust-lang/rust/issues/97362> for more information + = help: add `#![feature(closure_lifetime_binder)]` to the crate attributes to enable + = help: consider removing `for<...>` + +error[E0658]: `for<...>` binders for closures are experimental + --> $DIR/feature-gate-closure_lifetime_binder.rs:4:5 + | +LL | for<'a> || -> () {}; + | ^^^^^^^ + | + = note: see issue #97362 <https://github.com/rust-lang/rust/issues/97362> for more information + = help: add `#![feature(closure_lifetime_binder)]` to the crate attributes to enable + = help: consider removing `for<...>` + +error[E0658]: `for<...>` binders for closures are experimental + --> $DIR/feature-gate-closure_lifetime_binder.rs:6:5 + | +LL | for<'a, 'b> |_: &'a ()| -> () {}; + | ^^^^^^^^^^^ + | + = note: see issue #97362 <https://github.com/rust-lang/rust/issues/97362> for more information + = help: add `#![feature(closure_lifetime_binder)]` to the crate attributes to enable + = help: consider removing `for<...>` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-closure_track_caller.rs b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs new file mode 100644 index 000000000..a8d63a814 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs @@ -0,0 +1,7 @@ +#![feature(stmt_expr_attributes)] +#![feature(generators)] + +fn main() { + let _closure = #[track_caller] || {}; //~ `#[track_caller]` on closures + let _generator = #[track_caller] || { yield; }; //~ `#[track_caller]` on closures +} diff --git a/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr new file mode 100644 index 000000000..ed63d74fe --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr @@ -0,0 +1,21 @@ +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/feature-gate-closure_track_caller.rs:5:20 + | +LL | let _closure = #[track_caller] || {}; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/feature-gate-closure_track_caller.rs:6:22 + | +LL | let _generator = #[track_caller] || { yield; }; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-collapse_debuginfo.rs b/tests/ui/feature-gates/feature-gate-collapse_debuginfo.rs new file mode 100644 index 000000000..f73bf579f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-collapse_debuginfo.rs @@ -0,0 +1,7 @@ +#[collapse_debuginfo] +//~^ ERROR the `#[collapse_debuginfo]` attribute is an experimental feature +macro_rules! foo { + ($e:expr) => { $e } +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-collapse_debuginfo.stderr b/tests/ui/feature-gates/feature-gate-collapse_debuginfo.stderr new file mode 100644 index 000000000..2cbde893a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-collapse_debuginfo.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[collapse_debuginfo]` attribute is an experimental feature + --> $DIR/feature-gate-collapse_debuginfo.rs:1:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #100758 <https://github.com/rust-lang/rust/issues/100758> for more information + = help: add `#![feature(collapse_debuginfo)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-compiler-builtins.rs b/tests/ui/feature-gates/feature-gate-compiler-builtins.rs new file mode 100644 index 000000000..0d64f1fdc --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-compiler-builtins.rs @@ -0,0 +1,3 @@ +#![compiler_builtins] //~ ERROR the `#[compiler_builtins]` attribute is + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-compiler-builtins.stderr b/tests/ui/feature-gates/feature-gate-compiler-builtins.stderr new file mode 100644 index 000000000..9d04aef86 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-compiler-builtins.stderr @@ -0,0 +1,11 @@ +error[E0658]: the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate which contains compiler-rt intrinsics and will never be stable + --> $DIR/feature-gate-compiler-builtins.rs:1:1 + | +LL | #![compiler_builtins] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(compiler_builtins)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-concat_bytes.rs b/tests/ui/feature-gates/feature-gate-concat_bytes.rs new file mode 100644 index 000000000..07d63cb11 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-concat_bytes.rs @@ -0,0 +1,4 @@ +fn main() { + let a = concat_bytes!(b'A', b"BC"); //~ ERROR use of unstable library feature 'concat_bytes' + assert_eq!(a, &[65, 66, 67]); +} diff --git a/tests/ui/feature-gates/feature-gate-concat_bytes.stderr b/tests/ui/feature-gates/feature-gate-concat_bytes.stderr new file mode 100644 index 000000000..4b3ee4c19 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-concat_bytes.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature 'concat_bytes' + --> $DIR/feature-gate-concat_bytes.rs:2:13 + | +LL | let a = concat_bytes!(b'A', b"BC"); + | ^^^^^^^^^^^^ + | + = note: see issue #87555 <https://github.com/rust-lang/rust/issues/87555> for more information + = help: add `#![feature(concat_bytes)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-concat_idents.rs b/tests/ui/feature-gates/feature-gate-concat_idents.rs new file mode 100644 index 000000000..68caf3d71 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-concat_idents.rs @@ -0,0 +1,9 @@ +const XY_1: i32 = 10; + +fn main() { + const XY_2: i32 = 20; + let a = concat_idents!(X, Y_1); //~ ERROR `concat_idents` is not stable + let b = concat_idents!(X, Y_2); //~ ERROR `concat_idents` is not stable + assert_eq!(a, 10); + assert_eq!(b, 20); +} diff --git a/tests/ui/feature-gates/feature-gate-concat_idents.stderr b/tests/ui/feature-gates/feature-gate-concat_idents.stderr new file mode 100644 index 000000000..0454fd494 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-concat_idents.stderr @@ -0,0 +1,21 @@ +error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change + --> $DIR/feature-gate-concat_idents.rs:5:13 + | +LL | let a = concat_idents!(X, Y_1); + | ^^^^^^^^^^^^^ + | + = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information + = help: add `#![feature(concat_idents)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change + --> $DIR/feature-gate-concat_idents.rs:6:13 + | +LL | let b = concat_idents!(X, Y_2); + | ^^^^^^^^^^^^^ + | + = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information + = help: add `#![feature(concat_idents)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.rs b/tests/ui/feature-gates/feature-gate-concat_idents2.rs new file mode 100644 index 000000000..9660ffeaf --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-concat_idents2.rs @@ -0,0 +1,4 @@ +fn main() { + concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough + //~| ERROR cannot find value `ab` in this scope +} diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.stderr b/tests/ui/feature-gates/feature-gate-concat_idents2.stderr new file mode 100644 index 000000000..8663bc7ca --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-concat_idents2.stderr @@ -0,0 +1,21 @@ +error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change + --> $DIR/feature-gate-concat_idents2.rs:2:5 + | +LL | concat_idents!(a, b); + | ^^^^^^^^^^^^^ + | + = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information + = help: add `#![feature(concat_idents)]` to the crate attributes to enable + +error[E0425]: cannot find value `ab` in this scope + --> $DIR/feature-gate-concat_idents2.rs:2:5 + | +LL | concat_idents!(a, b); + | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + | + = note: this error originates in the macro `concat_idents` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0425, E0658. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/feature-gates/feature-gate-concat_idents3.rs b/tests/ui/feature-gates/feature-gate-concat_idents3.rs new file mode 100644 index 000000000..81710fd9f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-concat_idents3.rs @@ -0,0 +1,7 @@ +const XY_1: i32 = 10; + +fn main() { + const XY_2: i32 = 20; + assert_eq!(10, concat_idents!(X, Y_1)); //~ ERROR `concat_idents` is not stable + assert_eq!(20, concat_idents!(X, Y_2)); //~ ERROR `concat_idents` is not stable +} diff --git a/tests/ui/feature-gates/feature-gate-concat_idents3.stderr b/tests/ui/feature-gates/feature-gate-concat_idents3.stderr new file mode 100644 index 000000000..1316107a3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-concat_idents3.stderr @@ -0,0 +1,21 @@ +error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change + --> $DIR/feature-gate-concat_idents3.rs:5:20 + | +LL | assert_eq!(10, concat_idents!(X, Y_1)); + | ^^^^^^^^^^^^^ + | + = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information + = help: add `#![feature(concat_idents)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change + --> $DIR/feature-gate-concat_idents3.rs:6:20 + | +LL | assert_eq!(20, concat_idents!(X, Y_2)); + | ^^^^^^^^^^^^^ + | + = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information + = help: add `#![feature(concat_idents)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-const-indexing.rs b/tests/ui/feature-gates/feature-gate-const-indexing.rs new file mode 100644 index 000000000..2b1067b34 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-const-indexing.rs @@ -0,0 +1,8 @@ +// build-pass (FIXME(62277): could be check-pass?) + +fn main() { + const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47]; + const IDX: usize = 3; + const VAL: i32 = ARR[IDX]; + const BLUB: [i32; (ARR[0] - 41) as usize] = [5]; +} diff --git a/tests/ui/feature-gates/feature-gate-const_refs_to_cell.rs b/tests/ui/feature-gates/feature-gate-const_refs_to_cell.rs new file mode 100644 index 000000000..63159ed05 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-const_refs_to_cell.rs @@ -0,0 +1,12 @@ +// check-pass + +#![feature(const_refs_to_cell)] + +const FOO: () = { + let x = std::cell::Cell::new(42); + let y = &x; +}; + +fn main() { + FOO; +} diff --git a/tests/ui/feature-gates/feature-gate-custom_attribute.rs b/tests/ui/feature-gates/feature-gate-custom_attribute.rs new file mode 100644 index 000000000..936cab268 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-custom_attribute.rs @@ -0,0 +1,18 @@ +// Check that literals in attributes parse just fine. + +#[fake_attr] //~ ERROR cannot find attribute `fake_attr` in this scope +#[fake_attr(100)] //~ ERROR cannot find attribute `fake_attr` in this scope +#[fake_attr(1, 2, 3)] //~ ERROR cannot find attribute `fake_attr` in this scope +#[fake_attr("hello")] //~ ERROR cannot find attribute `fake_attr` in this scope +#[fake_attr(name = "hello")] //~ ERROR cannot find attribute `fake_attr` in this scope +#[fake_attr(1, "hi", key = 12, true, false)] //~ ERROR cannot find attribute `fake_attr` in th +#[fake_attr(key = "hello", val = 10)] //~ ERROR cannot find attribute `fake_attr` in this scop +#[fake_attr(key("hello"), val(10))] //~ ERROR cannot find attribute `fake_attr` in this scope +#[fake_attr(enabled = true, disabled = false)] //~ ERROR cannot find attribute `fake_attr` in +#[fake_attr(true)] //~ ERROR cannot find attribute `fake_attr` in this scope +#[fake_attr(pi = 3.14159)] //~ ERROR cannot find attribute `fake_attr` in this scope +#[fake_attr(b"hi")] //~ ERROR cannot find attribute `fake_attr` in this scope +#[fake_doc(r"doc")] //~ ERROR cannot find attribute `fake_doc` in this scope +struct Q {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-custom_attribute.stderr b/tests/ui/feature-gates/feature-gate-custom_attribute.stderr new file mode 100644 index 000000000..b7c45ec1f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-custom_attribute.stderr @@ -0,0 +1,80 @@ +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:3:3 + | +LL | #[fake_attr] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:4:3 + | +LL | #[fake_attr(100)] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:5:3 + | +LL | #[fake_attr(1, 2, 3)] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:6:3 + | +LL | #[fake_attr("hello")] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:7:3 + | +LL | #[fake_attr(name = "hello")] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:8:3 + | +LL | #[fake_attr(1, "hi", key = 12, true, false)] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:9:3 + | +LL | #[fake_attr(key = "hello", val = 10)] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:10:3 + | +LL | #[fake_attr(key("hello"), val(10))] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:11:3 + | +LL | #[fake_attr(enabled = true, disabled = false)] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:12:3 + | +LL | #[fake_attr(true)] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:13:3 + | +LL | #[fake_attr(pi = 3.14159)] + | ^^^^^^^^^ + +error: cannot find attribute `fake_attr` in this scope + --> $DIR/feature-gate-custom_attribute.rs:14:3 + | +LL | #[fake_attr(b"hi")] + | ^^^^^^^^^ + +error: cannot find attribute `fake_doc` in this scope + --> $DIR/feature-gate-custom_attribute.rs:15:3 + | +LL | #[fake_doc(r"doc")] + | ^^^^^^^^ + +error: aborting due to 13 previous errors + diff --git a/tests/ui/feature-gates/feature-gate-custom_attribute2.rs b/tests/ui/feature-gates/feature-gate-custom_attribute2.rs new file mode 100644 index 000000000..724e53deb --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-custom_attribute2.rs @@ -0,0 +1,58 @@ +// This test ensures that attributes on formals in generic parameter +// lists are included when we are checking for unstable attributes. + +struct StLt<#[lt_struct] 'a>(&'a u32); +//~^ ERROR cannot find attribute `lt_struct` in this scope +struct StTy<#[ty_struct] I>(I); +//~^ ERROR cannot find attribute `ty_struct` in this scope + +enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } +//~^ ERROR cannot find attribute `lt_enum` in this scope +enum EnTy<#[ty_enum] J> { A(J), B } +//~^ ERROR cannot find attribute `ty_enum` in this scope + +trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } +//~^ ERROR cannot find attribute `lt_trait` in this scope +trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } +//~^ ERROR cannot find attribute `ty_trait` in this scope + +type TyLt<#[lt_type] 'd> = &'d u32; +//~^ ERROR cannot find attribute `lt_type` in this scope +type TyTy<#[ty_type] L> = (L, ); +//~^ ERROR cannot find attribute `ty_type` in this scope + +impl<#[lt_inherent] 'e> StLt<'e> { } +//~^ ERROR cannot find attribute `lt_inherent` in this scope +impl<#[ty_inherent] M> StTy<M> { } +//~^ ERROR cannot find attribute `ty_inherent` in this scope + +impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { + //~^ ERROR cannot find attribute `lt_impl_for` in this scope + fn foo(&self, _: &'f [u32]) -> &'f u32 { loop { } } +} +impl<#[ty_impl_for] N> TrTy<N> for StTy<N> { + //~^ ERROR cannot find attribute `ty_impl_for` in this scope + fn foo(&self, _: N) { } +} + +fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } +//~^ ERROR cannot find attribute `lt_fn` in this scope +fn f_ty<#[ty_fn] O>(_: O) { } +//~^ ERROR cannot find attribute `ty_fn` in this scope + +impl<I> StTy<I> { + fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } + //~^ ERROR cannot find attribute `lt_meth` in this scope + fn m_ty<#[ty_meth] P>(_: P) { } + //~^ ERROR cannot find attribute `ty_meth` in this scope +} + +fn hof_lt<Q>(_: Q) + where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 + //~^ ERROR cannot find attribute `lt_hof` in this scope +{ +} + +fn main() { + +} diff --git a/tests/ui/feature-gates/feature-gate-custom_attribute2.stderr b/tests/ui/feature-gates/feature-gate-custom_attribute2.stderr new file mode 100644 index 000000000..f22871117 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-custom_attribute2.stderr @@ -0,0 +1,104 @@ +error: cannot find attribute `lt_struct` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:4:15 + | +LL | struct StLt<#[lt_struct] 'a>(&'a u32); + | ^^^^^^^^^ + +error: cannot find attribute `ty_struct` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:6:15 + | +LL | struct StTy<#[ty_struct] I>(I); + | ^^^^^^^^^ + +error: cannot find attribute `lt_enum` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:9:13 + | +LL | enum EnLt<#[lt_enum] 'b> { A(&'b u32), B } + | ^^^^^^^ + +error: cannot find attribute `ty_enum` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:11:13 + | +LL | enum EnTy<#[ty_enum] J> { A(J), B } + | ^^^^^^^ + +error: cannot find attribute `lt_trait` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:14:14 + | +LL | trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; } + | ^^^^^^^^ + +error: cannot find attribute `ty_trait` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:16:14 + | +LL | trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); } + | ^^^^^^^^ + +error: cannot find attribute `lt_type` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:19:13 + | +LL | type TyLt<#[lt_type] 'd> = &'d u32; + | ^^^^^^^ + +error: cannot find attribute `ty_type` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:21:13 + | +LL | type TyTy<#[ty_type] L> = (L, ); + | ^^^^^^^ + +error: cannot find attribute `lt_inherent` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:24:8 + | +LL | impl<#[lt_inherent] 'e> StLt<'e> { } + | ^^^^^^^^^^^ + +error: cannot find attribute `ty_inherent` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:26:8 + | +LL | impl<#[ty_inherent] M> StTy<M> { } + | ^^^^^^^^^^^ + +error: cannot find attribute `lt_impl_for` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:29:8 + | +LL | impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> { + | ^^^^^^^^^^^ + +error: cannot find attribute `ty_impl_for` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:33:8 + | +LL | impl<#[ty_impl_for] N> TrTy<N> for StTy<N> { + | ^^^^^^^^^^^ + +error: cannot find attribute `lt_fn` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:38:11 + | +LL | fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } } + | ^^^^^ + +error: cannot find attribute `ty_fn` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:40:11 + | +LL | fn f_ty<#[ty_fn] O>(_: O) { } + | ^^^^^ + +error: cannot find attribute `lt_meth` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:44:15 + | +LL | fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } } + | ^^^^^^^ + +error: cannot find attribute `ty_meth` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:46:15 + | +LL | fn m_ty<#[ty_meth] P>(_: P) { } + | ^^^^^^^ + +error: cannot find attribute `lt_hof` in this scope + --> $DIR/feature-gate-custom_attribute2.rs:51:21 + | +LL | where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32 + | ^^^^^^ + +error: aborting due to 17 previous errors + diff --git a/tests/ui/feature-gates/feature-gate-custom_mir.rs b/tests/ui/feature-gates/feature-gate-custom_mir.rs new file mode 100644 index 000000000..0126dde2f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-custom_mir.rs @@ -0,0 +1,12 @@ +#![feature(core_intrinsics)] + +extern crate core; + +#[custom_mir(dialect = "built")] //~ ERROR the `#[custom_mir]` attribute is just used for the Rust test suite +pub fn foo(_x: i32) -> i32 { + 0 +} + +fn main() { + assert_eq!(2, foo(2)); +} diff --git a/tests/ui/feature-gates/feature-gate-custom_mir.stderr b/tests/ui/feature-gates/feature-gate-custom_mir.stderr new file mode 100644 index 000000000..3c149d30d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-custom_mir.stderr @@ -0,0 +1,11 @@ +error[E0658]: the `#[custom_mir]` attribute is just used for the Rust test suite + --> $DIR/feature-gate-custom_mir.rs:5:1 + | +LL | #[custom_mir(dialect = "built")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(custom_mir)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-custom_test_frameworks.rs b/tests/ui/feature-gates/feature-gate-custom_test_frameworks.rs new file mode 100644 index 000000000..83bb153ba --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-custom_test_frameworks.rs @@ -0,0 +1,6 @@ +#![test_runner(main)] //~ ERROR custom test frameworks are an unstable feature + +#[test_case] //~ ERROR custom test frameworks are an unstable feature +fn f() {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-custom_test_frameworks.stderr b/tests/ui/feature-gates/feature-gate-custom_test_frameworks.stderr new file mode 100644 index 000000000..b65b009a3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-custom_test_frameworks.stderr @@ -0,0 +1,21 @@ +error[E0658]: use of unstable library feature 'custom_test_frameworks': custom test frameworks are an unstable feature + --> $DIR/feature-gate-custom_test_frameworks.rs:3:3 + | +LL | #[test_case] + | ^^^^^^^^^ + | + = note: see issue #50297 <https://github.com/rust-lang/rust/issues/50297> for more information + = help: add `#![feature(custom_test_frameworks)]` to the crate attributes to enable + +error[E0658]: custom test frameworks are an unstable feature + --> $DIR/feature-gate-custom_test_frameworks.rs:1:1 + | +LL | #![test_runner(main)] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #50297 <https://github.com/rust-lang/rust/issues/50297> for more information + = help: add `#![feature(custom_test_frameworks)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-debugger-visualizer.rs b/tests/ui/feature-gates/feature-gate-debugger-visualizer.rs new file mode 100644 index 000000000..4c4dc450d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-debugger-visualizer.rs @@ -0,0 +1,3 @@ +#![debugger_visualizer(natvis_file = "auxiliary/debugger-visualizer.natvis")] //~ ERROR the `#[debugger_visualizer]` attribute is an experimental feature + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-debugger-visualizer.stderr b/tests/ui/feature-gates/feature-gate-debugger-visualizer.stderr new file mode 100644 index 000000000..e9367fbc6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-debugger-visualizer.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[debugger_visualizer]` attribute is an experimental feature + --> $DIR/feature-gate-debugger-visualizer.rs:1:1 + | +LL | #![debugger_visualizer(natvis_file = "auxiliary/debugger-visualizer.natvis")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #95939 <https://github.com/rust-lang/rust/issues/95939> for more information + = help: add `#![feature(debugger_visualizer)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-decl_macro.rs b/tests/ui/feature-gates/feature-gate-decl_macro.rs new file mode 100644 index 000000000..d002c5dbb --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-decl_macro.rs @@ -0,0 +1,5 @@ +#![allow(unused_macros)] + +macro m() {} //~ ERROR `macro` is experimental + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-decl_macro.stderr b/tests/ui/feature-gates/feature-gate-decl_macro.stderr new file mode 100644 index 000000000..800caf252 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-decl_macro.stderr @@ -0,0 +1,12 @@ +error[E0658]: `macro` is experimental + --> $DIR/feature-gate-decl_macro.rs:3:1 + | +LL | macro m() {} + | ^^^^^^^^^^^^ + | + = note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information + = help: add `#![feature(decl_macro)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs b/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs new file mode 100644 index 000000000..33038e24b --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.rs @@ -0,0 +1,12 @@ +#![allow(unused)] + +fn avg<T=i32>(_: T) {} +//~^ ERROR defaults for type parameters are only allowed +//~| WARN this was previously accepted + +struct S<T>(T); +impl<T=i32> S<T> {} +//~^ ERROR defaults for type parameters are only allowed +//~| WARN this was previously accepted + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr b/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr new file mode 100644 index 000000000..308de2692 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-default_type_parameter_fallback.stderr @@ -0,0 +1,21 @@ +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/feature-gate-default_type_parameter_fallback.rs:3:8 + | +LL | fn avg<T=i32>(_: T) {} + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + +error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + --> $DIR/feature-gate-default_type_parameter_fallback.rs:8:6 + | +LL | impl<T=i32> S<T> {} + | ^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> + +error: aborting due to 2 previous errors + diff --git a/tests/ui/feature-gates/feature-gate-deprecated_safe.rs b/tests/ui/feature-gates/feature-gate-deprecated_safe.rs new file mode 100644 index 000000000..d5f4a4705 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-deprecated_safe.rs @@ -0,0 +1,7 @@ +#[deprecated_safe(since = "TBD", note = "...")] //~ ERROR: the `#[deprecated_safe]` attribute is an experimental feature +unsafe fn deprecated_safe_fn() {} + +#[deprecated_safe(since = "TBD", note = "...")] //~ ERROR: the `#[deprecated_safe]` attribute is an experimental feature +unsafe trait DeprecatedSafeTrait {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-deprecated_safe.stderr b/tests/ui/feature-gates/feature-gate-deprecated_safe.stderr new file mode 100644 index 000000000..5e98a1faa --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-deprecated_safe.stderr @@ -0,0 +1,21 @@ +error[E0658]: the `#[deprecated_safe]` attribute is an experimental feature + --> $DIR/feature-gate-deprecated_safe.rs:1:1 + | +LL | #[deprecated_safe(since = "TBD", note = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #94978 <https://github.com/rust-lang/rust/issues/94978> for more information + = help: add `#![feature(deprecated_safe)]` to the crate attributes to enable + +error[E0658]: the `#[deprecated_safe]` attribute is an experimental feature + --> $DIR/feature-gate-deprecated_safe.rs:4:1 + | +LL | #[deprecated_safe(since = "TBD", note = "...")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #94978 <https://github.com/rust-lang/rust/issues/94978> for more information + = help: add `#![feature(deprecated_safe)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-doc_cfg.rs b/tests/ui/feature-gates/feature-gate-doc_cfg.rs new file mode 100644 index 000000000..b12b8a105 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-doc_cfg.rs @@ -0,0 +1,2 @@ +#[doc(cfg(unix))] //~ ERROR: `#[doc(cfg)]` is experimental +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-doc_cfg.stderr b/tests/ui/feature-gates/feature-gate-doc_cfg.stderr new file mode 100644 index 000000000..fe88e08c1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-doc_cfg.stderr @@ -0,0 +1,12 @@ +error[E0658]: `#[doc(cfg)]` is experimental + --> $DIR/feature-gate-doc_cfg.rs:1:1 + | +LL | #[doc(cfg(unix))] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #43781 <https://github.com/rust-lang/rust/issues/43781> for more information + = help: add `#![feature(doc_cfg)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-doc_masked.rs b/tests/ui/feature-gates/feature-gate-doc_masked.rs new file mode 100644 index 000000000..bde3af6b5 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-doc_masked.rs @@ -0,0 +1,4 @@ +#[doc(masked)] //~ ERROR: `#[doc(masked)]` is experimental +extern crate std as realstd; + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-doc_masked.stderr b/tests/ui/feature-gates/feature-gate-doc_masked.stderr new file mode 100644 index 000000000..80522b6ee --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-doc_masked.stderr @@ -0,0 +1,12 @@ +error[E0658]: `#[doc(masked)]` is experimental + --> $DIR/feature-gate-doc_masked.rs:1:1 + | +LL | #[doc(masked)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #44027 <https://github.com/rust-lang/rust/issues/44027> for more information + = help: add `#![feature(doc_masked)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-doc_notable_trait.rs b/tests/ui/feature-gates/feature-gate-doc_notable_trait.rs new file mode 100644 index 000000000..7f3392ead --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-doc_notable_trait.rs @@ -0,0 +1,4 @@ +#[doc(notable_trait)] //~ ERROR: `#[doc(notable_trait)]` is experimental +trait SomeTrait {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-doc_notable_trait.stderr b/tests/ui/feature-gates/feature-gate-doc_notable_trait.stderr new file mode 100644 index 000000000..1f9bef40c --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-doc_notable_trait.stderr @@ -0,0 +1,12 @@ +error[E0658]: `#[doc(notable_trait)]` is experimental + --> $DIR/feature-gate-doc_notable_trait.rs:1:1 + | +LL | #[doc(notable_trait)] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #45040 <https://github.com/rust-lang/rust/issues/45040> for more information + = help: add `#![feature(doc_notable_trait)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.rs b/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.rs new file mode 100644 index 000000000..ded08b93f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.rs @@ -0,0 +1,6 @@ +pub fn main() { + match 22 { + 0 .. 3 => {} //~ ERROR exclusive range pattern syntax is experimental + _ => {} + } +} diff --git a/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.stderr b/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.stderr new file mode 100644 index 000000000..6d7f4844a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-exclusive-range-pattern.stderr @@ -0,0 +1,12 @@ +error[E0658]: exclusive range pattern syntax is experimental + --> $DIR/feature-gate-exclusive-range-pattern.rs:3:9 + | +LL | 0 .. 3 => {} + | ^^^^^^ + | + = note: see issue #37854 <https://github.com/rust-lang/rust/issues/37854> for more information + = help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-exhaustive-patterns.rs b/tests/ui/feature-gates/feature-gate-exhaustive-patterns.rs new file mode 100644 index 000000000..f0cc9ea70 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-exhaustive-patterns.rs @@ -0,0 +1,9 @@ +#![feature(never_type)] + +fn foo() -> Result<u32, !> { + Ok(123) +} + +fn main() { + let Ok(_x) = foo(); //~ ERROR refutable pattern in local binding +} diff --git a/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr b/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr new file mode 100644 index 000000000..49e7ab608 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr @@ -0,0 +1,17 @@ +error[E0005]: refutable pattern in local binding + --> $DIR/feature-gate-exhaustive-patterns.rs:8:9 + | +LL | let Ok(_x) = foo(); + | ^^^^^^ pattern `Err(_)` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `Result<u32, !>` +help: you might want to use `let else` to handle the variant that isn't matched + | +LL | let Ok(_x) = foo() else { todo!() }; + | ++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/feature-gates/feature-gate-extern_absolute_paths.rs b/tests/ui/feature-gates/feature-gate-extern_absolute_paths.rs new file mode 100644 index 000000000..cff273ce2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-extern_absolute_paths.rs @@ -0,0 +1,5 @@ +use core::default; //~ ERROR unresolved import `core` + +fn main() { + let _: u8 = ::core::default::Default(); //~ ERROR failed to resolve +} diff --git a/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr b/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr new file mode 100644 index 000000000..3bae23a4a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-extern_absolute_paths.stderr @@ -0,0 +1,20 @@ +error[E0432]: unresolved import `core` + --> $DIR/feature-gate-extern_absolute_paths.rs:1:5 + | +LL | use core::default; + | ^^^^ maybe a missing crate `core`? + | + = help: consider adding `extern crate core` to use the `core` crate + +error[E0433]: failed to resolve: maybe a missing crate `core`? + --> $DIR/feature-gate-extern_absolute_paths.rs:4:19 + | +LL | let _: u8 = ::core::default::Default(); + | ^^^^ maybe a missing crate `core`? + | + = help: consider adding `extern crate core` to use the `core` crate + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0432, E0433. +For more information about an error, try `rustc --explain E0432`. diff --git a/tests/ui/feature-gates/feature-gate-extern_prelude.rs b/tests/ui/feature-gates/feature-gate-extern_prelude.rs new file mode 100644 index 000000000..237099e79 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-extern_prelude.rs @@ -0,0 +1 @@ +can-only-test-this-in-run-make-fulldeps //~ ERROR expected one of `!` or `::`, found `-` diff --git a/tests/ui/feature-gates/feature-gate-extern_prelude.stderr b/tests/ui/feature-gates/feature-gate-extern_prelude.stderr new file mode 100644 index 000000000..d72e47e9e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-extern_prelude.stderr @@ -0,0 +1,8 @@ +error: expected one of `!` or `::`, found `-` + --> $DIR/feature-gate-extern_prelude.rs:1:4 + | +LL | can-only-test-this-in-run-make-fulldeps + | ^ expected one of `!` or `::` + +error: aborting due to previous error + diff --git a/tests/ui/feature-gates/feature-gate-extern_types.rs b/tests/ui/feature-gates/feature-gate-extern_types.rs new file mode 100644 index 000000000..103f8eed6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-extern_types.rs @@ -0,0 +1,5 @@ +extern "C" { + type T; //~ ERROR extern types are experimental +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-extern_types.stderr b/tests/ui/feature-gates/feature-gate-extern_types.stderr new file mode 100644 index 000000000..923fae400 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-extern_types.stderr @@ -0,0 +1,12 @@ +error[E0658]: extern types are experimental + --> $DIR/feature-gate-extern_types.rs:2:5 + | +LL | type T; + | ^^^^^^^ + | + = note: see issue #43467 <https://github.com/rust-lang/rust/issues/43467> for more information + = help: add `#![feature(extern_types)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-feature-gate.rs b/tests/ui/feature-gates/feature-gate-feature-gate.rs new file mode 100644 index 000000000..3c98e16a1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-feature-gate.rs @@ -0,0 +1,4 @@ +#![forbid(unstable_features)] +#![feature(intrinsics)] //~ ERROR unstable feature + +fn main() { } diff --git a/tests/ui/feature-gates/feature-gate-feature-gate.stderr b/tests/ui/feature-gates/feature-gate-feature-gate.stderr new file mode 100644 index 000000000..ad97741da --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-feature-gate.stderr @@ -0,0 +1,14 @@ +error: unstable feature + --> $DIR/feature-gate-feature-gate.rs:2:12 + | +LL | #![feature(intrinsics)] + | ^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/feature-gate-feature-gate.rs:1:11 + | +LL | #![forbid(unstable_features)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/feature-gates/feature-gate-ffi_const.rs b/tests/ui/feature-gates/feature-gate-ffi_const.rs new file mode 100644 index 000000000..9f3d783cc --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-ffi_const.rs @@ -0,0 +1,6 @@ +#![crate_type = "lib"] + +extern "C" { + #[ffi_const] //~ ERROR the `#[ffi_const]` attribute is an experimental feature + pub fn foo(); +} diff --git a/tests/ui/feature-gates/feature-gate-ffi_const.stderr b/tests/ui/feature-gates/feature-gate-ffi_const.stderr new file mode 100644 index 000000000..bed6a2ce4 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-ffi_const.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[ffi_const]` attribute is an experimental feature + --> $DIR/feature-gate-ffi_const.rs:4:5 + | +LL | #[ffi_const] + | ^^^^^^^^^^^^ + | + = note: see issue #58328 <https://github.com/rust-lang/rust/issues/58328> for more information + = help: add `#![feature(ffi_const)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-ffi_pure.rs b/tests/ui/feature-gates/feature-gate-ffi_pure.rs new file mode 100644 index 000000000..b0dfa01ff --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-ffi_pure.rs @@ -0,0 +1,6 @@ +#![crate_type = "lib"] + +extern "C" { + #[ffi_pure] //~ ERROR the `#[ffi_pure]` attribute is an experimental feature + pub fn foo(); +} diff --git a/tests/ui/feature-gates/feature-gate-ffi_pure.stderr b/tests/ui/feature-gates/feature-gate-ffi_pure.stderr new file mode 100644 index 000000000..2b0308fd6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-ffi_pure.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[ffi_pure]` attribute is an experimental feature + --> $DIR/feature-gate-ffi_pure.rs:4:5 + | +LL | #[ffi_pure] + | ^^^^^^^^^^^ + | + = note: see issue #58329 <https://github.com/rust-lang/rust/issues/58329> for more information + = help: add `#![feature(ffi_pure)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-ffi_returns_twice.rs b/tests/ui/feature-gates/feature-gate-ffi_returns_twice.rs new file mode 100644 index 000000000..f35453435 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-ffi_returns_twice.rs @@ -0,0 +1,6 @@ +#![crate_type = "lib"] + +extern "C" { + #[ffi_returns_twice] //~ ERROR the `#[ffi_returns_twice]` attribute is an experimental feature + pub fn foo(); +} diff --git a/tests/ui/feature-gates/feature-gate-ffi_returns_twice.stderr b/tests/ui/feature-gates/feature-gate-ffi_returns_twice.stderr new file mode 100644 index 000000000..3585355ab --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-ffi_returns_twice.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[ffi_returns_twice]` attribute is an experimental feature + --> $DIR/feature-gate-ffi_returns_twice.rs:4:5 + | +LL | #[ffi_returns_twice] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #58314 <https://github.com/rust-lang/rust/issues/58314> for more information + = help: add `#![feature(ffi_returns_twice)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-fn_align.rs b/tests/ui/feature-gates/feature-gate-fn_align.rs new file mode 100644 index 000000000..ea873dba2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-fn_align.rs @@ -0,0 +1,4 @@ +#![crate_type = "lib"] + +#[repr(align(16))] //~ ERROR `repr(align)` attributes on functions are unstable +fn requires_alignment() {} diff --git a/tests/ui/feature-gates/feature-gate-fn_align.stderr b/tests/ui/feature-gates/feature-gate-fn_align.stderr new file mode 100644 index 000000000..5ff124e48 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-fn_align.stderr @@ -0,0 +1,12 @@ +error[E0658]: `repr(align)` attributes on functions are unstable + --> $DIR/feature-gate-fn_align.rs:3:8 + | +LL | #[repr(align(16))] + | ^^^^^^^^^ + | + = note: see issue #82232 <https://github.com/rust-lang/rust/issues/82232> for more information + = help: add `#![feature(fn_align)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-format_args_nl.rs b/tests/ui/feature-gates/feature-gate-format_args_nl.rs new file mode 100644 index 000000000..aeee2fbad --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-format_args_nl.rs @@ -0,0 +1,3 @@ +fn main() { + format_args_nl!(""); //~ ERROR `format_args_nl` is only for internal language use +} diff --git a/tests/ui/feature-gates/feature-gate-format_args_nl.stderr b/tests/ui/feature-gates/feature-gate-format_args_nl.stderr new file mode 100644 index 000000000..b211e2f8e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-format_args_nl.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'format_args_nl': `format_args_nl` is only for internal language use and is subject to change + --> $DIR/feature-gate-format_args_nl.rs:2:5 + | +LL | format_args_nl!(""); + | ^^^^^^^^^^^^^^ + | + = help: add `#![feature(format_args_nl)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-fundamental.rs b/tests/ui/feature-gates/feature-gate-fundamental.rs new file mode 100644 index 000000000..70e013392 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-fundamental.rs @@ -0,0 +1,4 @@ +#[fundamental] //~ ERROR the `#[fundamental]` attribute is an experimental feature +struct Fundamental; + +fn main() { } diff --git a/tests/ui/feature-gates/feature-gate-fundamental.stderr b/tests/ui/feature-gates/feature-gate-fundamental.stderr new file mode 100644 index 000000000..1ae8d9128 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-fundamental.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[fundamental]` attribute is an experimental feature + --> $DIR/feature-gate-fundamental.rs:1:1 + | +LL | #[fundamental] + | ^^^^^^^^^^^^^^ + | + = note: see issue #29635 <https://github.com/rust-lang/rust/issues/29635> for more information + = help: add `#![feature(fundamental)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-generators.rs b/tests/ui/feature-gates/feature-gate-generators.rs new file mode 100644 index 000000000..931fee134 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-generators.rs @@ -0,0 +1,10 @@ +fn main() { + yield true; //~ ERROR yield syntax is experimental + //~^ ERROR yield expression outside of generator literal +} + +#[cfg(FALSE)] +fn foo() { + yield; //~ ERROR yield syntax is experimental + yield 0; //~ ERROR yield syntax is experimental +} diff --git a/tests/ui/feature-gates/feature-gate-generators.stderr b/tests/ui/feature-gates/feature-gate-generators.stderr new file mode 100644 index 000000000..dfea178a6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-generators.stderr @@ -0,0 +1,37 @@ +error[E0658]: yield syntax is experimental + --> $DIR/feature-gate-generators.rs:2:5 + | +LL | yield true; + | ^^^^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(generators)]` to the crate attributes to enable + +error[E0658]: yield syntax is experimental + --> $DIR/feature-gate-generators.rs:8:5 + | +LL | yield; + | ^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(generators)]` to the crate attributes to enable + +error[E0658]: yield syntax is experimental + --> $DIR/feature-gate-generators.rs:9:5 + | +LL | yield 0; + | ^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(generators)]` to the crate attributes to enable + +error[E0627]: yield expression outside of generator literal + --> $DIR/feature-gate-generators.rs:2:5 + | +LL | yield true; + | ^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0627, E0658. +For more information about an error, try `rustc --explain E0627`. diff --git a/tests/ui/feature-gates/feature-gate-generic_arg_infer.normal.stderr b/tests/ui/feature-gates/feature-gate-generic_arg_infer.normal.stderr new file mode 100644 index 000000000..56123a983 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-generic_arg_infer.normal.stderr @@ -0,0 +1,43 @@ +error: in expressions, `_` can only be used on the left-hand side of an assignment + --> $DIR/feature-gate-generic_arg_infer.rs:11:27 + | +LL | let _x: [u8; 3] = [0; _]; + | ^ `_` not allowed here + +error: in expressions, `_` can only be used on the left-hand side of an assignment + --> $DIR/feature-gate-generic_arg_infer.rs:14:18 + | +LL | let _y: [u8; _] = [0; 3]; + | ^ `_` not allowed here + +error[E0658]: using `_` for array lengths is unstable + --> $DIR/feature-gate-generic_arg_infer.rs:14:18 + | +LL | let _y: [u8; _] = [0; 3]; + | ^ help: consider specifying the array length: `3` + | + = note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information + = help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable + +error[E0747]: type provided when a constant was expected + --> $DIR/feature-gate-generic_arg_infer.rs:20:20 + | +LL | let _x = foo::<_>([1,2]); + | ^ + | + = help: const arguments cannot yet be inferred with `_` + = help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable + +error[E0658]: using `_` for array lengths is unstable + --> $DIR/feature-gate-generic_arg_infer.rs:11:27 + | +LL | let _x: [u8; 3] = [0; _]; + | ^ + | + = note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information + = help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0658, E0747. +For more information about an error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs b/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs new file mode 100644 index 000000000..afd14b784 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs @@ -0,0 +1,23 @@ +// [feature] run-pass +// revisions: normal feature + +#![cfg_attr(feature, feature(generic_arg_infer))] + +fn foo<const N: usize>(_: [u8; N]) -> [u8; N] { + [0; N] +} + +fn bar() { + let _x: [u8; 3] = [0; _]; + //[normal]~^ ERROR: using `_` for array lengths is unstable + //[normal]~| ERROR: in expressions, `_` can only be used on the left-hand side of an assignment + let _y: [u8; _] = [0; 3]; + //[normal]~^ ERROR: using `_` for array lengths is unstable + //[normal]~| ERROR: in expressions, `_` can only be used on the left-hand side of an assignment +} + +fn main() { + let _x = foo::<_>([1,2]); + //[normal]~^ ERROR: type provided when a constant was expected + let _y = bar(); +} diff --git a/tests/ui/feature-gates/feature-gate-generic_associated_types_extended.rs b/tests/ui/feature-gates/feature-gate-generic_associated_types_extended.rs new file mode 100644 index 000000000..7842d44ac --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-generic_associated_types_extended.rs @@ -0,0 +1,4 @@ +// This feature doesn't *currently* fire on any specific code; it's just a +// behavior change. Future changes might. +#[rustc_error] //~ the +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-generic_associated_types_extended.stderr b/tests/ui/feature-gates/feature-gate-generic_associated_types_extended.stderr new file mode 100644 index 000000000..bb1622628 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-generic_associated_types_extended.stderr @@ -0,0 +1,11 @@ +error[E0658]: the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable + --> $DIR/feature-gate-generic_associated_types_extended.rs:3:1 + | +LL | #[rustc_error] + | ^^^^^^^^^^^^^^ + | + = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs b/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs new file mode 100644 index 000000000..0db8088f7 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs @@ -0,0 +1,6 @@ +fn f() -> impl Fn() -> impl Sized { || () } +//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +fn g() -> &'static dyn Fn() -> impl Sized { &|| () } +//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr b/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr new file mode 100644 index 000000000..760dcb615 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr @@ -0,0 +1,21 @@ +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24 + | +LL | fn f() -> impl Fn() -> impl Sized { || () } + | ^^^^^^^^^^ + | + = note: see issue #99697 <https://github.com/rust-lang/rust/issues/99697> for more information + = help: add `#![feature(impl_trait_in_fn_trait_return)]` to the crate attributes to enable + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32 + | +LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () } + | ^^^^^^^^^^ + | + = note: see issue #99697 <https://github.com/rust-lang/rust/issues/99697> for more information + = help: add `#![feature(impl_trait_in_fn_trait_return)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/feature-gates/feature-gate-imported_main.rs b/tests/ui/feature-gates/feature-gate-imported_main.rs new file mode 100644 index 000000000..b351d0d0e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-imported_main.rs @@ -0,0 +1,6 @@ +pub mod foo { + pub fn bar() { + println!("Hello world!"); + } +} +use foo::bar as main; //~ ERROR using an imported function as entry point diff --git a/tests/ui/feature-gates/feature-gate-imported_main.stderr b/tests/ui/feature-gates/feature-gate-imported_main.stderr new file mode 100644 index 000000000..3b879fdfc --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-imported_main.stderr @@ -0,0 +1,12 @@ +error[E0658]: using an imported function as entry point `main` is experimental + --> $DIR/feature-gate-imported_main.rs:6:5 + | +LL | use foo::bar as main; + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #28937 <https://github.com/rust-lang/rust/issues/28937> for more information + = help: add `#![feature(imported_main)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-inherent_associated_types.rs b/tests/ui/feature-gates/feature-gate-inherent_associated_types.rs new file mode 100644 index 000000000..fc7c6dbc0 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-inherent_associated_types.rs @@ -0,0 +1,10 @@ +// Test that inherent associated types cannot be used when inherent_associated_types +// feature gate is not used. + +struct Foo; + +impl Foo { + type Bar = isize; //~ERROR inherent associated types are unstable +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-inherent_associated_types.stderr b/tests/ui/feature-gates/feature-gate-inherent_associated_types.stderr new file mode 100644 index 000000000..76e65d239 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-inherent_associated_types.stderr @@ -0,0 +1,12 @@ +error[E0658]: inherent associated types are unstable + --> $DIR/feature-gate-inherent_associated_types.rs:7:5 + | +LL | type Bar = isize; + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information + = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-inline_const.rs b/tests/ui/feature-gates/feature-gate-inline_const.rs new file mode 100644 index 000000000..43ff90d23 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-inline_const.rs @@ -0,0 +1,6 @@ +fn main() { + let _ = const { + //~^ ERROR inline-const is experimental [E0658] + true + }; +} diff --git a/tests/ui/feature-gates/feature-gate-inline_const.stderr b/tests/ui/feature-gates/feature-gate-inline_const.stderr new file mode 100644 index 000000000..be2f56715 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-inline_const.stderr @@ -0,0 +1,12 @@ +error[E0658]: inline-const is experimental + --> $DIR/feature-gate-inline_const.rs:2:13 + | +LL | let _ = const { + | ^^^^^ + | + = note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information + = help: add `#![feature(inline_const)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-inline_const_pat.rs b/tests/ui/feature-gates/feature-gate-inline_const_pat.rs new file mode 100644 index 000000000..3d0df289f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-inline_const_pat.rs @@ -0,0 +1,4 @@ +fn main() { + let const { () } = (); + //~^ ERROR inline-const in pattern position is experimental [E0658] +} diff --git a/tests/ui/feature-gates/feature-gate-inline_const_pat.stderr b/tests/ui/feature-gates/feature-gate-inline_const_pat.stderr new file mode 100644 index 000000000..ca533d850 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-inline_const_pat.stderr @@ -0,0 +1,12 @@ +error[E0658]: inline-const in pattern position is experimental + --> $DIR/feature-gate-inline_const_pat.rs:2:9 + | +LL | let const { () } = (); + | ^^^^^ + | + = note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information + = help: add `#![feature(inline_const_pat)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-intrinsics.rs b/tests/ui/feature-gates/feature-gate-intrinsics.rs new file mode 100644 index 000000000..e0dc3cc57 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-intrinsics.rs @@ -0,0 +1,8 @@ +extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change + fn bar(); //~ ERROR unrecognized intrinsic function: `bar` +} + +extern "rust-intrinsic" fn baz() {} //~ ERROR intrinsics are subject to change +//~^ ERROR intrinsic must be in + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-intrinsics.stderr b/tests/ui/feature-gates/feature-gate-intrinsics.stderr new file mode 100644 index 000000000..8f943d357 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-intrinsics.stderr @@ -0,0 +1,32 @@ +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-intrinsics.rs:1:8 + | +LL | extern "rust-intrinsic" { + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(intrinsics)]` to the crate attributes to enable + +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gate-intrinsics.rs:5:8 + | +LL | extern "rust-intrinsic" fn baz() {} + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(intrinsics)]` to the crate attributes to enable + +error[E0093]: unrecognized intrinsic function: `bar` + --> $DIR/feature-gate-intrinsics.rs:2:5 + | +LL | fn bar(); + | ^^^^^^^^^ unrecognized intrinsic + +error: intrinsic must be in `extern "rust-intrinsic" { ... }` block + --> $DIR/feature-gate-intrinsics.rs:5:34 + | +LL | extern "rust-intrinsic" fn baz() {} + | ^^ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0093, E0658. +For more information about an error, try `rustc --explain E0093`. diff --git a/tests/ui/feature-gates/feature-gate-is_sorted.rs b/tests/ui/feature-gates/feature-gate-is_sorted.rs new file mode 100644 index 000000000..359ed835b --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-is_sorted.rs @@ -0,0 +1,13 @@ +fn main() { + // Assert `Iterator` methods are unstable + assert!([1, 2, 2, 9].iter().is_sorted()); + //~^ ERROR: use of unstable library feature 'is_sorted': new API + assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs())); + //~^ ERROR: use of unstable library feature 'is_sorted': new API + + // Assert `[T]` methods are unstable + assert!([1, 2, 2, 9].is_sorted()); + //~^ ERROR: use of unstable library feature 'is_sorted': new API + assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs())); + //~^ ERROR: use of unstable library feature 'is_sorted': new API +} diff --git a/tests/ui/feature-gates/feature-gate-is_sorted.stderr b/tests/ui/feature-gates/feature-gate-is_sorted.stderr new file mode 100644 index 000000000..ccac82707 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-is_sorted.stderr @@ -0,0 +1,39 @@ +error[E0658]: use of unstable library feature 'is_sorted': new API + --> $DIR/feature-gate-is_sorted.rs:3:33 + | +LL | assert!([1, 2, 2, 9].iter().is_sorted()); + | ^^^^^^^^^ + | + = note: see issue #53485 <https://github.com/rust-lang/rust/issues/53485> for more information + = help: add `#![feature(is_sorted)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'is_sorted': new API + --> $DIR/feature-gate-is_sorted.rs:5:39 + | +LL | assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs())); + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #53485 <https://github.com/rust-lang/rust/issues/53485> for more information + = help: add `#![feature(is_sorted)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'is_sorted': new API + --> $DIR/feature-gate-is_sorted.rs:9:26 + | +LL | assert!([1, 2, 2, 9].is_sorted()); + | ^^^^^^^^^ + | + = note: see issue #53485 <https://github.com/rust-lang/rust/issues/53485> for more information + = help: add `#![feature(is_sorted)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'is_sorted': new API + --> $DIR/feature-gate-is_sorted.rs:11:32 + | +LL | assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs())); + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #53485 <https://github.com/rust-lang/rust/issues/53485> for more information + = help: add `#![feature(is_sorted)]` to the crate attributes to enable + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-lang-items.rs b/tests/ui/feature-gates/feature-gate-lang-items.rs new file mode 100644 index 000000000..93262f217 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-lang-items.rs @@ -0,0 +1,5 @@ +#[lang = "foo"] //~ ERROR language items are subject to change + //~^ ERROR definition of an unknown language item: `foo` +trait Foo {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-lang-items.stderr b/tests/ui/feature-gates/feature-gate-lang-items.stderr new file mode 100644 index 000000000..c2496863f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-lang-items.stderr @@ -0,0 +1,18 @@ +error[E0658]: language items are subject to change + --> $DIR/feature-gate-lang-items.rs:1:1 + | +LL | #[lang = "foo"] + | ^^^^^^^^^^^^^^^ + | + = help: add `#![feature(lang_items)]` to the crate attributes to enable + +error[E0522]: definition of an unknown language item: `foo` + --> $DIR/feature-gate-lang-items.rs:1:1 + | +LL | #[lang = "foo"] + | ^^^^^^^^^^^^^^^ definition of unknown language item `foo` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0522, E0658. +For more information about an error, try `rustc --explain E0522`. diff --git a/tests/ui/feature-gates/feature-gate-large-assignments.rs b/tests/ui/feature-gates/feature-gate-large-assignments.rs new file mode 100644 index 000000000..7e9e574bf --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-large-assignments.rs @@ -0,0 +1,5 @@ +// check that `move_size_limit is feature-gated + +#![move_size_limit = "42"] //~ ERROR the `#[move_size_limit]` attribute is an experimental feature + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-large-assignments.stderr b/tests/ui/feature-gates/feature-gate-large-assignments.stderr new file mode 100644 index 000000000..8ddc3043e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-large-assignments.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[move_size_limit]` attribute is an experimental feature + --> $DIR/feature-gate-large-assignments.rs:3:1 + | +LL | #![move_size_limit = "42"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #83518 <https://github.com/rust-lang/rust/issues/83518> for more information + = help: add `#![feature(large_assignments)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-link_cfg.rs b/tests/ui/feature-gates/feature-gate-link_cfg.rs new file mode 100644 index 000000000..d30ee3bcf --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-link_cfg.rs @@ -0,0 +1,5 @@ +#[link(name = "foo", cfg(foo))] +//~^ ERROR: is unstable +extern "C" {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-link_cfg.stderr b/tests/ui/feature-gates/feature-gate-link_cfg.stderr new file mode 100644 index 000000000..8f47d5965 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-link_cfg.stderr @@ -0,0 +1,12 @@ +error[E0658]: link cfg is unstable + --> $DIR/feature-gate-link_cfg.rs:1:22 + | +LL | #[link(name = "foo", cfg(foo))] + | ^^^^^^^^ + | + = note: see issue #37406 <https://github.com/rust-lang/rust/issues/37406> for more information + = help: add `#![feature(link_cfg)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-link_llvm_intrinsics.rs b/tests/ui/feature-gates/feature-gate-link_llvm_intrinsics.rs new file mode 100644 index 000000000..7391ea94e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-link_llvm_intrinsics.rs @@ -0,0 +1,7 @@ +extern "C" { + #[link_name = "llvm.sqrt.f32"] + fn sqrt(x: f32) -> f32; +//~^ ERROR linking to LLVM intrinsics is experimental +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-link_llvm_intrinsics.stderr b/tests/ui/feature-gates/feature-gate-link_llvm_intrinsics.stderr new file mode 100644 index 000000000..6bce5b823 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-link_llvm_intrinsics.stderr @@ -0,0 +1,12 @@ +error[E0658]: linking to LLVM intrinsics is experimental + --> $DIR/feature-gate-link_llvm_intrinsics.rs:3:5 + | +LL | fn sqrt(x: f32) -> f32; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #29602 <https://github.com/rust-lang/rust/issues/29602> for more information + = help: add `#![feature(link_llvm_intrinsics)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-linkage.rs b/tests/ui/feature-gates/feature-gate-linkage.rs new file mode 100644 index 000000000..505f31ec6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-linkage.rs @@ -0,0 +1,6 @@ +extern "C" { + #[linkage = "extern_weak"] static foo: *mut isize; + //~^ ERROR: the `linkage` attribute is experimental and not portable +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-linkage.stderr b/tests/ui/feature-gates/feature-gate-linkage.stderr new file mode 100644 index 000000000..a1c73e555 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-linkage.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `linkage` attribute is experimental and not portable across platforms + --> $DIR/feature-gate-linkage.rs:2:5 + | +LL | #[linkage = "extern_weak"] static foo: *mut isize; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #29603 <https://github.com/rust-lang/rust/issues/29603> for more information + = help: add `#![feature(linkage)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-lint-reasons.rs b/tests/ui/feature-gates/feature-gate-lint-reasons.rs new file mode 100644 index 000000000..7756074e2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-lint-reasons.rs @@ -0,0 +1,5 @@ +#![warn(nonstandard_style, reason = "the standard should be respected")] +//~^ ERROR lint reasons are experimental +//~| ERROR lint reasons are experimental + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-lint-reasons.stderr b/tests/ui/feature-gates/feature-gate-lint-reasons.stderr new file mode 100644 index 000000000..12793c7a2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-lint-reasons.stderr @@ -0,0 +1,21 @@ +error[E0658]: lint reasons are experimental + --> $DIR/feature-gate-lint-reasons.rs:1:28 + | +LL | #![warn(nonstandard_style, reason = "the standard should be respected")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54503 <https://github.com/rust-lang/rust/issues/54503> for more information + = help: add `#![feature(lint_reasons)]` to the crate attributes to enable + +error[E0658]: lint reasons are experimental + --> $DIR/feature-gate-lint-reasons.rs:1:28 + | +LL | #![warn(nonstandard_style, reason = "the standard should be respected")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54503 <https://github.com/rust-lang/rust/issues/54503> for more information + = help: add `#![feature(lint_reasons)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-log_syntax.rs b/tests/ui/feature-gates/feature-gate-log_syntax.rs new file mode 100644 index 000000000..181f66cb0 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-log_syntax.rs @@ -0,0 +1,3 @@ +fn main() { + log_syntax!() //~ ERROR `log_syntax!` is not stable enough +} diff --git a/tests/ui/feature-gates/feature-gate-log_syntax.stderr b/tests/ui/feature-gates/feature-gate-log_syntax.stderr new file mode 100644 index 000000000..fdc1c8553 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-log_syntax.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature 'log_syntax': `log_syntax!` is not stable enough for use and is subject to change + --> $DIR/feature-gate-log_syntax.rs:2:5 + | +LL | log_syntax!() + | ^^^^^^^^^^ + | + = note: see issue #29598 <https://github.com/rust-lang/rust/issues/29598> for more information + = help: add `#![feature(log_syntax)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-log_syntax.stdout b/tests/ui/feature-gates/feature-gate-log_syntax.stdout new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-log_syntax.stdout @@ -0,0 +1 @@ + diff --git a/tests/ui/feature-gates/feature-gate-log_syntax2.rs b/tests/ui/feature-gates/feature-gate-log_syntax2.rs new file mode 100644 index 000000000..db1a96f1f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-log_syntax2.rs @@ -0,0 +1,3 @@ +fn main() { + println!("{:?}", log_syntax!()); //~ ERROR `log_syntax!` is not stable +} diff --git a/tests/ui/feature-gates/feature-gate-log_syntax2.stderr b/tests/ui/feature-gates/feature-gate-log_syntax2.stderr new file mode 100644 index 000000000..6deb4a46c --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-log_syntax2.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature 'log_syntax': `log_syntax!` is not stable enough for use and is subject to change + --> $DIR/feature-gate-log_syntax2.rs:2:22 + | +LL | println!("{:?}", log_syntax!()); + | ^^^^^^^^^^ + | + = note: see issue #29598 <https://github.com/rust-lang/rust/issues/29598> for more information + = help: add `#![feature(log_syntax)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-log_syntax2.stdout b/tests/ui/feature-gates/feature-gate-log_syntax2.stdout new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-log_syntax2.stdout @@ -0,0 +1 @@ + diff --git a/tests/ui/feature-gates/feature-gate-marker_trait_attr.rs b/tests/ui/feature-gates/feature-gate-marker_trait_attr.rs new file mode 100644 index 000000000..5050c4792 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-marker_trait_attr.rs @@ -0,0 +1,9 @@ +use std::fmt::{Debug, Display}; + +#[marker] trait ExplicitMarker {} +//~^ ERROR the `#[marker]` attribute is an experimental feature + +impl<T: Display> ExplicitMarker for T {} +impl<T: Debug> ExplicitMarker for T {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-marker_trait_attr.stderr b/tests/ui/feature-gates/feature-gate-marker_trait_attr.stderr new file mode 100644 index 000000000..e3c3756fd --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-marker_trait_attr.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[marker]` attribute is an experimental feature + --> $DIR/feature-gate-marker_trait_attr.rs:3:1 + | +LL | #[marker] trait ExplicitMarker {} + | ^^^^^^^^^ + | + = note: see issue #29864 <https://github.com/rust-lang/rust/issues/29864> for more information + = help: add `#![feature(marker_trait_attr)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-may-dangle.rs b/tests/ui/feature-gates/feature-gate-may-dangle.rs new file mode 100644 index 000000000..23db92c15 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-may-dangle.rs @@ -0,0 +1,11 @@ +// gate-test-dropck_eyepatch + +// Check that `may_dangle` is rejected if `dropck_eyepatch` feature gate is absent. + +struct Pt<A>(A); +unsafe impl<#[may_dangle] A> Drop for Pt<A> { + //~^ ERROR `may_dangle` has unstable semantics and may be removed in the future + fn drop(&mut self) { } +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-may-dangle.stderr b/tests/ui/feature-gates/feature-gate-may-dangle.stderr new file mode 100644 index 000000000..d47a76a50 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-may-dangle.stderr @@ -0,0 +1,12 @@ +error[E0658]: `may_dangle` has unstable semantics and may be removed in the future + --> $DIR/feature-gate-may-dangle.rs:6:13 + | +LL | unsafe impl<#[may_dangle] A> Drop for Pt<A> { + | ^^^^^^^^^^^^^ + | + = note: see issue #34761 <https://github.com/rust-lang/rust/issues/34761> for more information + = help: add `#![feature(dropck_eyepatch)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-min_const_fn.rs b/tests/ui/feature-gates/feature-gate-min_const_fn.rs new file mode 100644 index 000000000..8f9b43300 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-min_const_fn.rs @@ -0,0 +1,35 @@ +// Test use of min_const_fn without feature gate. + +const fn foo() -> usize { 0 } // stabilized + +trait Foo { + const fn foo() -> u32; //~ ERROR functions in traits cannot be declared const + const fn bar() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const +} + +impl Foo for u32 { + const fn foo() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const +} + +trait Bar {} + +impl dyn Bar { + const fn baz() -> u32 { 0 } // stabilized +} + +static FOO: usize = foo(); +const BAR: usize = foo(); + +macro_rules! constant { + ($n:ident: $t:ty = $v:expr) => { + const $n: $t = $v; + } +} + +constant! { + BAZ: usize = foo() +} + +fn main() { + let x: [usize; foo()] = []; +} diff --git a/tests/ui/feature-gates/feature-gate-min_const_fn.stderr b/tests/ui/feature-gates/feature-gate-min_const_fn.stderr new file mode 100644 index 000000000..d7a585913 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-min_const_fn.stderr @@ -0,0 +1,21 @@ +error[E0379]: functions in traits cannot be declared const + --> $DIR/feature-gate-min_const_fn.rs:6:5 + | +LL | const fn foo() -> u32; + | ^^^^^ functions in traits cannot be const + +error[E0379]: functions in traits cannot be declared const + --> $DIR/feature-gate-min_const_fn.rs:7:5 + | +LL | const fn bar() -> u32 { 0 } + | ^^^^^ functions in traits cannot be const + +error[E0379]: functions in traits cannot be declared const + --> $DIR/feature-gate-min_const_fn.rs:11:5 + | +LL | const fn foo() -> u32 { 0 } + | ^^^^^ functions in traits cannot be const + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0379`. diff --git a/tests/ui/feature-gates/feature-gate-more-qualified-paths.rs b/tests/ui/feature-gates/feature-gate-more-qualified-paths.rs new file mode 100644 index 000000000..2e05acbfa --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-more-qualified-paths.rs @@ -0,0 +1,27 @@ +fn main() { + // destructure through a qualified path + let <Foo as A>::Assoc { br } = StructStruct { br: 2 }; + //~^ ERROR usage of qualified paths in this context is experimental + let _ = <Foo as A>::Assoc { br: 2 }; + //~^ ERROR usage of qualified paths in this context is experimental + let <E>::V(..) = E::V(0); + //~^ ERROR usage of qualified paths in this context is experimental +} + +struct StructStruct { + br: i8, +} + +struct Foo; + +trait A { + type Assoc; +} + +impl A for Foo { + type Assoc = StructStruct; +} + +enum E { + V(u8) +} diff --git a/tests/ui/feature-gates/feature-gate-more-qualified-paths.stderr b/tests/ui/feature-gates/feature-gate-more-qualified-paths.stderr new file mode 100644 index 000000000..80ebcabcf --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-more-qualified-paths.stderr @@ -0,0 +1,30 @@ +error[E0658]: usage of qualified paths in this context is experimental + --> $DIR/feature-gate-more-qualified-paths.rs:3:9 + | +LL | let <Foo as A>::Assoc { br } = StructStruct { br: 2 }; + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #86935 <https://github.com/rust-lang/rust/issues/86935> for more information + = help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable + +error[E0658]: usage of qualified paths in this context is experimental + --> $DIR/feature-gate-more-qualified-paths.rs:5:13 + | +LL | let _ = <Foo as A>::Assoc { br: 2 }; + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #86935 <https://github.com/rust-lang/rust/issues/86935> for more information + = help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable + +error[E0658]: usage of qualified paths in this context is experimental + --> $DIR/feature-gate-more-qualified-paths.rs:7:9 + | +LL | let <E>::V(..) = E::V(0); + | ^^^^^^ + | + = note: see issue #86935 <https://github.com/rust-lang/rust/issues/86935> for more information + = help: add `#![feature(more_qualified_paths)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-naked_functions.rs b/tests/ui/feature-gates/feature-gate-naked_functions.rs new file mode 100644 index 000000000..8e93b1941 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-naked_functions.rs @@ -0,0 +1,17 @@ +// needs-asm-support + +use std::arch::asm; + +#[naked] +//~^ the `#[naked]` attribute is an experimental feature +extern "C" fn naked() { + asm!("", options(noreturn)) +} + +#[naked] +//~^ the `#[naked]` attribute is an experimental feature +extern "C" fn naked_2() -> isize { + asm!("", options(noreturn)) +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-naked_functions.stderr b/tests/ui/feature-gates/feature-gate-naked_functions.stderr new file mode 100644 index 000000000..4378fb363 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-naked_functions.stderr @@ -0,0 +1,21 @@ +error[E0658]: the `#[naked]` attribute is an experimental feature + --> $DIR/feature-gate-naked_functions.rs:5:1 + | +LL | #[naked] + | ^^^^^^^^ + | + = note: see issue #32408 <https://github.com/rust-lang/rust/issues/32408> for more information + = help: add `#![feature(naked_functions)]` to the crate attributes to enable + +error[E0658]: the `#[naked]` attribute is an experimental feature + --> $DIR/feature-gate-naked_functions.rs:11:1 + | +LL | #[naked] + | ^^^^^^^^ + | + = note: see issue #32408 <https://github.com/rust-lang/rust/issues/32408> for more information + = help: add `#![feature(naked_functions)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.rs b/tests/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.rs new file mode 100644 index 000000000..132bc6ab0 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.rs @@ -0,0 +1,5 @@ +#[link(name = "foo", kind = "dylib", modifiers = "+as-needed")] +//~^ ERROR: linking modifier `as-needed` is unstable +extern "C" {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.stderr b/tests/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.stderr new file mode 100644 index 000000000..2ef6a1c04 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.stderr @@ -0,0 +1,12 @@ +error[E0658]: linking modifier `as-needed` is unstable + --> $DIR/feature-gate-native_link_modifiers_as_needed.rs:1:50 + | +LL | #[link(name = "foo", kind = "dylib", modifiers = "+as-needed")] + | ^^^^^^^^^^^^ + | + = note: see issue #81490 <https://github.com/rust-lang/rust/issues/81490> for more information + = help: add `#![feature(native_link_modifiers_as_needed)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-needs-allocator.rs b/tests/ui/feature-gates/feature-gate-needs-allocator.rs new file mode 100644 index 000000000..08954944b --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-needs-allocator.rs @@ -0,0 +1,3 @@ +#![needs_allocator] //~ ERROR the `#[needs_allocator]` attribute is + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-needs-allocator.stderr b/tests/ui/feature-gates/feature-gate-needs-allocator.stderr new file mode 100644 index 000000000..2b213aceb --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-needs-allocator.stderr @@ -0,0 +1,11 @@ +error[E0658]: the `#[needs_allocator]` attribute is an experimental feature + --> $DIR/feature-gate-needs-allocator.rs:1:1 + | +LL | #![needs_allocator] + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(allocator_internals)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-negate-unsigned.rs b/tests/ui/feature-gates/feature-gate-negate-unsigned.rs new file mode 100644 index 000000000..05e04f3e2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-negate-unsigned.rs @@ -0,0 +1,18 @@ +// Test that negating unsigned integers doesn't compile + +struct S; +impl std::ops::Neg for S { + type Output = u32; + fn neg(self) -> u32 { 0 } +} + +fn main() { + let _max: usize = -1; + //~^ ERROR cannot apply unary operator `-` to type `usize` + + let x = 5u8; + let _y = -x; + //~^ ERROR cannot apply unary operator `-` to type `u8` + + -S; // should not trigger the gate; issue 26840 +} diff --git a/tests/ui/feature-gates/feature-gate-negate-unsigned.stderr b/tests/ui/feature-gates/feature-gate-negate-unsigned.stderr new file mode 100644 index 000000000..d1f4ed5cb --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-negate-unsigned.stderr @@ -0,0 +1,22 @@ +error[E0600]: cannot apply unary operator `-` to type `usize` + --> $DIR/feature-gate-negate-unsigned.rs:10:23 + | +LL | let _max: usize = -1; + | ^^ + | | + | cannot apply unary operator `-` + | help: you may have meant the maximum value of `usize`: `usize::MAX` + | + = note: unsigned values cannot be negated + +error[E0600]: cannot apply unary operator `-` to type `u8` + --> $DIR/feature-gate-negate-unsigned.rs:14:14 + | +LL | let _y = -x; + | ^^ cannot apply unary operator `-` + | + = note: unsigned values cannot be negated + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0600`. diff --git a/tests/ui/feature-gates/feature-gate-never_type.rs b/tests/ui/feature-gates/feature-gate-never_type.rs new file mode 100644 index 000000000..be8c27dbb --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-never_type.rs @@ -0,0 +1,17 @@ +// Test that ! errors when used in illegal positions with feature(never_type) disabled + +trait Foo { + type Wub; +} + +type Ma = (u32, !, i32); //~ ERROR type is experimental +type Meeshka = Vec<!>; //~ ERROR type is experimental +type Mow = &'static fn(!) -> !; //~ ERROR type is experimental +type Skwoz = &'static mut !; //~ ERROR type is experimental + +impl Foo for Meeshka { + type Wub = !; //~ ERROR type is experimental +} + +fn main() { +} diff --git a/tests/ui/feature-gates/feature-gate-never_type.stderr b/tests/ui/feature-gates/feature-gate-never_type.stderr new file mode 100644 index 000000000..0a59cae9c --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-never_type.stderr @@ -0,0 +1,48 @@ +error[E0658]: the `!` type is experimental + --> $DIR/feature-gate-never_type.rs:7:17 + | +LL | type Ma = (u32, !, i32); + | ^ + | + = note: see issue #35121 <https://github.com/rust-lang/rust/issues/35121> for more information + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error[E0658]: the `!` type is experimental + --> $DIR/feature-gate-never_type.rs:8:20 + | +LL | type Meeshka = Vec<!>; + | ^ + | + = note: see issue #35121 <https://github.com/rust-lang/rust/issues/35121> for more information + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error[E0658]: the `!` type is experimental + --> $DIR/feature-gate-never_type.rs:9:24 + | +LL | type Mow = &'static fn(!) -> !; + | ^ + | + = note: see issue #35121 <https://github.com/rust-lang/rust/issues/35121> for more information + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error[E0658]: the `!` type is experimental + --> $DIR/feature-gate-never_type.rs:10:27 + | +LL | type Skwoz = &'static mut !; + | ^ + | + = note: see issue #35121 <https://github.com/rust-lang/rust/issues/35121> for more information + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error[E0658]: the `!` type is experimental + --> $DIR/feature-gate-never_type.rs:13:16 + | +LL | type Wub = !; + | ^ + | + = note: see issue #35121 <https://github.com/rust-lang/rust/issues/35121> for more information + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-no_core.rs b/tests/ui/feature-gates/feature-gate-no_core.rs new file mode 100644 index 000000000..706efd786 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-no_core.rs @@ -0,0 +1,5 @@ +#![crate_type = "rlib"] + +#![no_core] //~ ERROR the `#[no_core]` attribute is an experimental feature + +pub struct S {} diff --git a/tests/ui/feature-gates/feature-gate-no_core.stderr b/tests/ui/feature-gates/feature-gate-no_core.stderr new file mode 100644 index 000000000..8430a9ec6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-no_core.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[no_core]` attribute is an experimental feature + --> $DIR/feature-gate-no_core.rs:3:1 + | +LL | #![no_core] + | ^^^^^^^^^^^ + | + = note: see issue #29639 <https://github.com/rust-lang/rust/issues/29639> for more information + = help: add `#![feature(no_core)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-no_coverage.rs b/tests/ui/feature-gates/feature-gate-no_coverage.rs new file mode 100644 index 000000000..fd4c6f760 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-no_coverage.rs @@ -0,0 +1,13 @@ +#![crate_type = "lib"] + +#[derive(PartialEq, Eq)] // ensure deriving `Eq` does not enable `feature(no_coverage)` +struct Foo { + a: u8, + b: u32, +} + +#[no_coverage] //~ ERROR the `#[no_coverage]` attribute is an experimental feature +fn requires_feature_no_coverage() -> bool { + let bar = Foo { a: 0, b: 0 }; + bar == Foo { a: 0, b: 0 } +} diff --git a/tests/ui/feature-gates/feature-gate-no_coverage.stderr b/tests/ui/feature-gates/feature-gate-no_coverage.stderr new file mode 100644 index 000000000..f7167e0b7 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-no_coverage.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[no_coverage]` attribute is an experimental feature + --> $DIR/feature-gate-no_coverage.rs:9:1 + | +LL | #[no_coverage] + | ^^^^^^^^^^^^^^ + | + = note: see issue #84605 <https://github.com/rust-lang/rust/issues/84605> for more information + = help: add `#![feature(no_coverage)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-no_sanitize.rs b/tests/ui/feature-gates/feature-gate-no_sanitize.rs new file mode 100644 index 000000000..66a9263e1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-no_sanitize.rs @@ -0,0 +1,4 @@ +#[no_sanitize(address)] +//~^ the `#[no_sanitize]` attribute is an experimental feature +fn main() { +} diff --git a/tests/ui/feature-gates/feature-gate-no_sanitize.stderr b/tests/ui/feature-gates/feature-gate-no_sanitize.stderr new file mode 100644 index 000000000..399335700 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-no_sanitize.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[no_sanitize]` attribute is an experimental feature + --> $DIR/feature-gate-no_sanitize.rs:1:1 + | +LL | #[no_sanitize(address)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #39699 <https://github.com/rust-lang/rust/issues/39699> for more information + = help: add `#![feature(no_sanitize)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs new file mode 100644 index 000000000..9b646060a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.rs @@ -0,0 +1,34 @@ +// check-fail + +#![deny(non_exhaustive_omitted_patterns)] +//~^ WARNING unknown lint: `non_exhaustive_omitted_patterns` +//~| WARNING unknown lint: `non_exhaustive_omitted_patterns` +#![allow(non_exhaustive_omitted_patterns)] +//~^ WARNING unknown lint: `non_exhaustive_omitted_patterns` +//~| WARNING unknown lint: `non_exhaustive_omitted_patterns` + +fn main() { + enum Foo { + A, B, C, + } + + #[allow(non_exhaustive_omitted_patterns)] + //~^ WARNING unknown lint: `non_exhaustive_omitted_patterns` + //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` + //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` + //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` + match Foo::A { + Foo::A => {} + Foo::B => {} + } + //~^^^^ ERROR non-exhaustive patterns: `Foo::C` not covered + + match Foo::A { + Foo::A => {} + Foo::B => {} + #[warn(non_exhaustive_omitted_patterns)] + _ => {} + } + //~^^^ WARNING unknown lint: `non_exhaustive_omitted_patterns` + //~| WARNING unknown lint: `non_exhaustive_omitted_patterns` +} diff --git a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr new file mode 100644 index 000000000..4d79ce3c6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr @@ -0,0 +1,124 @@ +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:3:1 + | +LL | #![deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + = note: `#[warn(unknown_lints)]` on by default + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:6:1 + | +LL | #![allow(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 + | +LL | #[allow(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 + | +LL | #[allow(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:29:9 + | +LL | #[warn(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:3:1 + | +LL | #![deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:6:1 + | +LL | #![allow(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 + | +LL | #[allow(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:15:5 + | +LL | #[allow(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +warning: unknown lint: `non_exhaustive_omitted_patterns` + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:29:9 + | +LL | #[warn(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `non_exhaustive_omitted_patterns` lint is unstable + = note: see issue #89554 <https://github.com/rust-lang/rust/issues/89554> for more information + = help: add `#![feature(non_exhaustive_omitted_patterns_lint)]` to the crate attributes to enable + +error[E0004]: non-exhaustive patterns: `Foo::C` not covered + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:20:11 + | +LL | match Foo::A { + | ^^^^^^ pattern `Foo::C` not covered + | +note: `Foo` defined here + --> $DIR/feature-gate-non_exhaustive_omitted_patterns_lint.rs:12:15 + | +LL | enum Foo { + | --- +LL | A, B, C, + | ^ not covered + = note: the matched value is of type `Foo` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Foo::B => {} +LL + Foo::C => todo!() + | + +error: aborting due to previous error; 10 warnings emitted + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs b/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs new file mode 100644 index 000000000..37348e476 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs @@ -0,0 +1,41 @@ +// Test that the use of the non object-safe trait objects +// are gated by `object_safe_for_dispatch` feature gate. + +trait NonObjectSafe1: Sized {} + +trait NonObjectSafe2 { + fn static_fn() {} +} + +trait NonObjectSafe3 { + fn foo<T>(&self); +} + +trait NonObjectSafe4 { + fn foo(&self, s: &Self); +} + +fn takes_non_object_safe_ref<T>(obj: &dyn NonObjectSafe1) { + //~^ ERROR E0038 +} + +fn return_non_object_safe_ref() -> &'static dyn NonObjectSafe2 { + //~^ ERROR E0038 + loop {} +} + +fn takes_non_object_safe_box(obj: Box<dyn NonObjectSafe3>) { + //~^ ERROR E0038 +} + +fn return_non_object_safe_rc() -> std::rc::Rc<dyn NonObjectSafe4> { + //~^ ERROR E0038 + loop {} +} + +trait Trait {} + +impl Trait for dyn NonObjectSafe1 {} +//~^ ERROR E0038 + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.stderr b/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.stderr new file mode 100644 index 000000000..d76c697fe --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.stderr @@ -0,0 +1,83 @@ +error[E0038]: the trait `NonObjectSafe1` cannot be made into an object + --> $DIR/feature-gate-object_safe_for_dispatch.rs:18:39 + | +LL | fn takes_non_object_safe_ref<T>(obj: &dyn NonObjectSafe1) { + | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23 + | +LL | trait NonObjectSafe1: Sized {} + | -------------- ^^^^^ ...because it requires `Self: Sized` + | | + | this trait cannot be made into an object... + +error[E0038]: the trait `NonObjectSafe2` cannot be made into an object + --> $DIR/feature-gate-object_safe_for_dispatch.rs:22:45 + | +LL | fn return_non_object_safe_ref() -> &'static dyn NonObjectSafe2 { + | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe2` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/feature-gate-object_safe_for_dispatch.rs:7:8 + | +LL | trait NonObjectSafe2 { + | -------------- this trait cannot be made into an object... +LL | fn static_fn() {} + | ^^^^^^^^^ ...because associated function `static_fn` has no `self` parameter +help: consider turning `static_fn` into a method by giving it a `&self` argument + | +LL | fn static_fn(&self) {} + | +++++ +help: alternatively, consider constraining `static_fn` so it does not apply to trait objects + | +LL | fn static_fn() where Self: Sized {} + | +++++++++++++++++ + +error[E0038]: the trait `NonObjectSafe3` cannot be made into an object + --> $DIR/feature-gate-object_safe_for_dispatch.rs:27:39 + | +LL | fn takes_non_object_safe_box(obj: Box<dyn NonObjectSafe3>) { + | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe3` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/feature-gate-object_safe_for_dispatch.rs:11:8 + | +LL | trait NonObjectSafe3 { + | -------------- this trait cannot be made into an object... +LL | fn foo<T>(&self); + | ^^^ ...because method `foo` has generic type parameters + = help: consider moving `foo` to another trait + +error[E0038]: the trait `NonObjectSafe4` cannot be made into an object + --> $DIR/feature-gate-object_safe_for_dispatch.rs:31:47 + | +LL | fn return_non_object_safe_rc() -> std::rc::Rc<dyn NonObjectSafe4> { + | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe4` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/feature-gate-object_safe_for_dispatch.rs:15:22 + | +LL | trait NonObjectSafe4 { + | -------------- this trait cannot be made into an object... +LL | fn foo(&self, s: &Self); + | ^^^^^ ...because method `foo` references the `Self` type in this parameter + = help: consider moving `foo` to another trait + +error[E0038]: the trait `NonObjectSafe1` cannot be made into an object + --> $DIR/feature-gate-object_safe_for_dispatch.rs:38:16 + | +LL | impl Trait for dyn NonObjectSafe1 {} + | ^^^^^^^^^^^^^^^^^^ `NonObjectSafe1` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/feature-gate-object_safe_for_dispatch.rs:4:23 + | +LL | trait NonObjectSafe1: Sized {} + | -------------- ^^^^^ ...because it requires `Self: Sized` + | | + | this trait cannot be made into an object... + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/feature-gates/feature-gate-omit-gdb-pretty-printer-section.rs b/tests/ui/feature-gates/feature-gate-omit-gdb-pretty-printer-section.rs new file mode 100644 index 000000000..66bf79738 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-omit-gdb-pretty-printer-section.rs @@ -0,0 +1,2 @@ +#[omit_gdb_pretty_printer_section] //~ ERROR the `#[omit_gdb_pretty_printer_section]` attribute is +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-omit-gdb-pretty-printer-section.stderr b/tests/ui/feature-gates/feature-gate-omit-gdb-pretty-printer-section.stderr new file mode 100644 index 000000000..a5ec3599f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-omit-gdb-pretty-printer-section.stderr @@ -0,0 +1,11 @@ +error[E0658]: the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite + --> $DIR/feature-gate-omit-gdb-pretty-printer-section.rs:1:1 + | +LL | #[omit_gdb_pretty_printer_section] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(omit_gdb_pretty_printer_section)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-optimize_attribute.rs b/tests/ui/feature-gates/feature-gate-optimize_attribute.rs new file mode 100644 index 000000000..15aa3a6af --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-optimize_attribute.rs @@ -0,0 +1,18 @@ +#![crate_type="rlib"] +#![optimize(speed)] //~ ERROR the `#[optimize]` attribute is an experimental feature + +#[optimize(size)] //~ ERROR the `#[optimize]` attribute is an experimental feature +mod module { + +#[optimize(size)] //~ ERROR the `#[optimize]` attribute is an experimental feature +fn size() {} + +#[optimize(speed)] //~ ERROR the `#[optimize]` attribute is an experimental feature +fn speed() {} + +#[optimize(banana)] +//~^ ERROR the `#[optimize]` attribute is an experimental feature +//~| ERROR E0722 +fn not_known() {} + +} diff --git a/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr b/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr new file mode 100644 index 000000000..a3ced3515 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-optimize_attribute.stderr @@ -0,0 +1,55 @@ +error[E0658]: the `#[optimize]` attribute is an experimental feature + --> $DIR/feature-gate-optimize_attribute.rs:7:1 + | +LL | #[optimize(size)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information + = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable + +error[E0658]: the `#[optimize]` attribute is an experimental feature + --> $DIR/feature-gate-optimize_attribute.rs:10:1 + | +LL | #[optimize(speed)] + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information + = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable + +error[E0658]: the `#[optimize]` attribute is an experimental feature + --> $DIR/feature-gate-optimize_attribute.rs:13:1 + | +LL | #[optimize(banana)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information + = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable + +error[E0658]: the `#[optimize]` attribute is an experimental feature + --> $DIR/feature-gate-optimize_attribute.rs:4:1 + | +LL | #[optimize(size)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information + = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable + +error[E0658]: the `#[optimize]` attribute is an experimental feature + --> $DIR/feature-gate-optimize_attribute.rs:2:1 + | +LL | #![optimize(speed)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information + = help: add `#![feature(optimize_attribute)]` to the crate attributes to enable + +error[E0722]: invalid argument + --> $DIR/feature-gate-optimize_attribute.rs:13:12 + | +LL | #[optimize(banana)] + | ^^^^^^ + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0658, E0722. +For more information about an error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-overlapping_marker_traits.rs b/tests/ui/feature-gates/feature-gate-overlapping_marker_traits.rs new file mode 100644 index 000000000..6922d6f83 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-overlapping_marker_traits.rs @@ -0,0 +1,9 @@ +use std::fmt::{Debug, Display}; + +trait MyMarker {} + +impl<T: Display> MyMarker for T {} +impl<T: Debug> MyMarker for T {} +//~^ ERROR E0119 + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-overlapping_marker_traits.stderr b/tests/ui/feature-gates/feature-gate-overlapping_marker_traits.stderr new file mode 100644 index 000000000..0526c6dc8 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-overlapping_marker_traits.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `MyMarker` + --> $DIR/feature-gate-overlapping_marker_traits.rs:6:1 + | +LL | impl<T: Display> MyMarker for T {} + | ------------------------------- first implementation here +LL | impl<T: Debug> MyMarker for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs new file mode 100644 index 000000000..4c77180b7 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs @@ -0,0 +1,17 @@ +fn main() { + match 0usize { + //~^ ERROR non-exhaustive patterns: `_` not covered + //~| NOTE pattern `_` not covered + //~| NOTE the matched value is of type `usize` + //~| NOTE `usize` does not have a fixed maximum value + 0..=usize::MAX => {} + } + + match 0isize { + //~^ ERROR non-exhaustive patterns: `_` not covered + //~| NOTE pattern `_` not covered + //~| NOTE the matched value is of type `isize` + //~| NOTE `isize` does not have a fixed maximum value + isize::MIN..=isize::MAX => {} + } +} diff --git a/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr new file mode 100644 index 000000000..b55106833 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr @@ -0,0 +1,33 @@ +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/feature-gate-precise_pointer_size_matching.rs:2:11 + | +LL | match 0usize { + | ^^^^^^ pattern `_` not covered + | + = note: the matched value is of type `usize` + = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ 0..=usize::MAX => {} +LL + _ => todo!() + | + +error[E0004]: non-exhaustive patterns: `_` not covered + --> $DIR/feature-gate-precise_pointer_size_matching.rs:10:11 + | +LL | match 0isize { + | ^^^^^^ pattern `_` not covered + | + = note: the matched value is of type `isize` + = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ isize::MIN..=isize::MAX => {} +LL + _ => todo!() + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/feature-gates/feature-gate-prelude_import.rs b/tests/ui/feature-gates/feature-gate-prelude_import.rs new file mode 100644 index 000000000..a338bf973 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-prelude_import.rs @@ -0,0 +1,4 @@ +#[prelude_import] //~ ERROR `#[prelude_import]` is for use by rustc only +use std::prelude::v1::*; + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-prelude_import.stderr b/tests/ui/feature-gates/feature-gate-prelude_import.stderr new file mode 100644 index 000000000..8686aed8f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-prelude_import.stderr @@ -0,0 +1,11 @@ +error[E0658]: `#[prelude_import]` is for use by rustc only + --> $DIR/feature-gate-prelude_import.rs:1:1 + | +LL | #[prelude_import] + | ^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(prelude_import)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-profiler-runtime.rs b/tests/ui/feature-gates/feature-gate-profiler-runtime.rs new file mode 100644 index 000000000..f8a709634 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-profiler-runtime.rs @@ -0,0 +1,3 @@ +#![profiler_runtime] //~ ERROR the `#[profiler_runtime]` attribute is + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-profiler-runtime.stderr b/tests/ui/feature-gates/feature-gate-profiler-runtime.stderr new file mode 100644 index 000000000..18e6503c5 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-profiler-runtime.stderr @@ -0,0 +1,11 @@ +error[E0658]: the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate which contains the profiler runtime and will never be stable + --> $DIR/feature-gate-profiler-runtime.rs:1:1 + | +LL | #![profiler_runtime] + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(profiler_runtime)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-public_private_dependencies.rs b/tests/ui/feature-gates/feature-gate-public_private_dependencies.rs new file mode 100644 index 000000000..b8fb4b8dc --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-public_private_dependencies.rs @@ -0,0 +1,20 @@ +// This test is different from other feature gate tests. +// Instead of checking that an error occurs without the feature gate, +// it checks that *no* errors/warnings occurs without the feature gate. +// This is due to the fact that 'public_private_dependencies' just enables +// a lint, so disabling it shouldn't cause any code to stop compiling. + +// run-pass +// aux-build:pub_dep.rs + +// Without ![feature(public_private_dependencies)], +// this should do nothing/ +#![deny(exported_private_dependencies)] + +extern crate pub_dep; + +pub struct Foo { + pub field: pub_dep::PubType +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib-2.rs b/tests/ui/feature-gates/feature-gate-raw-dylib-2.rs new file mode 100644 index 000000000..fc47a9061 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-raw-dylib-2.rs @@ -0,0 +1,12 @@ +// only-x86 +#[link(name = "foo")] +extern "C" { + #[link_ordinal(42)] + //~^ ERROR: `#[link_ordinal]` is unstable on x86 + fn foo(); + #[link_ordinal(5)] + //~^ ERROR: `#[link_ordinal]` is unstable on x86 + static mut imported_variable: i32; +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib-2.stderr b/tests/ui/feature-gates/feature-gate-raw-dylib-2.stderr new file mode 100644 index 000000000..0e900760d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-raw-dylib-2.stderr @@ -0,0 +1,21 @@ +error[E0658]: `#[link_ordinal]` is unstable on x86 + --> $DIR/feature-gate-raw-dylib-2.rs:4:5 + | +LL | #[link_ordinal(42)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information + = help: add `#![feature(raw_dylib)]` to the crate attributes to enable + +error[E0658]: `#[link_ordinal]` is unstable on x86 + --> $DIR/feature-gate-raw-dylib-2.rs:7:5 + | +LL | #[link_ordinal(5)] + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information + = help: add `#![feature(raw_dylib)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.rs b/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.rs new file mode 100644 index 000000000..295f502d6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.rs @@ -0,0 +1,8 @@ +// only-windows +// only-x86 +#[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] +//~^ ERROR link kind `raw-dylib` is unstable on x86 +//~| ERROR import name type is unstable +extern "C" {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.stderr b/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.stderr new file mode 100644 index 000000000..d6b165b76 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-raw-dylib-import-name-type.stderr @@ -0,0 +1,21 @@ +error[E0658]: link kind `raw-dylib` is unstable on x86 + --> $DIR/feature-gate-raw-dylib-import-name-type.rs:3:29 + | +LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] + | ^^^^^^^^^^^ + | + = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information + = help: add `#![feature(raw_dylib)]` to the crate attributes to enable + +error[E0658]: import name type is unstable + --> $DIR/feature-gate-raw-dylib-import-name-type.rs:3:61 + | +LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] + | ^^^^^^^^^^^ + | + = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information + = help: add `#![feature(raw_dylib)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib.rs b/tests/ui/feature-gates/feature-gate-raw-dylib.rs new file mode 100644 index 000000000..291cca8fd --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-raw-dylib.rs @@ -0,0 +1,7 @@ +// only-windows +// only-x86 +#[link(name = "foo", kind = "raw-dylib")] +//~^ ERROR: link kind `raw-dylib` is unstable on x86 +extern "C" {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-raw-dylib.stderr b/tests/ui/feature-gates/feature-gate-raw-dylib.stderr new file mode 100644 index 000000000..f02241e49 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-raw-dylib.stderr @@ -0,0 +1,12 @@ +error[E0658]: link kind `raw-dylib` is unstable on x86 + --> $DIR/feature-gate-raw-dylib.rs:3:29 + | +LL | #[link(name = "foo", kind = "raw-dylib")] + | ^^^^^^^^^^^ + | + = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information + = help: add `#![feature(raw_dylib)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-register_tool.rs b/tests/ui/feature-gates/feature-gate-register_tool.rs new file mode 100644 index 000000000..e59959328 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-register_tool.rs @@ -0,0 +1,3 @@ +#![register_tool(tool)] //~ ERROR the `#[register_tool]` attribute is an experimental feature + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-register_tool.stderr b/tests/ui/feature-gates/feature-gate-register_tool.stderr new file mode 100644 index 000000000..9ffaaa8de --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-register_tool.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[register_tool]` attribute is an experimental feature + --> $DIR/feature-gate-register_tool.rs:1:1 + | +LL | #![register_tool(tool)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #66079 <https://github.com/rust-lang/rust/issues/66079> for more information + = help: add `#![feature(register_tool)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-repr-simd.rs b/tests/ui/feature-gates/feature-gate-repr-simd.rs new file mode 100644 index 000000000..c527404f5 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-repr-simd.rs @@ -0,0 +1,9 @@ +#[repr(simd)] //~ error: SIMD types are experimental +struct Foo(u64, u64); + +#[repr(C)] //~ ERROR conflicting representation hints +//~^ WARN this was previously accepted +#[repr(simd)] //~ error: SIMD types are experimental +struct Bar(u64, u64); + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-repr-simd.stderr b/tests/ui/feature-gates/feature-gate-repr-simd.stderr new file mode 100644 index 000000000..5b1270a19 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-repr-simd.stderr @@ -0,0 +1,35 @@ +error[E0658]: SIMD types are experimental and possibly buggy + --> $DIR/feature-gate-repr-simd.rs:1:1 + | +LL | #[repr(simd)] + | ^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(repr_simd)]` to the crate attributes to enable + +error[E0658]: SIMD types are experimental and possibly buggy + --> $DIR/feature-gate-repr-simd.rs:6:1 + | +LL | #[repr(simd)] + | ^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(repr_simd)]` to the crate attributes to enable + +error[E0566]: conflicting representation hints + --> $DIR/feature-gate-repr-simd.rs:4:8 + | +LL | #[repr(C)] + | ^ +LL | +LL | #[repr(simd)] + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #68585 <https://github.com/rust-lang/rust/issues/68585> + = note: `#[deny(conflicting_repr_hints)]` on by default + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0566, E0658. +For more information about an error, try `rustc --explain E0566`. diff --git a/tests/ui/feature-gates/feature-gate-repr128.rs b/tests/ui/feature-gates/feature-gate-repr128.rs new file mode 100644 index 000000000..0290874dd --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-repr128.rs @@ -0,0 +1,6 @@ +#[repr(u128)] +enum A { //~ ERROR repr with 128-bit type is unstable + A(u64) +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-repr128.stderr b/tests/ui/feature-gates/feature-gate-repr128.stderr new file mode 100644 index 000000000..3999a6d2d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-repr128.stderr @@ -0,0 +1,12 @@ +error[E0658]: repr with 128-bit type is unstable + --> $DIR/feature-gate-repr128.rs:2:1 + | +LL | enum A { + | ^^^^^^ + | + = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information + = help: add `#![feature(repr128)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs new file mode 100644 index 000000000..637765fff --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.rs @@ -0,0 +1,18 @@ +// edition:2021 + +// async_fn_in_trait is not enough to allow use of RPITIT +#![allow(incomplete_features)] +#![feature(async_fn_in_trait)] + +trait Foo { + fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return + fn baz() -> Box<impl std::fmt::Display>; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return +} + +// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also +// feature-gate-async_fn_in_trait.rs) +trait AsyncFoo { + async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr new file mode 100644 index 000000000..aeabed4a6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-return_position_impl_trait_in_trait.stderr @@ -0,0 +1,30 @@ +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return + --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17 + | +LL | fn bar() -> impl Sized; + | ^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return + --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21 + | +LL | fn baz() -> Box<impl std::fmt::Display>; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return + --> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23 + | +LL | async fn bar() -> impl Sized; + | ^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/feature-gates/feature-gate-rust_cold_cc.rs b/tests/ui/feature-gates/feature-gate-rust_cold_cc.rs new file mode 100644 index 000000000..9ba8e32ac --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rust_cold_cc.rs @@ -0,0 +1,21 @@ +#![crate_type = "lib"] + +extern "rust-cold" fn fu() {} //~ ERROR rust-cold is experimental + +trait T { + extern "rust-cold" fn mu(); //~ ERROR rust-cold is experimental + extern "rust-cold" fn dmu() {} //~ ERROR rust-cold is experimental +} + +struct S; +impl T for S { + extern "rust-cold" fn mu() {} //~ ERROR rust-cold is experimental +} + +impl S { + extern "rust-cold" fn imu() {} //~ ERROR rust-cold is experimental +} + +type TAU = extern "rust-cold" fn(); //~ ERROR rust-cold is experimental + +extern "rust-cold" {} //~ ERROR rust-cold is experimental diff --git a/tests/ui/feature-gates/feature-gate-rust_cold_cc.stderr b/tests/ui/feature-gates/feature-gate-rust_cold_cc.stderr new file mode 100644 index 000000000..ab7e5f036 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rust_cold_cc.stderr @@ -0,0 +1,66 @@ +error[E0658]: rust-cold is experimental and subject to change + --> $DIR/feature-gate-rust_cold_cc.rs:3:8 + | +LL | extern "rust-cold" fn fu() {} + | ^^^^^^^^^^^ + | + = note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information + = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable + +error[E0658]: rust-cold is experimental and subject to change + --> $DIR/feature-gate-rust_cold_cc.rs:6:12 + | +LL | extern "rust-cold" fn mu(); + | ^^^^^^^^^^^ + | + = note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information + = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable + +error[E0658]: rust-cold is experimental and subject to change + --> $DIR/feature-gate-rust_cold_cc.rs:7:12 + | +LL | extern "rust-cold" fn dmu() {} + | ^^^^^^^^^^^ + | + = note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information + = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable + +error[E0658]: rust-cold is experimental and subject to change + --> $DIR/feature-gate-rust_cold_cc.rs:12:12 + | +LL | extern "rust-cold" fn mu() {} + | ^^^^^^^^^^^ + | + = note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information + = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable + +error[E0658]: rust-cold is experimental and subject to change + --> $DIR/feature-gate-rust_cold_cc.rs:16:12 + | +LL | extern "rust-cold" fn imu() {} + | ^^^^^^^^^^^ + | + = note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information + = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable + +error[E0658]: rust-cold is experimental and subject to change + --> $DIR/feature-gate-rust_cold_cc.rs:19:19 + | +LL | type TAU = extern "rust-cold" fn(); + | ^^^^^^^^^^^ + | + = note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information + = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable + +error[E0658]: rust-cold is experimental and subject to change + --> $DIR/feature-gate-rust_cold_cc.rs:21:8 + | +LL | extern "rust-cold" {} + | ^^^^^^^^^^^ + | + = note: see issue #97544 <https://github.com/rust-lang/rust/issues/97544> for more information + = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-rustc-allow-const-fn-unstable.rs b/tests/ui/feature-gates/feature-gate-rustc-allow-const-fn-unstable.rs new file mode 100644 index 000000000..19d8fa87f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustc-allow-const-fn-unstable.rs @@ -0,0 +1,6 @@ +#![allow(unused_macros)] + +#[rustc_allow_const_fn_unstable()] //~ ERROR rustc_allow_const_fn_unstable side-steps +const fn foo() { } + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-rustc-allow-const-fn-unstable.stderr b/tests/ui/feature-gates/feature-gate-rustc-allow-const-fn-unstable.stderr new file mode 100644 index 000000000..a549cb64e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustc-allow-const-fn-unstable.stderr @@ -0,0 +1,12 @@ +error[E0658]: rustc_allow_const_fn_unstable side-steps feature gating and stability checks + --> $DIR/feature-gate-rustc-allow-const-fn-unstable.rs:3:1 + | +LL | #[rustc_allow_const_fn_unstable()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #69399 <https://github.com/rust-lang/rust/issues/69399> for more information + = help: add `#![feature(rustc_allow_const_fn_unstable)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-rustc-attrs-1.rs b/tests/ui/feature-gates/feature-gate-rustc-attrs-1.rs new file mode 100644 index 000000000..667bc9f8d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustc-attrs-1.rs @@ -0,0 +1,7 @@ +// Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate. + +#[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable +#[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable +#[rustc_nonnull_optimization_guaranteed] //~ ERROR the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable niche optimizations in libcore and libstd and will never be stable + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr b/tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr new file mode 100644 index 000000000..45a095903 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustc-attrs-1.stderr @@ -0,0 +1,27 @@ +error[E0658]: the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable + --> $DIR/feature-gate-rustc-attrs-1.rs:3:1 + | +LL | #[rustc_variance] + | ^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable + +error[E0658]: the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable + --> $DIR/feature-gate-rustc-attrs-1.rs:4:1 + | +LL | #[rustc_error] + | ^^^^^^^^^^^^^^ + | + = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable + +error[E0658]: the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable niche optimizations in libcore and libstd and will never be stable + --> $DIR/feature-gate-rustc-attrs-1.rs:5:1 + | +LL | #[rustc_nonnull_optimization_guaranteed] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-rustc-attrs.rs b/tests/ui/feature-gates/feature-gate-rustc-attrs.rs new file mode 100644 index 000000000..c985298a3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustc-attrs.rs @@ -0,0 +1,23 @@ +// Test that `#[rustc_*]` attributes are gated by `rustc_attrs` feature gate. + +#![feature(decl_macro)] + +mod rustc { pub macro unknown() {} } +mod unknown { pub macro rustc() {} } + +#[rustc::unknown] +//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler +//~| ERROR expected attribute, found macro `rustc::unknown` +fn f() {} + +#[unknown::rustc] +//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler +//~| ERROR expected attribute, found macro `unknown::rustc` +fn g() {} + +#[rustc_dummy] +//~^ ERROR the `#[rustc_dummy]` attribute is just used for rustc unit tests +#[rustc_unknown] +//~^ ERROR attributes starting with `rustc` are reserved for use by the `rustc` compiler +//~| ERROR cannot find attribute `rustc_unknown` in this scope +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-rustc-attrs.stderr b/tests/ui/feature-gates/feature-gate-rustc-attrs.stderr new file mode 100644 index 000000000..1517a7a5c --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustc-attrs.stderr @@ -0,0 +1,47 @@ +error: attributes starting with `rustc` are reserved for use by the `rustc` compiler + --> $DIR/feature-gate-rustc-attrs.rs:8:3 + | +LL | #[rustc::unknown] + | ^^^^^ + +error: expected attribute, found macro `rustc::unknown` + --> $DIR/feature-gate-rustc-attrs.rs:8:3 + | +LL | #[rustc::unknown] + | ^^^^^^^^^^^^^^ not an attribute + +error: attributes starting with `rustc` are reserved for use by the `rustc` compiler + --> $DIR/feature-gate-rustc-attrs.rs:13:12 + | +LL | #[unknown::rustc] + | ^^^^^ + +error: expected attribute, found macro `unknown::rustc` + --> $DIR/feature-gate-rustc-attrs.rs:13:3 + | +LL | #[unknown::rustc] + | ^^^^^^^^^^^^^^ not an attribute + +error: attributes starting with `rustc` are reserved for use by the `rustc` compiler + --> $DIR/feature-gate-rustc-attrs.rs:20:3 + | +LL | #[rustc_unknown] + | ^^^^^^^^^^^^^ + +error: cannot find attribute `rustc_unknown` in this scope + --> $DIR/feature-gate-rustc-attrs.rs:20:3 + | +LL | #[rustc_unknown] + | ^^^^^^^^^^^^^ + +error[E0658]: the `#[rustc_dummy]` attribute is just used for rustc unit tests and will never be stable + --> $DIR/feature-gate-rustc-attrs.rs:18:1 + | +LL | #[rustc_dummy] + | ^^^^^^^^^^^^^^ + | + = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-rustc_const_unstable.rs b/tests/ui/feature-gates/feature-gate-rustc_const_unstable.rs new file mode 100644 index 000000000..d7daaaaa1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustc_const_unstable.rs @@ -0,0 +1,7 @@ +// Test internal const fn feature gate. + +#[rustc_const_unstable(feature="fzzzzzt")] //~ stability attributes may not be used outside +pub const fn bazinga() {} + +fn main() { +} diff --git a/tests/ui/feature-gates/feature-gate-rustc_const_unstable.stderr b/tests/ui/feature-gates/feature-gate-rustc_const_unstable.stderr new file mode 100644 index 000000000..48493b786 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustc_const_unstable.stderr @@ -0,0 +1,9 @@ +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/feature-gate-rustc_const_unstable.rs:3:1 + | +LL | #[rustc_const_unstable(feature="fzzzzzt")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs b/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs new file mode 100644 index 000000000..58306a4cf --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs @@ -0,0 +1,10 @@ +#[doc(keyword = "match")] //~ ERROR: `#[doc(keyword)]` is meant for internal use only +/// wonderful +mod foo {} + +trait Mine {} + +#[doc(fake_variadic)] //~ ERROR: `#[doc(fake_variadic)]` is meant for internal use only +impl<T> Mine for (T,) {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr b/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr new file mode 100644 index 000000000..c4272a2c0 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr @@ -0,0 +1,21 @@ +error[E0658]: `#[doc(keyword)]` is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:1:1 + | +LL | #[doc(keyword = "match")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #90418 <https://github.com/rust-lang/rust/issues/90418> for more information + = help: add `#![feature(rustdoc_internals)]` to the crate attributes to enable + +error[E0658]: `#[doc(fake_variadic)]` is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:7:1 + | +LL | #[doc(fake_variadic)] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #90418 <https://github.com/rust-lang/rust/issues/90418> for more information + = help: add `#![feature(rustdoc_internals)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-simd-ffi.rs b/tests/ui/feature-gates/feature-gate-simd-ffi.rs new file mode 100644 index 000000000..abffa4a10 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-simd-ffi.rs @@ -0,0 +1,13 @@ +#![feature(repr_simd)] +#![allow(dead_code)] + +#[repr(simd)] +#[derive(Copy, Clone)] +struct LocalSimd(u8, u8); + +extern "C" { + fn baz() -> LocalSimd; //~ ERROR use of SIMD type + fn qux(x: LocalSimd); //~ ERROR use of SIMD type +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-simd-ffi.stderr b/tests/ui/feature-gates/feature-gate-simd-ffi.stderr new file mode 100644 index 000000000..8166b6baa --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-simd-ffi.stderr @@ -0,0 +1,18 @@ +error: use of SIMD type `LocalSimd` in FFI is highly experimental and may result in invalid code + --> $DIR/feature-gate-simd-ffi.rs:9:17 + | +LL | fn baz() -> LocalSimd; + | ^^^^^^^^^ + | + = help: add `#![feature(simd_ffi)]` to the crate attributes to enable + +error: use of SIMD type `LocalSimd` in FFI is highly experimental and may result in invalid code + --> $DIR/feature-gate-simd-ffi.rs:10:15 + | +LL | fn qux(x: LocalSimd); + | ^^^^^^^^^ + | + = help: add `#![feature(simd_ffi)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + diff --git a/tests/ui/feature-gates/feature-gate-simd.rs b/tests/ui/feature-gates/feature-gate-simd.rs new file mode 100644 index 000000000..d01d33de2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-simd.rs @@ -0,0 +1,11 @@ +// pretty-expanded FIXME #23616 + +#[repr(simd)] //~ ERROR SIMD types are experimental +struct RGBA { + r: f32, + g: f32, + b: f32, + a: f32 +} + +pub fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-simd.stderr b/tests/ui/feature-gates/feature-gate-simd.stderr new file mode 100644 index 000000000..6e0e0b270 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-simd.stderr @@ -0,0 +1,12 @@ +error[E0658]: SIMD types are experimental and possibly buggy + --> $DIR/feature-gate-simd.rs:3:1 + | +LL | #[repr(simd)] + | ^^^^^^^^^^^^^ + | + = note: see issue #27731 <https://github.com/rust-lang/rust/issues/27731> for more information + = help: add `#![feature(repr_simd)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-staged_api.rs b/tests/ui/feature-gates/feature-gate-staged_api.rs new file mode 100644 index 000000000..2571ab5d1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-staged_api.rs @@ -0,0 +1,14 @@ +#![stable(feature = "a", since = "b")] +//~^ ERROR stability attributes may not be used outside of the standard library +mod inner_private_module { + // UnnameableTypeAlias isn't marked as reachable, so no stability annotation is required here + pub type UnnameableTypeAlias = u8; +} + +#[stable(feature = "a", since = "b")] +//~^ ERROR stability attributes may not be used outside of the standard library +pub fn f() -> inner_private_module::UnnameableTypeAlias { + 0 +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-staged_api.stderr b/tests/ui/feature-gates/feature-gate-staged_api.stderr new file mode 100644 index 000000000..951bb5a17 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-staged_api.stderr @@ -0,0 +1,15 @@ +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/feature-gate-staged_api.rs:8:1 + | +LL | #[stable(feature = "a", since = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/feature-gate-staged_api.rs:1:1 + | +LL | #![stable(feature = "a", since = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/feature-gates/feature-gate-start.rs b/tests/ui/feature-gates/feature-gate-start.rs new file mode 100644 index 000000000..e617f1c47 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-start.rs @@ -0,0 +1,3 @@ +#[start] +fn foo(_: isize, _: *const *const u8) -> isize { 0 } +//~^ ERROR `#[start]` functions are experimental diff --git a/tests/ui/feature-gates/feature-gate-start.stderr b/tests/ui/feature-gates/feature-gate-start.stderr new file mode 100644 index 000000000..eec9d1a29 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-start.stderr @@ -0,0 +1,12 @@ +error[E0658]: `#[start]` functions are experimental and their signature may change over time + --> $DIR/feature-gate-start.rs:2:1 + | +LL | fn foo(_: isize, _: *const *const u8) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #29633 <https://github.com/rust-lang/rust/issues/29633> for more information + = help: add `#![feature(start)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs new file mode 100644 index 000000000..f213e8933 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs @@ -0,0 +1,4 @@ +const X: i32 = #[allow(dead_code)] 8; +//~^ ERROR attributes on expressions are experimental + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr new file mode 100644 index 000000000..57ffaed78 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr @@ -0,0 +1,12 @@ +error[E0658]: attributes on expressions are experimental + --> $DIR/feature-gate-stmt_expr_attributes.rs:1:16 + | +LL | const X: i32 = #[allow(dead_code)] 8; + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information + = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-strict_provenance.rs b/tests/ui/feature-gates/feature-gate-strict_provenance.rs new file mode 100644 index 000000000..75d0ee570 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-strict_provenance.rs @@ -0,0 +1,19 @@ +// check-pass + +#![deny(fuzzy_provenance_casts)] +//~^ WARNING unknown lint: `fuzzy_provenance_casts` +//~| WARNING unknown lint: `fuzzy_provenance_casts` +//~| WARNING unknown lint: `fuzzy_provenance_casts` +#![deny(lossy_provenance_casts)] +//~^ WARNING unknown lint: `lossy_provenance_casts` +//~| WARNING unknown lint: `lossy_provenance_casts` +//~| WARNING unknown lint: `lossy_provenance_casts` + +fn main() { + // no warnings emitted since the lints are not activated + + let _dangling = 16_usize as *const u8; + + let x: u8 = 37; + let _addr: usize = &x as *const u8 as usize; +} diff --git a/tests/ui/feature-gates/feature-gate-strict_provenance.stderr b/tests/ui/feature-gates/feature-gate-strict_provenance.stderr new file mode 100644 index 000000000..751da87cc --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-strict_provenance.stderr @@ -0,0 +1,63 @@ +warning: unknown lint: `fuzzy_provenance_casts` + --> $DIR/feature-gate-strict_provenance.rs:3:1 + | +LL | #![deny(fuzzy_provenance_casts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `fuzzy_provenance_casts` lint is unstable + = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information + = help: add `#![feature(strict_provenance)]` to the crate attributes to enable + = note: `#[warn(unknown_lints)]` on by default + +warning: unknown lint: `lossy_provenance_casts` + --> $DIR/feature-gate-strict_provenance.rs:7:1 + | +LL | #![deny(lossy_provenance_casts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `lossy_provenance_casts` lint is unstable + = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information + = help: add `#![feature(strict_provenance)]` to the crate attributes to enable + +warning: unknown lint: `fuzzy_provenance_casts` + --> $DIR/feature-gate-strict_provenance.rs:3:1 + | +LL | #![deny(fuzzy_provenance_casts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `fuzzy_provenance_casts` lint is unstable + = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information + = help: add `#![feature(strict_provenance)]` to the crate attributes to enable + +warning: unknown lint: `lossy_provenance_casts` + --> $DIR/feature-gate-strict_provenance.rs:7:1 + | +LL | #![deny(lossy_provenance_casts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `lossy_provenance_casts` lint is unstable + = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information + = help: add `#![feature(strict_provenance)]` to the crate attributes to enable + +warning: unknown lint: `fuzzy_provenance_casts` + --> $DIR/feature-gate-strict_provenance.rs:3:1 + | +LL | #![deny(fuzzy_provenance_casts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `fuzzy_provenance_casts` lint is unstable + = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information + = help: add `#![feature(strict_provenance)]` to the crate attributes to enable + +warning: unknown lint: `lossy_provenance_casts` + --> $DIR/feature-gate-strict_provenance.rs:7:1 + | +LL | #![deny(lossy_provenance_casts)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `lossy_provenance_casts` lint is unstable + = note: see issue #95228 <https://github.com/rust-lang/rust/issues/95228> for more information + = help: add `#![feature(strict_provenance)]` to the crate attributes to enable + +warning: 6 warnings emitted + diff --git a/tests/ui/feature-gates/feature-gate-test_unstable_lint.rs b/tests/ui/feature-gates/feature-gate-test_unstable_lint.rs new file mode 100644 index 000000000..c398394cb --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-test_unstable_lint.rs @@ -0,0 +1,9 @@ +// check-pass + +// `test_unstable_lint` is for testing and should never be stabilized. +#![allow(test_unstable_lint)] +//~^ WARNING unknown lint: `test_unstable_lint` +//~| WARNING unknown lint: `test_unstable_lint` +//~| WARNING unknown lint: `test_unstable_lint` + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-test_unstable_lint.stderr b/tests/ui/feature-gates/feature-gate-test_unstable_lint.stderr new file mode 100644 index 000000000..b4d6aa658 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-test_unstable_lint.stderr @@ -0,0 +1,30 @@ +warning: unknown lint: `test_unstable_lint` + --> $DIR/feature-gate-test_unstable_lint.rs:4:1 + | +LL | #![allow(test_unstable_lint)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `test_unstable_lint` lint is unstable + = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable + = note: `#[warn(unknown_lints)]` on by default + +warning: unknown lint: `test_unstable_lint` + --> $DIR/feature-gate-test_unstable_lint.rs:4:1 + | +LL | #![allow(test_unstable_lint)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `test_unstable_lint` lint is unstable + = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable + +warning: unknown lint: `test_unstable_lint` + --> $DIR/feature-gate-test_unstable_lint.rs:4:1 + | +LL | #![allow(test_unstable_lint)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `test_unstable_lint` lint is unstable + = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable + +warning: 3 warnings emitted + diff --git a/tests/ui/feature-gates/feature-gate-thread_local.rs b/tests/ui/feature-gates/feature-gate-thread_local.rs new file mode 100644 index 000000000..0efae1f6b --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-thread_local.rs @@ -0,0 +1,11 @@ +// Test that `#[thread_local]` attribute is gated by `thread_local` +// feature gate. +// +// (Note that the `thread_local!` macro is explicitly *not* gated; it +// is given permission to expand into this unstable attribute even +// when the surrounding context does not have permission to use it.) + +#[thread_local] //~ ERROR `#[thread_local]` is an experimental feature +static FOO: i32 = 3; + +pub fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-thread_local.stderr b/tests/ui/feature-gates/feature-gate-thread_local.stderr new file mode 100644 index 000000000..6352e9087 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-thread_local.stderr @@ -0,0 +1,12 @@ +error[E0658]: `#[thread_local]` is an experimental feature, and does not currently handle destructors + --> $DIR/feature-gate-thread_local.rs:8:1 + | +LL | #[thread_local] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #29594 <https://github.com/rust-lang/rust/issues/29594> for more information + = help: add `#![feature(thread_local)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-trace_macros.rs b/tests/ui/feature-gates/feature-gate-trace_macros.rs new file mode 100644 index 000000000..07159b7b5 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-trace_macros.rs @@ -0,0 +1,3 @@ +fn main() { + trace_macros!(true); //~ ERROR: `trace_macros` is not stable +} diff --git a/tests/ui/feature-gates/feature-gate-trace_macros.stderr b/tests/ui/feature-gates/feature-gate-trace_macros.stderr new file mode 100644 index 000000000..3978d4111 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-trace_macros.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change + --> $DIR/feature-gate-trace_macros.rs:2:5 + | +LL | trace_macros!(true); + | ^^^^^^^^^^^^ + | + = note: see issue #29598 <https://github.com/rust-lang/rust/issues/29598> for more information + = help: add `#![feature(trace_macros)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-trait-alias.rs b/tests/ui/feature-gates/feature-gate-trait-alias.rs new file mode 100644 index 000000000..819085add --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-trait-alias.rs @@ -0,0 +1,4 @@ +trait Foo = Default; +//~^ ERROR trait aliases are experimental + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-trait-alias.stderr b/tests/ui/feature-gates/feature-gate-trait-alias.stderr new file mode 100644 index 000000000..41cd6dbd8 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-trait-alias.stderr @@ -0,0 +1,12 @@ +error[E0658]: trait aliases are experimental + --> $DIR/feature-gate-trait-alias.rs:1:1 + | +LL | trait Foo = Default; + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information + = help: add `#![feature(trait_alias)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-trait_upcasting.rs b/tests/ui/feature-gates/feature-gate-trait_upcasting.rs new file mode 100644 index 000000000..e4102f1cf --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-trait_upcasting.rs @@ -0,0 +1,13 @@ +trait Foo {} + +trait Bar: Foo {} + +impl Foo for () {} + +impl Bar for () {} + +fn main() { + let bar: &dyn Bar = &(); + let foo: &dyn Foo = bar; + //~^ ERROR trait upcasting coercion is experimental [E0658] +} diff --git a/tests/ui/feature-gates/feature-gate-trait_upcasting.stderr b/tests/ui/feature-gates/feature-gate-trait_upcasting.stderr new file mode 100644 index 000000000..93afa7845 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-trait_upcasting.stderr @@ -0,0 +1,13 @@ +error[E0658]: cannot cast `dyn Bar` to `dyn Foo`, trait upcasting coercion is experimental + --> $DIR/feature-gate-trait_upcasting.rs:11:25 + | +LL | let foo: &dyn Foo = bar; + | ^^^ + | + = note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information + = help: add `#![feature(trait_upcasting)]` to the crate attributes to enable + = note: required when coercing `&dyn Bar` into `&dyn Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-transparent_unions.rs b/tests/ui/feature-gates/feature-gate-transparent_unions.rs new file mode 100644 index 000000000..73cac0a49 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-transparent_unions.rs @@ -0,0 +1,7 @@ +#[repr(transparent)] +union OkButUnstableUnion { //~ ERROR transparent unions are unstable + field: u8, + zst: (), +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-transparent_unions.stderr b/tests/ui/feature-gates/feature-gate-transparent_unions.stderr new file mode 100644 index 000000000..65c8fe052 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-transparent_unions.stderr @@ -0,0 +1,12 @@ +error[E0658]: transparent unions are unstable + --> $DIR/feature-gate-transparent_unions.rs:2:1 + | +LL | union OkButUnstableUnion { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #60405 <https://github.com/rust-lang/rust/issues/60405> for more information + = help: add `#![feature(transparent_unions)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-trivial_bounds-lint.rs b/tests/ui/feature-gates/feature-gate-trivial_bounds-lint.rs new file mode 100644 index 000000000..8f68d5d6d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-trivial_bounds-lint.rs @@ -0,0 +1,8 @@ +// run-pass + +#![allow(unused)] +#![deny(trivial_bounds)] // Ignored without the trivial_bounds feature flag. + +struct A where i32: Copy; + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-trivial_bounds.rs b/tests/ui/feature-gates/feature-gate-trivial_bounds.rs new file mode 100644 index 000000000..3dbaf5dea --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-trivial_bounds.rs @@ -0,0 +1,69 @@ +#![allow(unused)] +#![allow(type_alias_bounds)] + +pub trait Foo { + fn test(&self); +} + +fn generic_function<X: Foo>(x: X) {} + +enum E where i32: Foo { V } //~ ERROR + +struct S where i32: Foo; //~ ERROR + +trait T where i32: Foo {} //~ ERROR + +union U where i32: Foo { f: i32 } //~ ERROR + +type Y where i32: Foo = (); // OK - bound is ignored + +impl Foo for () where i32: Foo { //~ ERROR + fn test(&self) { + 3i32.test(); + Foo::test(&4i32); + generic_function(5i32); + } +} + +fn f() where i32: Foo //~ ERROR +{ + let s = S; + 3i32.test(); + Foo::test(&4i32); + generic_function(5i32); +} + +fn use_op(s: String) -> String where String: ::std::ops::Neg<Output=String> { //~ ERROR + -s +} + +fn use_for() where i32: Iterator { //~ ERROR + for _ in 2i32 {} +} + +trait A {} + +impl A for i32 {} + +struct Dst<X: ?Sized> { + x: X, +} + +struct TwoStrs(str, str) where str: Sized; //~ ERROR + + +fn unsized_local() where Dst<dyn A>: Sized { //~ ERROR + let x: Dst<dyn A> = *(Box::new(Dst { x: 1 }) as Box<Dst<dyn A>>); +} + +fn return_str() -> str where str: Sized { //~ ERROR + *"Sized".to_string().into_boxed_str() +} + +// This is currently accepted because the function pointer isn't +// considered global. +fn global_hr(x: fn(&())) where fn(&()): Foo { // OK + x.test(); +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr new file mode 100644 index 000000000..1b87ebd9f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -0,0 +1,118 @@ +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/feature-gate-trivial_bounds.rs:10:14 + | +LL | enum E where i32: Foo { V } + | ^^^^^^^^ the trait `Foo` is not implemented for `i32` + | + = help: the trait `Foo` is implemented for `()` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/feature-gate-trivial_bounds.rs:12:16 + | +LL | struct S where i32: Foo; + | ^^^^^^^^ the trait `Foo` is not implemented for `i32` + | + = help: the trait `Foo` is implemented for `()` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/feature-gate-trivial_bounds.rs:14:15 + | +LL | trait T where i32: Foo {} + | ^^^^^^^^ the trait `Foo` is not implemented for `i32` + | + = help: the trait `Foo` is implemented for `()` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/feature-gate-trivial_bounds.rs:16:15 + | +LL | union U where i32: Foo { f: i32 } + | ^^^^^^^^ the trait `Foo` is not implemented for `i32` + | + = help: the trait `Foo` is implemented for `()` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/feature-gate-trivial_bounds.rs:20:23 + | +LL | impl Foo for () where i32: Foo { + | ^^^^^^^^ the trait `Foo` is not implemented for `i32` + | + = help: the trait `Foo` is implemented for `()` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/feature-gate-trivial_bounds.rs:28:14 + | +LL | fn f() where i32: Foo + | ^^^^^^^^ the trait `Foo` is not implemented for `i32` + | + = help: the trait `Foo` is implemented for `()` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the trait bound `String: Neg` is not satisfied + --> $DIR/feature-gate-trivial_bounds.rs:36:38 + | +LL | fn use_op(s: String) -> String where String: ::std::ops::Neg<Output=String> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Neg` is not implemented for `String` + | + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: `i32` is not an iterator + --> $DIR/feature-gate-trivial_bounds.rs:40:20 + | +LL | fn use_for() where i32: Iterator { + | ^^^^^^^^^^^^^ `i32` is not an iterator + | + = help: the trait `Iterator` is not implemented for `i32` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/feature-gate-trivial_bounds.rs:52:32 + | +LL | struct TwoStrs(str, str) where str: Sized; + | ^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time + --> $DIR/feature-gate-trivial_bounds.rs:55:26 + | +LL | fn unsized_local() where Dst<dyn A>: Sized { + | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `Dst<(dyn A + 'static)>`, the trait `Sized` is not implemented for `(dyn A + 'static)` +note: required because it appears within the type `Dst<(dyn A + 'static)>` + --> $DIR/feature-gate-trivial_bounds.rs:48:8 + | +LL | struct Dst<X: ?Sized> { + | ^^^ + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/feature-gate-trivial_bounds.rs:59:30 + | +LL | fn return_str() -> str where str: Sized { + | ^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + +error: aborting due to 11 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/feature-gates/feature-gate-try_blocks.rs b/tests/ui/feature-gates/feature-gate-try_blocks.rs new file mode 100644 index 000000000..06cadd82c --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-try_blocks.rs @@ -0,0 +1,9 @@ +// compile-flags: --edition 2018 + +pub fn main() { + let try_result: Option<_> = try { //~ ERROR `try` expression is experimental + let x = 5; + x + }; + assert_eq!(try_result, Some(5)); +} diff --git a/tests/ui/feature-gates/feature-gate-try_blocks.stderr b/tests/ui/feature-gates/feature-gate-try_blocks.stderr new file mode 100644 index 000000000..022409f95 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-try_blocks.stderr @@ -0,0 +1,16 @@ +error[E0658]: `try` expression is experimental + --> $DIR/feature-gate-try_blocks.rs:4:33 + | +LL | let try_result: Option<_> = try { + | _________________________________^ +LL | | let x = 5; +LL | | x +LL | | }; + | |_____^ + | + = note: see issue #31436 <https://github.com/rust-lang/rust/issues/31436> for more information + = help: add `#![feature(try_blocks)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-type_alias_impl_trait.rs b/tests/ui/feature-gates/feature-gate-type_alias_impl_trait.rs new file mode 100644 index 000000000..6dfd7f684 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-type_alias_impl_trait.rs @@ -0,0 +1,34 @@ +// ignore-compare-mode-chalk +// check-pass +#![feature(type_alias_impl_trait)] +use std::fmt::Debug; + +type Foo = impl Debug; + +struct Bar(Foo); +fn define() -> Bar { + Bar(42) +} + +type Foo2 = impl Debug; + +fn define2() { + let x = || -> Foo2 { 42 }; +} + +type Foo3 = impl Debug; + +fn define3(x: Foo3) { + let y: i32 = x; +} +fn define3_1() { + define3(42) +} + +type Foo4 = impl Debug; + +fn define4() { + let y: Foo4 = 42; +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-type_ascription.rs b/tests/ui/feature-gates/feature-gate-type_ascription.rs new file mode 100644 index 000000000..7a5971573 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-type_ascription.rs @@ -0,0 +1,5 @@ +// Type ascription is unstable + +fn main() { + let a = 10: u8; //~ ERROR type ascription is experimental +} diff --git a/tests/ui/feature-gates/feature-gate-type_ascription.stderr b/tests/ui/feature-gates/feature-gate-type_ascription.stderr new file mode 100644 index 000000000..615d5b9a1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-type_ascription.stderr @@ -0,0 +1,12 @@ +error[E0658]: type ascription is experimental + --> $DIR/feature-gate-type_ascription.rs:4:13 + | +LL | let a = 10: u8; + | ^^^^^^ + | + = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information + = help: add `#![feature(type_ascription)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs new file mode 100644 index 000000000..eecf2046c --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs @@ -0,0 +1,37 @@ +// Test that manual impls of the `Fn` traits are not possible without +// a feature gate. In fact, the specialized check for these cases +// never triggers (yet), because they encounter other problems around +// angle bracket vs parentheses notation. + +#![feature(fn_traits)] + +struct Foo; +impl Fn<()> for Foo { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change +//~| ERROR manual implementations of `Fn` are experimental + extern "rust-call" fn call(self, args: ()) -> () {} + //~^ ERROR rust-call ABI is subject to change +} +struct Foo1; +impl FnOnce() for Foo1 { +//~^ ERROR associated type bindings are not allowed here +//~| ERROR manual implementations of `FnOnce` are experimental + extern "rust-call" fn call_once(self, args: ()) -> () {} + //~^ ERROR rust-call ABI is subject to change +} +struct Bar; +impl FnMut<()> for Bar { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change +//~| ERROR manual implementations of `FnMut` are experimental + extern "rust-call" fn call_mut(&self, args: ()) -> () {} + //~^ ERROR rust-call ABI is subject to change +} +struct Baz; +impl FnOnce<()> for Baz { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change +//~| ERROR manual implementations of `FnOnce` are experimental + extern "rust-call" fn call_once(&self, args: ()) -> () {} + //~^ ERROR rust-call ABI is subject to change +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr new file mode 100644 index 000000000..f647380ef --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -0,0 +1,105 @@ +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:12:12 + | +LL | extern "rust-call" fn call(self, args: ()) -> () {} + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:19:12 + | +LL | extern "rust-call" fn call_once(self, args: ()) -> () {} + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:26:12 + | +LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:33:12 + | +LL | extern "rust-call" fn call_once(&self, args: ()) -> () {} + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:9:6 + | +LL | impl Fn<()> for Foo { + | ^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0183]: manual implementations of `Fn` are experimental + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:9:6 + | +LL | impl Fn<()> for Foo { + | ^^^^^^ manual implementations of `Fn` are experimental + | + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0183]: manual implementations of `FnOnce` are experimental + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:16:6 + | +LL | impl FnOnce() for Foo1 { + | ^^^^^^^^ manual implementations of `FnOnce` are experimental + | + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0229]: associated type bindings are not allowed here + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:16:6 + | +LL | impl FnOnce() for Foo1 { + | ^^^^^^^^ associated type not allowed here + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:23:6 + | +LL | impl FnMut<()> for Bar { + | ^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0183]: manual implementations of `FnMut` are experimental + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:23:6 + | +LL | impl FnMut<()> for Bar { + | ^^^^^^^^^ manual implementations of `FnMut` are experimental + | + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:6 + | +LL | impl FnOnce<()> for Baz { + | ^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0183]: manual implementations of `FnOnce` are experimental + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:6 + | +LL | impl FnOnce<()> for Baz { + | ^^^^^^^^^^ manual implementations of `FnOnce` are experimental + | + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error: aborting due to 12 previous errors + +Some errors have detailed explanations: E0183, E0229, E0658. +For more information about an error, try `rustc --explain E0183`. diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-method-calls.rs b/tests/ui/feature-gates/feature-gate-unboxed-closures-method-calls.rs new file mode 100644 index 000000000..42f7c5f0f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-method-calls.rs @@ -0,0 +1,9 @@ +#![allow(dead_code)] + +fn foo<F: Fn()>(mut f: F) { + f.call(()); //~ ERROR use of unstable library feature 'fn_traits' + f.call_mut(()); //~ ERROR use of unstable library feature 'fn_traits' + f.call_once(()); //~ ERROR use of unstable library feature 'fn_traits' +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-method-calls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-method-calls.stderr new file mode 100644 index 000000000..c61382c64 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-method-calls.stderr @@ -0,0 +1,30 @@ +error[E0658]: use of unstable library feature 'fn_traits' + --> $DIR/feature-gate-unboxed-closures-method-calls.rs:4:7 + | +LL | f.call(()); + | ^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(fn_traits)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'fn_traits' + --> $DIR/feature-gate-unboxed-closures-method-calls.rs:5:7 + | +LL | f.call_mut(()); + | ^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(fn_traits)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'fn_traits' + --> $DIR/feature-gate-unboxed-closures-method-calls.rs:6:7 + | +LL | f.call_once(()); + | ^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(fn_traits)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-ufcs-calls.rs b/tests/ui/feature-gates/feature-gate-unboxed-closures-ufcs-calls.rs new file mode 100644 index 000000000..25c90492e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-ufcs-calls.rs @@ -0,0 +1,9 @@ +#![allow(dead_code)] + +fn foo<F: Fn()>(mut f: F) { + Fn::call(&f, ()); //~ ERROR use of unstable library feature 'fn_traits' + FnMut::call_mut(&mut f, ()); //~ ERROR use of unstable library feature 'fn_traits' + FnOnce::call_once(f, ()); //~ ERROR use of unstable library feature 'fn_traits' +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-ufcs-calls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-ufcs-calls.stderr new file mode 100644 index 000000000..50eaeecde --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-ufcs-calls.stderr @@ -0,0 +1,30 @@ +error[E0658]: use of unstable library feature 'fn_traits' + --> $DIR/feature-gate-unboxed-closures-ufcs-calls.rs:4:5 + | +LL | Fn::call(&f, ()); + | ^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(fn_traits)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'fn_traits' + --> $DIR/feature-gate-unboxed-closures-ufcs-calls.rs:5:5 + | +LL | FnMut::call_mut(&mut f, ()); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(fn_traits)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'fn_traits' + --> $DIR/feature-gate-unboxed-closures-ufcs-calls.rs:6:5 + | +LL | FnOnce::call_once(f, ()); + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(fn_traits)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures.rs b/tests/ui/feature-gates/feature-gate-unboxed-closures.rs new file mode 100644 index 000000000..ebc5a2536 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures.rs @@ -0,0 +1,18 @@ +#![feature(fn_traits)] + +struct Test; + +impl FnOnce<(u32, u32)> for Test { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change +//~| ERROR manual implementations of `FnOnce` are experimental + type Output = u32; + + extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { + a + b + } + //~^^^ ERROR rust-call ABI is subject to change +} + +fn main() { + assert_eq!(Test(1u32, 2u32), 3u32); +} diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures.stderr new file mode 100644 index 000000000..a763c28de --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures.stderr @@ -0,0 +1,30 @@ +error[E0658]: rust-call ABI is subject to change + --> $DIR/feature-gate-unboxed-closures.rs:10:12 + | +LL | extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { + | ^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change + --> $DIR/feature-gate-unboxed-closures.rs:5:6 + | +LL | impl FnOnce<(u32, u32)> for Test { + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error[E0183]: manual implementations of `FnOnce` are experimental + --> $DIR/feature-gate-unboxed-closures.rs:5:6 + | +LL | impl FnOnce<(u32, u32)> for Test { + | ^^^^^^^^^^^^^^^^^^ manual implementations of `FnOnce` are experimental + | + = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0183, E0658. +For more information about an error, try `rustc --explain E0183`. diff --git a/tests/ui/feature-gates/feature-gate-unix_sigpipe.rs b/tests/ui/feature-gates/feature-gate-unix_sigpipe.rs new file mode 100644 index 000000000..46dc3f6cc --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unix_sigpipe.rs @@ -0,0 +1,4 @@ +#![crate_type = "bin"] + +#[unix_sigpipe = "inherit"] //~ the `#[unix_sigpipe]` attribute is an experimental feature +fn main () {} diff --git a/tests/ui/feature-gates/feature-gate-unix_sigpipe.stderr b/tests/ui/feature-gates/feature-gate-unix_sigpipe.stderr new file mode 100644 index 000000000..cf3284467 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unix_sigpipe.stderr @@ -0,0 +1,12 @@ +error[E0658]: the `#[unix_sigpipe]` attribute is an experimental feature + --> $DIR/feature-gate-unix_sigpipe.rs:3:1 + | +LL | #[unix_sigpipe = "inherit"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #97889 <https://github.com/rust-lang/rust/issues/97889> for more information + = help: add `#![feature(unix_sigpipe)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs new file mode 100644 index 000000000..0680d2344 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.rs @@ -0,0 +1,17 @@ +// edition:2018 +#![forbid(incomplete_features, unsafe_code)] +#![feature(unsafe_pin_internals)] +//~^ ERROR the feature `unsafe_pin_internals` is incomplete and may not be safe to use + +use core::{marker::PhantomPinned, pin::Pin}; + +/// The `unsafe_pin_internals` is indeed unsound. +fn non_unsafe_pin_new_unchecked<T>(pointer: &mut T) -> Pin<&mut T> { + Pin { pointer } +} + +fn main() { + let mut self_referential = PhantomPinned; + let _: Pin<&mut PhantomPinned> = non_unsafe_pin_new_unchecked(&mut self_referential); + core::mem::forget(self_referential); // move and disable drop glue! +} diff --git a/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.stderr b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.stderr new file mode 100644 index 000000000..4d0c931b4 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unsafe_pin_internals.stderr @@ -0,0 +1,14 @@ +error: the feature `unsafe_pin_internals` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/feature-gate-unsafe_pin_internals.rs:3:12 + | +LL | #![feature(unsafe_pin_internals)] + | ^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/feature-gate-unsafe_pin_internals.rs:2:11 + | +LL | #![forbid(incomplete_features, unsafe_code)] + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/feature-gates/feature-gate-unsized_fn_params.rs b/tests/ui/feature-gates/feature-gate-unsized_fn_params.rs new file mode 100644 index 000000000..c04e57843 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unsized_fn_params.rs @@ -0,0 +1,30 @@ +#![allow(unused, bare_trait_objects)] +#[repr(align(256))] +struct A { + v: u8, +} + +trait Foo { + fn foo(&self); +} + +impl Foo for A { + fn foo(&self) { + assert_eq!(self as *const A as usize % 256, 0); + } +} + +fn foo(x: dyn Foo) { //~ ERROR [E0277] + x.foo() +} + +fn bar(x: Foo) { //~ ERROR [E0277] + x.foo() +} + +fn qux(_: [()]) {} //~ ERROR [E0277] + +fn main() { + let x: Box<dyn Foo> = Box::new(A { v: 22 }); + foo(*x); //~ ERROR [E0277] +} diff --git a/tests/ui/feature-gates/feature-gate-unsized_fn_params.stderr b/tests/ui/feature-gates/feature-gate-unsized_fn_params.stderr new file mode 100644 index 000000000..92c713926 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unsized_fn_params.stderr @@ -0,0 +1,60 @@ +error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time + --> $DIR/feature-gate-unsized_fn_params.rs:17:8 + | +LL | fn foo(x: dyn Foo) { + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Foo + 'static)` + = help: unsized fn params are gated as an unstable feature +help: you can use `impl Trait` as the argument type + | +LL | fn foo(x: impl Foo) { + | ~~~~ +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn foo(x: &dyn Foo) { + | + + +error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time + --> $DIR/feature-gate-unsized_fn_params.rs:21:8 + | +LL | fn bar(x: Foo) { + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Foo + 'static)` + = help: unsized fn params are gated as an unstable feature +help: you can use `impl Trait` as the argument type + | +LL | fn bar(x: impl Foo) { + | ++++ +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn bar(x: &Foo) { + | + + +error[E0277]: the size for values of type `[()]` cannot be known at compilation time + --> $DIR/feature-gate-unsized_fn_params.rs:25:8 + | +LL | fn qux(_: [()]) {} + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[()]` + = help: unsized fn params are gated as an unstable feature +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn qux(_: &[()]) {} + | + + +error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time + --> $DIR/feature-gate-unsized_fn_params.rs:29:9 + | +LL | foo(*x); + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Foo + 'static)` + = note: all function arguments must have a statically known size + = help: unsized fn params are gated as an unstable feature + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/feature-gates/feature-gate-unsized_locals.rs b/tests/ui/feature-gates/feature-gate-unsized_locals.rs new file mode 100644 index 000000000..3686e7b37 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unsized_locals.rs @@ -0,0 +1,5 @@ +fn f(f: dyn FnOnce()) {} +//~^ ERROR E0277 + +fn main() { +} diff --git a/tests/ui/feature-gates/feature-gate-unsized_locals.stderr b/tests/ui/feature-gates/feature-gate-unsized_locals.stderr new file mode 100644 index 000000000..9aeeb88cf --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unsized_locals.stderr @@ -0,0 +1,20 @@ +error[E0277]: the size for values of type `(dyn FnOnce() + 'static)` cannot be known at compilation time + --> $DIR/feature-gate-unsized_locals.rs:1:6 + | +LL | fn f(f: dyn FnOnce()) {} + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn FnOnce() + 'static)` + = help: unsized fn params are gated as an unstable feature +help: you can use `impl Trait` as the argument type + | +LL | fn f(f: impl FnOnce()) {} + | ~~~~ +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn f(f: &dyn FnOnce()) {} + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs b/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs new file mode 100644 index 000000000..c3d62a231 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs @@ -0,0 +1,4 @@ +fn main() { + let _ : &(dyn Send,) = &((),); + //~^ ERROR unsized tuple coercion is not stable enough +} diff --git a/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr b/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr new file mode 100644 index 000000000..bea6cee0a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr @@ -0,0 +1,12 @@ +error[E0658]: unsized tuple coercion is not stable enough for use and is subject to change + --> $DIR/feature-gate-unsized_tuple_coercion.rs:2:28 + | +LL | let _ : &(dyn Send,) = &((),); + | ^^^^^^ + | + = note: see issue #42877 <https://github.com/rust-lang/rust/issues/42877> for more information + = help: add `#![feature(unsized_tuple_coercion)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-used_with_arg.rs b/tests/ui/feature-gates/feature-gate-used_with_arg.rs new file mode 100644 index 000000000..1c8f01bde --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-used_with_arg.rs @@ -0,0 +1,7 @@ +#[used(linker)] //~ ERROR `#[used(linker)]` is currently unstable +static mut USED_LINKER: [usize; 1] = [0]; + +#[used(compiler)] //~ ERROR `#[used(compiler)]` is currently unstable +static mut USED_COMPILER: [usize; 1] = [0]; + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-used_with_arg.stderr b/tests/ui/feature-gates/feature-gate-used_with_arg.stderr new file mode 100644 index 000000000..d115bf4e3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-used_with_arg.stderr @@ -0,0 +1,21 @@ +error[E0658]: `#[used(linker)]` is currently unstable + --> $DIR/feature-gate-used_with_arg.rs:1:1 + | +LL | #[used(linker)] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #93798 <https://github.com/rust-lang/rust/issues/93798> for more information + = help: add `#![feature(used_with_arg)]` to the crate attributes to enable + +error[E0658]: `#[used(compiler)]` is currently unstable + --> $DIR/feature-gate-used_with_arg.rs:4:1 + | +LL | #[used(compiler)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #93798 <https://github.com/rust-lang/rust/issues/93798> for more information + = help: add `#![feature(used_with_arg)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-vectorcall.rs b/tests/ui/feature-gates/feature-gate-vectorcall.rs new file mode 100644 index 000000000..5a6c6d288 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-vectorcall.rs @@ -0,0 +1,31 @@ +// gate-test-abi_vectorcall +// needs-llvm-components: x86 +// compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib +#![no_core] +#![feature(no_core, lang_items)] +#[lang="sized"] +trait Sized { } + +// Test that the "vectorcall-unwind" ABI is feature-gated, and cannot be used when +// the `c_unwind` feature gate is not used. + +extern "vectorcall" fn f() {} //~ ERROR vectorcall is experimental + +trait T { + extern "vectorcall" fn m(); //~ ERROR vectorcall is experimental + + extern "vectorcall" fn dm() {} //~ ERROR vectorcall is experimental +} + +struct S; +impl T for S { + extern "vectorcall" fn m() {} //~ ERROR vectorcall is experimental +} + +impl S { + extern "vectorcall" fn im() {} //~ ERROR vectorcall is experimental +} + +type TA = extern "vectorcall" fn(); //~ ERROR vectorcall is experimental + +extern "vectorcall" {} //~ ERROR vectorcall is experimental diff --git a/tests/ui/feature-gates/feature-gate-vectorcall.stderr b/tests/ui/feature-gates/feature-gate-vectorcall.stderr new file mode 100644 index 000000000..55ee76ec3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-vectorcall.stderr @@ -0,0 +1,59 @@ +error[E0658]: vectorcall is experimental and subject to change + --> $DIR/feature-gate-vectorcall.rs:12:8 + | +LL | extern "vectorcall" fn f() {} + | ^^^^^^^^^^^^ + | + = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable + +error[E0658]: vectorcall is experimental and subject to change + --> $DIR/feature-gate-vectorcall.rs:15:12 + | +LL | extern "vectorcall" fn m(); + | ^^^^^^^^^^^^ + | + = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable + +error[E0658]: vectorcall is experimental and subject to change + --> $DIR/feature-gate-vectorcall.rs:17:12 + | +LL | extern "vectorcall" fn dm() {} + | ^^^^^^^^^^^^ + | + = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable + +error[E0658]: vectorcall is experimental and subject to change + --> $DIR/feature-gate-vectorcall.rs:22:12 + | +LL | extern "vectorcall" fn m() {} + | ^^^^^^^^^^^^ + | + = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable + +error[E0658]: vectorcall is experimental and subject to change + --> $DIR/feature-gate-vectorcall.rs:26:12 + | +LL | extern "vectorcall" fn im() {} + | ^^^^^^^^^^^^ + | + = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable + +error[E0658]: vectorcall is experimental and subject to change + --> $DIR/feature-gate-vectorcall.rs:29:18 + | +LL | type TA = extern "vectorcall" fn(); + | ^^^^^^^^^^^^ + | + = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable + +error[E0658]: vectorcall is experimental and subject to change + --> $DIR/feature-gate-vectorcall.rs:31:8 + | +LL | extern "vectorcall" {} + | ^^^^^^^^^^^^ + | + = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-wasm_abi.rs b/tests/ui/feature-gates/feature-gate-wasm_abi.rs new file mode 100644 index 000000000..222c88daf --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-wasm_abi.rs @@ -0,0 +1,26 @@ +// needs-llvm-components: webassembly +// compile-flags: --target=wasm32-unknown-unknown --crate-type=rlib +#![no_core] +#![feature(no_core, lang_items)] +#[lang="sized"] +trait Sized { } + +extern "wasm" fn fu() {} //~ ERROR wasm ABI is experimental + +trait T { + extern "wasm" fn mu(); //~ ERROR wasm ABI is experimental + extern "wasm" fn dmu() {} //~ ERROR wasm ABI is experimental +} + +struct S; +impl T for S { + extern "wasm" fn mu() {} //~ ERROR wasm ABI is experimental +} + +impl S { + extern "wasm" fn imu() {} //~ ERROR wasm ABI is experimental +} + +type TAU = extern "wasm" fn(); //~ ERROR wasm ABI is experimental + +extern "wasm" {} //~ ERROR wasm ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-wasm_abi.stderr b/tests/ui/feature-gates/feature-gate-wasm_abi.stderr new file mode 100644 index 000000000..0140002e3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-wasm_abi.stderr @@ -0,0 +1,66 @@ +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-wasm_abi.rs:8:8 + | +LL | extern "wasm" fn fu() {} + | ^^^^^^ + | + = note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-wasm_abi.rs:11:12 + | +LL | extern "wasm" fn mu(); + | ^^^^^^ + | + = note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-wasm_abi.rs:12:12 + | +LL | extern "wasm" fn dmu() {} + | ^^^^^^ + | + = note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-wasm_abi.rs:17:12 + | +LL | extern "wasm" fn mu() {} + | ^^^^^^ + | + = note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-wasm_abi.rs:21:12 + | +LL | extern "wasm" fn imu() {} + | ^^^^^^ + | + = note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-wasm_abi.rs:24:19 + | +LL | type TAU = extern "wasm" fn(); + | ^^^^^^ + | + = note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + +error[E0658]: wasm ABI is experimental and subject to change + --> $DIR/feature-gate-wasm_abi.rs:26:8 + | +LL | extern "wasm" {} + | ^^^^^^ + | + = note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information + = help: add `#![feature(wasm_abi)]` to the crate attributes to enable + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-with_negative_coherence.rs b/tests/ui/feature-gates/feature-gate-with_negative_coherence.rs new file mode 100644 index 000000000..d1d0a6a90 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-with_negative_coherence.rs @@ -0,0 +1,8 @@ +trait Foo { } + +impl<T: std::ops::DerefMut> Foo for T { } + +impl<T> Foo for &T { } +//~^ ERROR conflicting implementations of trait `Foo` for type `&_` [E0119] + +fn main() { } diff --git a/tests/ui/feature-gates/feature-gate-with_negative_coherence.stderr b/tests/ui/feature-gates/feature-gate-with_negative_coherence.stderr new file mode 100644 index 000000000..d4c201b5d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-with_negative_coherence.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `&_` + --> $DIR/feature-gate-with_negative_coherence.rs:5:1 + | +LL | impl<T: std::ops::DerefMut> Foo for T { } + | ------------------------------------- first implementation here +LL | +LL | impl<T> Foo for &T { } + | ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/feature-gates/feature-gate-yeet_expr-in-cfg.rs b/tests/ui/feature-gates/feature-gate-yeet_expr-in-cfg.rs new file mode 100644 index 000000000..a33bd3450 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-yeet_expr-in-cfg.rs @@ -0,0 +1,19 @@ +// compile-flags: --edition 2021 + +pub fn demo() -> Option<i32> { + #[cfg(nope)] + { + do yeet //~ ERROR `do yeet` expression is experimental + } + + Some(1) +} + +#[cfg(nope)] +pub fn alternative() -> Result<(), String> { + do yeet "hello"; //~ ERROR `do yeet` expression is experimental +} + +fn main() { + demo(); +} diff --git a/tests/ui/feature-gates/feature-gate-yeet_expr-in-cfg.stderr b/tests/ui/feature-gates/feature-gate-yeet_expr-in-cfg.stderr new file mode 100644 index 000000000..f90c379bd --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-yeet_expr-in-cfg.stderr @@ -0,0 +1,21 @@ +error[E0658]: `do yeet` expression is experimental + --> $DIR/feature-gate-yeet_expr-in-cfg.rs:6:9 + | +LL | do yeet + | ^^^^^^^ + | + = note: see issue #96373 <https://github.com/rust-lang/rust/issues/96373> for more information + = help: add `#![feature(yeet_expr)]` to the crate attributes to enable + +error[E0658]: `do yeet` expression is experimental + --> $DIR/feature-gate-yeet_expr-in-cfg.rs:14:5 + | +LL | do yeet "hello"; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #96373 <https://github.com/rust-lang/rust/issues/96373> for more information + = help: add `#![feature(yeet_expr)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-yeet_expr.rs b/tests/ui/feature-gates/feature-gate-yeet_expr.rs new file mode 100644 index 000000000..978a84cf6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-yeet_expr.rs @@ -0,0 +1,9 @@ +// compile-flags: --edition 2018 + +pub fn demo() -> Option<i32> { + do yeet //~ ERROR `do yeet` expression is experimental +} + +pub fn main() -> Result<(), String> { + do yeet "hello"; //~ ERROR `do yeet` expression is experimental +} diff --git a/tests/ui/feature-gates/feature-gate-yeet_expr.stderr b/tests/ui/feature-gates/feature-gate-yeet_expr.stderr new file mode 100644 index 000000000..8d1b92370 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-yeet_expr.stderr @@ -0,0 +1,21 @@ +error[E0658]: `do yeet` expression is experimental + --> $DIR/feature-gate-yeet_expr.rs:4:5 + | +LL | do yeet + | ^^^^^^^ + | + = note: see issue #96373 <https://github.com/rust-lang/rust/issues/96373> for more information + = help: add `#![feature(yeet_expr)]` to the crate attributes to enable + +error[E0658]: `do yeet` expression is experimental + --> $DIR/feature-gate-yeet_expr.rs:8:5 + | +LL | do yeet "hello"; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #96373 <https://github.com/rust-lang/rust/issues/96373> for more information + = help: add `#![feature(yeet_expr)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.rs b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.rs new file mode 100644 index 000000000..1285cca6b --- /dev/null +++ b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.rs @@ -0,0 +1,14 @@ +// tests that input to a macro is checked for use of gated features. If this +// test succeeds due to the acceptance of a feature, pick a new feature to +// test. Not ideal, but oh well :( + +fn main() { + let a = &[1, 2, 3]; + println!("{}", { + extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change + fn atomic_fence(); + } + atomic_fence(); + 42 + }); +} diff --git a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr new file mode 100644 index 000000000..218e02927 --- /dev/null +++ b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr @@ -0,0 +1,11 @@ +error[E0658]: intrinsics are subject to change + --> $DIR/feature-gated-feature-in-macro-arg.rs:8:16 + | +LL | extern "rust-intrinsic" { + | ^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(intrinsics)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/gated-bad-feature.rs b/tests/ui/feature-gates/gated-bad-feature.rs new file mode 100644 index 000000000..51f2db555 --- /dev/null +++ b/tests/ui/feature-gates/gated-bad-feature.rs @@ -0,0 +1,10 @@ +#![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] +//~^ ERROR malformed `feature` +//~| ERROR malformed `feature` +//~| ERROR unknown feature `foo` +//~| ERROR unknown feature `foo_bar_baz` +#![feature] //~ ERROR malformed `feature` attribute +#![feature = "foo"] //~ ERROR malformed `feature` attribute +#![feature(test_removed_feature)] //~ ERROR: feature has been removed + +fn main() {} diff --git a/tests/ui/feature-gates/gated-bad-feature.stderr b/tests/ui/feature-gates/gated-bad-feature.stderr new file mode 100644 index 000000000..2d01bdf3c --- /dev/null +++ b/tests/ui/feature-gates/gated-bad-feature.stderr @@ -0,0 +1,46 @@ +error[E0556]: malformed `feature` attribute input + --> $DIR/gated-bad-feature.rs:1:25 + | +LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] + | ^^^^^^^^ help: expected just one word: `foo` + +error[E0556]: malformed `feature` attribute input + --> $DIR/gated-bad-feature.rs:1:35 + | +LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] + | ^^^^^^^^^^^ help: expected just one word: `foo` + +error[E0557]: feature has been removed + --> $DIR/gated-bad-feature.rs:8:12 + | +LL | #![feature(test_removed_feature)] + | ^^^^^^^^^^^^^^^^^^^^ feature has been removed + +error: malformed `feature` attribute input + --> $DIR/gated-bad-feature.rs:6:1 + | +LL | #![feature] + | ^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]` + +error: malformed `feature` attribute input + --> $DIR/gated-bad-feature.rs:7:1 + | +LL | #![feature = "foo"] + | ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]` + +error[E0635]: unknown feature `foo_bar_baz` + --> $DIR/gated-bad-feature.rs:1:12 + | +LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] + | ^^^^^^^^^^^ + +error[E0635]: unknown feature `foo` + --> $DIR/gated-bad-feature.rs:1:48 + | +LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] + | ^^^ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0556, E0557, E0635. +For more information about an error, try `rustc --explain E0556`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-bench.rs b/tests/ui/feature-gates/issue-43106-gating-of-bench.rs new file mode 100644 index 000000000..796325b79 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-bench.rs @@ -0,0 +1,10 @@ +// The non-crate level cases are in issue-43106-gating-of-builtin-attrs.rs. +// See issue-12997-1.rs and issue-12997-2.rs to see how `#[bench]` is +// handled in "weird places" when `--test` is passed. + +#![feature(custom_inner_attributes)] + +#![bench = "4100"] +//~^ ERROR cannot determine resolution for the attribute macro `bench` +//~^^ ERROR `bench` attribute cannot be used at crate level +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-bench.stderr b/tests/ui/feature-gates/issue-43106-gating-of-bench.stderr new file mode 100644 index 000000000..6b3322119 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-bench.stderr @@ -0,0 +1,21 @@ +error: cannot determine resolution for the attribute macro `bench` + --> $DIR/issue-43106-gating-of-bench.rs:7:4 + | +LL | #![bench = "4100"] + | ^^^^^ + | + = note: import resolution is stuck, try simplifying macro imports + +error: `bench` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-bench.rs:7:1 + | +LL | #![bench = "4100"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: perhaps you meant to use an outer attribute + | +LL | #[bench = "4100"] + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs new file mode 100644 index 000000000..1fe133ac2 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs @@ -0,0 +1,160 @@ +//~ NOTE: not an `extern crate` item +//~^ NOTE: not a free function, impl method or static +//~^^ NOTE: not a function or closure +// This is testing whether various builtin attributes signals an +// error or warning when put in "weird" places. +// +// (This file sits on its own because it actually signals an error, +// which would mess up the treatment of other cases in +// issue-43106-gating-of-builtin-attrs.rs) + + +#![macro_export] +//~^ ERROR: `macro_export` attribute cannot be used at crate level +#![rustc_main] //~ ERROR: the `#[rustc_main]` attribute is used internally to specify +//~^ ERROR: `rustc_main` attribute cannot be used at crate level +#![start] +//~^ ERROR: `start` attribute cannot be used at crate level +#![repr()] +//~^ ERROR: `repr` attribute cannot be used at crate level +#![path = "3800"] +//~^ ERROR: `path` attribute cannot be used at crate level +#![automatically_derived] +//~^ ERROR: `automatically_derived` attribute cannot be used at crate level +#![no_mangle] +#![no_link] +//~^ ERROR: attribute should be applied to an `extern crate` item +#![export_name = "2200"] +//~^ ERROR: attribute should be applied to a free function, impl method or static +#![inline] +//~^ ERROR: attribute should be applied to function or closure +#[inline] +//~^ ERROR attribute should be applied to function or closure +mod inline { + //~^ NOTE not a function or closure + + mod inner { #![inline] } + //~^ ERROR attribute should be applied to function or closure + //~| NOTE not a function or closure + + #[inline = "2100"] fn f() { } + //~^ ERROR attribute must be of the form + //~| WARN this was previously accepted + //~| NOTE #[deny(ill_formed_attribute_input)]` on by default + //~| NOTE for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + + #[inline] struct S; + //~^ ERROR attribute should be applied to function or closure + //~| NOTE not a function or closure + + #[inline] type T = S; + //~^ ERROR attribute should be applied to function or closure + //~| NOTE not a function or closure + + #[inline] impl S { } + //~^ ERROR attribute should be applied to function or closure + //~| NOTE not a function or closure +} + +#[no_link] +//~^ ERROR attribute should be applied to an `extern crate` item +mod no_link { + //~^ NOTE not an `extern crate` item + + mod inner { #![no_link] } + //~^ ERROR attribute should be applied to an `extern crate` item + //~| NOTE not an `extern crate` item + + #[no_link] fn f() { } + //~^ ERROR attribute should be applied to an `extern crate` item + //~| NOTE not an `extern crate` item + + #[no_link] struct S; + //~^ ERROR attribute should be applied to an `extern crate` item + //~| NOTE not an `extern crate` item + + #[no_link]type T = S; + //~^ ERROR attribute should be applied to an `extern crate` item + //~| NOTE not an `extern crate` item + + #[no_link] impl S { } + //~^ ERROR attribute should be applied to an `extern crate` item + //~| NOTE not an `extern crate` item +} + +#[export_name = "2200"] +//~^ ERROR attribute should be applied to a free function, impl method or static +mod export_name { + //~^ NOTE not a free function, impl method or static + + mod inner { #![export_name="2200"] } + //~^ ERROR attribute should be applied to a free function, impl method or static + //~| NOTE not a free function, impl method or static + + #[export_name = "2200"] fn f() { } + + #[export_name = "2200"] struct S; + //~^ ERROR attribute should be applied to a free function, impl method or static + //~| NOTE not a free function, impl method or static + + #[export_name = "2200"] type T = S; + //~^ ERROR attribute should be applied to a free function, impl method or static + //~| NOTE not a free function, impl method or static + + #[export_name = "2200"] impl S { } + //~^ ERROR attribute should be applied to a free function, impl method or static + //~| NOTE not a free function, impl method or static + + trait Tr { + #[export_name = "2200"] fn foo(); + //~^ ERROR attribute should be applied to a free function, impl method or static + //~| NOTE not a free function, impl method or static + + #[export_name = "2200"] fn bar() {} + //~^ ERROR attribute should be applied to a free function, impl method or static + //~| NOTE not a free function, impl method or static + } +} + +#[start] +//~^ ERROR: `start` attribute can only be used on functions +mod start { + mod inner { #![start] } + //~^ ERROR: `start` attribute can only be used on functions + + // for `fn f()` case, see feature-gate-start.rs + + #[start] struct S; + //~^ ERROR: `start` attribute can only be used on functions + + #[start] type T = S; + //~^ ERROR: `start` attribute can only be used on functions + + #[start] impl S { } + //~^ ERROR: `start` attribute can only be used on functions +} + +#[repr(C)] +//~^ ERROR: attribute should be applied to a struct, enum, or union +mod repr { +//~^ NOTE not a struct, enum, or union + mod inner { #![repr(C)] } + //~^ ERROR: attribute should be applied to a struct, enum, or union + //~| NOTE not a struct, enum, or union + + #[repr(C)] fn f() { } + //~^ ERROR: attribute should be applied to a struct, enum, or union + //~| NOTE not a struct, enum, or union + + struct S; + + #[repr(C)] type T = S; + //~^ ERROR: attribute should be applied to a struct, enum, or union + //~| NOTE not a struct, enum, or union + + #[repr(C)] impl S { } + //~^ ERROR: attribute should be applied to a struct, enum, or union + //~| NOTE not a struct, enum, or union +} + +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr new file mode 100644 index 000000000..787670404 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr @@ -0,0 +1,310 @@ +error[E0658]: the `#[rustc_main]` attribute is used internally to specify test entry point function + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:14:1 + | +LL | #![rustc_main] + | ^^^^^^^^^^^^^^ + | + = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable + +error: attribute must be of the form `#[inline]` or `#[inline(always|never)]` + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:40:5 + | +LL | #[inline = "2100"] fn f() { } + | ^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +error: `start` attribute can only be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:119:1 + | +LL | #[start] + | ^^^^^^^^ + +error: `start` attribute can only be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:122:17 + | +LL | mod inner { #![start] } + | ^^^^^^^^^ + +error: `start` attribute can only be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:127:5 + | +LL | #[start] struct S; + | ^^^^^^^^ + +error: `start` attribute can only be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:130:5 + | +LL | #[start] type T = S; + | ^^^^^^^^ + +error: `start` attribute can only be used on functions + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:133:5 + | +LL | #[start] impl S { } + | ^^^^^^^^ + +error[E0518]: attribute should be applied to function or closure + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:31:1 + | +LL | #[inline] + | ^^^^^^^^^ +LL | +LL | / mod inline { +LL | | +LL | | +LL | | mod inner { #![inline] } +... | +LL | | +LL | | } + | |_- not a function or closure + +error: attribute should be applied to an `extern crate` item + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:59:1 + | +LL | #[no_link] + | ^^^^^^^^^^ +LL | +LL | / mod no_link { +LL | | +LL | | +LL | | mod inner { #![no_link] } +... | +LL | | +LL | | } + | |_- not an `extern crate` item + +error: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:85:1 + | +LL | #[export_name = "2200"] + | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | / mod export_name { +LL | | +LL | | +LL | | mod inner { #![export_name="2200"] } +... | +LL | | } +LL | | } + | |_- not a free function, impl method or static + +error[E0517]: attribute should be applied to a struct, enum, or union + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:137:8 + | +LL | #[repr(C)] + | ^ +LL | +LL | / mod repr { +LL | | +LL | | mod inner { #![repr(C)] } +LL | | +... | +LL | | +LL | | } + | |_- not a struct, enum, or union + +error: attribute should be applied to an `extern crate` item + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:25:1 + | +LL | #![no_link] + | ^^^^^^^^^^^ not an `extern crate` item + +error: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:27:1 + | +LL | #![export_name = "2200"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ not a free function, impl method or static + +error[E0518]: attribute should be applied to function or closure + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:29:1 + | +LL | #![inline] + | ^^^^^^^^^^ not a function or closure + +error: `macro_export` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1 + | +LL | #![macro_export] + | ^^^^^^^^^^^^^^^^ + | +help: perhaps you meant to use an outer attribute + | +LL | #[macro_export] + | + +error: `rustc_main` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:14:1 + | +LL | #![rustc_main] + | ^^^^^^^^^^^^^^ + | +help: perhaps you meant to use an outer attribute + | +LL | #[rustc_main] + | ~~~~~~~~~~~~~ + +error: `start` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:16:1 + | +LL | #![start] + | ^^^^^^^^^ + | +help: perhaps you meant to use an outer attribute + | +LL | #[start] + | + +error: `repr` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:18:1 + | +LL | #![repr()] + | ^^^^^^^^^^ + | +help: perhaps you meant to use an outer attribute + | +LL | #[repr()] + | + +error: `path` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:20:1 + | +LL | #![path = "3800"] + | ^^^^^^^^^^^^^^^^^ + | +help: perhaps you meant to use an outer attribute + | +LL | #[path = "3800"] + | + +error: `automatically_derived` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:22:1 + | +LL | #![automatically_derived] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: perhaps you meant to use an outer attribute + | +LL | #[automatically_derived] + | + +error[E0518]: attribute should be applied to function or closure + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:36:17 + | +LL | mod inner { #![inline] } + | ------------^^^^^^^^^^-- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5 + | +LL | #[inline] struct S; + | ^^^^^^^^^ --------- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:50:5 + | +LL | #[inline] type T = S; + | ^^^^^^^^^ ----------- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:54:5 + | +LL | #[inline] impl S { } + | ^^^^^^^^^ ---------- not a function or closure + +error: attribute should be applied to an `extern crate` item + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:64:17 + | +LL | mod inner { #![no_link] } + | ------------^^^^^^^^^^^-- not an `extern crate` item + +error: attribute should be applied to an `extern crate` item + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:68:5 + | +LL | #[no_link] fn f() { } + | ^^^^^^^^^^ ---------- not an `extern crate` item + +error: attribute should be applied to an `extern crate` item + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:72:5 + | +LL | #[no_link] struct S; + | ^^^^^^^^^^ --------- not an `extern crate` item + +error: attribute should be applied to an `extern crate` item + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:76:5 + | +LL | #[no_link]type T = S; + | ^^^^^^^^^^----------- not an `extern crate` item + +error: attribute should be applied to an `extern crate` item + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:80:5 + | +LL | #[no_link] impl S { } + | ^^^^^^^^^^ ---------- not an `extern crate` item + +error: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:90:17 + | +LL | mod inner { #![export_name="2200"] } + | ------------^^^^^^^^^^^^^^^^^^^^^^-- not a free function, impl method or static + +error: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:96:5 + | +LL | #[export_name = "2200"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a free function, impl method or static + +error: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:100:5 + | +LL | #[export_name = "2200"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a free function, impl method or static + +error: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:104:5 + | +LL | #[export_name = "2200"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a free function, impl method or static + +error: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:109:9 + | +LL | #[export_name = "2200"] fn foo(); + | ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a free function, impl method or static + +error: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:113:9 + | +LL | #[export_name = "2200"] fn bar() {} + | ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a free function, impl method or static + +error[E0517]: attribute should be applied to a struct, enum, or union + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:141:25 + | +LL | mod inner { #![repr(C)] } + | --------------------^---- not a struct, enum, or union + +error[E0517]: attribute should be applied to a struct, enum, or union + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:145:12 + | +LL | #[repr(C)] fn f() { } + | ^ ---------- not a struct, enum, or union + +error[E0517]: attribute should be applied to a struct, enum, or union + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:151:12 + | +LL | #[repr(C)] type T = S; + | ^ ----------- not a struct, enum, or union + +error[E0517]: attribute should be applied to a struct, enum, or union + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:155:12 + | +LL | #[repr(C)] impl S { } + | ^ ---------- not a struct, enum, or union + +error: aborting due to 39 previous errors + +Some errors have detailed explanations: E0517, E0518, E0658. +For more information about an error, try `rustc --explain E0517`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs new file mode 100644 index 000000000..1fa315f3d --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs @@ -0,0 +1,772 @@ +//~ NOTE not a function +//~| NOTE not a foreign function or static +//~| NOTE cannot be applied to crates +//~| NOTE not an `extern` block +// This test enumerates as many compiler-builtin ungated attributes as +// possible (that is, all the mutually compatible ones), and checks +// that we get "expected" (*) warnings for each in the various weird +// places that users might put them in the syntax. +// +// (*): The word "expected" is in quotes above because the cases where +// warnings are and are not emitted might not match a user's intuition +// nor the rustc developers' intent. I am really just trying to +// capture today's behavior in a test, not so that it become enshrined +// as the absolute behavior going forward, but rather so that we do +// not change the behavior in the future without even being *aware* of +// the change when it happens. +// +// At the time of authoring, the attributes here are listed in the +// order that they occur in `librustc_feature`. +// +// Any builtin attributes that: +// +// - are not stable, or +// +// - could not be included here covering the same cases as the other +// attributes without raising an *error* from rustc (note though +// that warnings are of course expected) +// +// have their own test case referenced by filename in an inline +// comment. +// +// The test feeds numeric inputs to each attribute that accepts them +// without error. We do this for two reasons: (1.) to exercise how +// inputs are handled by each, and (2.) to ease searching for related +// occurrences in the source text. + +// check-pass + +#![feature(test)] +#![warn(unused_attributes, unknown_lints)] +//~^ NOTE the lint level is defined here +//~| NOTE the lint level is defined here + +// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES + +#![warn(x5400)] //~ WARN unknown lint: `x5400` +#![allow(x5300)] //~ WARN unknown lint: `x5300` +#![forbid(x5200)] //~ WARN unknown lint: `x5200` +#![deny(x5100)] //~ WARN unknown lint: `x5100` +#![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs) +// skipping testing of cfg +// skipping testing of cfg_attr +#![should_panic] //~ WARN `#[should_panic]` only has an effect +#![ignore] //~ WARN `#[ignore]` only has an effect on functions +#![no_implicit_prelude] +#![reexport_test_harness_main = "2900"] +// see gated-link-args.rs +// see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700" +// (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600") +#![proc_macro_derive()] //~ WARN `#[proc_macro_derive]` only has an effect +#![doc = "2400"] +#![cold] //~ WARN attribute should be applied to a function +//~^ WARN this was previously accepted +#![link()] //~ WARN attribute should be applied to an `extern` block +//~^ WARN this was previously accepted +#![link_name = "1900"] +//~^ WARN attribute should be applied to a foreign function +//~^^ WARN this was previously accepted by the compiler +#![link_section = "1800"] +//~^ WARN attribute should be applied to a function or static +//~^^ WARN this was previously accepted by the compiler +#![must_use] +//~^ WARN `#[must_use]` has no effect +// see issue-43106-gating-of-stable.rs +// see issue-43106-gating-of-unstable.rs +// see issue-43106-gating-of-deprecated.rs +#![windows_subsystem = "windows"] + +// UNGATED CRATE-LEVEL BUILT-IN ATTRIBUTES + +#![crate_name = "0900"] +#![crate_type = "bin"] // cannot pass "0800" here + +#![crate_id = "10"] +//~^ WARN use of deprecated attribute +//~| HELP remove this attribute +//~| NOTE `#[warn(deprecated)]` on by default + +// FIXME(#44232) we should warn that this isn't used. +#![feature(rust1)] +//~^ WARN no longer requires an attribute to enable +//~| NOTE `#[warn(stable_features)]` on by default + +#![no_start] +//~^ WARN use of deprecated attribute +//~| HELP remove this attribute + +// (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400") +#![no_builtins] +#![recursion_limit = "0200"] +#![type_length_limit = "0100"] + +// USES OF BUILT-IN ATTRIBUTES IN OTHER ("UNUSUAL") PLACES + +#[warn(x5400)] +//~^ WARN unknown lint: `x5400` +mod warn { + mod inner { #![warn(x5400)] } + //~^ WARN unknown lint: `x5400` + + #[warn(x5400)] fn f() { } + //~^ WARN unknown lint: `x5400` + + #[warn(x5400)] struct S; + //~^ WARN unknown lint: `x5400` + + #[warn(x5400)] type T = S; + //~^ WARN unknown lint: `x5400` + + #[warn(x5400)] impl S { } + //~^ WARN unknown lint: `x5400` +} + +#[allow(x5300)] +//~^ WARN unknown lint: `x5300` +mod allow { + mod inner { #![allow(x5300)] } + //~^ WARN unknown lint: `x5300` + + #[allow(x5300)] fn f() { } + //~^ WARN unknown lint: `x5300` + + #[allow(x5300)] struct S; + //~^ WARN unknown lint: `x5300` + + #[allow(x5300)] type T = S; + //~^ WARN unknown lint: `x5300` + + #[allow(x5300)] impl S { } + //~^ WARN unknown lint: `x5300` +} + +#[forbid(x5200)] +//~^ WARN unknown lint: `x5200` +mod forbid { + mod inner { #![forbid(x5200)] } + //~^ WARN unknown lint: `x5200` + + #[forbid(x5200)] fn f() { } + //~^ WARN unknown lint: `x5200` + + #[forbid(x5200)] struct S; + //~^ WARN unknown lint: `x5200` + + #[forbid(x5200)] type T = S; + //~^ WARN unknown lint: `x5200` + + #[forbid(x5200)] impl S { } + //~^ WARN unknown lint: `x5200` +} + +#[deny(x5100)] +//~^ WARN unknown lint: `x5100` +mod deny { + mod inner { #![deny(x5100)] } + //~^ WARN unknown lint: `x5100` + + #[deny(x5100)] fn f() { } + //~^ WARN unknown lint: `x5100` + + #[deny(x5100)] struct S; + //~^ WARN unknown lint: `x5100` + + #[deny(x5100)] type T = S; + //~^ WARN unknown lint: `x5100` + + #[deny(x5100)] impl S { } + //~^ WARN unknown lint: `x5100` +} + +#[macro_use] +mod macro_use { + mod inner { #![macro_use] } + + #[macro_use] fn f() { } + //~^ `#[macro_use]` only has an effect + + #[macro_use] struct S; + //~^ `#[macro_use]` only has an effect + + #[macro_use] type T = S; + //~^ `#[macro_use]` only has an effect + + #[macro_use] impl S { } + //~^ `#[macro_use]` only has an effect +} + +#[macro_export] +//~^ WARN `#[macro_export]` only has an effect on macro definitions +mod macro_export { + mod inner { #![macro_export] } + //~^ WARN `#[macro_export]` only has an effect on macro definitions + + #[macro_export] fn f() { } + //~^ WARN `#[macro_export]` only has an effect on macro definitions + + #[macro_export] struct S; + //~^ WARN `#[macro_export]` only has an effect on macro definitions + + #[macro_export] type T = S; + //~^ WARN `#[macro_export]` only has an effect on macro definitions + + #[macro_export] impl S { } + //~^ WARN `#[macro_export]` only has an effect on macro definitions +} + +// At time of unit test authorship, if compiling without `--test` then +// non-crate-level #[test] attributes seem to be ignored. + +#[test] +mod test { mod inner { #![test] } + + fn f() { } + + struct S; + + type T = S; + + impl S { } +} + +// At time of unit test authorship, if compiling without `--test` then +// non-crate-level #[bench] attributes seem to be ignored. + +#[bench] +mod bench { + mod inner { #![bench] } + + #[bench] + struct S; + + #[bench] + type T = S; + + #[bench] + impl S { } +} + +#[path = "3800"] +mod path { + mod inner { #![path="3800"] } + + #[path = "3800"] fn f() { } + //~^ WARN `#[path]` only has an effect + + #[path = "3800"] struct S; + //~^ WARN `#[path]` only has an effect + + #[path = "3800"] type T = S; + //~^ WARN `#[path]` only has an effect + + #[path = "3800"] impl S { } + //~^ WARN `#[path]` only has an effect +} + +#[automatically_derived] +//~^ WARN `#[automatically_derived]` only has an effect +mod automatically_derived { + mod inner { #![automatically_derived] } + //~^ WARN `#[automatically_derived] + + #[automatically_derived] fn f() { } + //~^ WARN `#[automatically_derived] + + #[automatically_derived] struct S; + //~^ WARN `#[automatically_derived] + + #[automatically_derived] type T = S; + //~^ WARN `#[automatically_derived] + + #[automatically_derived] impl S { } +} + +#[no_mangle] +//~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] +//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +mod no_mangle { + //~^ NOTE not a free function, impl method or static + mod inner { #![no_mangle] } + //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a free function, impl method or static + + #[no_mangle] fn f() { } + + #[no_mangle] struct S; + //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a free function, impl method or static + + #[no_mangle] type T = S; + //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a free function, impl method or static + + #[no_mangle] impl S { } + //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a free function, impl method or static + + trait Tr { + #[no_mangle] fn foo(); + //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a free function, impl method or static + + #[no_mangle] fn bar() {} + //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a free function, impl method or static + } +} + +#[should_panic] +//~^ WARN `#[should_panic]` only has an effect on +mod should_panic { + mod inner { #![should_panic] } + //~^ WARN `#[should_panic]` only has an effect on + + #[should_panic] fn f() { } + + #[should_panic] struct S; + //~^ WARN `#[should_panic]` only has an effect on + + #[should_panic] type T = S; + //~^ WARN `#[should_panic]` only has an effect on + + #[should_panic] impl S { } + //~^ WARN `#[should_panic]` only has an effect on +} + +#[ignore] +//~^ WARN `#[ignore]` only has an effect on functions +mod ignore { + mod inner { #![ignore] } + //~^ WARN `#[ignore]` only has an effect on functions + + #[ignore] fn f() { } + + #[ignore] struct S; + //~^ WARN `#[ignore]` only has an effect on functions + + #[ignore] type T = S; + //~^ WARN `#[ignore]` only has an effect on functions + + #[ignore] impl S { } + //~^ WARN `#[ignore]` only has an effect on functions +} + +#[no_implicit_prelude] +mod no_implicit_prelude { + mod inner { #![no_implicit_prelude] } + + #[no_implicit_prelude] fn f() { } + //~^ WARN `#[no_implicit_prelude]` only has an effect + + #[no_implicit_prelude] struct S; + //~^ WARN `#[no_implicit_prelude]` only has an effect + + #[no_implicit_prelude] type T = S; + //~^ WARN `#[no_implicit_prelude]` only has an effect + + #[no_implicit_prelude] impl S { } + //~^ WARN `#[no_implicit_prelude]` only has an effect +} + +#[reexport_test_harness_main = "2900"] +//~^ WARN crate-level attribute should be +mod reexport_test_harness_main { + mod inner { #![reexport_test_harness_main="2900"] } + //~^ WARN crate-level attribute should be + + #[reexport_test_harness_main = "2900"] fn f() { } + //~^ WARN crate-level attribute should be + + #[reexport_test_harness_main = "2900"] struct S; + //~^ WARN crate-level attribute should be + + #[reexport_test_harness_main = "2900"] type T = S; + //~^ WARN crate-level attribute should be + + #[reexport_test_harness_main = "2900"] impl S { } + //~^ WARN crate-level attribute should be +} + +// Cannot feed "2700" to `#[macro_escape]` without signaling an error. +#[macro_escape] +//~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]` +mod macro_escape { + mod inner { #![macro_escape] } + //~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]` + //~| HELP try an outer attribute: `#[macro_use]` + + #[macro_escape] fn f() { } + //~^ WARN `#[macro_escape]` only has an effect + + #[macro_escape] struct S; + //~^ WARN `#[macro_escape]` only has an effect + + #[macro_escape] type T = S; + //~^ WARN `#[macro_escape]` only has an effect + + #[macro_escape] impl S { } + //~^ WARN `#[macro_escape]` only has an effect +} + +#[no_std] +//~^ WARN crate-level attribute should be an inner attribute +mod no_std { + mod inner { #![no_std] } +//~^ WARN crate-level attribute should be in the root module + + #[no_std] fn f() { } + //~^ WARN crate-level attribute should be an inner attribute + + #[no_std] struct S; + //~^ WARN crate-level attribute should be an inner attribute + + #[no_std] type T = S; + //~^ WARN crate-level attribute should be an inner attribute + + #[no_std] impl S { } + //~^ WARN crate-level attribute should be an inner attribute +} + +// At time of authorship, #[proc_macro_derive = "2500"] signals error +// when it occurs on a mod (apart from crate-level). Therefore it goes +// into its own file; see issue-43106-gating-of-proc_macro_derive.rs + +#[doc = "2400"] +mod doc { + mod inner { #![doc="2400"] } + + #[doc = "2400"] fn f() { } + + #[doc = "2400"] struct S; + + #[doc = "2400"] type T = S; + + #[doc = "2400"] impl S { } +} + +#[cold] +//~^ WARN attribute should be applied to a function +//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +mod cold { + //~^ NOTE not a function + + mod inner { #![cold] } + //~^ WARN attribute should be applied to a function + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a function + + #[cold] fn f() { } + + #[cold] struct S; + //~^ WARN attribute should be applied to a function + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a function + + #[cold] type T = S; + //~^ WARN attribute should be applied to a function + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a function + + #[cold] impl S { } + //~^ WARN attribute should be applied to a function + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a function +} + +#[link_name = "1900"] +//~^ WARN attribute should be applied to a foreign function or static [unused_attributes] +//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +mod link_name { + //~^ NOTE not a foreign function or static + + #[link_name = "1900"] + //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| HELP try `#[link(name = "1900")]` instead + extern "C" { } + //~^ NOTE not a foreign function or static + + mod inner { #![link_name="1900"] } + //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a foreign function or static + + #[link_name = "1900"] fn f() { } + //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a foreign function or static + + #[link_name = "1900"] struct S; + //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a foreign function or static + + #[link_name = "1900"] type T = S; + //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a foreign function or static + + #[link_name = "1900"] impl S { } + //~^ WARN attribute should be applied to a foreign function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a foreign function or static +} + +#[link_section = "1800"] +//~^ WARN attribute should be applied to a function or static [unused_attributes] +//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +mod link_section { + //~^ NOTE not a function or static + + mod inner { #![link_section="1800"] } + //~^ WARN attribute should be applied to a function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a function or static + + #[link_section = "1800"] fn f() { } + + #[link_section = "1800"] struct S; + //~^ WARN attribute should be applied to a function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a function or static + + #[link_section = "1800"] type T = S; + //~^ WARN attribute should be applied to a function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a function or static + + #[link_section = "1800"] impl S { } + //~^ WARN attribute should be applied to a function or static [unused_attributes] + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~| NOTE not a function or static +} + + +// Note that this is a `check-pass` test, so it will never invoke the linker. + +#[link()] +//~^ WARN attribute should be applied to an `extern` block +//~| WARN this was previously accepted +mod link { + //~^ NOTE not an `extern` block + + mod inner { #![link()] } + //~^ WARN attribute should be applied to an `extern` block + //~| WARN this was previously accepted + //~| NOTE not an `extern` block + + #[link()] fn f() { } + //~^ WARN attribute should be applied to an `extern` block + //~| WARN this was previously accepted + //~| NOTE not an `extern` block + + #[link()] struct S; + //~^ WARN attribute should be applied to an `extern` block + //~| WARN this was previously accepted + //~| NOTE not an `extern` block + + #[link()] type T = S; + //~^ WARN attribute should be applied to an `extern` block + //~| WARN this was previously accepted + //~| NOTE not an `extern` block + + #[link()] impl S { } + //~^ WARN attribute should be applied to an `extern` block + //~| WARN this was previously accepted + //~| NOTE not an `extern` block + + #[link()] extern "Rust" {} + //~^ WARN attribute should be applied to an `extern` block + //~| WARN this was previously accepted +} + +struct StructForDeprecated; + +#[deprecated] +mod deprecated { + mod inner { #![deprecated] } + + #[deprecated] fn f() { } + + #[deprecated] struct S1; + + #[deprecated] type T = super::StructForDeprecated; + + #[deprecated] impl super::StructForDeprecated { } +} + +#[must_use] //~ WARN `#[must_use]` has no effect +mod must_use { + mod inner { #![must_use] } //~ WARN `#[must_use]` has no effect + + #[must_use] fn f() { } + + #[must_use] struct S; + + #[must_use] type T = S; //~ WARN `#[must_use]` has no effect + + #[must_use] impl S { } //~ WARN `#[must_use]` has no effect +} + +#[windows_subsystem = "windows"] +//~^ WARN crate-level attribute should be an inner attribute +mod windows_subsystem { + mod inner { #![windows_subsystem="windows"] } + //~^ WARN crate-level attribute should be in the root module + + #[windows_subsystem = "windows"] fn f() { } + //~^ WARN crate-level attribute should be an inner attribute + + #[windows_subsystem = "windows"] struct S; + //~^ WARN crate-level attribute should be an inner attribute + + #[windows_subsystem = "windows"] type T = S; + //~^ WARN crate-level attribute should be an inner attribute + + #[windows_subsystem = "windows"] impl S { } + //~^ WARN crate-level attribute should be an inner attribute +} + +// BROKEN USES OF CRATE-LEVEL BUILT-IN ATTRIBUTES + +#[crate_name = "0900"] +//~^ WARN crate-level attribute should be an inner attribute +mod crate_name { + mod inner { #![crate_name="0900"] } +//~^ WARN crate-level attribute should be in the root module + + #[crate_name = "0900"] fn f() { } + //~^ WARN crate-level attribute should be an inner attribute + + #[crate_name = "0900"] struct S; + //~^ WARN crate-level attribute should be an inner attribute + + #[crate_name = "0900"] type T = S; + //~^ WARN crate-level attribute should be an inner attribute + + #[crate_name = "0900"] impl S { } + //~^ WARN crate-level attribute should be an inner attribute +} + +#[crate_type = "0800"] +//~^ WARN crate-level attribute should be an inner attribute +mod crate_type { + mod inner { #![crate_type="0800"] } +//~^ WARN crate-level attribute should be in the root module + + #[crate_type = "0800"] fn f() { } + //~^ WARN crate-level attribute should be an inner attribute + + #[crate_type = "0800"] struct S; + //~^ WARN crate-level attribute should be an inner attribute + + #[crate_type = "0800"] type T = S; + //~^ WARN crate-level attribute should be an inner attribute + + #[crate_type = "0800"] impl S { } + //~^ WARN crate-level attribute should be an inner attribute +} + +#[feature(x0600)] +//~^ WARN crate-level attribute should be an inner attribute +mod feature { + mod inner { #![feature(x0600)] } +//~^ WARN crate-level attribute should be in the root module + + #[feature(x0600)] fn f() { } + //~^ WARN crate-level attribute should be an inner attribute + + #[feature(x0600)] struct S; + //~^ WARN crate-level attribute should be an inner attribute + + #[feature(x0600)] type T = S; + //~^ WARN crate-level attribute should be an inner attribute + + #[feature(x0600)] impl S { } + //~^ WARN crate-level attribute should be an inner attribute +} + + +#[no_main] +//~^ WARN crate-level attribute should be an inner attribute +mod no_main_1 { + mod inner { #![no_main] } +//~^ WARN crate-level attribute should be in the root module + + #[no_main] fn f() { } + //~^ WARN crate-level attribute should be an inner attribute + + #[no_main] struct S; + //~^ WARN crate-level attribute should be an inner attribute + + #[no_main] type T = S; + //~^ WARN crate-level attribute should be an inner attribute + + #[no_main] impl S { } + //~^ WARN crate-level attribute should be an inner attribute +} + +#[no_builtins] +//~^ WARN crate-level attribute should be an inner attribute +mod no_builtins { + mod inner { #![no_builtins] } + //~^ WARN crate-level attribute should be in the root module + + #[no_builtins] fn f() { } + //~^ WARN crate-level attribute should be an inner attribute + + #[no_builtins] struct S; + //~^ WARN crate-level attribute should be an inner attribute + + #[no_builtins] type T = S; + //~^ WARN crate-level attribute should be an inner attribute + + #[no_builtins] impl S { } + //~^ WARN crate-level attribute should be an inner attribute +} + +#[recursion_limit="0200"] +//~^ WARN crate-level attribute should be an inner attribute +mod recursion_limit { + mod inner { #![recursion_limit="0200"] } +//~^ WARN crate-level attribute should be in the root module + + #[recursion_limit="0200"] fn f() { } + //~^ WARN crate-level attribute should be an inner attribute + + #[recursion_limit="0200"] struct S; + //~^ WARN crate-level attribute should be an inner attribute + + #[recursion_limit="0200"] type T = S; + //~^ WARN crate-level attribute should be an inner attribute + + #[recursion_limit="0200"] impl S { } + //~^ WARN crate-level attribute should be an inner attribute +} + +#[type_length_limit="0100"] +//~^ WARN crate-level attribute should be an inner attribute +mod type_length_limit { + mod inner { #![type_length_limit="0100"] } +//~^ WARN crate-level attribute should be in the root module + + #[type_length_limit="0100"] fn f() { } + //~^ WARN crate-level attribute should be an inner attribute + + #[type_length_limit="0100"] struct S; + //~^ WARN crate-level attribute should be an inner attribute + + #[type_length_limit="0100"] type T = S; + //~^ WARN crate-level attribute should be an inner attribute + + #[type_length_limit="0100"] impl S { } + //~^ WARN crate-level attribute should be an inner attribute +} + +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr new file mode 100644 index 000000000..300392679 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -0,0 +1,1181 @@ +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:400:17 + | +LL | mod inner { #![macro_escape] } + | ^^^^^^^^^^^^^^^^ + | + = help: try an outer attribute: `#[macro_use]` + +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:397:1 + | +LL | #[macro_escape] + | ^^^^^^^^^^^^^^^ + +warning: unknown lint: `x5400` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:46:9 + | +LL | #![warn(x5400)] + | ^^^^^ + | +note: the lint level is defined here + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:40:28 + | +LL | #![warn(unused_attributes, unknown_lints)] + | ^^^^^^^^^^^^^ + +warning: unknown lint: `x5300` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:47:10 + | +LL | #![allow(x5300)] + | ^^^^^ + +warning: unknown lint: `x5200` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:48:11 + | +LL | #![forbid(x5200)] + | ^^^^^ + +warning: unknown lint: `x5100` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:49:9 + | +LL | #![deny(x5100)] + | ^^^^^ + +warning: unknown lint: `x5400` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:105:8 + | +LL | #[warn(x5400)] + | ^^^^^ + +warning: unknown lint: `x5400` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:108:25 + | +LL | mod inner { #![warn(x5400)] } + | ^^^^^ + +warning: unknown lint: `x5400` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:111:12 + | +LL | #[warn(x5400)] fn f() { } + | ^^^^^ + +warning: unknown lint: `x5400` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:114:12 + | +LL | #[warn(x5400)] struct S; + | ^^^^^ + +warning: unknown lint: `x5400` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:117:12 + | +LL | #[warn(x5400)] type T = S; + | ^^^^^ + +warning: unknown lint: `x5400` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:120:12 + | +LL | #[warn(x5400)] impl S { } + | ^^^^^ + +warning: unknown lint: `x5300` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:124:9 + | +LL | #[allow(x5300)] + | ^^^^^ + +warning: unknown lint: `x5300` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:127:26 + | +LL | mod inner { #![allow(x5300)] } + | ^^^^^ + +warning: unknown lint: `x5300` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:130:13 + | +LL | #[allow(x5300)] fn f() { } + | ^^^^^ + +warning: unknown lint: `x5300` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:133:13 + | +LL | #[allow(x5300)] struct S; + | ^^^^^ + +warning: unknown lint: `x5300` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:136:13 + | +LL | #[allow(x5300)] type T = S; + | ^^^^^ + +warning: unknown lint: `x5300` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:139:13 + | +LL | #[allow(x5300)] impl S { } + | ^^^^^ + +warning: unknown lint: `x5200` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:143:10 + | +LL | #[forbid(x5200)] + | ^^^^^ + +warning: unknown lint: `x5200` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:146:27 + | +LL | mod inner { #![forbid(x5200)] } + | ^^^^^ + +warning: unknown lint: `x5200` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:149:14 + | +LL | #[forbid(x5200)] fn f() { } + | ^^^^^ + +warning: unknown lint: `x5200` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:152:14 + | +LL | #[forbid(x5200)] struct S; + | ^^^^^ + +warning: unknown lint: `x5200` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:155:14 + | +LL | #[forbid(x5200)] type T = S; + | ^^^^^ + +warning: unknown lint: `x5200` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:158:14 + | +LL | #[forbid(x5200)] impl S { } + | ^^^^^ + +warning: unknown lint: `x5100` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:162:8 + | +LL | #[deny(x5100)] + | ^^^^^ + +warning: unknown lint: `x5100` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:165:25 + | +LL | mod inner { #![deny(x5100)] } + | ^^^^^ + +warning: unknown lint: `x5100` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:168:12 + | +LL | #[deny(x5100)] fn f() { } + | ^^^^^ + +warning: unknown lint: `x5100` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:171:12 + | +LL | #[deny(x5100)] struct S; + | ^^^^^ + +warning: unknown lint: `x5100` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:174:12 + | +LL | #[deny(x5100)] type T = S; + | ^^^^^ + +warning: unknown lint: `x5100` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:177:12 + | +LL | #[deny(x5100)] impl S { } + | ^^^^^ + +warning: use of deprecated attribute `crate_id`: no longer used. + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:84:1 + | +LL | #![crate_id = "10"] + | ^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | + = note: `#[warn(deprecated)]` on by default + +warning: use of deprecated attribute `no_start`: no longer used. + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:94:1 + | +LL | #![no_start] + | ^^^^^^^^^^^^ help: remove this attribute + +warning: `#[macro_export]` only has an effect on macro definitions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:198:1 + | +LL | #[macro_export] + | ^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:40:9 + | +LL | #![warn(unused_attributes, unknown_lints)] + | ^^^^^^^^^^^^^^^^^ + +warning: `#[automatically_derived]` only has an effect on implementation blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:266:1 + | +LL | #[automatically_derived] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:284:1 + | +LL | #[no_mangle] + | ^^^^^^^^^^^^ +... +LL | / mod no_mangle { +LL | | +LL | | mod inner { #![no_mangle] } +LL | | +... | +LL | | } +LL | | } + | |_- not a free function, impl method or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: `#[should_panic]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:324:1 + | +LL | #[should_panic] + | ^^^^^^^^^^^^^^^ + +warning: `#[ignore]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:342:1 + | +LL | #[ignore] + | ^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:377:1 + | +LL | #[reexport_test_harness_main = "2900"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:417:1 + | +LL | #[no_std] + | ^^^^^^^^^ + +warning: attribute should be applied to a function definition + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:453:1 + | +LL | #[cold] + | ^^^^^^^ +... +LL | / mod cold { +LL | | +LL | | +LL | | mod inner { #![cold] } +... | +LL | | +LL | | } + | |_- not a function definition + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a foreign function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:482:1 + | +LL | #[link_name = "1900"] + | ^^^^^^^^^^^^^^^^^^^^^ +... +LL | / mod link_name { +LL | | +LL | | +LL | | #[link_name = "1900"] +... | +LL | | +LL | | } + | |_- not a foreign function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:521:1 + | +LL | #[link_section = "1800"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | / mod link_section { +LL | | +LL | | +LL | | mod inner { #![link_section="1800"] } +... | +LL | | +LL | | } + | |_- not a function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to an `extern` block with non-Rust ABI + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:553:1 + | +LL | #[link()] + | ^^^^^^^^^ +... +LL | / mod link { +LL | | +LL | | +LL | | mod inner { #![link()] } +... | +LL | | +LL | | } + | |_- not an `extern` block + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: `#[must_use]` has no effect when applied to a module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:604:1 + | +LL | #[must_use] + | ^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:617:1 + | +LL | #[windows_subsystem = "windows"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:638:1 + | +LL | #[crate_name = "0900"] + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:657:1 + | +LL | #[crate_type = "0800"] + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:676:1 + | +LL | #[feature(x0600)] + | ^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:696:1 + | +LL | #[no_main] + | ^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:715:1 + | +LL | #[no_builtins] + | ^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:734:1 + | +LL | #[recursion_limit="0200"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:753:1 + | +LL | #[type_length_limit="0100"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[should_panic]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:53:1 + | +LL | #![should_panic] + | ^^^^^^^^^^^^^^^^ + +warning: `#[ignore]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:54:1 + | +LL | #![ignore] + | ^^^^^^^^^^ + +warning: `#[proc_macro_derive]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:60:1 + | +LL | #![proc_macro_derive()] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: attribute should be applied to a function definition + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1 + | +LL | #![cold] + | ^^^^^^^^ cannot be applied to crates + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to an `extern` block with non-Rust ABI + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:64:1 + | +LL | #![link()] + | ^^^^^^^^^^ not an `extern` block + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a foreign function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:66:1 + | +LL | #![link_name = "1900"] + | ^^^^^^^^^^^^^^^^^^^^^^ not a foreign function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1 + | +LL | #![link_section = "1800"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: `#[must_use]` has no effect when applied to a module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1 + | +LL | #![must_use] + | ^^^^^^^^^^^^ + +warning: `#[macro_use]` only has an effect on `extern crate` and modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:185:5 + | +LL | #[macro_use] fn f() { } + | ^^^^^^^^^^^^ + +warning: `#[macro_use]` only has an effect on `extern crate` and modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:188:5 + | +LL | #[macro_use] struct S; + | ^^^^^^^^^^^^ + +warning: `#[macro_use]` only has an effect on `extern crate` and modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:191:5 + | +LL | #[macro_use] type T = S; + | ^^^^^^^^^^^^ + +warning: `#[macro_use]` only has an effect on `extern crate` and modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:194:5 + | +LL | #[macro_use] impl S { } + | ^^^^^^^^^^^^ + +warning: `#[macro_export]` only has an effect on macro definitions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:201:17 + | +LL | mod inner { #![macro_export] } + | ^^^^^^^^^^^^^^^^ + +warning: `#[macro_export]` only has an effect on macro definitions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:204:5 + | +LL | #[macro_export] fn f() { } + | ^^^^^^^^^^^^^^^ + +warning: `#[macro_export]` only has an effect on macro definitions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:207:5 + | +LL | #[macro_export] struct S; + | ^^^^^^^^^^^^^^^ + +warning: `#[macro_export]` only has an effect on macro definitions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:210:5 + | +LL | #[macro_export] type T = S; + | ^^^^^^^^^^^^^^^ + +warning: `#[macro_export]` only has an effect on macro definitions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:213:5 + | +LL | #[macro_export] impl S { } + | ^^^^^^^^^^^^^^^ + +warning: `#[path]` only has an effect on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:253:5 + | +LL | #[path = "3800"] fn f() { } + | ^^^^^^^^^^^^^^^^ + +warning: `#[path]` only has an effect on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:256:5 + | +LL | #[path = "3800"] struct S; + | ^^^^^^^^^^^^^^^^ + +warning: `#[path]` only has an effect on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:259:5 + | +LL | #[path = "3800"] type T = S; + | ^^^^^^^^^^^^^^^^ + +warning: `#[path]` only has an effect on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:262:5 + | +LL | #[path = "3800"] impl S { } + | ^^^^^^^^^^^^^^^^ + +warning: `#[automatically_derived]` only has an effect on implementation blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:269:17 + | +LL | mod inner { #![automatically_derived] } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[automatically_derived]` only has an effect on implementation blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:272:5 + | +LL | #[automatically_derived] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[automatically_derived]` only has an effect on implementation blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:275:5 + | +LL | #[automatically_derived] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[automatically_derived]` only has an effect on implementation blocks + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:278:5 + | +LL | #[automatically_derived] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:289:17 + | +LL | mod inner { #![no_mangle] } + | ------------^^^^^^^^^^^^^-- not a free function, impl method or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:296:5 + | +LL | #[no_mangle] struct S; + | ^^^^^^^^^^^^ --------- not a free function, impl method or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:301:5 + | +LL | #[no_mangle] type T = S; + | ^^^^^^^^^^^^ ----------- not a free function, impl method or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:306:5 + | +LL | #[no_mangle] impl S { } + | ^^^^^^^^^^^^ ---------- not a free function, impl method or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:312:9 + | +LL | #[no_mangle] fn foo(); + | ^^^^^^^^^^^^ --------- not a free function, impl method or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a free function, impl method or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:317:9 + | +LL | #[no_mangle] fn bar() {} + | ^^^^^^^^^^^^ ----------- not a free function, impl method or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: `#[should_panic]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:327:17 + | +LL | mod inner { #![should_panic] } + | ^^^^^^^^^^^^^^^^ + +warning: `#[should_panic]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:332:5 + | +LL | #[should_panic] struct S; + | ^^^^^^^^^^^^^^^ + +warning: `#[should_panic]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:335:5 + | +LL | #[should_panic] type T = S; + | ^^^^^^^^^^^^^^^ + +warning: `#[should_panic]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:338:5 + | +LL | #[should_panic] impl S { } + | ^^^^^^^^^^^^^^^ + +warning: `#[ignore]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:345:17 + | +LL | mod inner { #![ignore] } + | ^^^^^^^^^^ + +warning: `#[ignore]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:350:5 + | +LL | #[ignore] struct S; + | ^^^^^^^^^ + +warning: `#[ignore]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:353:5 + | +LL | #[ignore] type T = S; + | ^^^^^^^^^ + +warning: `#[ignore]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:356:5 + | +LL | #[ignore] impl S { } + | ^^^^^^^^^ + +warning: `#[no_implicit_prelude]` only has an effect on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:364:5 + | +LL | #[no_implicit_prelude] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[no_implicit_prelude]` only has an effect on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:367:5 + | +LL | #[no_implicit_prelude] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[no_implicit_prelude]` only has an effect on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:370:5 + | +LL | #[no_implicit_prelude] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[no_implicit_prelude]` only has an effect on modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:373:5 + | +LL | #[no_implicit_prelude] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:380:17 + | +LL | mod inner { #![reexport_test_harness_main="2900"] } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:383:5 + | +LL | #[reexport_test_harness_main = "2900"] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:386:5 + | +LL | #[reexport_test_harness_main = "2900"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:389:5 + | +LL | #[reexport_test_harness_main = "2900"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:392:5 + | +LL | #[reexport_test_harness_main = "2900"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: `#[macro_escape]` only has an effect on `extern crate` and modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:404:5 + | +LL | #[macro_escape] fn f() { } + | ^^^^^^^^^^^^^^^ + +warning: `#[macro_escape]` only has an effect on `extern crate` and modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:407:5 + | +LL | #[macro_escape] struct S; + | ^^^^^^^^^^^^^^^ + +warning: `#[macro_escape]` only has an effect on `extern crate` and modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:410:5 + | +LL | #[macro_escape] type T = S; + | ^^^^^^^^^^^^^^^ + +warning: `#[macro_escape]` only has an effect on `extern crate` and modules + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:413:5 + | +LL | #[macro_escape] impl S { } + | ^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:420:17 + | +LL | mod inner { #![no_std] } + | ^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:423:5 + | +LL | #[no_std] fn f() { } + | ^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:426:5 + | +LL | #[no_std] struct S; + | ^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:429:5 + | +LL | #[no_std] type T = S; + | ^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:432:5 + | +LL | #[no_std] impl S { } + | ^^^^^^^^^ + +warning: attribute should be applied to a function definition + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:459:17 + | +LL | mod inner { #![cold] } + | ------------^^^^^^^^-- not a function definition + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a function definition + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:466:5 + | +LL | #[cold] struct S; + | ^^^^^^^ --------- not a function definition + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a function definition + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:471:5 + | +LL | #[cold] type T = S; + | ^^^^^^^ ----------- not a function definition + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a function definition + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5 + | +LL | #[cold] impl S { } + | ^^^^^^^ ---------- not a function definition + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a foreign function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 + | +LL | #[link_name = "1900"] + | ^^^^^^^^^^^^^^^^^^^^^ +... +LL | extern "C" { } + | -------------- not a foreign function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +help: try `#[link(name = "1900")]` instead + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:488:5 + | +LL | #[link_name = "1900"] + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: attribute should be applied to a foreign function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:495:17 + | +LL | mod inner { #![link_name="1900"] } + | ------------^^^^^^^^^^^^^^^^^^^^-- not a foreign function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a foreign function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:500:5 + | +LL | #[link_name = "1900"] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a foreign function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:505:5 + | +LL | #[link_name = "1900"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^ --------- not a foreign function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a foreign function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:510:5 + | +LL | #[link_name = "1900"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^ ----------- not a foreign function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a foreign function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:515:5 + | +LL | #[link_name = "1900"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:527:17 + | +LL | mod inner { #![link_section="1800"] } + | ------------^^^^^^^^^^^^^^^^^^^^^^^-- not a function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:534:5 + | +LL | #[link_section = "1800"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^^ --------- not a function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:539:5 + | +LL | #[link_section = "1800"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to a function or static + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:544:5 + | +LL | #[link_section = "1800"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to an `extern` block with non-Rust ABI + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:559:17 + | +LL | mod inner { #![link()] } + | ------------^^^^^^^^^^-- not an `extern` block + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to an `extern` block with non-Rust ABI + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:564:5 + | +LL | #[link()] fn f() { } + | ^^^^^^^^^ ---------- not an `extern` block + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to an `extern` block with non-Rust ABI + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:569:5 + | +LL | #[link()] struct S; + | ^^^^^^^^^ --------- not an `extern` block + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to an `extern` block with non-Rust ABI + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:574:5 + | +LL | #[link()] type T = S; + | ^^^^^^^^^ ----------- not an `extern` block + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to an `extern` block with non-Rust ABI + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:579:5 + | +LL | #[link()] impl S { } + | ^^^^^^^^^ ---------- not an `extern` block + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: attribute should be applied to an `extern` block with non-Rust ABI + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:584:5 + | +LL | #[link()] extern "Rust" {} + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +warning: `#[must_use]` has no effect when applied to a module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:606:17 + | +LL | mod inner { #![must_use] } + | ^^^^^^^^^^^^ + +warning: `#[must_use]` has no effect when applied to a type alias + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:612:5 + | +LL | #[must_use] type T = S; + | ^^^^^^^^^^^ + +warning: `#[must_use]` has no effect when applied to an implementation block + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:5 + | +LL | #[must_use] impl S { } + | ^^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:17 + | +LL | mod inner { #![windows_subsystem="windows"] } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:623:5 + | +LL | #[windows_subsystem = "windows"] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5 + | +LL | #[windows_subsystem = "windows"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:629:5 + | +LL | #[windows_subsystem = "windows"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:632:5 + | +LL | #[windows_subsystem = "windows"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:641:17 + | +LL | mod inner { #![crate_name="0900"] } + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:644:5 + | +LL | #[crate_name = "0900"] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:647:5 + | +LL | #[crate_name = "0900"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:650:5 + | +LL | #[crate_name = "0900"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:653:5 + | +LL | #[crate_name = "0900"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:660:17 + | +LL | mod inner { #![crate_type="0800"] } + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:663:5 + | +LL | #[crate_type = "0800"] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:666:5 + | +LL | #[crate_type = "0800"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:669:5 + | +LL | #[crate_type = "0800"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:672:5 + | +LL | #[crate_type = "0800"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:679:17 + | +LL | mod inner { #![feature(x0600)] } + | ^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:682:5 + | +LL | #[feature(x0600)] fn f() { } + | ^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:685:5 + | +LL | #[feature(x0600)] struct S; + | ^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:688:5 + | +LL | #[feature(x0600)] type T = S; + | ^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:5 + | +LL | #[feature(x0600)] impl S { } + | ^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:699:17 + | +LL | mod inner { #![no_main] } + | ^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:702:5 + | +LL | #[no_main] fn f() { } + | ^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:705:5 + | +LL | #[no_main] struct S; + | ^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:708:5 + | +LL | #[no_main] type T = S; + | ^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:5 + | +LL | #[no_main] impl S { } + | ^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:17 + | +LL | mod inner { #![no_builtins] } + | ^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5 + | +LL | #[no_builtins] fn f() { } + | ^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:5 + | +LL | #[no_builtins] struct S; + | ^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:727:5 + | +LL | #[no_builtins] type T = S; + | ^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:730:5 + | +LL | #[no_builtins] impl S { } + | ^^^^^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:17 + | +LL | mod inner { #![recursion_limit="0200"] } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:740:5 + | +LL | #[recursion_limit="0200"] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:743:5 + | +LL | #[recursion_limit="0200"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:5 + | +LL | #[recursion_limit="0200"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:749:5 + | +LL | #[recursion_limit="0200"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be in the root module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:756:17 + | +LL | mod inner { #![type_length_limit="0100"] } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:759:5 + | +LL | #[type_length_limit="0100"] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:5 + | +LL | #[type_length_limit="0100"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:765:5 + | +LL | #[type_length_limit="0100"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:768:5 + | +LL | #[type_length_limit="0100"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: the feature `rust1` has been stable since 1.0.0 and no longer requires an attribute to enable + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:90:12 + | +LL | #![feature(rust1)] + | ^^^^^ + | + = note: `#[warn(stable_features)]` on by default + +warning: 173 warnings emitted + diff --git a/tests/ui/feature-gates/issue-43106-gating-of-deprecated.rs b/tests/ui/feature-gates/issue-43106-gating-of-deprecated.rs new file mode 100644 index 000000000..5e1d08dd9 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-deprecated.rs @@ -0,0 +1,12 @@ +// This test just shows that a crate-level `#![deprecated]` does not +// signal a warning or error. (This file sits on its own because a +// crate-level `#![deprecated]` causes all that crate's item +// definitions to be deprecated, which is a pain to work with.) +// +// (For non-crate-level cases, see issue-43106-gating-of-builtin-attrs.rs) + +// check-pass + +#![deprecated] + +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-derive-2.rs b/tests/ui/feature-gates/issue-43106-gating-of-derive-2.rs new file mode 100644 index 000000000..3276309f7 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-derive-2.rs @@ -0,0 +1,20 @@ +// This test checks cases where the derive-macro does not exist. + +mod derive { + #[derive(x3300)] + //~^ ERROR cannot find derive macro `x3300` in this scope + //~| ERROR cannot find derive macro `x3300` in this scope + union U { f: i32 } + + #[derive(x3300)] + //~^ ERROR cannot find derive macro `x3300` in this scope + //~| ERROR cannot find derive macro `x3300` in this scope + enum E { } + + #[derive(x3300)] + //~^ ERROR cannot find derive macro `x3300` in this scope + //~| ERROR cannot find derive macro `x3300` in this scope + struct S; +} + +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-derive-2.stderr b/tests/ui/feature-gates/issue-43106-gating-of-derive-2.stderr new file mode 100644 index 000000000..ab1659173 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-derive-2.stderr @@ -0,0 +1,38 @@ +error: cannot find derive macro `x3300` in this scope + --> $DIR/issue-43106-gating-of-derive-2.rs:14:14 + | +LL | #[derive(x3300)] + | ^^^^^ + +error: cannot find derive macro `x3300` in this scope + --> $DIR/issue-43106-gating-of-derive-2.rs:14:14 + | +LL | #[derive(x3300)] + | ^^^^^ + +error: cannot find derive macro `x3300` in this scope + --> $DIR/issue-43106-gating-of-derive-2.rs:9:14 + | +LL | #[derive(x3300)] + | ^^^^^ + +error: cannot find derive macro `x3300` in this scope + --> $DIR/issue-43106-gating-of-derive-2.rs:9:14 + | +LL | #[derive(x3300)] + | ^^^^^ + +error: cannot find derive macro `x3300` in this scope + --> $DIR/issue-43106-gating-of-derive-2.rs:4:14 + | +LL | #[derive(x3300)] + | ^^^^^ + +error: cannot find derive macro `x3300` in this scope + --> $DIR/issue-43106-gating-of-derive-2.rs:4:14 + | +LL | #[derive(x3300)] + | ^^^^^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/feature-gates/issue-43106-gating-of-derive.rs b/tests/ui/feature-gates/issue-43106-gating-of-derive.rs new file mode 100644 index 000000000..86a352251 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-derive.rs @@ -0,0 +1,33 @@ +// `#![derive]` raises errors when it occurs at contexts other than ADT +// definitions. + +#[derive(Debug)] +//~^ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s +mod derive { + mod inner { #![derive(Debug)] } + //~^ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s + //~| ERROR inner macro attributes are unstable + + #[derive(Debug)] + //~^ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s + fn derive() { } + + #[derive(Copy, Clone)] // (can't derive Debug for unions) + union U { f: i32 } + + #[derive(Debug)] + struct S; + + #[derive(Debug)] + enum E { } + + #[derive(Debug)] + //~^ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s + type T = S; + + #[derive(Debug)] + //~^ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s + impl S { } +} + +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-derive.stderr b/tests/ui/feature-gates/issue-43106-gating-of-derive.stderr new file mode 100644 index 000000000..bb8651ffb --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-derive.stderr @@ -0,0 +1,64 @@ +error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s + --> $DIR/issue-43106-gating-of-derive.rs:4:1 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ not applicable here +LL | +LL | / mod derive { +LL | | mod inner { #![derive(Debug)] } +LL | | +LL | | +... | +LL | | impl S { } +LL | | } + | |_- not a `struct`, `enum` or `union` + +error[E0658]: inner macro attributes are unstable + --> $DIR/issue-43106-gating-of-derive.rs:7:20 + | +LL | mod inner { #![derive(Debug)] } + | ^^^^^^ + | + = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information + = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable + +error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s + --> $DIR/issue-43106-gating-of-derive.rs:7:17 + | +LL | mod inner { #![derive(Debug)] } + | ------------^^^^^^^^^^^^^^^^^-- + | | | + | | not applicable here + | not a `struct`, `enum` or `union` + +error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s + --> $DIR/issue-43106-gating-of-derive.rs:11:5 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ not applicable here +LL | +LL | fn derive() { } + | --------------- not a `struct`, `enum` or `union` + +error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s + --> $DIR/issue-43106-gating-of-derive.rs:24:5 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ not applicable here +LL | +LL | type T = S; + | ----------- not a `struct`, `enum` or `union` + +error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s + --> $DIR/issue-43106-gating-of-derive.rs:28:5 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ not applicable here +LL | +LL | impl S { } + | ---------- not a `struct`, `enum` or `union` + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0658, E0774. +For more information about an error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-macro_escape.rs b/tests/ui/feature-gates/issue-43106-gating-of-macro_escape.rs new file mode 100644 index 000000000..de00bc4cb --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-macro_escape.rs @@ -0,0 +1,11 @@ +// Testing that crate-level `#![macro_escape]` is not gated beyond a +// depecation warning. This file sits on its own, because crate-level +// `#![macro_escape]` is incompatible with crate-level `#![macro_use]` +// already present in issue-43106-gating-of-builtin-attrs. + +// check-pass + +#![macro_escape] +//~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]` + +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-macro_escape.stderr b/tests/ui/feature-gates/issue-43106-gating-of-macro_escape.stderr new file mode 100644 index 000000000..0eaec5202 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-macro_escape.stderr @@ -0,0 +1,10 @@ +warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` + --> $DIR/issue-43106-gating-of-macro_escape.rs:8:1 + | +LL | #![macro_escape] + | ^^^^^^^^^^^^^^^^ + | + = help: try an outer attribute: `#[macro_use]` + +warning: 1 warning emitted + diff --git a/tests/ui/feature-gates/issue-43106-gating-of-macro_use.rs b/tests/ui/feature-gates/issue-43106-gating-of-macro_use.rs new file mode 100644 index 000000000..6a7ef7939 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-macro_use.rs @@ -0,0 +1,25 @@ +// This is just a check-list of the cases where feeding arguments to +// `#[macro_use]` is rejected. (The cases where no error is emitted +// corresponds to cases where the attribute is currently unused, so we +// get that warning; see issue-43106-gating-of-builtin-attrs.rs + +#![macro_use(my_macro)] +//~^ ERROR arguments to `macro_use` are not allowed here + +#[macro_use(my_macro)] +//~^ ERROR arguments to `macro_use` are not allowed here +mod macro_escape { + mod inner { #![macro_use(my_macro)] } + //~^ ERROR arguments to `macro_use` are not allowed here + + #[macro_use = "2700"] struct S; + //~^ ERROR malformed `macro_use` attribute + + #[macro_use] fn f() { } + + #[macro_use] type T = S; + + #[macro_use] impl S { } +} + +fn main() { } diff --git a/tests/ui/feature-gates/issue-43106-gating-of-macro_use.stderr b/tests/ui/feature-gates/issue-43106-gating-of-macro_use.stderr new file mode 100644 index 000000000..9a12851f2 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-macro_use.stderr @@ -0,0 +1,33 @@ +error: arguments to `macro_use` are not allowed here + --> $DIR/issue-43106-gating-of-macro_use.rs:12:17 + | +LL | mod inner { #![macro_use(my_macro)] } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: arguments to `macro_use` are not allowed here + --> $DIR/issue-43106-gating-of-macro_use.rs:9:1 + | +LL | #[macro_use(my_macro)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: arguments to `macro_use` are not allowed here + --> $DIR/issue-43106-gating-of-macro_use.rs:6:1 + | +LL | #![macro_use(my_macro)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: malformed `macro_use` attribute input + --> $DIR/issue-43106-gating-of-macro_use.rs:15:5 + | +LL | #[macro_use = "2700"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[macro_use(name1, name2, ...)] struct S; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | #[macro_use] struct S; + | ~~~~~~~~~~~~ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs new file mode 100644 index 000000000..a94ffd602 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs @@ -0,0 +1,34 @@ +// At time of authorship, #[proc_macro_derive = "2500"] will emit an +// error when it occurs on a mod (apart from crate-level), but will +// not descend further into the mod for other occurrences of the same +// error. +// +// This file sits on its own because the "weird" occurrences here +// signal errors, making it incompatible with the "warnings only" +// nature of issue-43106-gating-of-builtin-attrs.rs + +#[proc_macro_derive()] +//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions +mod proc_macro_derive1 { + mod inner { #![proc_macro_derive()] } + // (no error issued here if there was one on outer module) +} + +mod proc_macro_derive2 { + mod inner { #![proc_macro_derive()] } + //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions + + #[proc_macro_derive()] fn f() { } + //~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` + + #[proc_macro_derive()] struct S; + //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions + + #[proc_macro_derive()] type T = S; + //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions + + #[proc_macro_derive()] impl S { } + //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions +} + +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr new file mode 100644 index 000000000..e202b472d --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr @@ -0,0 +1,38 @@ +error: the `#[proc_macro_derive]` attribute may only be used on bare functions + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:10:1 + | +LL | #[proc_macro_derive()] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_derive]` attribute may only be used on bare functions + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:18:17 + | +LL | mod inner { #![proc_macro_derive()] } + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:21:5 + | +LL | #[proc_macro_derive()] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_derive]` attribute may only be used on bare functions + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:24:5 + | +LL | #[proc_macro_derive()] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_derive]` attribute may only be used on bare functions + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:27:5 + | +LL | #[proc_macro_derive()] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_derive]` attribute may only be used on bare functions + --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:30:5 + | +LL | #[proc_macro_derive()] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/feature-gates/issue-43106-gating-of-stable.rs b/tests/ui/feature-gates/issue-43106-gating-of-stable.rs new file mode 100644 index 000000000..621ec01bb --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-stable.rs @@ -0,0 +1,35 @@ +// Testing gating of `#[stable]` in "weird" places. +// +// This file sits on its own because these signal errors, making +// this test incompatible with the "warnings only" nature of +// issue-43106-gating-of-builtin-attrs.rs + +#![stable()] +//~^ ERROR stability attributes may not be used outside of the standard library + +#[stable()] +//~^ ERROR stability attributes may not be used outside of the standard library +mod stable { + mod inner { + #![stable()] + //~^ ERROR stability attributes may not be used outside of the standard library + } + + #[stable()] + //~^ ERROR stability attributes may not be used outside of the standard library + fn f() {} + + #[stable()] + //~^ ERROR stability attributes may not be used outside of the standard library + struct S; + + #[stable()] + //~^ ERROR stability attributes may not be used outside of the standard library + type T = S; + + #[stable()] + //~^ ERROR stability attributes may not be used outside of the standard library + impl S {} +} + +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-stable.stderr b/tests/ui/feature-gates/issue-43106-gating-of-stable.stderr new file mode 100644 index 000000000..677fef3a9 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-stable.stderr @@ -0,0 +1,45 @@ +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-stable.rs:14:9 + | +LL | #![stable()] + | ^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-stable.rs:18:5 + | +LL | #[stable()] + | ^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-stable.rs:22:5 + | +LL | #[stable()] + | ^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-stable.rs:26:5 + | +LL | #[stable()] + | ^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-stable.rs:30:5 + | +LL | #[stable()] + | ^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-stable.rs:10:1 + | +LL | #[stable()] + | ^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-stable.rs:7:1 + | +LL | #![stable()] + | ^^^^^^^^^^^^ + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-test.rs b/tests/ui/feature-gates/issue-43106-gating-of-test.rs new file mode 100644 index 000000000..39835c926 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-test.rs @@ -0,0 +1,7 @@ +// The non-crate level cases are in issue-43106-gating-of-builtin-attrs.rs. + +#![allow(soft_unstable)] +#![test = "4200"] +//~^ ERROR cannot determine resolution for the attribute macro `test` +//~^^ ERROR `test` attribute cannot be used at crate level +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-test.stderr b/tests/ui/feature-gates/issue-43106-gating-of-test.stderr new file mode 100644 index 000000000..300a9966d --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-test.stderr @@ -0,0 +1,21 @@ +error: cannot determine resolution for the attribute macro `test` + --> $DIR/issue-43106-gating-of-test.rs:4:4 + | +LL | #![test = "4200"] + | ^^^^ + | + = note: import resolution is stuck, try simplifying macro imports + +error: `test` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-test.rs:4:1 + | +LL | #![test = "4200"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: perhaps you meant to use an outer attribute + | +LL | #[test = "4200"] + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/feature-gates/issue-43106-gating-of-unstable.rs b/tests/ui/feature-gates/issue-43106-gating-of-unstable.rs new file mode 100644 index 000000000..d507bcd8f --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-unstable.rs @@ -0,0 +1,35 @@ +// Testing gating of `#[unstable]` in "weird" places. +// +// This file sits on its own because these signal errors, making +// this test incompatible with the "warnings only" nature of +// issue-43106-gating-of-builtin-attrs.rs + +#![unstable()] +//~^ ERROR stability attributes may not be used outside of the standard library + +#[unstable()] +//~^ ERROR stability attributes may not be used outside of the standard library +mod unstable { + mod inner { + #![unstable()] + //~^ ERROR stability attributes may not be used outside of the standard library + } + + #[unstable()] + //~^ ERROR stability attributes may not be used outside of the standard library + fn f() {} + + #[unstable()] + //~^ ERROR stability attributes may not be used outside of the standard library + struct S; + + #[unstable()] + //~^ ERROR stability attributes may not be used outside of the standard library + type T = S; + + #[unstable()] + //~^ ERROR stability attributes may not be used outside of the standard library + impl S {} +} + +fn main() {} diff --git a/tests/ui/feature-gates/issue-43106-gating-of-unstable.stderr b/tests/ui/feature-gates/issue-43106-gating-of-unstable.stderr new file mode 100644 index 000000000..a2f361878 --- /dev/null +++ b/tests/ui/feature-gates/issue-43106-gating-of-unstable.stderr @@ -0,0 +1,45 @@ +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-unstable.rs:14:9 + | +LL | #![unstable()] + | ^^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-unstable.rs:18:5 + | +LL | #[unstable()] + | ^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-unstable.rs:22:5 + | +LL | #[unstable()] + | ^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-unstable.rs:26:5 + | +LL | #[unstable()] + | ^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-unstable.rs:30:5 + | +LL | #[unstable()] + | ^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-unstable.rs:10:1 + | +LL | #[unstable()] + | ^^^^^^^^^^^^^ + +error[E0734]: stability attributes may not be used outside of the standard library + --> $DIR/issue-43106-gating-of-unstable.rs:7:1 + | +LL | #![unstable()] + | ^^^^^^^^^^^^^^ + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0734`. diff --git a/tests/ui/feature-gates/issue-49983-see-issue-0.rs b/tests/ui/feature-gates/issue-49983-see-issue-0.rs new file mode 100644 index 000000000..eeb80d014 --- /dev/null +++ b/tests/ui/feature-gates/issue-49983-see-issue-0.rs @@ -0,0 +1,6 @@ +extern crate core; + +// error should not say "(see issue #0)" +#[allow(unused_imports)] use core::ptr::Unique; //~ ERROR use of unstable library feature + +fn main() {} diff --git a/tests/ui/feature-gates/issue-49983-see-issue-0.stderr b/tests/ui/feature-gates/issue-49983-see-issue-0.stderr new file mode 100644 index 000000000..314238a34 --- /dev/null +++ b/tests/ui/feature-gates/issue-49983-see-issue-0.stderr @@ -0,0 +1,11 @@ +error[E0658]: use of unstable library feature 'ptr_internals': use `NonNull` instead and consider `PhantomData<T>` (if you also use `#[may_dangle]`), `Send`, and/or `Sync` + --> $DIR/issue-49983-see-issue-0.rs:4:30 + | +LL | #[allow(unused_imports)] use core::ptr::Unique; + | ^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(ptr_internals)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/rustc-private.rs b/tests/ui/feature-gates/rustc-private.rs new file mode 100644 index 000000000..7b8944bb0 --- /dev/null +++ b/tests/ui/feature-gates/rustc-private.rs @@ -0,0 +1,5 @@ +// gate-test-rustc_private + +extern crate libc; //~ ERROR use of unstable library feature 'rustc_private' + +fn main() {} diff --git a/tests/ui/feature-gates/rustc-private.stderr b/tests/ui/feature-gates/rustc-private.stderr new file mode 100644 index 000000000..1a8536d37 --- /dev/null +++ b/tests/ui/feature-gates/rustc-private.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? + --> $DIR/rustc-private.rs:3:1 + | +LL | extern crate libc; + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #27812 <https://github.com/rust-lang/rust/issues/27812> for more information + = help: add `#![feature(rustc_private)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/soft-syntax-gates-with-errors.rs b/tests/ui/feature-gates/soft-syntax-gates-with-errors.rs new file mode 100644 index 000000000..49f1cba71 --- /dev/null +++ b/tests/ui/feature-gates/soft-syntax-gates-with-errors.rs @@ -0,0 +1,30 @@ +// check-fail +// This file is used to test the behavior of the early-pass syntax warnings. +// If macro syntax is stabilized, replace with a different unstable syntax. + +macro a() {} +//~^ ERROR: `macro` is experimental + +#[cfg(FALSE)] +macro b() {} + +macro_rules! identity { + ($($x:tt)*) => ($($x)*); +} + +identity! { + macro c() {} + //~^ ERROR: `macro` is experimental +} + +#[cfg(FALSE)] +identity! { + macro d() {} // No error +} + +identity! { + #[cfg(FALSE)] + macro e() {} +} + +fn main() {} diff --git a/tests/ui/feature-gates/soft-syntax-gates-with-errors.stderr b/tests/ui/feature-gates/soft-syntax-gates-with-errors.stderr new file mode 100644 index 000000000..49550d811 --- /dev/null +++ b/tests/ui/feature-gates/soft-syntax-gates-with-errors.stderr @@ -0,0 +1,21 @@ +error[E0658]: `macro` is experimental + --> $DIR/soft-syntax-gates-with-errors.rs:5:1 + | +LL | macro a() {} + | ^^^^^^^^^^^^ + | + = note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information + = help: add `#![feature(decl_macro)]` to the crate attributes to enable + +error[E0658]: `macro` is experimental + --> $DIR/soft-syntax-gates-with-errors.rs:16:5 + | +LL | macro c() {} + | ^^^^^^^^^^^^ + | + = note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information + = help: add `#![feature(decl_macro)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/soft-syntax-gates-without-errors.rs b/tests/ui/feature-gates/soft-syntax-gates-without-errors.rs new file mode 100644 index 000000000..ca4ad2320 --- /dev/null +++ b/tests/ui/feature-gates/soft-syntax-gates-without-errors.rs @@ -0,0 +1,26 @@ +// check-pass +// This file is used to test the behavior of the early-pass syntax warnings. +// If macro syntax is stabilized, replace with a different unstable syntax. + +#[cfg(FALSE)] +macro b() {} +//~^ WARN: `macro` is experimental +//~| WARN: unstable syntax + +macro_rules! identity { + ($($x:tt)*) => ($($x)*); +} + +#[cfg(FALSE)] +identity! { + macro d() {} // No error +} + +identity! { + #[cfg(FALSE)] + macro e() {} + //~^ WARN: `macro` is experimental + //~| WARN: unstable syntax +} + +fn main() {} diff --git a/tests/ui/feature-gates/soft-syntax-gates-without-errors.stderr b/tests/ui/feature-gates/soft-syntax-gates-without-errors.stderr new file mode 100644 index 000000000..3d9c22e54 --- /dev/null +++ b/tests/ui/feature-gates/soft-syntax-gates-without-errors.stderr @@ -0,0 +1,24 @@ +warning: `macro` is experimental + --> $DIR/soft-syntax-gates-without-errors.rs:6:1 + | +LL | macro b() {} + | ^^^^^^^^^^^^ + | + = note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information + = help: add `#![feature(decl_macro)]` to the crate attributes to enable + = warning: unstable syntax can change at any point in the future, causing a hard error! + = note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> + +warning: `macro` is experimental + --> $DIR/soft-syntax-gates-without-errors.rs:21:5 + | +LL | macro e() {} + | ^^^^^^^^^^^^ + | + = note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information + = help: add `#![feature(decl_macro)]` to the crate attributes to enable + = warning: unstable syntax can change at any point in the future, causing a hard error! + = note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> + +warning: 2 warnings emitted + diff --git a/tests/ui/feature-gates/stability-attribute-consistency.rs b/tests/ui/feature-gates/stability-attribute-consistency.rs new file mode 100644 index 000000000..6ee7003c3 --- /dev/null +++ b/tests/ui/feature-gates/stability-attribute-consistency.rs @@ -0,0 +1,16 @@ +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +#![feature(staged_api)] + +#[stable(feature = "foo", since = "1.0.0")] +fn foo_stable_1_0_0() {} + +#[stable(feature = "foo", since = "1.29.0")] +//~^ ERROR feature `foo` is declared stable since 1.29.0 +fn foo_stable_1_29_0() {} + +#[unstable(feature = "foo", issue = "none")] +//~^ ERROR feature `foo` is declared unstable +fn foo_unstable() {} + +fn main() {} diff --git a/tests/ui/feature-gates/stability-attribute-consistency.stderr b/tests/ui/feature-gates/stability-attribute-consistency.stderr new file mode 100644 index 000000000..1b93d3c96 --- /dev/null +++ b/tests/ui/feature-gates/stability-attribute-consistency.stderr @@ -0,0 +1,15 @@ +error[E0711]: feature `foo` is declared stable since 1.29.0, but was previously declared stable since 1.0.0 + --> $DIR/stability-attribute-consistency.rs:8:1 + | +LL | #[stable(feature = "foo", since = "1.29.0")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0711]: feature `foo` is declared unstable, but was previously declared stable + --> $DIR/stability-attribute-consistency.rs:12:1 + | +LL | #[unstable(feature = "foo", issue = "none")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0711`. diff --git a/tests/ui/feature-gates/stable-features.rs b/tests/ui/feature-gates/stable-features.rs new file mode 100644 index 000000000..ed7f0899d --- /dev/null +++ b/tests/ui/feature-gates/stable-features.rs @@ -0,0 +1,14 @@ +// Testing that the stable_features lint catches use of stable +// language and lib features. + +#![deny(stable_features)] + +#![feature(test_accepted_feature)] +//~^ ERROR the feature `test_accepted_feature` has been stable since 1.0.0 + +#![feature(rust1)] +//~^ ERROR the feature `rust1` has been stable since 1.0.0 + +fn main() { + let _foo: Vec<()> = Vec::new(); +} diff --git a/tests/ui/feature-gates/stable-features.stderr b/tests/ui/feature-gates/stable-features.stderr new file mode 100644 index 000000000..831b40b86 --- /dev/null +++ b/tests/ui/feature-gates/stable-features.stderr @@ -0,0 +1,20 @@ +error: the feature `test_accepted_feature` has been stable since 1.0.0 and no longer requires an attribute to enable + --> $DIR/stable-features.rs:6:12 + | +LL | #![feature(test_accepted_feature)] + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/stable-features.rs:4:9 + | +LL | #![deny(stable_features)] + | ^^^^^^^^^^^^^^^ + +error: the feature `rust1` has been stable since 1.0.0 and no longer requires an attribute to enable + --> $DIR/stable-features.rs:9:12 + | +LL | #![feature(rust1)] + | ^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/feature-gates/trace_macros-gate.rs b/tests/ui/feature-gates/trace_macros-gate.rs new file mode 100644 index 000000000..c9af04741 --- /dev/null +++ b/tests/ui/feature-gates/trace_macros-gate.rs @@ -0,0 +1,14 @@ +// Test that the trace_macros feature gate is on. + +fn main() { + trace_macros!(); //~ ERROR `trace_macros` is not stable + //~| ERROR trace_macros! accepts only `true` or `false` + trace_macros!(true); //~ ERROR `trace_macros` is not stable + trace_macros!(false); //~ ERROR `trace_macros` is not stable + + macro_rules! expando { + ($x: ident) => { trace_macros!($x) } //~ ERROR `trace_macros` is not stable + } + + expando!(true); +} diff --git a/tests/ui/feature-gates/trace_macros-gate.stderr b/tests/ui/feature-gates/trace_macros-gate.stderr new file mode 100644 index 000000000..1ca10aeec --- /dev/null +++ b/tests/ui/feature-gates/trace_macros-gate.stderr @@ -0,0 +1,49 @@ +error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change + --> $DIR/trace_macros-gate.rs:4:5 + | +LL | trace_macros!(); + | ^^^^^^^^^^^^ + | + = note: see issue #29598 <https://github.com/rust-lang/rust/issues/29598> for more information + = help: add `#![feature(trace_macros)]` to the crate attributes to enable + +error: trace_macros! accepts only `true` or `false` + --> $DIR/trace_macros-gate.rs:4:5 + | +LL | trace_macros!(); + | ^^^^^^^^^^^^^^^ + +error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change + --> $DIR/trace_macros-gate.rs:6:5 + | +LL | trace_macros!(true); + | ^^^^^^^^^^^^ + | + = note: see issue #29598 <https://github.com/rust-lang/rust/issues/29598> for more information + = help: add `#![feature(trace_macros)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change + --> $DIR/trace_macros-gate.rs:7:5 + | +LL | trace_macros!(false); + | ^^^^^^^^^^^^ + | + = note: see issue #29598 <https://github.com/rust-lang/rust/issues/29598> for more information + = help: add `#![feature(trace_macros)]` to the crate attributes to enable + +error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change + --> $DIR/trace_macros-gate.rs:10:26 + | +LL | ($x: ident) => { trace_macros!($x) } + | ^^^^^^^^^^^^ +... +LL | expando!(true); + | -------------- in this macro invocation + | + = note: see issue #29598 <https://github.com/rust-lang/rust/issues/29598> for more information + = help: add `#![feature(trace_macros)]` to the crate attributes to enable + = note: this error originates in the macro `expando` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/unknown-feature.rs b/tests/ui/feature-gates/unknown-feature.rs new file mode 100644 index 000000000..20fd932d4 --- /dev/null +++ b/tests/ui/feature-gates/unknown-feature.rs @@ -0,0 +1,3 @@ +#![feature(unknown_rust_feature)] //~ ERROR unknown feature + +fn main() {} diff --git a/tests/ui/feature-gates/unknown-feature.stderr b/tests/ui/feature-gates/unknown-feature.stderr new file mode 100644 index 000000000..e5c05872d --- /dev/null +++ b/tests/ui/feature-gates/unknown-feature.stderr @@ -0,0 +1,9 @@ +error[E0635]: unknown feature `unknown_rust_feature` + --> $DIR/unknown-feature.rs:1:12 + | +LL | #![feature(unknown_rust_feature)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/feature-gates/unstable-attribute-allow-issue-0.rs b/tests/ui/feature-gates/unstable-attribute-allow-issue-0.rs new file mode 100644 index 000000000..bffe43262 --- /dev/null +++ b/tests/ui/feature-gates/unstable-attribute-allow-issue-0.rs @@ -0,0 +1,13 @@ +// Check that an issue value can be explicitly set to "0" instead of "none" +#![crate_type = "lib"] +#![feature(staged_api)] +#![stable(feature = "stable_test_feature", since = "1.0.0")] + +#[unstable(feature = "unstable_test_feature", issue = "0")] +fn unstable_issue_0() {} //~^ ERROR `issue` must be a non-zero numeric string or "none" + +#[unstable(feature = "unstable_test_feature", issue = "none")] +fn unstable_issue_none() {} + +#[unstable(feature = "unstable_test_feature", issue = "something")] +fn unstable_issue_not_allowed() {} //~^ ERROR `issue` must be a non-zero numeric string or "none" diff --git a/tests/ui/feature-gates/unstable-attribute-allow-issue-0.stderr b/tests/ui/feature-gates/unstable-attribute-allow-issue-0.stderr new file mode 100644 index 000000000..4ed42101a --- /dev/null +++ b/tests/ui/feature-gates/unstable-attribute-allow-issue-0.stderr @@ -0,0 +1,19 @@ +error[E0545]: `issue` must be a non-zero numeric string or "none" + --> $DIR/unstable-attribute-allow-issue-0.rs:6:47 + | +LL | #[unstable(feature = "unstable_test_feature", issue = "0")] + | ^^^^^^^^--- + | | + | `issue` must not be "0", use "none" instead + +error[E0545]: `issue` must be a non-zero numeric string or "none" + --> $DIR/unstable-attribute-allow-issue-0.rs:12:47 + | +LL | #[unstable(feature = "unstable_test_feature", issue = "something")] + | ^^^^^^^^----------- + | | + | invalid digit found in string + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0545`. |