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

Fix stability hole with `static _` #55983

Merged
merged 2 commits into from Nov 20, 2018

Conversation

Projects
None yet
8 participants
@oli-obk
Contributor

oli-obk commented Nov 15, 2018

The underscore_const_names only gated const items with _ as the name.

static _: () = (); works on beta without feature gates right now, this PR fixes that.

@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Nov 15, 2018

r? @pnkfelix

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

@petrochenkov

This comment has been minimized.

Contributor

petrochenkov commented Nov 15, 2018

Hmm, this is not even a part of the RFC.
Looks like this happened accidentally because fn parse_item_const is used for both constants and statics.

@oli-obk

This comment has been minimized.

Contributor

oli-obk commented Nov 15, 2018

Well, in any case we should block this from ending up in stable.

@rust-highfive

This comment was marked as resolved.

Collaborator

rust-highfive commented Nov 15, 2018

The job x86_64-gnu-llvm-5.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:1b7c42bc:start=1542295205547712327,finish=1542295208531036195,duration=2983323868
$ 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
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-5.0
---
[00:51:39] .................................................................................................... 4500/5019
[00:51:43] .......................................................................................i............ 4600/5019
[00:51:46] .................................................................................................... 4700/5019
[00:51:50] .................................................................................................... 4800/5019
[00:51:53] ..............F..................................................................................... 4900/5019
[00:51:55] ..........................................................i......................................... 5000/5019
rror","spans":[{"file_name":"/checkout/src/test/ui/underscore_const_names_feature_gate.rs","byte_start":472,"byte_end":489,"line_start":11,"line_end":11,"column_start":1,"column_end":18,"is_primary":true,"text":[{"text":"const _: () = (); //~ ERROR is unstable","highlight_start":1,"highlight_end":18}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"add #![feature(underscore_const_names)] to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0658]: naming constants with `_` is unstable (see issue #54912)\n  --> /checkout/src/test/ui/underscore_const_names_feature_gate.rs:11:1\n   |\nLL | const _: () = (); //~ ERROR is unstable\n   | ^^^^^^^^^^^^^^^^^\n   |\n   = help: add #![feature(underscore_const_names)] to the crate attributes to enable\n\n"}
[00:51:56] {"message":"naming constants with `_` is unstable (see issue #54912)","code":{"code":"E0658","explanation":"\nAn unstable feature was used.\n\nErroneous code example:\n\n```compile_fail,E658\n#[repr(u128)] // error: use of unstable library feature 'repr128'\nenum Foo {\n    Bar(u64),\n}\n```\n\nIf you're using a stable or a beta version of rustc, you won't be able to use\nany unstable features. In order to do so, please switch to a nightly version of\nrustc (by using rustup).\n\nIf you're using a nightly version of rustc, just add the corresponding feature\nto be able to use it:\n\n```\n#![feature(repr128)]\n\n#[repr(u128)] // ok!\nenum Foo {\n    Bar(u64),\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/underscore_const_names_feature_gate.rs","byte_start":512,"byte_end":530,"line_start":12,"line_end":12,"column_start":1,"column_end":19,"is_primary":true,"text":[{"text":"static _: () = (); //~ ERROR is unstable","highlight_start":1,"highlight_end":19}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"add #![feature(underscore_const_names)] to the crate attributes to enable","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0658]: naming constants with `_` is unstable (see issue #54912)\n  --> /checkout/src/test/ui/underscore_const_names_feature_gate.rs:12:1\n   |\nLL | static _: () = (); //~ ERROR is unstable\n   | ^^^^^^^^^^^^^^^^^^\n   |\n   = help: add #![feature(underscore_const_names)] to the crate attributes to enable\n\n"}
[00:51:56] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:51:56] {"message":"For more information about this error, try `rustc --explain E0658`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0658`.\n"}
[00:51:56] ------------------------------------------
[00:51:56] 
[00:51:56] thread '[ui] ui/underscore_const_names_feature_gate.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3282:9
[00:51:56] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[00:51:56] 
[00:51:56] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:503:22
[00:51:56] 
[00:51:56] 
[00:51:56] 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-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--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" "5.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"
[00:51:56] 
[00:51:56] 
[00:51:56] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:51:56] Build completed unsuccessfully in 0:03:49
[00:51:56] Build completed unsuccessfully in 0:03:49
[00:51:56] Makefile:58: recipe for target 'check' failed
[00:51:56] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:19699598
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Thu Nov 15 16:12:15 UTC 2018
---
travis_time:end:01a3dea6:start=1542298336537033170,finish=1542298336542549093,duration=5515923
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00b5a978
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog

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)

@oli-obk

This comment has been minimized.

Contributor

oli-obk commented Nov 17, 2018

r? @nikomatsakis (reviewer suggestion from github)

@alexcrichton

This comment has been minimized.

Member

alexcrichton commented Nov 19, 2018

@bors: p=1

beta nominated

@Mark-Simulacrum

This comment has been minimized.

Member

Mark-Simulacrum commented Nov 20, 2018

I'm going to accept this as it seems like the correct fix and we're rather close on deadlines (and is largely just making something "even more" unstable, so probably can't hurt to land/backport).

@bors r+

@bors

This comment has been minimized.

Contributor

bors commented Nov 20, 2018

📌 Commit 9b87911 has been approved by Mark-Simulacrum

@bors

This comment has been minimized.

Contributor

bors commented Nov 20, 2018

⌛️ Testing commit 9b87911 with merge 046e054...

bors added a commit that referenced this pull request Nov 20, 2018

Auto merge of #55983 - oli-obk:static_, r=Mark-Simulacrum
Fix stability hole with `static _`

The `underscore_const_names` only gated const items with `_` as the name.

`static _: () = ();` works on beta without feature gates right now, this PR fixes that.
@bors

This comment has been minimized.

Contributor

bors commented Nov 20, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: Mark-Simulacrum
Pushing 046e054 to master...

@bors bors merged commit 9b87911 into rust-lang:master Nov 20, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@nikomatsakis nikomatsakis referenced this pull request Nov 20, 2018

Merged

beta backport rollup #56102

20 of 20 tasks complete

bors added a commit that referenced this pull request Nov 20, 2018

Auto merge of #56102 - nikomatsakis:beta, r=alexcrichton
beta backport rollup

Backports of some beta-approved PRs

- [x] #55385: NLL: cast causes failure to promote to static
- [x] #56043: remove "approx env bounds" if we already know from trait
- [x] #56003: do not propagate inferred bounds on trait objects if they involve `Self`
- [x] #55852: Rewrite `...` as `..=` as a `MachineApplicable` 2018 idiom lint
- [x] #55804: rustdoc: don't inline `pub use some_crate` unless directly asked to
- [x] #56059: Increase `Duration` approximate equal threshold to 1us
- [x]  Keep resolved defs in path prefixes and emit them in save-analysis #54145
- [x]  Adjust Ids of path segments in visibility modifiers #55487
- [x]  save-analysis: bug fix and optimisation. #55521
- [x]   save-analysis: be even more aggressive about ignorning macro-generated defs #55936
- [x]  save-analysis: fallback to using path id #56060
- [x]  save-analysis: Don't panic for macro-generated use globs #55879
- [x]  Add temporary renames to manifests for rustfmt/clippy #56081
- [x] Revert #51601 #56049
- [x]  Fix stability hole with `static _` #55983
- [x] #56077
- [x] Fix Rustdoc ICE when checking blanket impls #55258
- [x]  Updated RELEASES.md for 1.31.0 #55678
- [x] ~~#56061~~ #56111
- [x]  Stabilize `extern_crate_item_prelude` #56032

Still running tests locally, and I plan to backport @nrc's other PRs too

(cc @petrochenkov -- thanks for the advice)

bors added a commit that referenced this pull request Dec 6, 2018

Auto merge of #56392 - petrochenkov:regensym, r=oli-obk
Delay gensym creation for "underscore items" (`use foo as _`/`const _`) until name resolution

So they cannot be cloned by macros. See #56303 for the discussion.

Mostly fix cross-crate use of underscore items by inverting the "gensyms are lost in metadata" bug as described in #56303 (comment).
Fix unused import warnings for single-segment imports (first commit) and `use crate_name as _` imports (as specified in #56303 (comment)).
Prohibit accidentally implemented `static _: TYPE = EXPR;` (cc #55983).
Add more tests for `use foo as _` imports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment