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

use NonZeroU32 in newtype_index!macro, change syntax #53315

Merged
merged 12 commits into from
Sep 8, 2018

Conversation

nikomatsakis
Copy link
Contributor

Various improvements to the newtype_index! macro:

  • Use NonZeroU32 so that Option<T> is cheap
  • More ergonomic helper method, no need to import Idx trait all the time
  • Improve syntax to use struct keyword so that ripgrep works to find type def'n

Fixes #50337

I'm curious to see if this passes tests =)

r? @oli-obk (picked because of reviewer suggestions...)

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

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

r=me, unless you feel comments need addressing.


fn d2() -> ty::DebruijnIndex {
ty::INNERMOST.shifted_in(1)
}
Copy link
Member

Choose a reason for hiding this comment

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

Why was this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because the get method of NonZeroU32 is not a const fn, so we cannot evaluate shifted_in as a const method anymore.

@nikomatsakis
Copy link
Contributor Author

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Aug 14, 2018

📌 Commit fa86a854e679ff9833715ae5968f200a5d3ce09f has been approved by Mark-Simulacrum

@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 Aug 14, 2018
@eddyb
Copy link
Member

eddyb commented Aug 14, 2018

@bors r- The unsafe part seems UB to me. Wait, there's random +1 in places?!

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 14, 2018
@eddyb
Copy link
Member

eddyb commented Aug 14, 2018

@bors try

(let's do some benchmarking here first)

@bors
Copy link
Contributor

bors commented Aug 14, 2018

⌛ Trying commit fa86a854e679ff9833715ae5968f200a5d3ce09f with merge 850f704f57dbfefaf6714cedb1a0d880529b9a5a...

@bors
Copy link
Contributor

bors commented Aug 14, 2018

☀️ Test successful - status-travis
State: approved= try=True

@eddyb
Copy link
Member

eddyb commented Aug 14, 2018

@rust-timer build 850f704f57dbfefaf6714cedb1a0d880529b9a5a

@rust-timer
Copy link
Collaborator

Insufficient permissions to issue commands to rust-timer.

@nikomatsakis
Copy link
Contributor Author

@rust-timer build 850f704f57dbfefaf6714cedb1a0d880529b9a5a

@rust-timer
Copy link
Collaborator

Success: Queued 850f704f57dbfefaf6714cedb1a0d880529b9a5a with parent 3e05f80, comparison URL.

@nikomatsakis
Copy link
Contributor Author

@eddyb profiling sounds good, yes

@nikomatsakis nikomatsakis added S-waiting-on-perf Status: Waiting on a perf run to be completed. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 14, 2018
@BurntPizza
Copy link
Contributor

Perf says this is pretty painful. I wonder how simply not using the 0th slot in the various indexmaps would compare, instead of adding and subtracting 1.

The searchability and ergro stuff is good though.

@nikomatsakis
Copy link
Contributor Author

Interesting. I'm quite surprised, actually. I can certainly roll back the NonZeroU32 commit — seems like it makes a good case for needing a NonMaxU32, though.

@nikomatsakis
Copy link
Contributor Author

That said, it seems like it's mostly a wash -- except for keccak, which is considerably slower (I wonder what makes it quite so different?). I've noticed the ctfe tests fluctuating 1-2% elsewhere.

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 15, 2018
@rust-highfive
Copy link
Collaborator

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.
[00:14:20]    Compiling rustc_allocator v0.0.0 (file:///checkout/src/librustc_allocator)
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]   --> librustc_mir/borrow_check/location.rs:30:1
[00:14:21]    |
[00:14:21] 30 | / newtype_index! {
[00:14:21] 31 | |     pub struct LocationIndex {
[00:14:21] 32 | |         DEBUG_FORMAT = "LocationIndex({})"
[00:14:21] 34 | | }
[00:14:21]    | |_^
[00:14:21]    |
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]   --> librustc_mir/borrow_check/location.rs:30:1
[00:14:21]    |
[00:14:21] 30 | / newtype_index! {
[00:14:21] 31 | |     pub struct LocationIndex {
[00:14:21] 32 | |         DEBUG_FORMAT = "LocationIndex({})"
[00:14:21] 34 | | }
[00:14:21]    | |_^
[00:14:21]    |
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]   --> librustc_mir/borrow_check/location.rs:30:1
[00:14:21]    |
[00:14:21] 30 | / newtype_index! {
[00:14:21] 31 | |     pub struct LocationIndex {
[00:14:21] 32 | |         DEBUG_FORMAT = "LocationIndex({})"
[00:14:21] 34 | | }
[00:14:21]    | |_^
[00:14:21]    |
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]   --> librustc_mir/borrow_check/location.rs:30:1
[00:14:21]    |
[00:14:21] 30 | / newtype_index! {
[00:14:21] 31 | |     pub struct LocationIndex {
[00:14:21] 32 | |         DEBUG_FORMAT = "LocationIndex({})"
[00:14:21] 34 | | }
[00:14:21]    | |_^
[00:14:21]    |
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/region_infer/values.rs:126:1
[00:14:21]     |
[00:14:21] 126 | / newtype_index! {
[00:14:21] 127 | |     pub struct PointIndex { DEBUG_FORMAT = "PointIndex({})" }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/region_infer/values.rs:126:1
[00:14:21]     |
[00:14:21] 126 | / newtype_index! {
[00:14:21] 127 | |     pub struct PointIndex { DEBUG_FORMAT = "PointIndex({})" }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/region_infer/values.rs:126:1
[00:14:21]     |
[00:14:21] 126 | / newtype_index! {
[00:14:21] 127 | |     pub struct PointIndex { DEBUG_FORMAT = "PointIndex({})" }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/region_infer/values.rs:126:1
[00:14:21]     |
[00:14:21] 126 | / newtype_index! {
[00:14:21] 127 | |     pub struct PointIndex { DEBUG_FORMAT = "PointIndex({})" }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/region_infer/values.rs:134:1
[00:14:21]     |
[00:14:21] 134 | / newtype_index! {
[00:14:21] 135 | |     pub struct PlaceholderIndex { DEBUG_FORMAT = "PlaceholderIndex({})" }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/region_infer/values.rs:134:1
[00:14:21]     |
[00:14:21] 134 | / newtype_index! {
[00:14:21] 135 | |     pub struct PlaceholderIndex { DEBUG_FORMAT = "PlaceholderIndex({})" }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/region_infer/values.rs:134:1
[00:14:21]     |
[00:14:21] 134 | / newtype_index! {
[00:14:21] 135 | |     pub struct PlaceholderIndex { DEBUG_FORMAT = "PlaceholderIndex({})" }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/region_infer/values.rs:134:1
[00:14:21]     |
[00:14:21] 134 | / newtype_index! {
[00:14:21] 135 | |     pub struct PlaceholderIndex { DEBUG_FORMAT = "PlaceholderIndex({})" }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs:100:1
[00:14:21]     |
[00:14:21] 100 | / newtype_index! {
[00:14:21] 101 | |     pub struct LiveVar { .. }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs:100:1
[00:14:21]     |
[00:14:21] 100 | / newtype_index! {
[00:14:21] 101 | |     pub struct LiveVar { .. }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs:100:1
[00:14:21]     |
[00:14:21] 100 | / newtype_index! {
[00:14:21] 101 | |     pub struct LiveVar { .. }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs:100:1
[00:14:21]     |
[00:14:21] 100 | / newtype_index! {
[00:14:21] 101 | |     pub struct LiveVar { .. }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]   --> librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs:51:1
[00:14:21]    |
[00:14:21] 51 | / newtype_index! {
[00:14:21] 52 | |     pub struct AppearanceIndex { .. }
[00:14:21]    | |_^
[00:14:21]    |
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]   --> librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs:51:1
[00:14:21]    |
[00:14:21] 51 | / newtype_index! {
[00:14:21] 52 | |     pub struct AppearanceIndex { .. }
[00:14:21]    | |_^
[00:14:21]    |
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]   --> librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs:51:1
[00:14:21]    |
[00:14:21] 51 | / newtype_index! {
[00:14:21] 52 | |     pub struct AppearanceIndex { .. }
[00:14:21]    | |_^
[00:14:21]    |
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]   --> librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs:51:1
[00:14:21]    |
[00:14:21] 51 | / newtype_index! {
[00:14:21] 52 | |     pub struct AppearanceIndex { .. }
[00:14:21]    | |_^
[00:14:21]    |
[00:14:21]    = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/constraints/mod.rs:101:1
[00:14:21]     |
[00:14:21] 101 | / newtype_index! {
[00:14:21] 102 | |     pub struct ConstraintIndex {
[00:14:21] 103 | |         DEBUG_FORMAT = "ConstraintIndex({})"
[00:14:21] 105 | | }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/constraints/mod.rs:101:1
[00:14:21]     |
[00:14:21] 101 | / newtype_index! {
[00:14:21] 102 | |     pub struct ConstraintIndex {
[00:14:21] 103 | |         DEBUG_FORMAT = "ConstraintIndex({})"
[00:14:21] 105 | | }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/constraints/mod.rs:101:1
[00:14:21]     |
[00:14:21] 101 | / newtype_index! {
[00:14:21] 102 | |     pub struct ConstraintIndex {
[00:14:21] 103 | |         DEBUG_FORMAT = "ConstraintIndex({})"
[00:14:21] 105 | | }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/constraints/mod.rs:101:1
[00:14:21]     |
[00:14:21] 101 | / newtype_index! {
[00:14:21] 102 | |     pub struct ConstraintIndex {
[00:14:21] 103 | |         DEBUG_FORMAT = "ConstraintIndex({})"
[00:14:21] 105 | | }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/constraints/mod.rs:107:1
[00:14:21]     |
[00:14:21] 107 | / newtype_index! {
[00:14:21] 108 | |     pub struct ConstraintSccIndex {
[00:14:21] 109 | |         DEBUG_FORMAT = "ConstraintSccIndex({})"
[00:14:21] 111 | | }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/constraints/mod.rs:107:1
[00:14:21]     |
[00:14:21] 107 | / newtype_index! {
[00:14:21] 108 | |     pub struct ConstraintSccIndex {
[00:14:21] 109 | |         DEBUG_FORMAT = "ConstraintSccIndex({})"
[00:14:21] 111 | | }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/constraints/mod.rs:107:1
[00:14:21]     |
[00:14:21] 107 | / newtype_index! {
[00:14:21] 108 | |     pub struct ConstraintSccIndex {
[00:14:21] 109 | |         DEBUG_FORMAT = "ConstraintSccIndex({})"
[00:14:21] 111 | | }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/borrow_check/nll/constraints/mod.rs:107:1
[00:14:21]     |
[00:14:21] 107 | / newtype_index! {
[00:14:21] 108 | |     pub struct ConstraintSccIndex {
[00:14:21] 109 | |         DEBUG_FORMAT = "ConstraintSccIndex({})"
[00:14:21] 111 | | }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/build/mod.rs:405:1
[00:14:21]     |
[00:14:21] 405 | / newtype_index! {
[00:14:21] 406 | |     pub struct ScopeId { .. }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/build/mod.rs:405:1
[00:14:21]     |
[00:14:21] 405 | / newtype_index! {
[00:14:21] 406 | |     pub struct ScopeId { .. }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/build/mod.rs:405:1
[00:14:21]     |
[00:14:21] 405 | / newtype_index! {
[00:14:21] 406 | |     pub struct ScopeId { .. }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error[E0658]: const fn is unstable (see issue #24111)
[00:14:21]    --> librustc_mir/build/mod.rs:405:1
[00:14:21]     |
[00:14:21] 405 | / newtype_index! {
[00:14:21] 406 | |     pub struct ScopeId { .. }
[00:14:21]     | |_^
[00:14:21]     |
[00:14:21]     = help: add #![feature(const_fn)] to the crate attributes to enable
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21]     = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:14:21] 
[00:14:21] error: aborting due to 32 previous errors
[00:14:21] 
[00:14:21] For more information about this error, try `rustc --explain E0658`.
[00:14:21] error: Could not compile `rustc_mir`.
[00:14:21] 
[00:14:21] Caused by:
[00:14:21]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_mir librustc_mir/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=9389ef21a7981207 -C extra-filename=-9389ef21a7981207 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern arena=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libarena-93ff3b002b18b7ed.so --extern bitflags=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libbitflags-5a39798fe03e47f4.rlib --extern byteorder=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libbyteorder-8246be02936c9b1b.rlib --extern either=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libeither-0a515e87c8afea9e.rlib --extern graphviz=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libgraphviz-45ae4394366d07fd.so --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-c55d6c95192e4906.rlib --extern log_settings=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog_settings-87ec950697a15ed0.rlib --extern polonius_engine=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libpolonius_engine-218f3033f29f5493.rlib --extern rustc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc-09c0f3a89ad0d6b5.so --extern rustc_apfloat=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_apfloat-96aac12abd62414d.rlib --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-05301c67193a930e.so --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-f4ac364f854372fe.so --extern rustc_target=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-4a08b81d2b6640c1.so --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-8d84add221c0f710.so --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-8d84add221c0f710.rlib --extern smallvec=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsmallvec-cb741677cd0e0351.rlib --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-0651ffc5a9129db1.so --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-47b99ffec2efbd05.so -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-ee16f6821aef40e9/out -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-52504d5ed57fefc2/out` (exit code: 1)
[00:15:39] error: build failed
[00:15:39] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:15:39] expected success, got: exit code: 101
[00:15:39] expected success, got: exit code: 101
[00:15:39] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1155:9
[00:15:39] travis_fold:end:stage0-rustc

[00:15:39] travis_time:end:stage0-rustc:start=1536257083669800583,finish=1536257642327562150,duration=558657761567


[00:15:39] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:15:39] Build completed unsuccessfully in 0:10:14
[00:15:39] Makefile:28: recipe for target 'all' failed
[00:15:39] make: *** [all] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:01775768
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@@ -28,6 +28,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(decl_macro)]
#![cfg_attr(stage0, feature(macro_vis_matcher))]
#![feature(exhaustive_patterns)]
#![feature(const_fn)]
Copy link
Contributor

Choose a reason for hiding this comment

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

min_const_fn should suffice I think?

@rust-highfive
Copy link
Collaborator

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.
[00:22:07]    Compiling syntax_pos v0.0.0 (file:///checkout/src/libsyntax_pos)
[00:22:11]    Compiling rustc_errors v0.0.0 (file:///checkout/src/librustc_errors)
[00:23:32]    Compiling proc_macro v0.0.0 (file:///checkout/src/libproc_macro)
[00:23:42]    Compiling syntax_ext v0.0.0 (file:///checkout/src/libsyntax_ext)
[00:25:18] error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
[00:25:18]   --> librustc/dep_graph/graph.rs:42:1
[00:25:18]    |
[00:25:18] 42 | / newtype_index! {
[00:25:18] 43 | |     pub struct DepNodeIndex { .. }
[00:25:18] 44 | | }
[00:25:18]    | |_^ call to unsafe function
[00:25:18]    |
[00:25:18]    = note: consult the function's documentation for information on how to avoid undefined behavior
[00:25:18] 
[00:25:18] 
[00:25:18] error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
[00:25:18]   --> librustc/dep_graph/serialized.rs:17:1
[00:25:18]    |
[00:25:18] 17 | / newtype_index! {
[00:25:18] 18 | |     pub struct SerializedDepNodeIndex { .. }
[00:25:18] 19 | | }
[00:25:18]    | |_^ call to unsafe function
[00:25:18]    |
[00:25:18]    = note: consult the function's documentation for information on how to avoid undefined behavior
[00:25:18] 
[00:25:18] 
[00:25:18] error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
[00:25:18]   --> librustc/hir/def_id.rs:18:1
[00:25:18]    |
[00:25:18] 18 | / newtype_index! {
[00:25:18] 19 | |     pub struct CrateNum {
[00:25:18] 20 | |         ENCODABLE = custom
[00:25:18] 21 | |         DEBUG_FORMAT = "crate{}",
[00:25:18] 38 | |     }
[00:25:18] 39 | | }
[00:25:18] 39 | | }
[00:25:18]    | |_^ call to unsafe function
[00:25:18]    |
[00:25:18]    = note: consult the function's documentation for information on how to avoid undefined behavior
[00:25:18] 
[00:25:18] 
[00:25:18] error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
[00:25:18]    --> librustc/middle/region.rs:162:1
[00:25:18]     |
[00:25:18] 162 | / newtype_index! {
[00:25:18] 163 | |     pub struct FirstStatementIndex {
[00:25:18] 164 | |         MAX = SCOPE_DATA_REMAINDER_MAX
[00:25:18] 166 | | }
[00:25:18] 166 | | }
[00:25:18]     | |_^ call to unsafe function
[00:25:18]     |
[00:25:18]     = note: consult the function's documentation for information on how to avoid undefined behavior
[00:25:18] 
[00:25:18] 
[00:25:18] error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
[00:25:18]     |
[00:25:18]     |
[00:25:18] 523 | / newtype_index! {
[00:25:18] 524 | |     pub struct Local {
[00:25:18] 525 | |         DEBUG_FORMAT = "_{}",
[00:25:18] 526 | |         const RETURN_PLACE = 0,
[00:25:18] 528 | | }
[00:25:18] 528 | | }
[00:25:18]     | |_^ call to unsafe function
[00:25:18]     |
[00:25:18]     = note: consult the function's documentation for information on how to avoid undefined behavior
[00:25:18] 
[00:25:18] 
[00:25:18] error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
[00:25:18]     |
[00:25:18]     |
[00:25:18] 853 | / newtype_index! {
[00:25:18] 854 | |     pub struct BasicBlock {
[00:25:18] 855 | |         DEBUG_FORMAT = "bb{}",
[00:25:18] 856 | |         const START_BLOCK = 0,
[00:25:18] 858 | | }
[00:25:18] 858 | | }
[00:25:18]     | |_^ call to unsafe function
[00:25:18]     |
[00:25:18]     = note: consult the function's documentation for information on how to avoid undefined behavior
[00:25:18] 
[00:25:18] 
[00:25:18] error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
[00:25:18]      |
[00:25:18]      |
[00:25:18] 1828 | / newtype_index! {
[00:25:18] 1829 | |     pub struct Field {
[00:25:18] 1830 | |         DEBUG_FORMAT = "field[{}]"
[00:25:18] 1832 | | }
[00:25:18] 1832 | | }
[00:25:18]      | |_^ call to unsafe function
[00:25:18]      = note: consult the function's documentation for defined behavior
[00:25:18]      = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[00:25:18] 
[00:25:18] 
[00:25:18] error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
[00:25:18]      |
[00:25:18]      |
[00:25:18] 2282 | / newtype_index! {
[00:25:18] 2283 | |     pub struct Promoted {
[00:25:18] 2284 | |         DEBUG_FORMAT = "promoted[{}]"
[00:25:18] 2286 | | }
[00:25:18] 2286 | | }
[00:25:18]      | |_^ call to unsafe function
[00:25:18]      |
[00:25:18]      = note: consult the function's documentation for information on how to avoid undefined behavior
[00:25:18] 
[00:25:18] 
[00:25:18] error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn
[00:25:18]     --> librustc/ty/sty.rs:1037:1
[00:25:18]      |
[00:25:18] 1037 | / newtype_index! {
[00:25:18] 1038 | |     pub struct DebruijnIndex {
[00:25:18] 1039 | |         DEBUG_FORMAT = "DebruijnIndex({})",
[00:25:18] 1040 | |         const INNERMOST = 0,
[00:25:18] 1042 | | }
[00:25:18] 1042 | | }
[00:25:18]      | |_^ call to unsafe function
[00:25:18]      |
[00:25:18]      = note: consult the function's documentation for information on how to avoid undefined behavior
[00:25:18]      = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for mo--> librustc/ty/sty.rs:1209:1
[00:25:18]      |
[00:25:18] 1209 | / newtype_index! {
[00:25:18] 1210 | |     pub struct CanonicalVar { .. }
[00:25:18] 1211 | | }
[00:25:18]      | |_^ call to unsafe function
[00:25:18]      |
[00:25:18]      = note: consult the function's documentation for information on how to avoid undefined behavior
[00:25:18] 
[00:25:18] 
/x86_64-unknown-linux-gnu/release/deps/libflate2-08846502955755cd.rlib --extern fmt_macros=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/libfmt_macros-e7104d970c23d2cc.so --extern graphviz=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/libgraphviz-841a904682cb156a.so --extern jobserver=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/libjobserver-66c9f18495b7efc1.rlib --extern lazy_static=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/liblazy_static-30e50b79f5426f18.rlib --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-dea5dd9d4edbf91b.rlib --extern parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/libparking_lot-957d165ae762b0f0.rlib --extern polonius_engine=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/libpolonius_engine-bd5d27287984d3a7.rlib --extern proc_macro=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/libproc_macro-6152f7dfc36c43e0.so --extern rustc_rayon=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_rayon-8d623e22b9a6906c.rlib --extern rustc_rayon_core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_rayon_core-4f89f42af5bccd40.rlib --extern rustc_apfloat=/checkout/obj/build/x86_64-unknown-li

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:007df281
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

];

unsafe {
$type::from_u32_unchecked(value)
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't possible with min const fn. needs the const fn feature gate in this crate

Copy link
Contributor

Choose a reason for hiding this comment

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

Or do the struct init directly without the unsafe fn call

@bors
Copy link
Contributor

bors commented Sep 6, 2018

☔ The latest upstream changes (presumably #52626) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor Author

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Sep 7, 2018

📌 Commit ab43c1e has been approved by Mark-Simulacrum

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 7, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Sep 8, 2018
…Simulacrum

use `NonZeroU32` in `newtype_index!`macro, change syntax

Various improvements to the `newtype_index!` macro:

- Use `NonZeroU32` so that `Option<T>` is cheap
- More ergonomic helper method, no need to import `Idx` trait all the time
- Improve syntax to use `struct` keyword so that ripgrep works to find type def'n

Fixes rust-lang#50337

I'm curious to see if this passes tests =)
bors added a commit that referenced this pull request Sep 8, 2018
Rollup of 10 pull requests

Successful merges:

 - #53315 (use `NonZeroU32` in `newtype_index!`macro, change syntax)
 - #53932 ([NLL] Remove base_place)
 - #53942 (Rewrite `precompute_borrows_out_of_scope` for fewer hash table lookups.)
 - #53973 (Have rust-lldb look for the rust-enabled lldb)
 - #53981 (Implement initializer() for FileDesc)
 - #53987 (rustbuild: allow configuring llvm version suffix)
 - #53993 (rustc_resolve: don't record uniform_paths canaries as reexports.)
 - #54007 (crates that provide a `panic_handler` are exempt from the `unused_extern_crates` lint)
 - #54040 (update books for next release)
 - #54050 (Update `petgraph` dependency to 0.4.13 to fix build with nightly)
@bors
Copy link
Contributor

bors commented Sep 8, 2018

⌛ Testing commit ab43c1e with merge 05cb29e...

@bors bors merged commit ab43c1e into rust-lang:master Sep 8, 2018
@spastorino
Copy link
Member

👏 👏 👏

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants