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 Step::sub_usize #60542

Merged
merged 1 commit into from May 29, 2019

Conversation

Projects
None yet
7 participants
@timvermeulen
Copy link
Contributor

commented May 4, 2019

Required for #54054.

I'm aware that the Step trait needs a rework, but this still seems like a reasonable addition?

This currently doesn't compile because Chalk contains a type that implement this trait, and this is a breaking change. How can that be fixed?

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented May 4, 2019

r? @bluss

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

@Centril

This comment has been minimized.

Copy link
Member

commented May 4, 2019

@rust-highfive rust-highfive assigned scottmcm and unassigned bluss May 4, 2019

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented May 4, 2019

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:19fdd00e:start=1556970234011461764,finish=1556970319010694282,duration=84999232518
$ 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
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:05:26]    Compiling polonius-engine v0.7.0
[00:05:27]    Compiling chalk-engine v0.9.0
[00:05:27]    Compiling serialize v0.0.0 (/checkout/src/libserialize)
[00:05:28]    Compiling rustc_apfloat v0.0.0 (/checkout/src/librustc_apfloat)
[00:05:29] error[E0046]: not all trait items implemented, missing: `sub_usize`
[00:05:29]   --> <::chalk_macros::index::index_struct macros>:10:69
[00:05:29]    |
[00:05:29] 1  |  / ( $ v : vis struct $ n : ident { $ vf : vis value : usize , } ) => {
[00:05:29] 2  |  | # [ derive ( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ] $ v
[00:05:29] 3  |  | struct $ n { $ vf value : usize , } impl $ n {
[00:05:29] 4  |  | # [ allow ( dead_code ) ] $ v fn get_and_increment ( & mut self ) -> Self {
[00:05:29] ...   |
[00:05:29] 10 |  | write ! ( fmt , "{}({})" , stringify ! ( $ n ) , self . value ) } } impl ::
[00:05:29]    |  |_____________________________________________________________________^
[00:05:29] 11 | || std :: iter :: Step for $ n {
[00:05:29] 12 | || fn steps_between ( start : & Self , end : & Self ) -> Option < usize > {
[00:05:29] 13 | || usize :: steps_between ( & start . value , & end . value ) } fn replace_one (
[00:05:29] ...  ||
[00:05:29] 22 | || usize :: add_usize ( & self . value , n ) . map ( | value | Self { value } ) }
[00:05:29] 23 | || } impl From < usize > for $ n {
[00:05:29]    | ||_^ missing `sub_usize` in implementation
[00:05:29] 24 |  | fn from ( value : usize ) -> Self { Self { value : value } } } }
[00:05:29]    |  |________________________________________________________________- in this expansion of `index_struct!`
[00:05:29]   ::: /cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/lib.rs:81:1
[00:05:29]    |
[00:05:29]    |
[00:05:29] 81 | /  index_struct! {
[00:05:29] 82 | |      pub struct TableIndex { // FIXME: pub b/c Fold
[00:05:29] 84 | |      }
[00:05:29] 85 | |  }
[00:05:29]    | |__- in this macro invocation
[00:05:29]    |
[00:05:29]    |
[00:05:29]    = note: `sub_usize` from trait: `fn(&Self, usize) -> std::option::Option<Self>`
[00:05:29] 
[00:05:29] error[E0046]: not all trait items implemented, missing: `sub_usize`
[00:05:29]   --> <::chalk_macros::index::index_struct macros>:10:69
[00:05:29]    |
[00:05:29] 1  |  / ( $ v : vis struct $ n : ident { $ vf : vis value : usize , } ) => {
[00:05:29] 2  |  | # [ derive ( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ] $ v
[00:05:29] 3  |  | struct $ n { $ vf value : usize , } impl $ n {
[00:05:29] 4  |  | # [ allow ( dead_code ) ] $ v fn get_and_increment ( & mut self ) -> Self {
[00:05:29] ...   |
[00:05:29] 10 |  | write ! ( fmt , "{}({})" , stringify ! ( $ n ) , self . value ) } } impl ::
[00:05:29]    |  |_____________________________________________________________________^
[00:05:29] 11 | || std :: iter :: Step for $ n {
[00:05:29] 12 | || fn steps_between ( start : & Self , end : & Self ) -> Option < usize > {
[00:05:29] 13 | || usize :: steps_between ( & start . value , & end . value ) } fn replace_one (
[00:05:29] ...  ||
[00:05:29] 22 | || usize :: add_usize ( & self . value , n ) . map ( | value | Self { value } ) }
[00:05:29] 23 | || } impl From < usize > for $ n {
[00:05:29]    | ||_^ missing `sub_usize` in implementation
[00:05:29] 24 |  | fn from ( value : usize ) -> Self { Self { value : value } } } }
[00:05:29]    |  |________________________________________________________________- in this expansion of `index_struct!`
[00:05:29]   ::: /cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/lib.rs:91:1
[00:05:29]    |
[00:05:29]    |
[00:05:29] 91 | /  index_struct! {
[00:05:29] 93 | |          value: usize,
[00:05:29] 94 | |      }
[00:05:29] 95 | |  }
[00:05:29]    | |__- in this macro invocation
[00:05:29]    | |__- in this macro invocation
[00:05:29]    |
[00:05:29]    = note: `sub_usize` from trait: `fn(&Self, usize) -> std::option::Option<Self>`
[00:05:29] 
[00:05:29] error[E0046]: not all trait items implemented, missing: `sub_usize`
[00:05:29]   --> <::chalk_macros::index::index_struct macros>:10:69
[00:05:29]    |
[00:05:29] 1  |   / ( $ v : vis struct $ n : ident { $ vf : vis value : usize , } ) => {
[00:05:29] 2  |   | # [ derive ( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ] $ v
[00:05:29] 3  |   | struct $ n { $ vf value : usize , } impl $ n {
[00:05:29] 4  |   | # [ allow ( dead_code ) ] $ v fn get_and_increment ( & mut self ) -> Self {
[00:05:29] ...    |
[00:05:29] 10 |   | write ! ( fmt , "{}({})" , stringify ! ( $ n ) , self . value ) } } impl ::
[00:05:29]    |   |_____________________________________________________________________^
[00:05:29] 11 |  || std :: iter :: Step for $ n {
[00:05:29] 12 |  || fn steps_between ( start : & Self , end : & Self ) -> Option < usize > {
[00:05:29] 13 |  || usize :: steps_between ( & start . value , & end . value ) } fn replace_one (
[00:05:29] ...   ||
[00:05:29] 22 |  || usize :: add_usize ( & self . value , n ) . map ( | value | Self { value } ) }
[00:05:29] 23 |  || } impl From < usize > for $ n {
[00:05:29]    |  ||_^ missing `sub_usize` in implementation
[00:05:29] 24 |   | fn from ( value : usize ) -> Self { Self { value : value } } } }
[00:05:29]    |   |________________________________________________________________- in this expansion of `index_struct!`
[00:05:29]   ::: /cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/stack.rs:15:1
[00:05:29]    |
[00:05:29]    |
[00:05:29] 15 | /   index_struct! {
[00:05:29] 16 | |       pub(crate) struct StackIndex {
[00:05:29] 18 | |       }
[00:05:29] 19 | |   }
[00:05:29]    | |___- in this macro invocation
[00:05:29]    |
[00:05:29]    |
[00:05:29]    = note: `sub_usize` from trait: `fn(&Self, usize) -> std::option::Option<Self>`
[00:05:29] 
[00:05:29] error[E0046]: not all trait items implemented, missing: `sub_usize`
[00:05:29]   --> <::chalk_macros::index::index_struct macros>:10:69
[00:05:29]    |
[00:05:29] 1  |  / ( $ v : vis struct $ n : ident { $ vf : vis value : usize , } ) => {
[00:05:29] 2  |  | # [ derive ( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ] $ v
[00:05:29] 3  |  | struct $ n { $ vf value : usize , } impl $ n {
[00:05:29] 4  |  | # [ allow ( dead_code ) ] $ v fn get_and_increment ( & mut self ) -> Self {
[00:05:29] ...   |
[00:05:29] 10 |  | write ! ( fmt , "{}({})" , stringify ! ( $ n ) , self . value ) } } impl ::
[00:05:29]    |  |_____________________________________________________________________^
[00:05:29] 11 | || std :: iter :: Step for $ n {
[00:05:29] 12 | || fn steps_between ( start : & Self , end : & Self ) -> Option < usize > {
[00:05:29] 13 | || usize :: steps_between ( & start . value , & end . value ) } fn replace_one (
[00:05:29] ...  ||
[00:05:29] 22 | || usize :: add_usize ( & self . value , n ) . map ( | value | Self { value } ) }
[00:05:29] 23 | || } impl From < usize > for $ n {
[00:05:29]    | ||_^ missing `sub_usize` in implementation
[00:05:29] 24 |  | fn from ( value : usize ) -> Self { Self { value : value } } } }
[00:05:29]    |  |________________________________________________________________- in this expansion of `index_struct!`
[00:05:29]   ::: /cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/table.rs:34:1
[00:05:29]    |
[00:05:29]    |
[00:05:29] 34 | /  index_struct! {
[00:05:29] 35 | |      pub(crate) struct AnswerIndex {
[00:05:29] 37 | |      }
[00:05:29] 38 | |  }
[00:05:29]    | |__- in this macro invocation
[00:05:29]    |
---
travis_time:end:06bdbbf4:start=1556970665511600523,finish=1556970665516285813,duration=4685290
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0c557c5d
$ 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\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:00270a5c
travis_time:start:00270a5c
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-

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)

@timvermeulen timvermeulen changed the title Step sub usize Add Step::sub_usize May 4, 2019

@scottmcm

This comment has been minimized.

Copy link
Member

commented May 9, 2019

I don't see a problem with the trait method addition, since the trait definitely needs a rework, but I don't know the best way to deal with the chalk failure. I guess you could add a default implementation that just calls sub_one n times?

Also, I would have expected this to be used somewhere -- presumably in <Range<T> as DoubleEndedIterator>::nth_back, but I don't see that change?

@timvermeulen

This comment has been minimized.

Copy link
Contributor Author

commented May 9, 2019

I guess you could add a default implementation that just calls sub_one n times?

I'm okay with that, although that wouldn't handle underflow correctly. Would it make sense to use the PartialOrd bound here to return None in case the value has wrapped around?

Also, I would have expected this to be used somewhere

I thought overriding Range::nth_back would make more sense in a separate PR, but I'm not opposed to adding it here 🙂

@timvermeulen

This comment has been minimized.

Copy link
Contributor Author

commented May 9, 2019

We could also give sub_usize a default implementation of unimplemented!(), and then remove it after Chalk is updated to include sub_usize.

@Dylan-DPC

This comment has been minimized.

Copy link
Member

commented May 20, 2019

ping from triage @timvermeulen any updates on this?

@timvermeulen timvermeulen force-pushed the timvermeulen:step_sub_usize branch from 197d06a to f1d0829 May 25, 2019

@scottmcm

This comment has been minimized.

Copy link
Member

commented May 29, 2019

This seems reasonable to me as a way to help the submodule dance, and travis is passing, so

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented May 29, 2019

📌 Commit f1d0829 has been approved by scottmcm

Centril added a commit to Centril/rust that referenced this pull request May 29, 2019

Rollup merge of rust-lang#60542 - timvermeulen:step_sub_usize, r=scot…
…tmcm

Add Step::sub_usize

Required for rust-lang#54054.

I'm aware that the `Step` trait needs a rework, but this still seems like a reasonable addition?

This currently doesn't compile because Chalk contains a type that implement this trait, and this is a breaking change. How can that be fixed?

Centril added a commit to Centril/rust that referenced this pull request May 29, 2019

Rollup merge of rust-lang#60542 - timvermeulen:step_sub_usize, r=scot…
…tmcm

Add Step::sub_usize

Required for rust-lang#54054.

I'm aware that the `Step` trait needs a rework, but this still seems like a reasonable addition?

This currently doesn't compile because Chalk contains a type that implement this trait, and this is a breaking change. How can that be fixed?

bors added a commit that referenced this pull request May 29, 2019

Auto merge of #61305 - Centril:rollup-t39m00m, r=Centril
Rollup of 11 pull requests

Successful merges:

 - #58975 (Implement `iter::Sum` and `iter::Product` for `Option`)
 - #60542 (Add Step::sub_usize)
 - #60555 (Implement nth_back for RChunks(Exact)(Mut))
 - #60766 (Weak::into_raw)
 - #61048 (Feature/nth back chunks)
 - #61191 (librustc_errors: Move annotation collection to own impl)
 - #61235 (Stabilize bufreader_buffer feature)
 - #61249 (Rename Place::local to Place::local_or_deref_local)
 - #61291 (Avoid unneeded bug!() call)
 - #61294 (Rename `TraitOrImpl` to `Assoc` and `trait_or_impl` to `assoc`.)
 - #61297 (Remove LLVM instruction stats and other (obsolete) codegen stats.)

Failed merges:

r? @ghost

@bors bors merged commit f1d0829 into rust-lang:master May 29, 2019

1 check passed

Travis CI - Pull Request Build Passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.