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

Switch libcore array implementations to const generics. #60466

Closed
wants to merge 5 commits into from

Conversation

crlf0710
Copy link
Member

@crlf0710 crlf0710 commented May 2, 2019

Switch libcore array implementations to const generics.

@rust-highfive
Copy link
Collaborator

r? @shepmaster

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 2, 2019
@crlf0710 crlf0710 force-pushed the array_const_generics branch 3 times, most recently from 05d9148 to 6067107 Compare May 2, 2019 09:21
@varkor
Copy link
Member

varkor commented May 2, 2019

There are still issues with array handling for consts generics, so I don't expect this to work quite yet.

@rust-highfive
Copy link
Collaborator

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

Click to expand the log.
travis_time:end:0744c453:start=1556788995527328370,finish=1556788997874399211,duration=2347070841
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:04:27] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[00:04:27] 
[00:04:27] note: rustc 1.35.0-beta.1 (2bc1d406d 2019-04-10) running on x86_64-unknown-linux-gnu
[00:04:27] 
[00:04:27] note: compiler flags: -Z external-macro-backtrace -Z unstable-options -Z force-unstable-if-unmarked -C opt-level=2 -C prefer-dynamic -C debug-assertions=y -C codegen-units=1 -C link-args=-Wl,-rpath,$ORIGIN/../lib --crate-type lib
[00:04:27] note: some of the compiler flags provided by cargo are hidden
[00:04:27] 
[00:04:27] error: Could not compile `core`.
[00:04:27] warning: build failed, waiting for other jobs to finish...
---
travis_time:end:00d25034:start=1556789279431610631,finish=1556789279436820375,duration=5209744
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:11d6f9b4
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:061ac4c1
travis_time:start:061ac4c1
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:028d532f
$ dmesg | grep -i kill

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

@crlf0710
Copy link
Member Author

crlf0710 commented May 2, 2019

Yes, and it will also be quite a while before the bootstrapping compiler can use const generics :)

@Centril Centril added needs-fcp This change is insta-stable, so needs a completed FCP to proceed. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 2, 2019
@Centril
Copy link
Contributor

Centril commented May 2, 2019

Even when we have working const generics on nightly we cannot actually land the impls because they would commit us to const generics on stable. As such, I think this PR will end up being closed soon.

@varkor
Copy link
Member

varkor commented May 2, 2019

because they would commit us to const generics on stable

I don't think that's true. We could use const generics unstably in rustc indefinitely to improve Rust's handling of arrays.

@Centril
Copy link
Contributor

Centril commented May 2, 2019

We could use const generics unstably in rustc indefinitely to improve Rust's handling of arrays.

Elaborate?

@varkor
Copy link
Member

varkor commented May 2, 2019

Using const generics in rustc, but disallowing them in user code allows user code to take advantage of impls on arrays whose lengths are greater than 32, without making any other features of const generics visible.

@Centril
Copy link
Contributor

Centril commented May 2, 2019

@varkor That still commits you to the underlying quantification over values (but specific to usize) which in my book is exposing const generics in a stable way, just not with the surface syntax. This is no different than using specialization inside the standard library for non-perf purposes (e.g. coherence or to improve dbg!) and we have expressly refused to do that. The same applies here; once const generics is stable we can commit to these impls. Alternatively you can find a way to feature gate implementations and then use it but that seems like a large project.

@varkor
Copy link
Member

varkor commented May 2, 2019

In theory, we could generate these impls with a macro for every value of a usize. Using const generics here doesn't let us do anything we couldn't technically do already in the language (unlike specialisation) — it just makes it sensible.

@cramertj
Copy link
Member

cramertj commented May 2, 2019

These particular impls are needed and wanted frequently enough that even if we never landed const generics I'd be heavily in support of an implementation via a custom compiler hack.

@rust-highfive
Copy link
Collaborator

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

