Skip to content

Commit f26da39

Browse files
committed
Add some tests for the current #![cfg(FALSE)] crate behavior
1 parent 6cc33b7 commit f26da39

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// It is unclear whether a fully unconfigured crate should link to standard library,
2+
// or what its `no_std`/`no_core`/`compiler_builtins` status, more precisely.
3+
// Currently the usual standard library prelude is added to such crates,
4+
// and therefore they link to libstd.
5+
6+
#![cfg(FALSE)]

tests/ui/cfg/cfg-false-feature.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// It is unclear which features should be in effect in a fully unconfigured crate (issue #104633).
2+
// Currently none on the features are in effect, so we get the feature gates reported.
3+
4+
// check-pass
5+
// compile-flags: --crate-type lib
6+
7+
#![feature(decl_macro)]
8+
#![cfg(FALSE)]
9+
#![feature(box_syntax)]
10+
11+
macro mac() {} //~ WARN `macro` is experimental
12+
//~| WARN unstable syntax can change at any point in the future
13+
14+
trait A = Clone; //~ WARN trait aliases are experimental
15+
//~| WARN unstable syntax can change at any point in the future
16+
17+
fn main() {
18+
let box _ = Box::new(0); //~ WARN box pattern syntax is experimental
19+
//~| WARN unstable syntax can change at any point in the future
20+
}

tests/ui/cfg/cfg-false-feature.stderr

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
warning: trait aliases are experimental
2+
--> $DIR/cfg-false-feature.rs:14:1
3+
|
4+
LL | trait A = Clone;
5+
| ^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information
8+
= help: add `#![feature(trait_alias)]` to the crate attributes to enable
9+
= warning: unstable syntax can change at any point in the future, causing a hard error!
10+
= note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860>
11+
12+
warning: `macro` is experimental
13+
--> $DIR/cfg-false-feature.rs:11:1
14+
|
15+
LL | macro mac() {}
16+
| ^^^^^^^^^^^^^^
17+
|
18+
= note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information
19+
= help: add `#![feature(decl_macro)]` to the crate attributes to enable
20+
= warning: unstable syntax can change at any point in the future, causing a hard error!
21+
= note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860>
22+
23+
warning: box pattern syntax is experimental
24+
--> $DIR/cfg-false-feature.rs:18:9
25+
|
26+
LL | let box _ = Box::new(0);
27+
| ^^^^^
28+
|
29+
= note: see issue #29641 <https://github.com/rust-lang/rust/issues/29641> for more information
30+
= help: add `#![feature(box_patterns)]` to the crate attributes to enable
31+
= warning: unstable syntax can change at any point in the future, causing a hard error!
32+
= note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860>
33+
34+
warning: 3 warnings emitted
35+

tests/ui/cfg/cfg_false_no_std.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Currently no error because the panic handler is supplied by libstd linked though the empty
2+
// library, but the desirable behavior is unclear (see comments in cfg_false_lib.rs).
3+
4+
// check-pass
5+
// aux-build: cfg_false_lib.rs
6+
7+
#![no_std]
8+
9+
extern crate cfg_false_lib as _;
10+
11+
fn main() {}

0 commit comments

Comments
 (0)