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 by-value iterator for arrays (WIP!) #62959

Open
wants to merge 2 commits into
base: master
from

Conversation

@LukasKalbertodt
Copy link
Contributor

commented Jul 24, 2019

This adds an iterator that can iterate over arrays by value, yielding all elements by value. However, this PR does not add a corresponding IntoIterator impl for arrays. The IntoIterator impl needs some discussion about backwards-compatibility that should take place in a separate PR. With this patch, this code should work (but there is currently still a bug):

#![feature(array_value_iter)]
use std::array::IntoIter;

let arr = [1, 2, 3];
for x in IntoIter::new(arr) {
    println!("{}", x);
}

TODO:

  • Get initial feedback
  • Add tests
  • Figure out why stage1 produces weird bugs (comment)
  • Add UI tests as mentioned here (will do that soon-ish)

Notes for reviewers

  • Is the use of MaybeUninit correct here? I think it has to be used due to the Clone impl which has to fill the dead array elements with something, but cannot fill it with a correct instance.
  • Are the unit tests sufficient?

CC #25725

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jul 24, 2019

r? @Mark-Simulacrum

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

@Centril
Copy link
Member

left a comment

Overall this looks nice. Here's some food for thought however:

  • I think some tests should also be added that exercise each impl you've provided here.
  • In particular, there should be tests collecting into a Vec<...> and then checking the contents.
  • It would be good to have tests that drop some elements on the floor in some positions (let _ = iter.next();)
  • Checking the boundary conditions around N and self.pos is a good idea.
  • Tests that also format!(...) the iterator to exercise Debug would be good.

(Some of these checks can be done in the same tests).

Also cc @scottmcm

src/libcore/array.rs Outdated Show resolved Hide resolved
/// This struct is created by the `IntoIterator::into_iter`] method on
/// arrays.
#[unstable(feature = "array_value_iter", issue = "0")]
pub struct IntoIter<T, const N: usize> {

This comment has been minimized.

Copy link
@Centril

Centril Jul 24, 2019

Member

I would like to see the constraint [T; N]: LengthAtMost32, repeated here, on Drop, and other impls, to make sure that const generics are not stably exposed (and this also means that struct IntoIter<..> itself cannot be stabilized until const generics are with this formulation).

This comment has been minimized.

Copy link
@Centril

Centril Jul 24, 2019

Member

Also please extend the UI tests in Scott's fashion (consult #62435 (comment)).

src/libcore/array.rs Outdated Show resolved Hide resolved
src/libcore/array.rs Outdated Show resolved Hide resolved
src/libcore/array.rs Outdated Show resolved Hide resolved
src/libcore/array.rs Outdated Show resolved Hide resolved
src/libcore/array.rs Outdated Show resolved Hide resolved
@Centril

This comment has been minimized.

Copy link
Member

commented Jul 24, 2019

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

commented Jul 24, 2019

This is unfortunately not backwards compatible. Arrays deref to slices and calling .into_iter currently returns &T but would begin returning T. cc @cuviper who has done investigation into this in the past - we should probably update the relevant issue.

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

commented Jul 25, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-07-24T23:00:04.8669121Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-24T23:00:04.8845170Z ##[command]git config gc.auto 0
2019-07-24T23:00:04.8912247Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-24T23:00:04.8956519Z ##[command]git config --get-all http.proxy
2019-07-24T23:00:04.9087094Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/62959/merge:refs/remotes/pull/62959/merge
---
2019-07-24T23:00:43.2903968Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-24T23:00:43.2904004Z 
2019-07-24T23:00:43.2904255Z   git checkout -b <new-branch-name>
2019-07-24T23:00:43.2904288Z 
2019-07-24T23:00:43.2904362Z HEAD is now at 548e199df Merge ac96d7734cd80556616f3c0d8deec4ee586caef6 into 03f19f7ff128a3b01eeab3f87f04cce22883f006
2019-07-24T23:00:43.3048598Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-24T23:00:43.3051546Z ==============================================================================
2019-07-24T23:00:43.3051617Z Task         : Bash
2019-07-24T23:00:43.3051659Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-25T00:01:19.7826315Z .................................................................................................... 200/5851
2019-07-25T00:01:24.7180990Z .................................................................................................... 300/5851
2019-07-25T00:01:28.2207641Z .................................................................................................... 400/5851
2019-07-25T00:01:32.1469397Z .................................................................................................... 500/5851
2019-07-25T00:01:36.2358319Z ........................................................................i........................... 600/5851
2019-07-25T00:01:45.5572163Z ...........................................F........................................................ 800/5851
2019-07-25T00:01:51.4719580Z .................................................................................................... 900/5851
2019-07-25T00:01:56.7068599Z ...................................................................................................i 1000/5851
2019-07-25T00:01:56.7068599Z ...................................................................................................i 1000/5851
2019-07-25T00:02:02.4184061Z ...........i........................................................................................ 1100/5851
2019-07-25T00:02:06.4667817Z .............................iiiii.................................................................. 1200/5851
2019-07-25T00:02:12.7613154Z .................................................................................................... 1400/5851
2019-07-25T00:02:15.6152105Z .................................................................................................... 1500/5851
2019-07-25T00:02:19.5824992Z .................................................................................................... 1600/5851
2019-07-25T00:02:22.3745405Z .................................................................................................... 1700/5851
2019-07-25T00:02:22.3745405Z .................................................................................................... 1700/5851
2019-07-25T00:02:25.9643423Z .....................................................................i.............................. 1800/5851
2019-07-25T00:02:34.9827257Z .................................................................................................... 2000/5851
2019-07-25T00:02:39.4125210Z .................................................................................................... 2100/5851
2019-07-25T00:02:43.3146414Z .................................................................................................... 2200/5851
2019-07-25T00:02:43.3146414Z .................................................................................................... 2200/5851
2019-07-25T00:02:47.4502815Z ......................................................i............................................. 2300/5851
2019-07-25T00:02:57.9133905Z .................................................................................................... 2500/5851
2019-07-25T00:03:02.2646221Z .................................................................................................... 2600/5851
2019-07-25T00:03:07.6408917Z .................................................................................................... 2700/5851
2019-07-25T00:03:11.7289446Z .................................................................................................... 2800/5851
2019-07-25T00:03:11.7289446Z .................................................................................................... 2800/5851
2019-07-25T00:03:16.3968020Z .................................................................................................... 2900/5851
2019-07-25T00:03:21.8427343Z .................................................................................................... 3000/5851
2019-07-25T00:03:26.5173068Z .................................................................................................... 3100/5851
2019-07-25T00:03:31.9727729Z .................................................................................................... 3200/5851
2019-07-25T00:03:35.7765238Z .....................................................FF............................................. 3300/5851
2019-07-25T00:03:39.6855007Z .................................................................................................... 3400/5851
2019-07-25T00:03:45.0665044Z .................................................................................................... 3500/5851
2019-07-25T00:03:49.1103849Z .....................i.............................................................................. 3600/5851
2019-07-25T00:03:53.4731084Z ..............................................................................................ii...i 3700/5851
2019-07-25T00:03:57.4755746Z ..ii................................................................................................ 3800/5851
2019-07-25T00:04:06.5772059Z .................................................................................................... 4000/5851
2019-07-25T00:04:06.5772059Z .................................................................................................... 4000/5851
2019-07-25T00:04:10.6217374Z ........ii.......................................................................................... 4100/5851
2019-07-25T00:04:12.7883745Z .............................i...................................................................... 4200/5851
2019-07-25T00:04:14.9782260Z ................................................................................................i... 4300/5851
2019-07-25T00:04:21.9510950Z .................................................................................................... 4500/5851
2019-07-25T00:04:40.4148610Z .................................................................................................... 4600/5851
2019-07-25T00:04:44.1582520Z .................................................................................................... 4700/5851
2019-07-25T00:04:48.0403249Z .................................................................................................... 4800/5851
---
2019-07-25T00:05:23.1189456Z .................................................................................................... 5400/5851
2019-07-25T00:05:27.2253336Z .................................................................................................... 5500/5851
2019-07-25T00:05:31.5300712Z .................................................................................................... 5600/5851
2019-07-25T00:05:34.8034572Z .................................................................................................... 5700/5851
2019-07-25T00:05:37.9490051Z ...........................................................................................i........ 5800/5851
2019-07-25T00:05:39.8571322Z failures:
2019-07-25T00:05:39.8628391Z 
2019-07-25T00:05:39.8629151Z ---- [ui] ui/const-generics/array-impls/core-traits-no-impls-length-33.rs stdout ----
2019-07-25T00:05:39.8629225Z diff of stderr:
2019-07-25T00:05:39.8629225Z diff of stderr:
2019-07-25T00:05:39.8629264Z 
2019-07-25T00:05:39.8629590Z 46              <&'a [T] as std::iter::IntoIterator>
2019-07-25T00:05:39.8629885Z 47              <&'a mut [T; _] as std::iter::IntoIterator>
2019-07-25T00:05:39.8630236Z 48              <&'a mut [T] as std::iter::IntoIterator>
2019-07-25T00:05:39.8630313Z +              <[T; _] as std::iter::IntoIterator>
2019-07-25T00:05:39.8630418Z 50 
2019-07-25T00:05:39.8630506Z 51 error: aborting due to 5 previous errors
2019-07-25T00:05:39.8630543Z 
2019-07-25T00:05:39.8630571Z 
2019-07-25T00:05:39.8630571Z 
2019-07-25T00:05:39.8630622Z The actual stderr differed from the expected stderr.
2019-07-25T00:05:39.8631053Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33/core-traits-no-impls-length-33.stderr
2019-07-25T00:05:39.8631619Z To update references, rerun the tests and pass the `--bless` flag
2019-07-25T00:05:39.8632399Z To only update this specific test, also pass `--test-args const-generics/array-impls/core-traits-no-impls-length-33.rs`
2019-07-25T00:05:39.8632545Z error: 1 errors occurred comparing output.
2019-07-25T00:05:39.8632596Z status: exit code: 1
2019-07-25T00:05:39.8632596Z status: exit code: 1
2019-07-25T00:05:39.8633590Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33/auxiliary" "-A" "unused"
2019-07-25T00:05:39.8634013Z ------------------------------------------
2019-07-25T00:05:39.8634053Z 
2019-07-25T00:05:39.8634311Z ------------------------------------------
2019-07-25T00:05:39.8634362Z stderr:
2019-07-25T00:05:39.8634362Z stderr:
2019-07-25T00:05:39.8634630Z ------------------------------------------
2019-07-25T00:05:39.8634691Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-07-25T00:05:39.8635010Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:2:22
2019-07-25T00:05:39.8635086Z    |
2019-07-25T00:05:39.8635144Z LL |     println!("{:?}", [0_usize; 33]);
2019-07-25T00:05:39.8635207Z    |                      ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-07-25T00:05:39.8635280Z    |
2019-07-25T00:05:39.8635338Z    = note: required because of the requirements on the impl of `std::fmt::Debug` for `[usize; 33]`
2019-07-25T00:05:39.8635406Z    = note: required by `std::fmt::Debug::fmt`
2019-07-25T00:05:39.8635456Z 
2019-07-25T00:05:39.8635509Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-07-25T00:05:39.8635833Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:9:9
2019-07-25T00:05:39.8635905Z    |
2019-07-25T00:05:39.8635954Z LL |     set.insert([0_usize; 33]);
2019-07-25T00:05:39.8636012Z    |         ^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-07-25T00:05:39.8636064Z    |
2019-07-25T00:05:39.8636275Z    = note: required because of the requirements on the impl of `std::cmp::Eq` for `[usize; 33]`
2019-07-25T00:05:39.8636323Z 
2019-07-25T00:05:39.8636467Z error[E0369]: binary operation `==` cannot be applied to type `[usize; 33]`
2019-07-25T00:05:39.8636847Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:14:19
2019-07-25T00:05:39.8636915Z    |
2019-07-25T00:05:39.8636980Z LL |     [0_usize; 33] == [1_usize; 33]
2019-07-25T00:05:39.8637256Z    |     ------------- ^^ ------------- [usize; 33]
2019-07-25T00:05:39.8637357Z    |     [usize; 33]
2019-07-25T00:05:39.8637420Z    |
2019-07-25T00:05:39.8637420Z    |
2019-07-25T00:05:39.8637474Z    = note: an implementation of `std::cmp::PartialEq` might be missing for `[usize; 33]`
2019-07-25T00:05:39.8637663Z 
2019-07-25T00:05:39.8637732Z error[E0369]: binary operation `<` cannot be applied to type `[usize; 33]`
2019-07-25T00:05:39.8638084Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:19:19
2019-07-25T00:05:39.8638222Z    |
2019-07-25T00:05:39.8638287Z LL |     [0_usize; 33] < [1_usize; 33]
2019-07-25T00:05:39.8638557Z    |     ------------- ^ ------------- [usize; 33]
2019-07-25T00:05:39.8638654Z    |     [usize; 33]
2019-07-25T00:05:39.8638715Z    |
2019-07-25T00:05:39.8638715Z    |
2019-07-25T00:05:39.8638896Z    = note: an implementation of `std::cmp::PartialOrd` might be missing for `[usize; 33]`
2019-07-25T00:05:39.8638933Z 
2019-07-25T00:05:39.8639002Z error[E0277]: the trait bound `&[usize; 33]: std::iter::IntoIterator` is not satisfied
2019-07-25T00:05:39.8639360Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:24:14
2019-07-25T00:05:39.8639416Z    |
2019-07-25T00:05:39.8639481Z LL |     for _ in &[0_usize; 33] {
2019-07-25T00:05:39.8639541Z    |              ^^^^^^^^^^^^^^ the trait `std::iter::IntoIterator` is not implemented for `&[usize; 33]`
2019-07-25T00:05:39.8639643Z    = help: the following implementations were found:
2019-07-25T00:05:39.8639643Z    = help: the following implementations were found:
2019-07-25T00:05:39.8639942Z              <&'a [T; _] as std::iter::IntoIterator>
2019-07-25T00:05:39.8640212Z              <&'a [T] as std::iter::IntoIterator>
2019-07-25T00:05:39.8640485Z              <&'a mut [T; _] as std::iter::IntoIterator>
2019-07-25T00:05:39.8640778Z              <&'a mut [T] as std::iter::IntoIterator>
2019-07-25T00:05:39.8640845Z              <[T; _] as std::iter::IntoIterator>
2019-07-25T00:05:39.8640951Z 
2019-07-25T00:05:39.8640999Z error: aborting due to 5 previous errors
2019-07-25T00:05:39.8641031Z 
2019-07-25T00:05:39.8641081Z Some errors have detailed explanations: E0277, E0369.
---
2019-07-25T00:05:39.8642690Z ---- [ui] ui/iterators/array.rs stdout ----
2019-07-25T00:05:39.8642738Z 
2019-07-25T00:05:39.8642788Z error: ui test compiled successfully!
2019-07-25T00:05:39.8642858Z status: exit code: 0
2019-07-25T00:05:39.8643657Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/iterators/array.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/array" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/array/auxiliary" "-A" "unused"
2019-07-25T00:05:39.8644047Z ------------------------------------------
2019-07-25T00:05:39.8644085Z 
2019-07-25T00:05:39.8644359Z ------------------------------------------
2019-07-25T00:05:39.8644411Z stderr:
---
2019-07-25T00:05:39.8645478Z ---- [ui] ui/iterators/array-of-ranges.rs stdout ----
2019-07-25T00:05:39.8645515Z 
2019-07-25T00:05:39.8645591Z error: ui test compiled successfully!
2019-07-25T00:05:39.8645640Z status: exit code: 0
2019-07-25T00:05:39.8646451Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/iterators/array-of-ranges.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/array-of-ranges" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/array-of-ranges/auxiliary" "-A" "unused"
2019-07-25T00:05:39.8646855Z ------------------------------------------
2019-07-25T00:05:39.8646894Z 
2019-07-25T00:05:39.8647149Z ------------------------------------------
2019-07-25T00:05:39.8647200Z stderr:
---
2019-07-25T00:05:39.8656140Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:535:22
2019-07-25T00:05:39.8656446Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-07-25T00:05:39.8669917Z 
2019-07-25T00:05:39.8670076Z 
2019-07-25T00:05:39.8675765Z 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 -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -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"
2019-07-25T00:05:39.8676480Z 
2019-07-25T00:05:39.8676691Z 
2019-07-25T00:05:39.8688639Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-07-25T00:05:39.8688798Z Build completed unsuccessfully in 0:58:32
2019-07-25T00:05:39.8688798Z Build completed unsuccessfully in 0:58:32
2019-07-25T00:05:40.8880475Z ##[error]Bash exited with code '1'.
2019-07-25T00:05:40.8932100Z ##[section]Starting: Checkout
2019-07-25T00:05:40.8935486Z ==============================================================================
2019-07-25T00:05:40.8935561Z Task         : Get sources
2019-07-25T00:05:40.8935612Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@LukasKalbertodt

This comment has been minimized.

Copy link
Contributor Author

commented Jul 25, 2019

@Centril Thanks a lot for the fairly in-depth review already! I will fix all of that once the bigger questions are resolved.

@Mark-Simulacrum I wasn't aware this is a problem. Sigh, that's unfortunate indeed. (I am a bit surprised about quickly closing the PR without a discussion though...)

From #49000 it seems like there has been a fair amount of discussion already. To sidestep the IntoIterator problem entirely for now, what do you think about changing this PR to only add the iterator type and an unstable fn owned_iter(self) -> IntoIter for arrays? That way the actual functionality is already there and we can discuss how we deal with IntoIterator afterwards. Makes sense?

@Centril

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

I also wonder if there has already been a crater run and what the fallout was? Maybe @cuviper knows.

Ostensibly some minor breakage could (it's a choice!) be justified as "inference breakage" and this is a rather large paper cut in the language which would be good to finally solve. (I'm also thinking of #59500 which technically was not "allowed" due to #[fundamental] but which we merged anyways and did not revert even with the ensuing reported regression).

To sidestep the IntoIterator problem entirely for now, what do you think about changing this PR to only add the iterator type and an unstable fn owned_iter(self) -> IntoIter for arrays? That way the actual functionality is already there and we can discuss how we deal with IntoIterator afterwards. Makes sense?

In my view a solid interim plan! Reopening so that we may consider that.

@Centril Centril reopened this Jul 25, 2019

@cuviper
Copy link
Member

left a comment

Please compare with #49000 for feature parity of what I did before. Most of it should be similar, apart from having real const generics now. I had as_slice() and as_mut_slice(), Clone, DoubleEndedIterator, ExactSizedIterator, FusedIterator, and TrustedLen. You could take my added tests too.

src/libcore/array.rs Outdated Show resolved Hide resolved
src/libcore/array.rs Outdated Show resolved Hide resolved
src/libcore/array.rs Outdated Show resolved Hide resolved
@cuviper

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

I also wonder if there has already been a crater run and what the fallout was?

I don't think we did a direct crater run with the new IntoIterator, but there was an attempt at running with the clippy lint denied, which failed horribly for unrelated reasons. (The rustflags interfered with build scripts, or something like that.)

@Centril

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

@cuviper In that case this is as good a time as any to try out a crater run then.

@scottmcm

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

My personal opinion: having this impl is so obviously the correct thing that I'd be willing to bend stability guarantees to have it, but we don't even need to because adding a new trait impl is an allowed change, no matter whether it breaks code. And the only code that it breaks, today, is code that was doing a.into_iter() when a.iter() would have done exactly the same thing for less typing, so any workaround needed to not trigger this change will make the code strictly better regardless.

src/libcore/array.rs Outdated Show resolved Hide resolved
@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Jul 25, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-07-25T00:29:20.4488943Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-25T00:29:20.4669657Z ##[command]git config gc.auto 0
2019-07-25T00:29:20.4758416Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-25T00:29:21.0275565Z ##[command]git config --get-all http.proxy
2019-07-25T00:29:21.0284231Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/62959/merge:refs/remotes/pull/62959/merge
---
2019-07-25T00:29:55.0317626Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-25T00:29:55.0317669Z 
2019-07-25T00:29:55.0317942Z   git checkout -b <new-branch-name>
2019-07-25T00:29:55.0317979Z 
2019-07-25T00:29:55.0318035Z HEAD is now at 1e59da182 Merge ac96d7734cd80556616f3c0d8deec4ee586caef6 into 03f19f7ff128a3b01eeab3f87f04cce22883f006
2019-07-25T00:29:55.0467828Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-25T00:29:55.0471870Z ==============================================================================
2019-07-25T00:29:55.0471938Z Task         : Bash
2019-07-25T00:29:55.0471990Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-25T01:31:37.3203333Z .................................................................................................... 200/5851
2019-07-25T01:31:41.7257933Z .................................................................................................... 300/5851
2019-07-25T01:31:45.7507633Z .................................................................................................... 400/5851
2019-07-25T01:31:49.8569186Z .................................................................................................... 500/5851
2019-07-25T01:31:53.9387336Z ........................................................................i........................... 600/5851
2019-07-25T01:32:03.2983968Z ...........................................F........................................................ 800/5851
2019-07-25T01:32:09.1665546Z .................................................................................................... 900/5851
2019-07-25T01:32:14.4177823Z ...................................................................................................i 1000/5851
2019-07-25T01:32:14.4177823Z ...................................................................................................i 1000/5851
2019-07-25T01:32:20.2618217Z ...........i........................................................................................ 1100/5851
2019-07-25T01:32:24.4560081Z .............................iiiii.................................................................. 1200/5851
2019-07-25T01:32:30.7476715Z .................................................................................................... 1400/5851
2019-07-25T01:32:33.6326220Z .................................................................................................... 1500/5851
2019-07-25T01:32:37.6983915Z .................................................................................................... 1600/5851
2019-07-25T01:32:40.5306699Z .................................................................................................... 1700/5851
2019-07-25T01:32:40.5306699Z .................................................................................................... 1700/5851
2019-07-25T01:32:44.0894927Z .....................................................................i.............................. 1800/5851
2019-07-25T01:32:53.0826993Z .................................................................................................... 2000/5851
2019-07-25T01:32:57.6491878Z .................................................................................................... 2100/5851
2019-07-25T01:33:01.5495637Z .................................................................................................... 2200/5851
2019-07-25T01:33:01.5495637Z .................................................................................................... 2200/5851
2019-07-25T01:33:05.6271391Z .....................................................i.............................................. 2300/5851
2019-07-25T01:33:16.1170253Z .................................................................................................... 2500/5851
2019-07-25T01:33:20.3911639Z .................................................................................................... 2600/5851
2019-07-25T01:33:25.7524092Z .................................................................................................... 2700/5851
2019-07-25T01:33:29.8749409Z .................................................................................................... 2800/5851
2019-07-25T01:33:29.8749409Z .................................................................................................... 2800/5851
2019-07-25T01:33:34.5740797Z .................................................................................................... 2900/5851
2019-07-25T01:33:40.0203523Z .................................................................................................... 3000/5851
2019-07-25T01:33:44.6333642Z .................................................................................................... 3100/5851
2019-07-25T01:33:50.0971821Z .................................................................................................... 3200/5851
2019-07-25T01:33:53.8461007Z .....................................................F.F............................................ 3300/5851
2019-07-25T01:34:03.0091293Z .................................................................................................... 3500/5851
2019-07-25T01:34:03.0091293Z .................................................................................................... 3500/5851
2019-07-25T01:34:06.8767639Z ....................i............................................................................... 3600/5851
2019-07-25T01:34:11.1701352Z ..............................................................................................ii...i 3700/5851
2019-07-25T01:34:15.1418514Z ..ii................................................................................................ 3800/5851
2019-07-25T01:34:24.2322574Z .................................................................................................... 4000/5851
2019-07-25T01:34:24.2322574Z .................................................................................................... 4000/5851
2019-07-25T01:34:28.3440545Z ........ii.......................................................................................... 4100/5851
2019-07-25T01:34:30.5441262Z .............................i...................................................................... 4200/5851
2019-07-25T01:34:32.7192532Z ................................................................................................i... 4300/5851
2019-07-25T01:34:39.6440542Z .................................................................................................... 4500/5851
2019-07-25T01:34:58.2847968Z .................................................................................................... 4600/5851
2019-07-25T01:35:02.0873676Z .................................................................................................... 4700/5851
2019-07-25T01:35:05.9840980Z .................................................................................................... 4800/5851
---
2019-07-25T01:35:41.6602113Z .................................................................................................... 5400/5851
2019-07-25T01:35:46.0620890Z .................................................................................................... 5500/5851
2019-07-25T01:35:50.1115179Z .................................................................................................... 5600/5851
2019-07-25T01:35:53.2952051Z .................................................................................................... 5700/5851
2019-07-25T01:35:56.4844043Z ...........................................................................................i........ 5800/5851
2019-07-25T01:35:58.3999511Z failures:
2019-07-25T01:35:58.4048260Z 
2019-07-25T01:35:58.4048964Z ---- [ui] ui/const-generics/array-impls/core-traits-no-impls-length-33.rs stdout ----
2019-07-25T01:35:58.4049039Z diff of stderr:
2019-07-25T01:35:58.4049039Z diff of stderr:
2019-07-25T01:35:58.4049068Z 
2019-07-25T01:35:58.4049320Z 46              <&'a [T] as std::iter::IntoIterator>
2019-07-25T01:35:58.4049532Z 47              <&'a mut [T; _] as std::iter::IntoIterator>
2019-07-25T01:35:58.4049738Z 48              <&'a mut [T] as std::iter::IntoIterator>
2019-07-25T01:35:58.4049799Z +              <[T; _] as std::iter::IntoIterator>
2019-07-25T01:35:58.4049881Z 50 
2019-07-25T01:35:58.4049945Z 51 error: aborting due to 5 previous errors
2019-07-25T01:35:58.4049972Z 
2019-07-25T01:35:58.4049994Z 
2019-07-25T01:35:58.4049994Z 
2019-07-25T01:35:58.4050032Z The actual stderr differed from the expected stderr.
2019-07-25T01:35:58.4050360Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33/core-traits-no-impls-length-33.stderr
2019-07-25T01:35:58.4050586Z To update references, rerun the tests and pass the `--bless` flag
2019-07-25T01:35:58.4050888Z To only update this specific test, also pass `--test-args const-generics/array-impls/core-traits-no-impls-length-33.rs`
2019-07-25T01:35:58.4050980Z error: 1 errors occurred comparing output.
2019-07-25T01:35:58.4051021Z status: exit code: 1
2019-07-25T01:35:58.4051021Z status: exit code: 1
2019-07-25T01:35:58.4052058Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/const-generics/array-impls/core-traits-no-impls-length-33/auxiliary" "-A" "unused"
2019-07-25T01:35:58.4052450Z ------------------------------------------
2019-07-25T01:35:58.4052484Z 
2019-07-25T01:35:58.4052691Z ------------------------------------------
2019-07-25T01:35:58.4052750Z stderr:
2019-07-25T01:35:58.4052750Z stderr:
2019-07-25T01:35:58.4052952Z ------------------------------------------
2019-07-25T01:35:58.4053003Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-07-25T01:35:58.4053275Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:2:22
2019-07-25T01:35:58.4053334Z    |
2019-07-25T01:35:58.4053374Z LL |     println!("{:?}", [0_usize; 33]);
2019-07-25T01:35:58.4053425Z    |                      ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-07-25T01:35:58.4053489Z    |
2019-07-25T01:35:58.4053537Z    = note: required because of the requirements on the impl of `std::fmt::Debug` for `[usize; 33]`
2019-07-25T01:35:58.4053717Z    = note: required by `std::fmt::Debug::fmt`
2019-07-25T01:35:58.4053745Z 
2019-07-25T01:35:58.4053790Z error[E0277]: arrays only have std trait implementations for lengths 0..=32
2019-07-25T01:35:58.4054084Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:9:9
2019-07-25T01:35:58.4054148Z    |
2019-07-25T01:35:58.4054187Z LL |     set.insert([0_usize; 33]);
2019-07-25T01:35:58.4054237Z    |         ^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]`
2019-07-25T01:35:58.4054302Z    |
2019-07-25T01:35:58.4054356Z    = note: required because of the requirements on the impl of `std::cmp::Eq` for `[usize; 33]`
2019-07-25T01:35:58.4054387Z 
2019-07-25T01:35:58.4054431Z error[E0369]: binary operation `==` cannot be applied to type `[usize; 33]`
2019-07-25T01:35:58.4054830Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:14:19
2019-07-25T01:35:58.4054873Z    |
2019-07-25T01:35:58.4054910Z LL |     [0_usize; 33] == [1_usize; 33]
2019-07-25T01:35:58.4055136Z    |     ------------- ^^ ------------- [usize; 33]
2019-07-25T01:35:58.4055214Z    |     [usize; 33]
2019-07-25T01:35:58.4055265Z    |
2019-07-25T01:35:58.4055265Z    |
2019-07-25T01:35:58.4055308Z    = note: an implementation of `std::cmp::PartialEq` might be missing for `[usize; 33]`
2019-07-25T01:35:58.4055377Z 
2019-07-25T01:35:58.4055419Z error[E0369]: binary operation `<` cannot be applied to type `[usize; 33]`
2019-07-25T01:35:58.4055870Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:19:19
2019-07-25T01:35:58.4055928Z    |
2019-07-25T01:35:58.4055970Z LL |     [0_usize; 33] < [1_usize; 33]
2019-07-25T01:35:58.4056218Z    |     ------------- ^ ------------- [usize; 33]
2019-07-25T01:35:58.4056307Z    |     [usize; 33]
2019-07-25T01:35:58.4056363Z    |
2019-07-25T01:35:58.4056363Z    |
2019-07-25T01:35:58.4056411Z    = note: an implementation of `std::cmp::PartialOrd` might be missing for `[usize; 33]`
2019-07-25T01:35:58.4056451Z 
2019-07-25T01:35:58.4056500Z error[E0277]: the trait bound `&[usize; 33]: std::iter::IntoIterator` is not satisfied
2019-07-25T01:35:58.4056798Z   --> /checkout/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs:24:14
2019-07-25T01:35:58.4056846Z    |
2019-07-25T01:35:58.4056888Z LL |     for _ in &[0_usize; 33] {
2019-07-25T01:35:58.4056959Z    |              ^^^^^^^^^^^^^^ the trait `std::iter::IntoIterator` is not implemented for `&[usize; 33]`
2019-07-25T01:35:58.4057139Z    = help: the following implementations were found:
2019-07-25T01:35:58.4057139Z    = help: the following implementations were found:
2019-07-25T01:35:58.4057431Z              <&'a [T; _] as std::iter::IntoIterator>
2019-07-25T01:35:58.4057661Z              <&'a [T] as std::iter::IntoIterator>
2019-07-25T01:35:58.4057894Z              <&'a mut [T; _] as std::iter::IntoIterator>
2019-07-25T01:35:58.4058143Z              <&'a mut [T] as std::iter::IntoIterator>
2019-07-25T01:35:58.4058194Z              <[T; _] as std::iter::IntoIterator>
2019-07-25T01:35:58.4058284Z 
2019-07-25T01:35:58.4058344Z error: aborting due to 5 previous errors
2019-07-25T01:35:58.4058372Z 
2019-07-25T01:35:58.4058416Z Some errors have detailed explanations: E0277, E0369.
---
2019-07-25T01:35:58.4059285Z ---- [ui] ui/iterators/array.rs stdout ----
2019-07-25T01:35:58.4059313Z 
2019-07-25T01:35:58.4059351Z error: ui test compiled successfully!
2019-07-25T01:35:58.4059388Z status: exit code: 0
2019-07-25T01:35:58.4060007Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/iterators/array.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/array" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/array/auxiliary" "-A" "unused"
2019-07-25T01:35:58.4062727Z ------------------------------------------
2019-07-25T01:35:58.4062760Z 
2019-07-25T01:35:58.4062955Z ------------------------------------------
2019-07-25T01:35:58.4063011Z stderr:
---
2019-07-25T01:35:58.4063700Z ---- [ui] ui/iterators/array-of-ranges.rs stdout ----
2019-07-25T01:35:58.4063727Z 
2019-07-25T01:35:58.4063781Z error: ui test compiled successfully!
2019-07-25T01:35:58.4063827Z status: exit code: 0
2019-07-25T01:35:58.4064467Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/iterators/array-of-ranges.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/array-of-ranges" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/iterators/array-of-ranges/auxiliary" "-A" "unused"
2019-07-25T01:35:58.4064759Z ------------------------------------------
2019-07-25T01:35:58.4064805Z 
2019-07-25T01:35:58.4064997Z ------------------------------------------
2019-07-25T01:35:58.4065036Z stderr:
---
2019-07-25T01:35:58.4068202Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:535:22
2019-07-25T01:35:58.4068291Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-07-25T01:35:58.4074224Z 
2019-07-25T01:35:58.4074339Z 
2019-07-25T01:35:58.4079725Z 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 -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -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"
2019-07-25T01:35:58.4080153Z 
2019-07-25T01:35:58.4080182Z 
2019-07-25T01:35:58.4091786Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-07-25T01:35:58.4091877Z Build completed unsuccessfully in 0:59:10
2019-07-25T01:35:58.4091877Z Build completed unsuccessfully in 0:59:10
2019-07-25T01:35:59.3292957Z ##[error]Bash exited with code '1'.
2019-07-25T01:35:59.3334688Z ##[section]Starting: Checkout
2019-07-25T01:35:59.3337283Z ==============================================================================
2019-07-25T01:35:59.3337340Z Task         : Get sources
2019-07-25T01:35:59.3337404Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@RalfJung

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

And the only code that it breaks, today, is code that was doing a.into_iter() when a.iter() would have done exactly the same thing for less typing,

Is that true? I think it also breaks code that does for x in a because for implicitly does into_iter().

We could probably have a clippy/rustc lint to start moving people away from that, though.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

for _ in a doesn't actually go through deref on a as we call IntoIterator::into_iter(a) instead of a.into_iter() in the desugaring, that is, https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a367b046176dcf7a3eb762da2ace045a doesn't compile.

@RalfJung

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

@Mark-Simulacrum ah, good point. That's great then!

The part about the lint still stands.

@Centril

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

for _ in a doesn't actually go through deref on a as we call IntoIterator::into_iter(a) instead of a.into_iter() in the desugaring, that is, https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a367b046176dcf7a3eb762da2ace045a doesn't compile.

(Relevant lowering code:

let iter = P(self.expr_ident(head_sp, iter, iter_pat_nid));
let ref_mut_iter = self.expr_mut_addr_of(head_sp, iter);
let next_path = &[sym::iter, sym::Iterator, sym::next];
let next_expr = P(self.expr_call_std_path(
head_sp,
next_path,
hir_vec![ref_mut_iter],
));
)

@cuviper

This comment has been minimized.

Copy link
Member

commented Jul 25, 2019

The clippy lint exists, although I don't think it was default-deny when we tried the crater run before.

https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_array

@bors

This comment was marked as resolved.

Copy link
Contributor

commented Jul 26, 2019

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

@LukasKalbertodt LukasKalbertodt force-pushed the LukasKalbertodt:array-value-iter branch from ac96d77 to cad2150 Jul 26, 2019

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Jul 26, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-07-26T13:10:07.6796398Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-26T13:10:07.7002660Z ##[command]git config gc.auto 0
2019-07-26T13:10:07.7082213Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-26T13:10:07.7130258Z ##[command]git config --get-all http.proxy
2019-07-26T13:10:07.7297228Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/62959/merge:refs/remotes/pull/62959/merge
---
2019-07-26T13:10:42.7364386Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-26T13:10:42.7364609Z 
2019-07-26T13:10:42.7365008Z   git checkout -b <new-branch-name>
2019-07-26T13:10:42.7365181Z 
2019-07-26T13:10:42.7365347Z HEAD is now at 90b1bbd77 Merge 6f72750669adc9b1021a0765589cebbd4e1ca712 into 1a563362865e6051d4c350544131228e8eff5138
2019-07-26T13:10:42.7531656Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-26T13:10:42.7535100Z ==============================================================================
2019-07-26T13:10:42.7535166Z Task         : Bash
2019-07-26T13:10:42.7535217Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-26T13:16:33.5836300Z    Compiling serde_json v1.0.40
2019-07-26T13:16:37.5713207Z    Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
2019-07-26T13:16:46.4366232Z     Finished release [optimized] target(s) in 1m 30s
2019-07-26T13:16:46.4444747Z tidy check
2019-07-26T13:16:46.6484834Z tidy error: /checkout/src/libcore/array.rs:151: TODO is deprecated; use FIXME
2019-07-26T13:16:48.2491644Z some tidy checks failed
2019-07-26T13:16:48.2492440Z 
2019-07-26T13:16:48.2492440Z 
2019-07-26T13:16:48.2496982Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor"
2019-07-26T13:16:48.2497444Z 
2019-07-26T13:16:48.2497475Z 
2019-07-26T13:16:48.2501093Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
2019-07-26T13:16:48.2502498Z Build completed unsuccessfully in 0:01:33
2019-07-26T13:16:48.2502498Z Build completed unsuccessfully in 0:01:33
2019-07-26T13:16:49.5641789Z ##[error]Bash exited with code '1'.
2019-07-26T13:16:49.5676291Z ##[section]Starting: Checkout
2019-07-26T13:16:49.5678055Z ==============================================================================
2019-07-26T13:16:49.5678107Z Task         : Get sources
2019-07-26T13:16:49.5678148Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

src/libcore/array.rs Outdated Show resolved Hide resolved
// the array is in an uninitialized state as all elements may be
// uninitialized (all bit patterns are valid). Compare the
// `MaybeUninit` docs for more information.
let mut new_data: [MaybeUninit<T>; N] = MaybeUninit::uninit().assume_init();

This comment has been minimized.

Copy link
@Centril

Centril Jul 26, 2019

Member

Use [MaybeUninit::UNINIT; N] and hoist let mut data out of the unsafe { block?

This comment has been minimized.

Copy link
@LukasKalbertodt

LukasKalbertodt Jul 26, 2019

Author Contributor
error[E0277]: the trait bound `T: marker::Copy` is not satisfied
   --> src/libcore/array.rs:330:49
    |
330 |         let mut new_data: [MaybeUninit<T>; N] = [MaybeUninit::UNINIT; N];
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `marker::Copy` is not implemented for `T`

But apart from that, I put the whole body in the unsafe block because all operations are closely linked basically. I'm a fan of sometimes using larger unsafe scopes to include the technically safe stuff which still has an effect on the unsafe stuff.

This comment has been minimized.

Copy link
@Centril

Centril Jul 26, 2019

Member

@LukasKalbertodt hmm; you probably need the feature gate in libcore/lib.rs then. (I see no test in the impl PR that actually mentions needing the gate... cc @davidtwco)

This comment has been minimized.

Copy link
@LukasKalbertodt

LukasKalbertodt Jul 27, 2019

Author Contributor

I'm afraid I don't understand. Are you talking about this feature? So you absolutely want to have it changed? If you don't have a strong opinion about this, I'd keep it as is.

This comment has been minimized.

Copy link
@Centril

Centril Jul 27, 2019

Member

Are you talking about this feature?

I am; See #62799 for an example of where it is used. To the change I noted above work you'll need #![cfg_attr(not(bootstrap), feature(const_in_array_repeat_expressions))] in libcore/lib.rs.

So you absolutely want to have it changed? If you don't have a strong opinion about this, I'd keep it as is.

I mean I don't insist on that it must happen now but the feature gate is intended to make this nicer among others and it avoids one unsafe { ... } entirely so we should use it if we can. This seems like as good a time as any.

This comment has been minimized.

Copy link
@Centril

Centril Jul 30, 2019

Member

add both versions (current and your suggestion) and select them via cfg, or

This option sounds best since it will guarantee that Mark will fix it once we cut a new release & update bootstrap. :)

This comment has been minimized.

Copy link
@scottmcm

scottmcm Jul 30, 2019

Member

Does this new iterator need to be available in bootstrap? Could the whole type just be cfg'd-out in bootstrap? (That also isolates it from any problems with const generics in the bootstrap compiler...)

This comment has been minimized.

Copy link
@Centril

Centril Jul 30, 2019

Member

If so I'd prefer putting the new stuff in its own module which is probably for the best anyways in terms of isolating the unsafe code and also for having better separation of concerns.

This comment has been minimized.

Copy link
@LukasKalbertodt

LukasKalbertodt Aug 3, 2019

Author Contributor

Locally (not pushed yet) I created a new module for the iterator stuff and guarded it with #[cfg(not(bootstrap))]. As this PR is still blocked by const generic bugs, it makes sense avoid waiting for the bootstrap compiler to update.

But regarding the original remark: [MaybeUninit::UNINIT; N] now leads to:

error: array lengths can't depend on generic parameters
   --> src/libcore/array/iter.rs:233:50
    |
233 |         let mut new_data = [MaybeUninit::UNINIT; {N}];
    |                                                  ^^^

Apparently this is a known limitation?

This comment has been minimized.

Copy link
@Centril

Centril Aug 3, 2019

Member

@LukasKalbertodt Interesting; This problem seems to arise due to the anonymous constant not having N in scope as the usual limitation wrt. not having scoped type variables.

I tried a work-around:

#![feature(const_generics)]

struct A<const N: usize>;

use core::mem::MaybeUninit;

impl<const N: usize> A<{N}> {
    fn foo() {
        let x: [MaybeUninit<u8>; N] = [MaybeUninit::UNINIT; _];
    }
}

but I forgot that _ is not a valid expression form (it should be!).

cc @varkor -- any ideas? if not we'll have to use the unsafe { ... } for now.

src/libcore/tests/array.rs Outdated Show resolved Hide resolved
src/libcore/tests/array.rs Show resolved Hide resolved
src/libcore/tests/array.rs Outdated Show resolved Hide resolved
@LukasKalbertodt

This comment has been minimized.

Copy link
Contributor Author

commented Jul 26, 2019

I tried adding UI tests, but now I noticed that after my rebase (and partial rewrite), the compiler crashes when I try to create the iterator. Test code:

#![feature(array_value_iter)]
use std::array::IntoIter;

fn main() {
    let arr = [1, 2, 3];
    let it = IntoIter::new(arr);
}

Compiling this with the stage 1 compiler results in this ICE:

thread 'rustc' panicked at 'assertion failed: !out_value.has_type_flags(TypeFlags::KEEP_IN_LOCAL_TCX)', src/librustc/infer/canonical/canonicalizer.rs:548:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call
             at /home/lukas/dev/rust/src/liballoc/boxed.rs:780
   7: rustc::util::common::panic_hook
             at src/librustc/util/common.rs:40
   8: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   9: std::panicking::begin_panic
             at /home/lukas/dev/rust/src/libstd/panicking.rs:411
  10: rustc::infer::canonical::canonicalizer::Canonicalizer::canonicalize
             at /home/lukas/dev/rust/<::std::macros::panic macros>:4
  11: rustc::infer::canonical::canonicalizer::<impl rustc::infer::InferCtxt>::canonicalize_response
             at /home/lukas/dev/rust/src/librustc/infer/canonical/canonicalizer.rs:93
  12: rustc::infer::canonical::query_response::<impl rustc::infer::InferCtxt>::make_query_response_ignoring_pending_obligations
             at /home/lukas/dev/rust/src/librustc/infer/canonical/query_response.rs:133
  13: rustc_typeck::check::method::probe::<impl rustc_typeck::check::FnCtxt>::probe_op::{{closure}}
             at src/librustc_typeck/check/method/probe.rs:305
  14: rustc::infer::InferCtxt::probe
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:844
  15: rustc_typeck::check::method::probe::<impl rustc_typeck::check::FnCtxt>::probe_op
             at src/librustc_typeck/check/method/probe.rs:288
  16: rustc_typeck::check::method::probe::<impl rustc_typeck::check::FnCtxt>::probe_for_name
             at src/librustc_typeck/check/method/probe.rs:251
  17: rustc_typeck::check::method::<impl rustc_typeck::check::FnCtxt>::resolve_ufcs
             at src/librustc_typeck/check/method/mod.rs:433
  18: rustc_typeck::check::FnCtxt::resolve_ty_and_res_ufcs
             at src/librustc_typeck/check/mod.rs:3468
  19: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_path
             at src/librustc_typeck/check/expr.rs:448
  20: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
             at src/librustc_typeck/check/expr.rs:219
  21: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
             at src/librustc_typeck/check/expr.rs:157
  22: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
             at src/librustc_typeck/check/expr.rs:118
  23: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr
             at src/librustc_typeck/check/expr.rs:122
  24: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
             at src/librustc_typeck/check/callee.rs:44
  25: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
             at src/librustc_typeck/check/expr.rs:257
  26: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
             at src/librustc_typeck/check/expr.rs:157
  27: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
             at src/librustc_typeck/check/expr.rs:118
  28: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_hint
             at src/librustc_typeck/check/expr.rs:110
  29: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_coercable_to_type
             at src/librustc_typeck/check/expr.rs:100
  30: rustc_typeck::check::FnCtxt::check_decl_initializer
             at src/librustc_typeck/check/mod.rs:3520
  31: rustc_typeck::check::FnCtxt::check_decl_local
             at src/librustc_typeck/check/mod.rs:3529
  32: rustc_typeck::check::FnCtxt::check_stmt
             at src/librustc_typeck/check/mod.rs:3564
  33: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
             at src/librustc_typeck/check/mod.rs:3640
  34: rustc_typeck::check::FnCtxt::with_breakable_ctxt
             at src/librustc_typeck/check/mod.rs:4412
  35: rustc_typeck::check::FnCtxt::check_block_with_expected
             at src/librustc_typeck/check/mod.rs:3638
  36: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
             at src/librustc_typeck/check/expr.rs:254
  37: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
             at src/librustc_typeck/check/expr.rs:157
  38: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
             at src/librustc_typeck/check/expr.rs:118
  39: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_hint
             at src/librustc_typeck/check/expr.rs:110
  40: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
             at src/librustc_typeck/check/expr.rs:644
  41: rustc_typeck::check::check_fn
             at src/librustc_typeck/check/mod.rs:1122
  42: rustc_typeck::check::typeck_tables_of::{{closure}}
             at src/librustc_typeck/check/mod.rs:855
  43: rustc_typeck::check::InheritedBuilder::enter::{{closure}}
             at src/librustc_typeck/check/mod.rs:619
  44: rustc::infer::InferCtxtBuilder::enter::{{closure}}
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:522
  45: rustc::ty::context::GlobalCtxt::enter_local::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1643
  46: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1866
  47: rustc::ty::context::tls::set_tlv
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1799
  48: rustc::ty::context::tls::enter_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1865
  49: rustc::ty::context::GlobalCtxt::enter_local::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1642
  50: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1972
  51: rustc::ty::context::tls::with_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1955
  52: rustc::ty::context::tls::with_context_opt
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1944
  53: rustc::ty::context::tls::with_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1955
  54: rustc::ty::context::tls::with_related_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1968
  55: rustc::ty::context::GlobalCtxt::enter_local
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1634
  56: rustc::infer::InferCtxtBuilder::enter
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:521
  57: rustc_typeck::check::InheritedBuilder::enter
             at src/librustc_typeck/check/mod.rs:619
  58: rustc_typeck::check::typeck_tables_of
             at src/librustc_typeck/check/mod.rs:834
  59: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:997
  60: rustc::ty::query::__query_compute::typeck_tables_of
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:948
  61: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:989
  62: rustc::dep_graph::graph::DepGraph::with_task_impl
             at /home/lukas/dev/rust/src/librustc/dep_graph/graph.rs:334
  63: rustc::dep_graph::graph::DepGraph::with_task
             at /home/lukas/dev/rust/src/librustc/dep_graph/graph.rs:202
  64: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:556
  65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:275
  66: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1866
  67: rustc::ty::context::tls::set_tlv
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1799
  68: rustc::ty::context::tls::enter_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1865
  69: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:274
  70: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1972
  71: rustc::ty::context::tls::with_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1955
  72: rustc::ty::context::tls::with_context_opt
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1944
  73: rustc::ty::context::tls::with_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1955
  74: rustc::ty::context::tls::with_related_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1968
  75: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:263
  76: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:548
  77: rustc::ty::query::plumbing::with_diagnostics
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:209
  78: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:547
  79: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:376
  80: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:610
  81: rustc::ty::query::TyCtxtEnsure::typeck_tables_of
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:1025
  82: rustc_typeck::check::typeck_item_bodies::{{closure}}
             at src/librustc_typeck/check/mod.rs:713
  83: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/mod.rs:2775
  84: core::iter::traits::iterator::Iterator::for_each::{{closure}}
             at /home/lukas/dev/rust/src/libcore/iter/traits/iterator.rs:602
  85: <core::slice::Iter<T> as core::iter::traits::iterator::Iterator>::fold
             at /home/lukas/dev/rust/src/libcore/slice/mod.rs:3187
  86: core::iter::traits::iterator::Iterator::for_each
             at /home/lukas/dev/rust/src/libcore/iter/traits/iterator.rs:602
  87: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
             at /home/lukas/dev/rust/src/librustc/ty/mod.rs:2774
  88: rustc_typeck::check::typeck_item_bodies
             at src/librustc_typeck/check/mod.rs:712
  89: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_item_bodies>::compute::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:997
  90: rustc::ty::query::__query_compute::typeck_item_bodies
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:948
  91: rustc::dep_graph::graph::DepGraph::with_task_impl
             at /home/lukas/dev/rust/src/librustc/dep_graph/graph.rs:334
  92: rustc::dep_graph::graph::DepGraph::with_task
             at /home/lukas/dev/rust/src/librustc/dep_graph/graph.rs:202
  93: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:556
  94: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:275
  95: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1866
  96: rustc::ty::context::tls::set_tlv
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1799
  97: rustc::ty::context::tls::enter_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1865
  98: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:274
  99: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1972
  100: rustc::ty::context::tls::with_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1955
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [typeck_tables_of] processing `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.38.0-dev running on x86_64-unknown-linux-gnu

Can anyone point me to a place where I can investigate this? Or is this an expected const generics bug? Any workaround? Any other information?

@Centril

This comment has been minimized.

Copy link
Member

commented Jul 26, 2019

Or is this an expected const generics bug?

cc @varkor

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jul 26, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-07-26T18:08:18.6585078Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-26T18:08:18.6757992Z ##[command]git config gc.auto 0
2019-07-26T18:08:18.6829846Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-26T18:08:18.6874892Z ##[command]git config --get-all http.proxy
2019-07-26T18:08:18.7001839Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/62959/merge:refs/remotes/pull/62959/merge
---
2019-07-26T18:08:54.3397534Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-26T18:08:54.3397689Z 
2019-07-26T18:08:54.3397970Z   git checkout -b <new-branch-name>
2019-07-26T18:08:54.3398090Z 
2019-07-26T18:08:54.3398229Z HEAD is now at e8e80bfc0 Merge 3b53b9e4208cfc53a98e95f211706eacf38841f3 into 1a563362865e6051d4c350544131228e8eff5138
2019-07-26T18:08:54.3533038Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-26T18:08:54.3536264Z ==============================================================================
2019-07-26T18:08:54.3536311Z Task         : Bash
2019-07-26T18:08:54.3536348Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-26T19:04:53.4731620Z .................................................................................................... 200/5862
2019-07-26T19:04:57.5071167Z .................................................................................................... 300/5862
2019-07-26T19:05:01.0354871Z .................................................................................................... 400/5862
2019-07-26T19:05:04.7658207Z .................................................................................................... 500/5862
2019-07-26T19:05:08.3985444Z ........................................................................i........................... 600/5862
2019-07-26T19:05:16.8542104Z .................................................................................................... 800/5862
2019-07-26T19:05:22.2068934Z .................................................................................................... 900/5862
2019-07-26T19:05:26.9920257Z .................................................................................................... 1000/5862
2019-07-26T19:05:26.9920257Z .................................................................................................... 1000/5862
2019-07-26T19:05:32.1978643Z i...........i....................................................................................... 1100/5862
2019-07-26T19:05:35.9131457Z ..............................iiiii................................................................. 1200/5862
2019-07-26T19:05:41.6635551Z .................................................................................................... 1400/5862
2019-07-26T19:05:44.1972292Z .................................................................................................... 1500/5862
2019-07-26T19:05:48.1698859Z .................................................................................................... 1600/5862
2019-07-26T19:05:50.2991874Z .................................................................................................... 1700/5862
2019-07-26T19:05:50.2991874Z .................................................................................................... 1700/5862
2019-07-26T19:05:53.5587934Z ......................................................................i............................. 1800/5862
2019-07-26T19:06:01.5529544Z .................................................................................................... 2000/5862
2019-07-26T19:06:05.6481040Z .................................................................................................... 2100/5862
2019-07-26T19:06:09.1463450Z .................................................................................................... 2200/5862
2019-07-26T19:06:09.1463450Z .................................................................................................... 2200/5862
2019-07-26T19:06:12.7415388Z ......................................................i............................................. 2300/5862
2019-07-26T19:06:22.2335358Z .................................................................................................... 2500/5862
2019-07-26T19:06:26.2384298Z .................................................................................................... 2600/5862
2019-07-26T19:06:31.1989664Z .................................................................................................... 2700/5862
2019-07-26T19:06:34.8430827Z .................................................................................................... 2800/5862
2019-07-26T19:06:34.8430827Z .................................................................................................... 2800/5862
2019-07-26T19:06:39.0122646Z .................................................................................................... 2900/5862
2019-07-26T19:06:44.0959965Z .................................................................................................... 3000/5862
2019-07-26T19:06:48.3507829Z .................................................................................................... 3100/5862
2019-07-26T19:06:53.5240334Z .................................................................................................... 3200/5862
2019-07-26T19:06:56.8555749Z .................................................................................................... 3300/5862
2019-07-26T19:07:00.5256295Z .................................................................................................... 3400/5862
2019-07-26T19:07:05.5719387Z .................................................................................................... 3500/5862
2019-07-26T19:07:09.1729508Z ......................i............................................................................. 3600/5862
2019-07-26T19:07:13.1928901Z .................................................................................................ii. 3700/5862
2019-07-26T19:07:16.7658582Z ..i..ii............................................................................................. 3800/5862
2019-07-26T19:07:25.1217289Z .................................................................................................... 4000/5862
2019-07-26T19:07:25.1217289Z .................................................................................................... 4000/5862
2019-07-26T19:07:28.9390375Z ................ii.................................................................................. 4100/5862
2019-07-26T19:07:30.9566365Z .....................................i.............................................................. 4200/5862
2019-07-26T19:07:33.0177021Z .................................................................................................... 4300/5862
2019-07-26T19:07:35.2319262Z ......i............................................................................................. 4400/5862
2019-07-26T19:07:55.8121470Z .................................................................................................... 4600/5862
2019-07-26T19:07:59.4069572Z .................................................................................................... 4700/5862
2019-07-26T19:08:03.0479571Z .................................................................................................... 4800/5862
2019-07-26T19:08:07.6406035Z .................................................................................................... 4900/5862
---
2019-07-26T19:08:39.2962518Z .................................................................................................... 5500/5862
2019-07-26T19:08:43.4612430Z .................................................................................................... 5600/5862
2019-07-26T19:08:46.3799350Z .................................................................................................... 5700/5862
2019-07-26T19:08:49.2826366Z .................................................................................................... 5800/5862
2019-07-26T19:08:51.3539842Z ..i...........................................................
2019-07-26T19:08:51.3541582Z 
2019-07-26T19:08:51.3612435Z  finished in 253.108
2019-07-26T19:08:51.3798501Z Check compiletest suite=run-pass mode=run-pass (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-07-26T19:08:51.5889620Z 
2019-07-26T19:08:51.5889620Z 
2019-07-26T19:08:51.5891298Z running 2907 tests
2019-07-26T19:09:06.3391364Z .................................................................................................... 100/2907
2019-07-26T19:09:21.0322346Z ..............................................................................i..................... 200/2907
2019-07-26T19:09:44.3214547Z ........................................................................F........................... 400/2907
2019-07-26T19:09:56.1324117Z .................................................................................................... 500/2907
2019-07-26T19:10:09.9094323Z .................................................................................................... 600/2907
2019-07-26T19:10:30.2210470Z .................................................................................................... 700/2907
2019-07-26T19:10:30.2210470Z .................................................................................................... 700/2907
2019-07-26T19:10:43.6998221Z .................................................................................................... 800/2907
2019-07-26T19:10:54.7551759Z .................................................................................................... 900/2907
2019-07-26T19:11:12.9994514Z .................................................................................................... 1000/2907
2019-07-26T19:11:27.5808113Z .................................................................................................... 1100/2907
2019-07-26T19:11:38.3509876Z .................................................................................................... 1200/2907
2019-07-26T19:11:50.3026333Z .................................................................................................... 1300/2907
2019-07-26T19:12:06.0327693Z .........ii......................................................................................... 1400/2907
2019-07-26T19:12:18.0083041Z .................................................................................................... 1500/2907
2019-07-26T19:12:30.2162031Z .............................................................i.......i.............................. 1600/2907
2019-07-26T19:13:01.5080151Z .................................................................................................... 1800/2907
2019-07-26T19:13:01.5080151Z .................................................................................................... 1800/2907
2019-07-26T19:13:15.6372963Z .............................................................................................i...... 1900/2907
2019-07-26T19:13:42.3459341Z .................................................................i.................................. 2000/2907
2019-07-26T19:14:23.4460711Z .................................................................................................... 2200/2907
2019-07-26T19:14:36.9924314Z .................................................................................................... 2300/2907
2019-07-26T19:14:36.9924314Z .................................................................................................... 2300/2907
2019-07-26T19:14:55.6646548Z ii.................................................................................................. 2400/2907
2019-07-26T19:15:48.2140884Z .................................................................................................... 2600/2907
2019-07-26T19:16:01.3255572Z .................................................................................................... 2700/2907
2019-07-26T19:16:12.4730304Z .................................................................................................... 2800/2907
2019-07-26T19:16:28.2365788Z .................................................................................................... 2900/2907
2019-07-26T19:16:28.2365788Z .................................................................................................... 2900/2907
2019-07-26T19:16:29.8698106Z .......
2019-07-26T19:16:29.8698225Z failures:
2019-07-26T19:16:29.8698302Z 
2019-07-26T19:16:29.8699605Z ---- [run-pass] run-pass/chalkify/builtin-copy-clone.rs stdout ----
2019-07-26T19:16:29.8700095Z 
2019-07-26T19:16:29.8704131Z error: test compilation failed although it shouldn't!
2019-07-26T19:16:29.8704196Z status: exit code: 101
2019-07-26T19:16:29.8704984Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/chalkify/builtin-copy-clone.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/run-pass/chalkify/builtin-copy-clone/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "chalk" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/chalkify/builtin-copy-clone/auxiliary"
2019-07-26T19:16:29.8705338Z ------------------------------------------
2019-07-26T19:16:29.8705395Z 
2019-07-26T19:16:29.8705615Z ------------------------------------------
2019-07-26T19:16:29.8705674Z stderr:
2019-07-26T19:16:29.8705674Z stderr:
2019-07-26T19:16:29.8705906Z ------------------------------------------
2019-07-26T19:16:29.8705979Z error: internal compiler error: src/librustc/ty/relate.rs:581: var types encountered in super_relate_consts: Const { ty: std::array::IntoIter<T, N>, val: Infer(Var(_#0c)) } Const { ty: std::array::IntoIter<T, N>, val: Infer(Var(_#0c)) }
2019-07-26T19:16:29.8706026Z 
2019-07-26T19:16:29.8706301Z thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:646:9
2019-07-26T19:16:29.8706739Z error: aborting due to previous error
2019-07-26T19:16:29.8706778Z 
2019-07-26T19:16:29.8706818Z 
2019-07-26T19:16:29.8706818Z 
2019-07-26T19:16:29.8706862Z note: the compiler unexpectedly panicked. this is a bug.
2019-07-26T19:16:29.8706889Z 
2019-07-26T19:16:29.8707684Z note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports
2019-07-26T19:16:29.8707740Z 
2019-07-26T19:16:29.8707978Z note: rustc 1.38.0-dev running on x86_64-unknown-linux-gnu
2019-07-26T19:16:29.8708008Z 
2019-07-26T19:16:29.8708286Z note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -Z chalk -C prefer-dynamic -C rpath -C debuginfo=0
2019-07-26T19:16:29.8708344Z 
2019-07-26T19:16:29.8708537Z ------------------------------------------
2019-07-26T19:16:29.8708582Z 
2019-07-26T19:16:29.8708605Z 
---
2019-07-26T19:16:29.8709629Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:535:22
2019-07-26T19:16:29.8709700Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-07-26T19:16:29.8709730Z 
2019-07-26T19:16:29.8709762Z 
2019-07-26T19:16:29.8711326Z 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/run-pass" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--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 -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -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"
2019-07-26T19:16:29.8714387Z 
2019-07-26T19:16:29.8714419Z 
2019-07-26T19:16:29.8714525Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-07-26T19:16:29.8714592Z Build completed unsuccessfully in 1:01:15
2019-07-26T19:16:29.8714592Z Build completed unsuccessfully in 1:01:15
2019-07-26T19:16:30.4782133Z ##[error]Bash exited with code '1'.
2019-07-26T19:16:30.4820678Z ##[section]Starting: Checkout
2019-07-26T19:16:30.4822257Z ==============================================================================
2019-07-26T19:16:30.4822306Z Task         : Get sources
2019-07-26T19:16:30.4832522Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

src/libcore/array.rs Outdated Show resolved Hide resolved
@LukasKalbertodt

This comment has been minimized.

Copy link
Contributor Author

commented Jul 26, 2019

Regarding the CI failure: the ICE looks a bit like this bug, but I have no idea what run-pass/chalkify/builtin-copy-clone.rs has to do with IntoIter. The ICE mentions std::array::IntoIter but the test does not mention that type at all. So it would be great if someone could help me out here, too.

@jonas-schievink

This comment has been minimized.

Copy link
Member

commented Jul 26, 2019

Does the test still fail if you comment out this line?

test_copy_clone([1; 56]);

It's possible that even the mention of an array type causes the compiler to look at the impls on arrays, and thus at the IntoIter return type. And perhaps chalk is very unhappy about const generics in general, so it fails only this test?

@LukasKalbertodt

This comment has been minimized.

Copy link
Contributor Author

commented Jul 26, 2019

@jonas-schievink Nope, that's not it (also note that there is no IntoIterator impl right now, so your theory wouldn't quite make sense right now). But I reduced the problem. Minimal example:

fn foo<T: Clone>(arg: T) {}
fn bar<T: Clone>(arg: T) {
    foo(arg);
}

Compiling this without chalk is fine. With -Zchalk, it produces this ICE:

error: internal compiler error: src/librustc/ty/relate.rs:581: var types encountered in super_relate_consts: Const { ty: std::array::IntoIter<T, N>, val: Infer(Var(_#0c)) } Const { ty: std::array::IntoIter<T, N>, val: Infer(Var(_#0c)) }

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:646:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call
             at /home/lukas/dev/rust/src/liballoc/boxed.rs:780
   7: rustc::util::common::panic_hook
             at src/librustc/util/common.rs:40
   8: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   9: std::panicking::begin_panic
             at /home/lukas/dev/rust/src/libstd/panicking.rs:411
  10: rustc_errors::Handler::bug
             at src/librustc_errors/lib.rs:646
  11: rustc::util::bug::opt_span_bug_fmt::{{closure}}
             at src/librustc/util/bug.rs:36
  12: rustc::ty::context::tls::with_opt::{{closure}}
             at src/librustc/ty/context.rs:1994
  13: rustc::ty::context::tls::with_context_opt
             at src/librustc/ty/context.rs:1944
  14: rustc::ty::context::tls::with_opt
             at src/librustc/ty/context.rs:1994
  15: rustc::util::bug::opt_span_bug_fmt
             at src/librustc/util/bug.rs:32
  16: rustc::util::bug::bug_fmt
             at src/librustc/util/bug.rs:12
  17: rustc::ty::relate::super_relate_consts
             at /home/lukas/dev/rust/src/librustc/macros.rs:44
  18: <rustc::infer::nll_relate::TypeGeneralizer<D> as rustc::ty::relate::TypeRelation>::consts
             at /home/lukas/dev/rust/src/librustc/infer/nll_relate/mod.rs:996
  19: <&rustc::ty::sty::Const as rustc::ty::relate::Relate>::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:692
  20: rustc::ty::relate::TypeRelation::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:43
  21: <rustc::ty::subst::Kind as rustc::ty::relate::Relate>::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:744
  22: rustc::ty::relate::TypeRelation::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:43
  23: <rustc::infer::nll_relate::TypeGeneralizer<D> as rustc::ty::relate::TypeRelation>::relate_with_variance
             at /home/lukas/dev/rust/src/librustc/infer/nll_relate/mod.rs:861
  24: rustc::ty::relate::relate_substs::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:141
  25: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
             at /home/lukas/dev/rust/src/libcore/ops/function.rs:283
  26: core::option::Option<T>::map
             at /home/lukas/dev/rust/src/libcore/option.rs:447
  27: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::next
             at /home/lukas/dev/rust/src/libcore/iter/adapters/mod.rs:570
  28: <<core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter::Adapter<Iter,E> as core::iter::traits::iterator::Iterator>::next
             at /home/lukas/dev/rust/src/libcore/result.rs:1323
  29: <&mut I as core::iter::traits::iterator::Iterator>::next
             at /home/lukas/dev/rust/src/libcore/iter/traits/iterator.rs:2706
  30: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.10/lib.rs:1357
  31: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.10/lib.rs:1342
  32: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter
             at /home/lukas/dev/rust/src/libcore/result.rs:1340
  33: core::iter::traits::iterator::Iterator::collect
             at /home/lukas/dev/rust/src/libcore/iter/traits/iterator.rs:1464
  34: <core::result::Result<T,E> as rustc::ty::context::InternIteratorElement<T,R>>::intern_with
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:2886
  35: <I as rustc::ty::context::InternAs<[T],R>>::intern_with
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:2858
  36: rustc::ty::context::TyCtxt::mk_substs
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:2717
  37: rustc::ty::relate::relate_substs
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:144
  38: rustc::ty::relate::TypeRelation::relate_item_substs
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:61
  39: rustc::ty::relate::super_relate_tys
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:392
  40: <rustc::infer::nll_relate::TypeGeneralizer<D> as rustc::ty::relate::TypeRelation>::tys
             at /home/lukas/dev/rust/src/librustc/infer/nll_relate/mod.rs:945
  41: <&rustc::ty::TyS as rustc::ty::relate::Relate>::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:336
  42: rustc::ty::relate::TypeRelation::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:43
  43: rustc::infer::nll_relate::TypeRelating<D>::generalize_value
             at /home/lukas/dev/rust/src/librustc/infer/nll_relate/mod.rs:395
  44: rustc::infer::nll_relate::TypeRelating<D>::relate_ty_var
             at /home/lukas/dev/rust/src/librustc/infer/nll_relate/mod.rs:348
  45: <rustc::infer::nll_relate::TypeRelating<D> as rustc::ty::relate::TypeRelation>::tys
             at /home/lukas/dev/rust/src/librustc/infer/nll_relate/mod.rs:558
  46: <&rustc::ty::TyS as rustc::ty::relate::Relate>::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:336
  47: rustc::ty::relate::TypeRelation::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:43
  48: <rustc::ty::subst::Kind as rustc::ty::relate::Relate>::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:741
  49: rustc::ty::relate::TypeRelation::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:43
  50: <rustc::infer::nll_relate::TypeRelating<D> as rustc::ty::relate::TypeRelation>::relate_with_variance
             at /home/lukas/dev/rust/src/librustc/infer/nll_relate/mod.rs:532
  51: rustc::ty::relate::relate_substs::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:141
  52: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
             at /home/lukas/dev/rust/src/libcore/ops/function.rs:283
  53: core::option::Option<T>::map
             at /home/lukas/dev/rust/src/libcore/option.rs:447
  54: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::next
             at /home/lukas/dev/rust/src/libcore/iter/adapters/mod.rs:570
  55: <<core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter::Adapter<Iter,E> as core::iter::traits::iterator::Iterator>::next
             at /home/lukas/dev/rust/src/libcore/result.rs:1323
  56: <&mut I as core::iter::traits::iterator::Iterator>::next
             at /home/lukas/dev/rust/src/libcore/iter/traits/iterator.rs:2706
  57: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.10/lib.rs:1357
  58: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-0.6.10/lib.rs:1342
  59: <core::result::Result<V,E> as core::iter::traits::collect::FromIterator<core::result::Result<A,E>>>::from_iter
             at /home/lukas/dev/rust/src/libcore/result.rs:1340
  60: core::iter::traits::iterator::Iterator::collect
             at /home/lukas/dev/rust/src/libcore/iter/traits/iterator.rs:1464
  61: <core::result::Result<T,E> as rustc::ty::context::InternIteratorElement<T,R>>::intern_with
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:2886
  62: <I as rustc::ty::context::InternAs<[T],R>>::intern_with
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:2858
  63: rustc::ty::context::TyCtxt::mk_substs
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:2717
  64: rustc::ty::relate::relate_substs
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:144
  65: <rustc::ty::sty::TraitRef as rustc::ty::relate::Relate>::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:286
  66: rustc::ty::relate::TypeRelation::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:43
  67: <rustc::ty::TraitPredicate as rustc::ty::relate::Relate>::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:766
  68: rustc::ty::relate::TypeRelation::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:43
  69: <rustc::traits::WhereClause as rustc::ty::relate::Relate>::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:793
  70: rustc::ty::relate::TypeRelation::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:43
  71: <rustc::traits::DomainGoal as rustc::ty::relate::Relate>::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:857
  72: rustc::ty::relate::TypeRelation::relate
             at /home/lukas/dev/rust/src/librustc/ty/relate.rs:43
  73: rustc_traits::chalk_context::unify::unify
             at src/librustc_traits/chalk_context/unify.rs:31
  74: rustc_traits::chalk_context::resolvent_ops::<impl chalk_engine::context::ResolventOps<rustc_traits::chalk_context::ChalkArenas,rustc_traits::chalk_context::ChalkArenas> for rustc_traits::chalk_context::ChalkInferenceContext>::resolvent_clause::{{closure}}
             at src/librustc_traits/chalk_context/resolvent_ops.rs:56
  75: rustc::infer::InferCtxt::probe
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:844
  76: rustc_traits::chalk_context::resolvent_ops::<impl chalk_engine::context::ResolventOps<rustc_traits::chalk_context::ChalkArenas,rustc_traits::chalk_context::ChalkArenas> for rustc_traits::chalk_context::ChalkInferenceContext>::resolvent_clause
             at src/librustc_traits/chalk_context/resolvent_ops.rs:42
  77: chalk_engine::logic::<impl chalk_engine::forest::Forest<C,CO>>::push_initial_strands_instantiated
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/logic.rs:773
  78: <chalk_engine::logic::<impl chalk_engine::forest::Forest<C,CO>>::push_initial_strands::PushInitialStrandsInstantiated<C,CO> as chalk_engine::context::WithInstantiatedUCanonicalGoal<C>>::with
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/logic.rs:753
  79: <rustc_traits::chalk_context::ChalkContext as chalk_engine::context::ContextOps<rustc_traits::chalk_context::ChalkArenas>>::instantiate_ucanonical_goal::{{closure}}
             at src/librustc_traits/chalk_context/mod.rs:224
  80: rustc::infer::InferCtxtBuilder::enter_with_canonical::{{closure}}
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:511
  81: rustc::infer::InferCtxtBuilder::enter::{{closure}}
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:522
  82: rustc::ty::context::GlobalCtxt::enter_local::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1643
  83: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1866
  84: rustc::ty::context::tls::set_tlv
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1799
  85: rustc::ty::context::tls::enter_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1865
  86: rustc::ty::context::GlobalCtxt::enter_local::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1642
  87: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1972
  88: rustc::ty::context::tls::with_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1955
  89: rustc::ty::context::tls::with_context_opt
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1944
  90: rustc::ty::context::tls::with_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1955
  91: rustc::ty::context::tls::with_related_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1968
  92: rustc::ty::context::GlobalCtxt::enter_local
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1634
  93: rustc::infer::InferCtxtBuilder::enter
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:521
  94: rustc::infer::InferCtxtBuilder::enter_with_canonical
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:508
  95: <rustc_traits::chalk_context::ChalkContext as chalk_engine::context::ContextOps<rustc_traits::chalk_context::ChalkArenas>>::instantiate_ucanonical_goal
             at src/librustc_traits/chalk_context/mod.rs:220
  96: chalk_engine::logic::<impl chalk_engine::forest::Forest<C,CO>>::push_initial_strands
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/logic.rs:731
  97: chalk_engine::logic::<impl chalk_engine::forest::Forest<C,CO>>::get_or_create_table_for_ucanonical_goal
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/logic.rs:713
  98: chalk_engine::logic::<impl chalk_engine::forest::Forest<C,CO>>::get_or_create_table_for_subgoal
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/logic.rs:683
  99: chalk_engine::logic::<impl chalk_engine::forest::Forest<C,CO>>::pursue_strand
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/logic.rs:497
  100: <chalk_engine::logic::PursueStrand<C,CO> as chalk_engine::logic::WithInstantiatedStrand<C,CO>>::with
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-engine-0.9.0/src/logic.rs:1327
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [evaluate_goal] evaluating trait selection obligation `^1_0: std::clone::Clone`
#1 [typeck_tables_of] processing `bar`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack

@scottmcm scottmcm removed the relnotes label Jul 27, 2019

@scottmcm

This comment has been minimized.

Copy link
Member

commented Jul 27, 2019

(Removed relnotes now that this is just the unstable library addition, not the impl.)

src/libcore/array.rs Outdated Show resolved Hide resolved
@varkor

This comment has been minimized.

Copy link
Member

commented Jul 28, 2019

Can anyone point me to a place where I can investigate this? Or is this an expected const generics bug? Any workaround? Any other information?

This isn't a const generics bug I've seen before, but that doesn't mean it's not one. If you could produce a minimal test case, that would be really helpful.

@bors

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2019

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

LukasKalbertodt added some commits Jul 24, 2019

Add `array::IntoIter` as a consuming/by-value array iterator
The iterator is implemented using const generics. It implements the
traits `Iterator`, `DoubleEndedIterator`, `ExactSizeIterator`,
`FusedIterator` and `TrustedLen`. It also contains a public method
`new` to create it from an array.

`IntoIterator` was not implemented for arrays yet, as there are still
some open questions regarding backwards compatibility. This commit
only adds the iterator impl and does not yet offer a convenient way
to obtain that iterator.
Add unit tests for `array::IntoIter`
Many tests are based on tests by Josh Stone <cuviper@gmail.com>

@LukasKalbertodt LukasKalbertodt force-pushed the LukasKalbertodt:array-value-iter branch from 3b53b9e to 706d396 Jul 29, 2019

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Jul 29, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-07-29T12:33:51.8281952Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-29T12:33:51.8451341Z ##[command]git config gc.auto 0
2019-07-29T12:33:51.8523906Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-29T12:33:51.8568278Z ##[command]git config --get-all http.proxy
2019-07-29T12:33:51.8702758Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/62959/merge:refs/remotes/pull/62959/merge
---
2019-07-29T12:34:25.2350067Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-29T12:34:25.2351553Z 
2019-07-29T12:34:25.2352305Z   git checkout -b <new-branch-name>
2019-07-29T12:34:25.2352688Z 
2019-07-29T12:34:25.2353101Z HEAD is now at 5ddf20b22 Merge 706d396b3d8d050cc59dbbd380d4abcd835b71a2 into 8b94e9e9188b65df38a5f1ae723617dc2dfb3155
2019-07-29T12:34:25.2474888Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-29T12:34:25.2477683Z ==============================================================================
2019-07-29T12:34:25.2477741Z Task         : Bash
2019-07-29T12:34:25.2477776Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-29T13:33:40.0303747Z .................................................................................................... 1400/8804
2019-07-29T13:33:45.8098768Z .................................................................................................... 1500/8804
2019-07-29T13:33:58.1357821Z ................................................................i...............i................... 1600/8804
2019-07-29T13:34:05.6766587Z .................................................................................................... 1700/8804
2019-07-29T13:34:20.2092729Z ..................................................iiiii............................................. 1800/8804
2019-07-29T13:34:31.1742634Z .................................................................................................... 2000/8804
2019-07-29T13:34:33.6921274Z .................................................................................................... 2100/8804
2019-07-29T13:34:37.4518196Z .................................................................................................... 2200/8804
2019-07-29T13:34:44.1015076Z .................................................................................................... 2300/8804
---
2019-07-29T13:38:26.5344611Z .................................................................................................... 5200/8804
2019-07-29T13:38:37.2269755Z .................................................................................................... 5300/8804
2019-07-29T13:38:44.8752277Z ..i................................................................................................. 5400/8804
2019-07-29T13:38:49.9167837Z .................................................................................................... 5500/8804
2019-07-29T13:39:01.5632383Z ................................................................................................ii.. 5600/8804
2019-07-29T13:39:16.2258327Z .i..ii...........i.................................................................................. 5700/8804
2019-07-29T13:39:30.4504004Z .................................................................................................... 5900/8804
2019-07-29T13:39:35.4279663Z ................................................................................................i..i 6000/8804
2019-07-29T13:39:50.1437787Z i................................................................................................... 6100/8804
2019-07-29T13:40:05.4605681Z .................................................................................................... 6200/8804
---
2019-07-29T13:43:52.2934387Z failures:
2019-07-29T13:43:52.2962097Z 
2019-07-29T13:43:52.2962550Z ---- [ui] ui/chalkify/builtin-copy-clone.rs stdout ----
2019-07-29T13:43:52.2962584Z 
2019-07-29T13:43:52.2962996Z error: test compilation failed although it shouldn't!
2019-07-29T13:43:52.2963056Z status: exit code: 101
2019-07-29T13:43:52.2964154Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/chalkify/builtin-copy-clone.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/chalkify/builtin-copy-clone/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "chalk" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/chalkify/builtin-copy-clone/auxiliary" "-A" "unused"
2019-07-29T13:43:52.2964736Z ------------------------------------------
2019-07-29T13:43:52.2964794Z 
2019-07-29T13:43:52.2965014Z ------------------------------------------
2019-07-29T13:43:52.2965064Z stderr:
2019-07-29T13:43:52.2965064Z stderr:
2019-07-29T13:43:52.2965290Z ------------------------------------------
2019-07-29T13:43:52.2965385Z error: internal compiler error: src/librustc/ty/relate.rs:581: var types encountered in super_relate_consts: Const { ty: std::array::IntoIter<T, N>, val: Infer(Var(_#0c)) } Const { ty: std::array::IntoIter<T, N>, val: Infer(Var(_#0c)) }
2019-07-29T13:43:52.2965441Z 
2019-07-29T13:43:52.2965715Z thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:644:9
2019-07-29T13:43:52.2965825Z error: aborting due to previous error
2019-07-29T13:43:52.2965856Z 
2019-07-29T13:43:52.2965901Z 
2019-07-29T13:43:52.2965901Z 
2019-07-29T13:43:52.2965948Z note: the compiler unexpectedly panicked. this is a bug.
2019-07-29T13:43:52.2965980Z 
2019-07-29T13:43:52.2966420Z note: we would appreciate a bug report: ***/blob/master/CONTRIBUTING.md#bug-reports
2019-07-29T13:43:52.2966459Z 
2019-07-29T13:43:52.2966703Z note: rustc 1.38.0-dev running on x86_64-unknown-linux-gnu
2019-07-29T13:43:52.2966737Z 
2019-07-29T13:43:52.2967058Z note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -Z chalk -C prefer-dynamic -C rpath -C debuginfo=0
2019-07-29T13:43:52.2967125Z 
2019-07-29T13:43:52.2967479Z ------------------------------------------
2019-07-29T13:43:52.2967513Z 
2019-07-29T13:43:52.2967553Z 
---
2019-07-29T13:43:52.2999298Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:533:22
2019-07-29T13:43:52.2999395Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-07-29T13:43:52.3022058Z 
2019-07-29T13:43:52.3022135Z 
2019-07-29T13:43:52.3027464Z 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 -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -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"
2019-07-29T13:43:52.3027835Z 
2019-07-29T13:43:52.3027863Z 
2019-07-29T13:43:52.3027956Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-07-29T13:43:52.3028003Z Build completed unsuccessfully in 1:02:53
2019-07-29T13:43:52.3028003Z Build completed unsuccessfully in 1:02:53
2019-07-29T13:43:53.0901202Z ##[error]Bash exited with code '1'.
2019-07-29T13:43:53.0954109Z ##[section]Starting: Checkout
2019-07-29T13:43:53.0956779Z ==============================================================================
2019-07-29T13:43:53.0956836Z Task         : Get sources
2019-07-29T13:43:53.0956900Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@LukasKalbertodt

This comment has been minimized.

Copy link
Contributor Author

commented Jul 29, 2019

@varkor

If you could produce a minimal test case, that would be really helpful.

This bug confuses me. I tried to find a minimal example that would trigger the bug on the playground, but I haven't succeeded. To me it seems like it only happens on stage1 with my change. Consider the following example:

#![feature(const_generics)]

pub struct Foo<T, const N: usize>([T; N]);

impl<T, const N: usize> Foo<T, {N}> {
    pub fn new() -> Self {
        unimplemented!()
    }
}

fn main() {
    let _: Foo<u32, 0> = Foo::new();
}

Compiling this with rustc 1.38.0-nightly (4560cb830 2019-07-28) works. Compiling this with the stage0 generated from this PR (i.e. the bootstrap compiler but with the new libcore, AFAI understand) works, too. Compiling this with stage1 generated from this PR fails, as already mentioned:

warning: the feature `const_generics` is incomplete and may cause the compiler to crash
 --> const-bug.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^

thread 'rustc' panicked at 'assertion failed: !out_value.has_type_flags(TypeFlags::KEEP_IN_LOCAL_TCX)', src/librustc/infer/canonical/canonicalizer.rs:548:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call
             at /home/lukas/dev/rust/src/liballoc/boxed.rs:784
   7: rustc::util::common::panic_hook
             at src/librustc/util/common.rs:40
   8: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   9: std::panicking::begin_panic
             at /home/lukas/dev/rust/src/libstd/panicking.rs:411
  10: rustc::infer::canonical::canonicalizer::Canonicalizer::canonicalize
             at /home/lukas/dev/rust/<::std::macros::panic macros>:4
  11: rustc::infer::canonical::canonicalizer::<impl rustc::infer::InferCtxt>::canonicalize_response
             at /home/lukas/dev/rust/src/librustc/infer/canonical/canonicalizer.rs:93
  12: rustc::infer::canonical::query_response::<impl rustc::infer::InferCtxt>::make_query_response_ignoring_pending_obligations
             at /home/lukas/dev/rust/src/librustc/infer/canonical/query_response.rs:133
  13: rustc_typeck::check::method::probe::<impl rustc_typeck::check::FnCtxt>::probe_op::{{closure}}
             at src/librustc_typeck/check/method/probe.rs:305
  14: rustc::infer::InferCtxt::probe
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:844
  15: rustc_typeck::check::method::probe::<impl rustc_typeck::check::FnCtxt>::probe_op
             at src/librustc_typeck/check/method/probe.rs:288
  16: rustc_typeck::check::method::probe::<impl rustc_typeck::check::FnCtxt>::probe_for_name
             at src/librustc_typeck/check/method/probe.rs:251
  17: rustc_typeck::check::method::<impl rustc_typeck::check::FnCtxt>::resolve_ufcs
             at src/librustc_typeck/check/method/mod.rs:433
  18: rustc_typeck::check::FnCtxt::resolve_ty_and_res_ufcs
             at src/librustc_typeck/check/mod.rs:3486
  19: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_path
             at src/librustc_typeck/check/expr.rs:448
  20: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
             at src/librustc_typeck/check/expr.rs:219
  21: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
             at src/librustc_typeck/check/expr.rs:157
  22: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
             at src/librustc_typeck/check/expr.rs:118
  23: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr
             at src/librustc_typeck/check/expr.rs:122
  24: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
             at src/librustc_typeck/check/callee.rs:44
  25: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
             at src/librustc_typeck/check/expr.rs:257
  26: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
             at src/librustc_typeck/check/expr.rs:157
  27: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
             at src/librustc_typeck/check/expr.rs:118
  28: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_hint
             at src/librustc_typeck/check/expr.rs:110
  29: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_coercable_to_type
             at src/librustc_typeck/check/expr.rs:100
  30: rustc_typeck::check::FnCtxt::check_decl_initializer
             at src/librustc_typeck/check/mod.rs:3538
  31: rustc_typeck::check::FnCtxt::check_decl_local
             at src/librustc_typeck/check/mod.rs:3547
  32: rustc_typeck::check::FnCtxt::check_stmt
             at src/librustc_typeck/check/mod.rs:3582
  33: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
             at src/librustc_typeck/check/mod.rs:3658
  34: rustc_typeck::check::FnCtxt::with_breakable_ctxt
             at src/librustc_typeck/check/mod.rs:4430
  35: rustc_typeck::check::FnCtxt::check_block_with_expected
             at src/librustc_typeck/check/mod.rs:3656
  36: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
             at src/librustc_typeck/check/expr.rs:254
  37: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
             at src/librustc_typeck/check/expr.rs:157
  38: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
             at src/librustc_typeck/check/expr.rs:118
  39: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_hint
             at src/librustc_typeck/check/expr.rs:110
  40: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
             at src/librustc_typeck/check/expr.rs:644
  41: rustc_typeck::check::check_fn
             at src/librustc_typeck/check/mod.rs:1122
  42: rustc_typeck::check::typeck_tables_of::{{closure}}
             at src/librustc_typeck/check/mod.rs:855
  43: rustc_typeck::check::InheritedBuilder::enter::{{closure}}
             at src/librustc_typeck/check/mod.rs:619
  44: rustc::infer::InferCtxtBuilder::enter::{{closure}}
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:522
  45: rustc::ty::context::GlobalCtxt::enter_local::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1609
  46: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1832
  47: rustc::ty::context::tls::set_tlv
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1765
  48: rustc::ty::context::tls::enter_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1831
  49: rustc::ty::context::GlobalCtxt::enter_local::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1608
  50: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1938
  51: rustc::ty::context::tls::with_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1921
  52: rustc::ty::context::tls::with_context_opt
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1910
  53: rustc::ty::context::tls::with_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1921
  54: rustc::ty::context::tls::with_related_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1934
  55: rustc::ty::context::GlobalCtxt::enter_local
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1600
  56: rustc::infer::InferCtxtBuilder::enter
             at /home/lukas/dev/rust/src/librustc/infer/mod.rs:521
  57: rustc_typeck::check::InheritedBuilder::enter
             at src/librustc_typeck/check/mod.rs:619
  58: rustc_typeck::check::typeck_tables_of
             at src/librustc_typeck/check/mod.rs:834
  59: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:997
  60: rustc::ty::query::__query_compute::typeck_tables_of
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:948
  61: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:989
  62: rustc::dep_graph::graph::DepGraph::with_task_impl
             at /home/lukas/dev/rust/src/librustc/dep_graph/graph.rs:334
  63: rustc::dep_graph::graph::DepGraph::with_task
             at /home/lukas/dev/rust/src/librustc/dep_graph/graph.rs:202
  64: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:556
  65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:275
  66: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1832
  67: rustc::ty::context::tls::set_tlv
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1765
  68: rustc::ty::context::tls::enter_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1831
  69: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:274
  70: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1938
  71: rustc::ty::context::tls::with_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1921
  72: rustc::ty::context::tls::with_context_opt
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1910
  73: rustc::ty::context::tls::with_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1921
  74: rustc::ty::context::tls::with_related_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1934
  75: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:263
  76: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:548
  77: rustc::ty::query::plumbing::with_diagnostics
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:209
  78: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:547
  79: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:376
  80: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:610
  81: rustc::ty::query::TyCtxtEnsure::typeck_tables_of
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:1025
  82: rustc_typeck::check::typeck_item_bodies::{{closure}}
             at src/librustc_typeck/check/mod.rs:713
  83: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/mod.rs:2775
  84: core::iter::traits::iterator::Iterator::for_each::{{closure}}
             at /home/lukas/dev/rust/src/libcore/iter/traits/iterator.rs:602
  85: <core::slice::Iter<T> as core::iter::traits::iterator::Iterator>::fold
             at /home/lukas/dev/rust/src/libcore/slice/mod.rs:3187
  86: core::iter::traits::iterator::Iterator::for_each
             at /home/lukas/dev/rust/src/libcore/iter/traits/iterator.rs:602
  87: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
             at /home/lukas/dev/rust/src/librustc/ty/mod.rs:2774
  88: rustc_typeck::check::typeck_item_bodies
             at src/librustc_typeck/check/mod.rs:712
  89: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_item_bodies>::compute::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:997
  90: rustc::ty::query::__query_compute::typeck_item_bodies
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:948
  91: rustc::dep_graph::graph::DepGraph::with_task_impl
             at /home/lukas/dev/rust/src/librustc/dep_graph/graph.rs:334
  92: rustc::dep_graph::graph::DepGraph::with_task
             at /home/lukas/dev/rust/src/librustc/dep_graph/graph.rs:202
  93: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::force_query_with_job::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:556
  94: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:275
  95: rustc::ty::context::tls::enter_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1832
  96: rustc::ty::context::tls::set_tlv
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1765
  97: rustc::ty::context::tls::enter_context
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1831
  98: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::start_query::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/query/plumbing.rs:274
  99: rustc::ty::context::tls::with_related_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1938
  100: rustc::ty::context::tls::with_context::{{closure}}
             at /home/lukas/dev/rust/src/librustc/ty/context.rs:1921
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
#0 [typeck_tables_of] processing `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.38.0-dev running on x86_64-unknown-linux-gnu

Additionally, there is this weird bug when using chalk, as described in this comment. This too only has a bug on stage1 (and potentially later stages) but not stage0 or nightly.

This all doesn't make a lot of sense to me. But it also seems like this only happens in stage1 (i.e. not reproducible on current nightly) and that the bootstrap process might have something to do with it.

I'd be happy to help investigating this bug, but I am not sure what else I could do right now. Looking at the backtrace only confuses me: I have no idea what the Canonicalizer is doing or what an infer-context is.

@Centril Centril removed this from the 1.38 milestone Jul 30, 2019

@varkor

This comment has been minimized.

Copy link
Member

commented Jul 30, 2019

Additionally, there is this weird bug when using chalk, as described in this comment.

I think this is caused by the same issue. I think the problem is that

let bound_to = infcx.resolve_const_var(const_var);

is supposed to be replacing any ConstValue::Infer(InferConst::Var(_))s with non-Vars, but it's failing for some reason (which means no replacement will occur). This means we have Vars floating around that aren't expected, which is the cause of both errors.

I had a quick look around, but I'm not really sure where the cause of this issue might be. I think we get an ConstVariableValue::Unknown when we want a ConstVariableValue::Known, which might mean we're not unifying something we should be. @eddyb might have a better idea of where to start looking.

@stephanemagnenat

This comment has been minimized.

Copy link

commented Aug 6, 2019

Does this PR still fixes #25725 now that IntoIterator impl for arrays is out of scope?

@LukasKalbertodt

This comment has been minimized.

Copy link
Contributor Author

commented Aug 6, 2019

@stephanemagnenat Good catch! Updated the top comment.

@Alexendoo

This comment has been minimized.

Copy link
Member

commented Aug 14, 2019

Ping from triage, @LukasKalbertodt any updates?

@LukasKalbertodt

This comment has been minimized.

Copy link
Contributor Author

commented Aug 14, 2019

@Alexendoo As far as I see it, I can't really do anything. This PR is blocked on at least one const generics bug. We're still waiting for responses from people (e.g. @varkor or @eddyb) about the nature of the bug and whether this PR can work around it. The only thing I planned on doing is rebasing it on masterevery few weeks to check if the bug is fixed (I won't push it every time though, to not trigger a useless CI run). Will do that soon-ish.

I don't mind keeping this PR open for some time until the bug is understood. But if you prefer, we can also close this and I will reopen the PR in the future again.

@Centril

This comment has been minimized.

Copy link
Member

commented Aug 14, 2019

I think it's fine to keep this open and rebase every now and then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.