Click to expand the log.
travis_time:end:01e02fbb:start=1556982930778490906,finish=1556983019455123521,duration=88676632615
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:27:21]    Compiling cmake v0.1.38
[00:27:21]    Compiling backtrace-sys v0.1.27
[00:27:25]    Compiling std v0.0.0 (/checkout/src/libstd)
[00:27:25]    Compiling rustc_tsan v0.0.0 (/checkout/src/librustc_tsan)
[00:27:25] error[E0119]: conflicting implementations of trait `convert::TryFrom<&[_]>`:
[00:27:25]     |
[00:27:25]     |
[00:27:25] 106 | impl<T, const N: usize> TryFrom<&[T]> for [T; N] where T: Copy {
[00:27:25]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
[00:27:25]    ::: src/libcore/convert.rs:565:1
[00:27:25]     |
[00:27:25]     |
[00:27:25] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:27:25]     | -------------------------------------------- first implementation here
[00:27:25] 
[00:27:25] error[E0119]: conflicting implementations of trait `convert::TryFrom<&[_]>` for type `&[type error]`:
[00:27:25]     |
[00:27:25]     |
[00:27:25] 115 | impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] {
[00:27:25]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&[type error]`
[00:27:25]    ::: src/libcore/convert.rs:565:1
[00:27:25]     |
[00:27:25]     |
[00:27:25] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:27:25]     | -------------------------------------------- first implementation here
[00:27:25] 
[00:27:25] error[E0119]: conflicting implementations of trait `convert::TryFrom<&mut [_]>` for type `&mut [type error]`:
[00:27:25]     |
[00:27:25]     |
[00:27:25] 129 | impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] {
[00:27:25]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&mut [type error]`
[00:27:25]    ::: src/libcore/convert.rs:565:1
[00:27:25]     |
[00:27:25]     |
[00:27:25] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:27:25]     | -------------------------------------------- first implementation here
[00:27:25] 
[00:27:25] error[E0119]: conflicting implementations of trait `iter::traits::collect::IntoIterator` for type `&[_; _]`:
[00:27:25]     |
[00:27:25]     |
[00:27:25] 241 | impl<I: Iterator> IntoIterator for I {
[00:27:25]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&[_; _]`
[00:27:25]    ::: src/libcore/array.rs:157:1
[00:27:25]     |
[00:27:25]     |
[00:27:25] 157 | impl<'a, T, const N: usize> IntoIterator for &'a [T; N] {
[00:27:25]     | ------------------------------------------------------- first implementation here
[00:27:25] error: aborting due to 4 previous errors
[00:27:25] 
[00:27:25] For more information about this error, try `rustc --explain E0119`.
[00:27:25] error: Could not compile `core`.
---
travis_time:end:1261a65e:start=1556984679997518335,finish=1556984680002602124,duration=5083789
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:07894bd8
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:21159d78
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/

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)

@jonas-schievink jonas-schievink added the relnotes Marks issues that should be documented in the release notes of the next release. label May 4, 2019
@jonas-schievink jonas-schievink added this to the 1.36 milestone May 4, 2019
}

#[stable(since = "1.4.0", feature = "array_default")]
impl<T, const N: usize> Default for [T; N] where T: Default {
Copy link
Member

Choose a reason for hiding this comment

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

The current Default impl for [T; 0] doesn't have a T: Default bound so this would be a breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

In the short term, i think we can put the original definition back. In the long term, how would we solve this? N > 0 or T: !Default or some overlapping specialization?

@Centril

Copy link
Member

Choose a reason for hiding this comment

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

If there was a good way to do this we could remove the bounds on the other [T; 0] impls as well: #52246.

Copy link
Member

Choose a reason for hiding this comment

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

Seems like an obvious candidate for specialization, though unfortunately I'm not aware of any existing efforts towards const-specialization. This is in the "minimal trivially sound" category, though, so again I'd personally be inclined to accept whatever minor hack we need to make it "just work".

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised that the unconstrained impl Default for [T; 0] even exists given #52246.
Is it some early pre-1.0 addition that was overlooked during stabilization?

Copy link
Member

Choose a reason for hiding this comment

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

@est31 you don't think the pattern from @rodrimati1992 would work for Serde?

Copy link
Member

Choose a reason for hiding this comment

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

@dtolnay it could possibly work. Not sure yet what const generics will allow in their initial version and what they don't. If I put @rodrimati1992 's code into the playpen I get "identifiers may currently not be used for const generics" errors on the true and false expressions. If I replace them with {0u8==0u8} and {0u8!=0u8}, I get tons of ICEs (link).

Copy link
Member

Choose a reason for hiding this comment

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

Let's check again after #60742 and #60839.

Copy link
Member

Choose a reason for hiding this comment

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

Still ICE's as of rustc 1.37.0-nightly (3ade426ed 2019-05-30) . I've filed a bug at #61383

Copy link
Member

Choose a reason for hiding this comment

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

Now there is a compilation error: #61935

@rust-highfive
Copy link
Collaborator

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

Click to expand the log.
travis_time:end:2eecc5a0:start=1557028563534341605,finish=1557028651814816423,duration=88280474818
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:27:42]    Compiling cmake v0.1.38
[00:27:42]    Compiling backtrace-sys v0.1.27
[00:27:45]    Compiling std v0.0.0 (/checkout/src/libstd)
[00:27:45]    Compiling rustc_lsan v0.0.0 (/checkout/src/librustc_lsan)
[00:27:46] error[E0119]: conflicting implementations of trait `convert::TryFrom<&[_]>`:
[00:27:46]     |
[00:27:46]     |
[00:27:46] 106 | impl<T, const N: usize> TryFrom<&[T]> for [T; N] where T: Copy {
[00:27:46]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
[00:27:46]    ::: src/libcore/convert.rs:565:1
[00:27:46]     |
[00:27:46]     |
[00:27:46] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:27:46]     | -------------------------------------------- first implementation here
[00:27:46] 
[00:27:46] error[E0119]: conflicting implementations of trait `convert::TryFrom<&[_]>` for type `&[type error]`:
[00:27:46]     |
[00:27:46]     |
[00:27:46] 115 | impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] {
[00:27:46]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&[type error]`
[00:27:46]    ::: src/libcore/convert.rs:565:1
[00:27:46]     |
[00:27:46]     |
[00:27:46] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:27:46]     | -------------------------------------------- first implementation here
[00:27:46] 
[00:27:46] error[E0119]: conflicting implementations of trait `convert::TryFrom<&mut [_]>` for type `&mut [type error]`:
[00:27:46]     |
[00:27:46]     |
[00:27:46] 129 | impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] {
[00:27:46]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&mut [type error]`
[00:27:46]    ::: src/libcore/convert.rs:565:1
[00:27:46]     |
[00:27:46]     |
[00:27:46] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:27:46]     | -------------------------------------------- first implementation here
[00:27:46] 
[00:27:46] error[E0119]: conflicting implementations of trait `iter::traits::collect::IntoIterator` for type `&[_; _]`:
[00:27:46]     |
[00:27:46]     |
[00:27:46] 241 | impl<I: Iterator> IntoIterator for I {
[00:27:46]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&[_; _]`
[00:27:46]    ::: src/libcore/array.rs:157:1
[00:27:46]     |
[00:27:46]     |
[00:27:46] 157 | impl<'a, T, const N: usize> IntoIterator for &'a [T; N] {
[00:27:46]     | ------------------------------------------------------- first implementation here
[00:27:46] error: aborting due to 4 previous errors
[00:27:46] 
[00:27:46] For more information about this error, try `rustc --explain E0119`.
[00:27:46] error: Could not compile `core`.
---
156508 ./src/llvm-project/clang
144972 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu
144968 ./obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release
142416 ./obj/build/bootstrap/debug/incremental/bootstrap-ngvt240vptb4
142412 ./obj/build/bootstrap/debug/incremental/bootstrap-ngvt240vptb4/s-fbx55aqn4o-1jmsec0-li41thz4lrxh
123640 ./src/llvm-project/llvm/test/CodeGen
108532 ./src/llvm-project/lldb
97596 ./src/llvm-project/clang/test
89976 ./src/llvm-emscripten/test/CodeGen

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)

@crlf0710
Copy link
Member Author

crlf0710 commented May 7, 2019

Rebased to master to pick up #53645.

@rust-highfive
Copy link
Collaborator

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

Click to expand the log.
travis_time:end:02cc2a1f:start=1557208150405668102,finish=1557208151158370166,duration=752702064
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:27:52]    Compiling compiler_builtins v0.1.10
[00:27:52]    Compiling cmake v0.1.38
[00:27:52]    Compiling backtrace-sys v0.1.27
[00:27:54]    Compiling std v0.0.0 (/checkout/src/libstd)
[00:27:56] error[E0119]: conflicting implementations of trait `convert::TryFrom<&[_]>`:
[00:27:56]     |
[00:27:56]     |
[00:27:56] 106 | impl<T, const N: usize> TryFrom<&[T]> for [T; N] where T: Copy {
[00:27:56]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
[00:27:56]    ::: src/libcore/convert.rs:565:1
[00:27:56]     |
[00:27:56]     |
[00:27:56] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:27:56]     | -------------------------------------------- first implementation here
[00:27:56] 
[00:27:56] error[E0119]: conflicting implementations of trait `convert::TryFrom<&[_]>` for type `&[type error]`:
[00:27:56]     |
[00:27:56]     |
[00:27:56] 115 | impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] {
[00:27:56]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&[type error]`
[00:27:56]    ::: src/libcore/convert.rs:565:1
[00:27:56]     |
[00:27:56]     |
[00:27:56] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:27:56]     | -------------------------------------------- first implementation here
[00:27:56] 
[00:27:56] error[E0119]: conflicting implementations of trait `convert::TryFrom<&mut [_]>` for type `&mut [type error]`:
[00:27:56]     |
[00:27:56]     |
[00:27:56] 129 | impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] {
[00:27:56]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&mut [type error]`
[00:27:56]    ::: src/libcore/convert.rs:565:1
[00:27:56]     |
[00:27:56]     |
[00:27:56] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:27:56]     | -------------------------------------------- first implementation here
[00:27:56] 
[00:27:56] error[E0119]: conflicting implementations of trait `iter::traits::collect::IntoIterator` for type `&[_; _]`:
[00:27:56]     |
[00:27:56]     |
[00:27:56] 241 | impl<I: Iterator> IntoIterator for I {
[00:27:56]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&[_; _]`
[00:27:56]    ::: src/libcore/array.rs:157:1
[00:27:56]     |
[00:27:56]     |
[00:27:56] 157 | impl<'a, T, const N: usize> IntoIterator for &'a [T; N] {
[00:27:56]     | ------------------------------------------------------- first implementation here
[00:27:56]    Compiling rustc_lsan v0.0.0 (/checkout/src/librustc_lsan)
[00:27:56]    Compiling rustc_msan v0.0.0 (/checkout/src/librustc_msan)
[00:27:56] error: aborting due to 4 previous errors
[00:27:56] 
---
19252 ./src/llvm-project/lldb/www/cpp_reference/html
18164 ./obj/build/x86_64-unknown-linux-gnu/stage0-codegen
17940 ./src/llvm-project/lldb/www/python_reference
travis_time:end:177a9f8c:start=1557209842834305831,finish=1557209843411631209,duration=57t ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:04e03f4f
$ dmesg | grep -i kill

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

@crlf0710
Copy link
Member Author

crlf0710 commented Jun 3, 2019

minimal repro of the ICE:

#![feature(const_generics)]

fn f<const LEN: usize>() {
    let a = [true; LEN];
}

play link

Filed #61490 . See #61336 .

@craterbot
Copy link
Collaborator

🎉 Experiment pr-60466 is completed!
📊 0 regressed and 2 fixed (60951 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Jun 3, 2019
@varkor
Copy link
Member

varkor commented Jun 3, 2019

The crater analysis looks good. Performance is also improved with this change.

Const generics as an entire feature still have a number of issues, but there don't seem to be any issues with replacing the array implementation. Now it's up to the teams to decide what to do here: #61415.

@bors
Copy link
Contributor

bors commented Jun 9, 2019

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

@rust-highfive
Copy link
Collaborator

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

Click to expand the log.
travis_time:end:0d7f522b:start=1560326291052938313,finish=1560326291844622880,duration=791684567
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
$ export GCP_CACHE_BUCKET=rust-lang-ci-cache
$ export AWS_ACCESS_KEY_ID=AKIA46X5W6CZEJZ6XT55
---
[00:04:53] 
[00:04:53]    Compiling build_helper v0.1.0 (/checkout/src/build_helper)
[00:04:54]    Compiling autocfg v0.1.4
[00:04:56]    Compiling backtrace v0.3.29
[00:04:58] error[E0119]: conflicting implementations of trait `convert::TryFrom<&[_]>`:
[00:04:58]     |
[00:04:58]     |
[00:04:58] 115 | impl<T, const N: usize> TryFrom<&[T]> for [T; N] where T: Copy {
[00:04:58]     | 
[00:04:58]    ::: src/libcore/convert.rs:565:1
[00:04:58]     |
[00:04:58]     |
[00:04:58] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:04:58]     | -------------------------------------------- first implementation here
[00:04:58] 
[00:04:58] error[E0119]: conflicting implementations of trait `convert::TryFrom<&[_]>` for type `&[type error]`:
[00:04:58]     |
[00:04:58]     |
[00:04:58] 124 | impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] {
[00:04:58]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&[type error]`
[00:04:58]    ::: src/libcore/convert.rs:565:1
[00:04:58]     |
[00:04:58]     |
[00:04:58] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:04:58]     | -------------------------------------------- first implementation here
[00:04:58] 
[00:04:58] error[E0119]: conflicting implementations of trait `convert::TryFrom<&mut [_]>` for type `&mut [type error]`:
[00:04:58]     |
[00:04:58]     |
[00:04:58] 138 | impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] {
[00:04:58]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&mut [type error]`
[00:04:58]    ::: src/libcore/convert.rs:565:1
[00:04:58]     |
[00:04:58]     |
[00:04:58] 565 | impl<T, U> TryFrom<U> for T where U: Into<T> {
[00:04:58]     | -------------------------------------------- first implementation here
[00:04:58] 
[00:04:58] error[E0119]: conflicting implementations of trait `iter::traits::collect::IntoIterator` for type `&[_; _]`:
[00:04:58]     |
[00:04:58]     |
[00:04:58] 241 | impl<I: Iterator> IntoIterator for I {
[00:04:58]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&[_; _]`
[00:04:58]    ::: src/libcore/array.rs:166:1
[00:04:58]     |
[00:04:58]     |
[00:04:58] 166 | impl<'a, T, const N: usize> IntoIterator for &'a [T; N] {
[00:04:58]     | ------------------------------------------------------- first implementation here
[00:04:58] error: aborting due to 4 previous errors
[00:04:58] 
[00:04:58] For more information about this error, try `rustc --explain E0119`.
[00:04:58] error: Could not compile `core`.

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)

@crlf0710
Copy link
Member Author

crlf0710 commented Jun 12, 2019

Rebased the commits.

This error disappeared for a while, but come out again on newest master.

But the diagnostics might imply something wierd is going on: it says
conflicting implementation for &mut [type error]

I can repro similar error with similar code. but i'm not sure whether array is actually defined this way, or is something special:

#![feature(fundamental)]
#![feature(const_generics)]
use std::marker::PhantomData;

#[fundamental] //after commenting out this line the compilation will pass.
struct MyArr<T, const L: usize>(PhantomData<T>);

trait MyInto<T> {
    fn my_into(self) -> T;
}

trait MyTryFrom<T> {
    fn my_try_from(v: T) -> Self;
}

impl<T, U> MyTryFrom<U> for T where U: MyInto<T> {
    fn my_try_from(v: U) -> Self {
        v.my_into()
    }
}

impl<T, const N: usize> MyTryFrom<&[T]> for MyArr<T, {N}> where T: Copy {
    fn my_try_from(v: &[T]) -> Self {
        MyArr(PhantomData)
    }
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=99b624ec1f0cd6c219abf2c8915820da

@Centril Centril removed needs-fcp This change is insta-stable, so needs a completed FCP to proceed. relnotes Marks issues that should be documented in the release notes of the next release. labels Jun 22, 2019
@Centril Centril removed this from the 1.37 milestone Jun 22, 2019
@Centril Centril removed T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jun 22, 2019
@Centril
Copy link
Contributor

Centril commented Jun 22, 2019

r? @Centril

Per T-Libs and T-Lang decisions in #61415 (comment) and #61415 (comment) respectively, we would be inclined to accept @petrochenkov idea in #61415 (comment) provided that there are:

  1. UI tests to show that implementations above 32 elements do not work.

  2. A perf run to demonstrate this is still beneficial.

@crlf0710 Feel free to either a) turn this PR into that, b) close this PR and file a new one for that ^--.

@rust-highfive rust-highfive assigned Centril and unassigned shepmaster Jun 22, 2019
@crlf0710
Copy link
Member Author

Sure, i will turn this PR into that in the next few days.

@Centril Centril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 3, 2019
@scottmcm
Copy link
Member

scottmcm commented Jul 6, 2019

Oops, I made a PR for this in #62435 without noticing this one.

@crlf0710
Copy link
Member Author

crlf0710 commented Jul 7, 2019

Oops, I made a PR for this in #62435 without noticing this one.

That's fine. I'll just close this in favor of #62435 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.