diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2021-07-23 16:19:22 +0300 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2022-03-01 01:57:10 +0200 |
| commit | c97c216efd542fbec5a7ccf9555f3cebb3198cec (patch) | |
| tree | 779e6d34d1bc9adef8be9ffe6c0a7fc8acca80af /src/test | |
| parent | dfcfaa4ec1dd8a5bda33874dc180509b74bb625f (diff) | |
| download | rust-c97c216efd542fbec5a7ccf9555f3cebb3198cec.tar.gz rust-c97c216efd542fbec5a7ccf9555f3cebb3198cec.zip | |
Direct users towards using Rust feature names in CLI
If they are trying to use features rustc doesn't yet know about, request a feature request. Additionally, also warn against using feature names without leading `+` or `-` signs.
Diffstat (limited to 'src/test')
10 files changed, 80 insertions, 15 deletions
diff --git a/src/test/ui/target-feature/missing-plusminus.rs b/src/test/ui/target-feature/missing-plusminus.rs new file mode 100644 index 00000000000..efee6592923 --- /dev/null +++ b/src/test/ui/target-feature/missing-plusminus.rs @@ -0,0 +1,2 @@ +// compile-flags: -Ctarget-feature=banana --crate-type=rlib +// build-pass diff --git a/src/test/ui/target-feature/missing-plusminus.stderr b/src/test/ui/target-feature/missing-plusminus.stderr new file mode 100644 index 00000000000..1d446107f70 --- /dev/null +++ b/src/test/ui/target-feature/missing-plusminus.stderr @@ -0,0 +1,18 @@ +warning: unknown feature specified for `-Ctarget-feature`: `banana` + | + = note: features must begin with a `+` to enable or `-` to disable it + +warning: unknown feature specified for `-Ctarget-feature`: `banana` + | + = note: features must begin with a `+` to enable or `-` to disable it + +warning: unknown feature specified for `-Ctarget-feature`: `banana` + | + = note: features must begin with a `+` to enable or `-` to disable it + +warning: unknown feature specified for `-Ctarget-feature`: `banana` + | + = note: features must begin with a `+` to enable or `-` to disable it + +warning: 4 warnings emitted + diff --git a/src/test/ui/target-feature/similar-feature-suggestion.rs b/src/test/ui/target-feature/similar-feature-suggestion.rs new file mode 100644 index 00000000000..4e4e2160cac --- /dev/null +++ b/src/test/ui/target-feature/similar-feature-suggestion.rs @@ -0,0 +1,6 @@ +// compile-flags: -Ctarget-feature=+rdrnd --crate-type=rlib --target=x86_64-unknown-linux-gnu +// build-pass +// needs-llvm-components: x86 + +#![feature(no_core)] +#![no_core] diff --git a/src/test/ui/target-feature/similar-feature-suggestion.stderr b/src/test/ui/target-feature/similar-feature-suggestion.stderr new file mode 100644 index 00000000000..de4d0064fbc --- /dev/null +++ b/src/test/ui/target-feature/similar-feature-suggestion.stderr @@ -0,0 +1,22 @@ +warning: unknown feature specified for `-Ctarget-feature`: `rdrnd` + | + = note: it is still passed through to the codegen backend + = help: you might have meant: `rdrand` + +warning: unknown feature specified for `-Ctarget-feature`: `rdrnd` + | + = note: it is still passed through to the codegen backend + = help: did you mean: `rdrand` + +warning: unknown feature specified for `-Ctarget-feature`: `rdrnd` + | + = note: it is still passed through to the codegen backend + = help: did you mean: `rdrand` + +warning: unknown feature specified for `-Ctarget-feature`: `rdrnd` + | + = note: it is still passed through to the codegen backend + = help: did you mean: `rdrand` + +warning: 4 warnings emitted + diff --git a/src/test/ui/target-feature/tied-features-cli.one.stderr b/src/test/ui/target-feature/tied-features-cli.one.stderr index 2bc64a76aae..0cc901eecaa 100644 --- a/src/test/ui/target-feature/tied-features-cli.one.stderr +++ b/src/test/ui/target-feature/tied-features-cli.one.stderr @@ -1,4 +1,4 @@ -error: Target features paca, pacg must all be enabled or disabled together +error: target features paca, pacg must all be enabled or disabled together error: aborting due to previous error diff --git a/src/test/ui/target-feature/tied-features-cli.rs b/src/test/ui/target-feature/tied-features-cli.rs index ea09d4fc460..72b7e3da530 100644 --- a/src/test/ui/target-feature/tied-features-cli.rs +++ b/src/test/ui/target-feature/tied-features-cli.rs @@ -1,9 +1,20 @@ -// only-aarch64 -// revisions: one two three four -//[one] compile-flags: -C target-feature=+paca -//[two] compile-flags: -C target-feature=-pacg,+pacg -//[three] compile-flags: -C target-feature=+paca,+pacg,-paca -//[four] check-pass -//[four] compile-flags: -C target-feature=-paca,+pacg -C target-feature=+paca +// revisions: one two three +// compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu +// needs-llvm-components: aarch64 +// +// +// [one] check-fail +// [one] compile-flags: -C target-feature=+paca +// [two] check-fail +// [two] compile-flags: -C target-feature=-pacg,+pacg +// [three] check-fail +// [three] compile-flags: -C target-feature=+paca,+pacg,-paca +// [four] build-pass +// [four] compile-flags: -C target-feature=-paca,+pacg -C target-feature=+paca +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized {} fn main() {} diff --git a/src/test/ui/target-feature/tied-features-cli.three.stderr b/src/test/ui/target-feature/tied-features-cli.three.stderr index 2bc64a76aae..0cc901eecaa 100644 --- a/src/test/ui/target-feature/tied-features-cli.three.stderr +++ b/src/test/ui/target-feature/tied-features-cli.three.stderr @@ -1,4 +1,4 @@ -error: Target features paca, pacg must all be enabled or disabled together +error: target features paca, pacg must all be enabled or disabled together error: aborting due to previous error diff --git a/src/test/ui/target-feature/tied-features-cli.two.stderr b/src/test/ui/target-feature/tied-features-cli.two.stderr index 2bc64a76aae..0cc901eecaa 100644 --- a/src/test/ui/target-feature/tied-features-cli.two.stderr +++ b/src/test/ui/target-feature/tied-features-cli.two.stderr @@ -1,4 +1,4 @@ -error: Target features paca, pacg must all be enabled or disabled together +error: target features paca, pacg must all be enabled or disabled together error: aborting due to previous error diff --git a/src/test/ui/target-feature/tied-features.rs b/src/test/ui/target-feature/tied-features.rs index 86400361db3..01353e9f70c 100644 --- a/src/test/ui/target-feature/tied-features.rs +++ b/src/test/ui/target-feature/tied-features.rs @@ -1,9 +1,15 @@ -// only-aarch64 // build-fail - +// compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu +// needs-llvm-components: aarch64 #![feature(aarch64_target_feature, target_feature_11)] +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized {} -fn main() { +// FIXME: this should not need to be public. +pub fn main() { #[target_feature(enable = "pacg")] //~^ ERROR must all be either enabled or disabled together unsafe fn inner() {} diff --git a/src/test/ui/target-feature/tied-features.stderr b/src/test/ui/target-feature/tied-features.stderr index 0b1460e0b75..6362c7ae60b 100644 --- a/src/test/ui/target-feature/tied-features.stderr +++ b/src/test/ui/target-feature/tied-features.stderr @@ -1,5 +1,5 @@ error: the target features paca, pacg must all be either enabled or disabled together - --> $DIR/tied-features.rs:7:5 + --> $DIR/tied-features.rs:13:5 | LL | #[target_feature(enable = "pacg")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[target_feature(enable = "pacg")] = help: add the missing features in a `target_feature` attribute error: the target features paca, pacg must all be either enabled or disabled together - --> $DIR/tied-features.rs:19:1 + --> $DIR/tied-features.rs:25:1 | LL | #[target_feature(enable = "paca")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
