summaryrefslogtreecommitdiffstats
path: root/tests/ui/cfg
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /tests/ui/cfg
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/cfg')
-rw-r--r--tests/ui/cfg/auxiliary/cfg_false_lib.rs6
-rw-r--r--tests/ui/cfg/cfg-false-feature.rs20
-rw-r--r--tests/ui/cfg/cfg-false-feature.stderr35
-rw-r--r--tests/ui/cfg/cfg_false_no_std.rs11
4 files changed, 72 insertions, 0 deletions
diff --git a/tests/ui/cfg/auxiliary/cfg_false_lib.rs b/tests/ui/cfg/auxiliary/cfg_false_lib.rs
new file mode 100644
index 000000000..3c011d72b
--- /dev/null
+++ b/tests/ui/cfg/auxiliary/cfg_false_lib.rs
@@ -0,0 +1,6 @@
+// It is unclear whether a fully unconfigured crate should link to standard library,
+// or what its `no_std`/`no_core`/`compiler_builtins` status, more precisely.
+// Currently the usual standard library prelude is added to such crates,
+// and therefore they link to libstd.
+
+#![cfg(FALSE)]
diff --git a/tests/ui/cfg/cfg-false-feature.rs b/tests/ui/cfg/cfg-false-feature.rs
new file mode 100644
index 000000000..21ea3ec79
--- /dev/null
+++ b/tests/ui/cfg/cfg-false-feature.rs
@@ -0,0 +1,20 @@
+// It is unclear which features should be in effect in a fully unconfigured crate (issue #104633).
+// Currently none on the features are in effect, so we get the feature gates reported.
+
+// check-pass
+// compile-flags: --crate-type lib
+
+#![feature(decl_macro)]
+#![cfg(FALSE)]
+#![feature(box_syntax)]
+
+macro mac() {} //~ WARN `macro` is experimental
+ //~| WARN unstable syntax can change at any point in the future
+
+trait A = Clone; //~ WARN trait aliases are experimental
+ //~| WARN unstable syntax can change at any point in the future
+
+fn main() {
+ let box _ = Box::new(0); //~ WARN box pattern syntax is experimental
+ //~| WARN unstable syntax can change at any point in the future
+}
diff --git a/tests/ui/cfg/cfg-false-feature.stderr b/tests/ui/cfg/cfg-false-feature.stderr
new file mode 100644
index 000000000..14673fbdb
--- /dev/null
+++ b/tests/ui/cfg/cfg-false-feature.stderr
@@ -0,0 +1,35 @@
+warning: trait aliases are experimental
+ --> $DIR/cfg-false-feature.rs:14:1
+ |
+LL | trait A = Clone;
+ | ^^^^^^^^^^^^^^^^
+ |
+ = 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
+ = 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/cfg-false-feature.rs:11:1
+ |
+LL | macro mac() {}
+ | ^^^^^^^^^^^^^^
+ |
+ = 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: box pattern syntax is experimental
+ --> $DIR/cfg-false-feature.rs:18:9
+ |
+LL | let box _ = Box::new(0);
+ | ^^^^^
+ |
+ = 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
+ = 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: 3 warnings emitted
+
diff --git a/tests/ui/cfg/cfg_false_no_std.rs b/tests/ui/cfg/cfg_false_no_std.rs
new file mode 100644
index 000000000..319ea0781
--- /dev/null
+++ b/tests/ui/cfg/cfg_false_no_std.rs
@@ -0,0 +1,11 @@
+// Currently no error because the panic handler is supplied by libstd linked though the empty
+// library, but the desirable behavior is unclear (see comments in cfg_false_lib.rs).
+
+// check-pass
+// aux-build: cfg_false_lib.rs
+
+#![no_std]
+
+extern crate cfg_false_lib as _;
+
+fn main() {}