Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -Z allow_features=... flag #59169

Merged
merged 2 commits into from
Mar 16, 2019
Merged

Conversation

tmandry
Copy link
Member

@tmandry tmandry commented Mar 13, 2019

Adds a compiler option to allow only whitelisted features.

For projects on nightly that want to prevent feature-creep (and maybe, someday, move off of nightly). Not being able to enforce this has been a problem on Fuchsia and at other big companies.

This doesn't support filtering edition feature flags, but someone is welcome to add that if they need it.

@rust-highfive
Copy link
Collaborator

r? @michaelwoerister

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 13, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:1af189e8:start=1552520069455033198,finish=1552520144729783184,duration=75274749986
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---
[00:30:48]    Compiling syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
[00:30:49] error: incorrect close delimiter: `)`
[00:30:49]     --> src/librustc/session/config.rs:3280:82
[00:30:49]      |
[00:30:49] 3280 |         opts.debugging_opts.allow_features = Some(vec![String::from("never_type"));
[00:30:49]      |                                                  |    |
[00:30:49]      |                                                  |    un-closed delimiter
[00:30:49]      |                                                  close delimiter possibly meant for this
[00:30:49] 

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:0be993d2:start=1552524552108732045,finish=1552524655288034000,duration=103179301955
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---
[01:14:02] ............................iiiii................................................................... 1100/5468
[01:14:05] .................................................................................................... 1200/5468
[01:14:08] .................................................................................................... 1300/5468
[01:14:11] .................................................................................................... 1400/5468
[01:14:14] ..............................................................F..................................... 1500/5468
[01:14:21] ..................................i................................................................. 1700/5468
[01:14:24] .................................................................................................... 1800/5468
[01:14:29] .................................................................................................... 1900/5468
[01:14:33] .................................................................................................... 2000/5468
---
[01:17:00] 
[01:17:00] 1 error[E0725]: the feature `rustc_const_unstable` is not in the list of allowed features
[01:17:00] 2   --> $DIR/allow-features.rs:6:12
[01:17:00] 3    |
[01:17:00] - LL | #![feature(rustc_const_unstable)] //~ ERROR not in the list of allowed features
[01:17:00] + LL | #![feature(rustc_const_unstable)]
[01:17:00] 6 
[01:17:00] 7 error: aborting due to previous error
[01:17:00] 
[01:17:00] 
[01:17:00] 
[01:17:00] The actual stderr differed from the expected stderr.
[01:17:00] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gate/allow-features/allow-features.stderr
[01:17:00] To update references, rerun the tests and pass the `--bless` flag
[01:17:00] To only update this specific test, also pass `--test-args feature-gate/allow-features.rs`
[01:17:00] error: 1 errors occurred comparing output.
[01:17:00] status: exit code: 1
[01:17:00] status: exit code: 1
[01:17:00] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/feature-gate/allow-features.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gate/allow-features/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "allow_features=rustc_diagnostic_macros" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gate/allow-features/auxiliary" "-A" "unused"
[01:17:00] ------------------------------------------
[01:17:00] 
[01:17:00] ------------------------------------------
[01:17:00] stderr:
[01:17:00] stderr:
[01:17:00] ------------------------------------------
[01:17:00] {"message":"the feature `rustc_const_unstable` is not in the list of allowed features","code":{"code":"E0725","explanation":"\nA feature attribute named a feature that was disallowed in the compiler\ncommand line flags.\n\nErroneous code example:\n\n```compile_fail,E0557\n#![feature(never_type)] // error: the feature `never_type` is not in\n                        // the list of allowed features\n```\n\nDelete the offending feature attribute, or add it to the list of allowed\nfeatures in the `-Z allow_features` flag.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/feature-gate/allow-features.rs","byte_start":190,"byte_end":210,"line_start":6,"line_end":6,"column_start":12,"column_end":32,"is_primary":true,"text":[{"text":"#![feature(rustc_const_unstable)] //~ ERROR not in the list of allowed features","highlight_start":12,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0725]: the feature `rustc_const_unstable` is not in the list of allowed features\n  --> /checkout/src/test/ui/feature-gate/allow-features.rs:6:12\n   |\nLL | #![feature(rustc_const_unstable)] //~ ERROR not in the list of allowed features\n   |            ^^^^^^^^^^^^^^^^^^^^\n\n"}
[01:17:00] {"message":"For more information about this error, try `rustc --explain E0725`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0725`.\n"}
[01:17:00] 
[01:17:00] ------------------------------------------
[01:17:00] 
---
[01:17:00] 
[01:17:00] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:496:22
[01:17:00] 
[01:17:00] 
[01:17:00] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:17:00] 
[01:17:00] 
[01:17:00] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:17:00] Build completed unsuccessfully in 0:04:47
[01:17:00] Build completed unsuccessfully in 0:04:47
[01:17:00] make: *** [check] Error 1
[01:17:00] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:3152fe6f
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Mar 14 02:08:05 UTC 2019
---
travis_time:end:0a0a6c49:start=1552529287521231908,finish=1552529287529670148,duration=8438240
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:121e3670
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:1cc034b2
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@petrochenkov
Copy link
Contributor

Some discussion about this is also happening in rust-lang/cargo#6627

rust-toolchain Outdated Show resolved Hide resolved
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:27ff0495:start=1552585191980436648,finish=1552585271763140515,duration=79782703867
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
Setting environment variables from .travis.yml
---
travis_time:start:test_debuginfo
Check compiletest suite=debuginfo mode=debuginfo-both (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:22:50] 
[01:22:50] running 120 tests
[01:23:15] .iiiii...i.....i..i...i..i.i...i.ii...i.....i..i....i..........iiii..........i...ii...i.......ii.i.i 100/120
[01:23:20] .i......iii.i.....ii
[01:23:20] 
[01:23:20]  finished in 30.632
[01:23:20] travis_fold:end:test_debuginfo

---
[01:51:10] 
[01:51:10] failures:
[01:51:10] 
[01:51:10] ---- /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0725 (line 11586) stdout ----
[01:51:10] thread '/checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0725 (line 11586)' panicked at 'test compiled while it wasn't supposed to', src/librustdoc/test.rs:300:13
[01:51:10] 
[01:51:10] 
[01:51:10] failures:
[01:51:10]     /checkout/obj/build/x86_64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0725 (line 11586)
---
[01:51:10] 
[01:51:10] 
[01:51:10] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:51:10] Build completed unsuccessfully in 0:40:24
[01:51:10] make: *** [check] Error 1
[01:51:10] Makefile:48: recipe for target 'check' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0333c61b
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Mar 14 19:32:31 UTC 2019

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@tmandry
Copy link
Member Author

tmandry commented Mar 14, 2019

Made this comma-separated instead of space-separated.

@cramertj
Copy link
Member

@bors r+

cc @rust-lang/compiler for the addition of a -Z flag to limit which unstable features are allowed.

@bors
Copy link
Contributor

bors commented Mar 14, 2019

📋 Looks like this PR is still in progress, ignoring approval.

Hint: Remove [WIP] from this PR's title when it is ready for review.

@tmandry tmandry changed the title [WIP] Add -Z allow_features=... flag Add -Z allow_features=... flag Mar 14, 2019
@tmandry
Copy link
Member Author

tmandry commented Mar 14, 2019

@bors r=cramertj rollup

@bors
Copy link
Contributor

bors commented Mar 14, 2019

📌 Commit 7c59ce9 has been approved by cramertj

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 14, 2019
Copy link
Member

@eddyb eddyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should block merging, but please open an issue if you don't want to fix right now.

match v {
Some(s) => {
let v = s.split(',').map(|s| s.to_string()).collect();
*slot = Some(v);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will this do if we see the flag multiple times?

I think we have this sort of problem all over the place, I would prefer if -Z allow_features=foo -Z allow_features=bar worked like -Z allow_features=foo,bar.

cc @rust-lang/compiler Should we do an audit? It's plausible fixing some of the other flags to do "the right thing" when provided multiple times may be a breaking change.

At least this one is unstable though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the flag is supplied multiple times the last invocation will override the previous ones. This is (afaict) the behavior of all the -Z flags that take a list of arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and I'm saying it's not intentional most of the time, it just arises from how the CLI arguments are parsed.

I wonder what would happen were we to try to switch to e.g. structopt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, was responding in answer to your original "What will this do if we see the flag multiple times?"-- I agree that trying to shift everything over to a different behavior would be a worthwhile thing to investigate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #59219

kennytm added a commit to kennytm/rust that referenced this pull request Mar 15, 2019
…ertj

Add `-Z allow_features=...` flag

Adds a compiler option to allow only whitelisted features.

For projects on nightly that want to prevent feature-creep (and maybe, someday, move off of nightly). Not being able to enforce this has been a problem on Fuchsia and at other big companies.

This doesn't support filtering edition feature flags, but someone is welcome to add that if they need it.
Centril added a commit to Centril/rust that referenced this pull request Mar 16, 2019
…ertj

Add `-Z allow_features=...` flag

Adds a compiler option to allow only whitelisted features.

For projects on nightly that want to prevent feature-creep (and maybe, someday, move off of nightly). Not being able to enforce this has been a problem on Fuchsia and at other big companies.

This doesn't support filtering edition feature flags, but someone is welcome to add that if they need it.
kennytm added a commit to kennytm/rust that referenced this pull request Mar 16, 2019
…ertj

Add `-Z allow_features=...` flag

Adds a compiler option to allow only whitelisted features.

For projects on nightly that want to prevent feature-creep (and maybe, someday, move off of nightly). Not being able to enforce this has been a problem on Fuchsia and at other big companies.

This doesn't support filtering edition feature flags, but someone is welcome to add that if they need it.
bors added a commit that referenced this pull request Mar 16, 2019
Rollup of 37 pull requests

Successful merges:

 - #58854 (appveyor: Use VS2017 for all our images)
 - #58855 (std: Spin for a global malloc lock on wasm32)
 - #58873 (Fix "Auto-hide item methods documentation" setting)
 - #58901 (Change `std::fs::copy` to use `copyfile` on MacOS and iOS)
 - #58933 (Move alloc::prelude::* to alloc::prelude::v1, make alloc a subset of std)
 - #58938 (core: ensure VaList passes improper_ctypes lint)
 - #58941 (MIPS: add r6 support)
 - #58949 (SGX target: Expose thread id function in os module)
 - #58959 (Add release notes for PR #56243)
 - #58976 (Default to integrated `rust-lld` linker for UEFI targets)
 - #59009 (Fix SGX implementations of read/write_vectored.)
 - #59025 (Fix generic argument lookup for Self)
 - #59036 (Fix ICE in MIR pretty printing)
 - #59037 (Avoid some common false positives in intra doc link checking)
 - #59072 (we can now skip should_panic tests with the libtest harness)
 - #59079 (add suggestions to invalid macro item error)
 - #59082 (A few improvements to comments in user-facing crates)
 - #59102 (Consistent naming for duration_float methods and additional f32 methods)
 - #59118 (rustc: fix ICE when trait alias has bare Self)
 - #59139 (Unregress using scalar unions in constants.)
 - #59146 (Suggest return lifetime when there's only one named lifetime)
 - #59147 (Make std time tests more robust for platform differences)
 - #59152 (Stabilize Range*::contains.)
 - #59156 ([wg-async-await] Add regression test for #55809.)
 - #59158 (Revert "Don't generate minification variable if minification disabled")
 - #59169 (Add `-Z allow_features=...` flag)
 - #59173 (bootstrap: Default to a sensible llvm-suffix.)
 - #59175 (Don't run test launching `echo` since that doesn't exist on Windows)
 - #59180 (Use try blocks in rustc_codegen_ssa)
 - #59185 (No old chestnuts in iter::repeat docs)
 - #59201 (Remove restriction on isize/usize in repr(simd))
 - #59204 (Output diagnostic information for rustdoc)
 - #59206 (Improved test output)
 - #59208 (Reduce a Code Repetition Related to Bit Operation)
 - #59212 (Add x86_64 musl host to the manifest)
 - #59221 (Option and Result: Add references to documentation of as_ref and as_mut)
 - #59231 (Stabilize Option::copied)
@bors bors merged commit 7c59ce9 into rust-lang:master Mar 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants