Skip to content

typeck: Fix const generic in repeat param ICE. - #61698

Merged
bors merged 1 commit into
rust-lang:masterfrom
davidtwco:ice-const-generic-length
Jun 12, 2019
Merged

typeck: Fix const generic in repeat param ICE.#61698
bors merged 1 commit into
rust-lang:masterfrom
davidtwco:ice-const-generic-length

Conversation

@davidtwco

Copy link
Copy Markdown
Member

Fixes#61336. Turns out this wasn't related to #49147 after all.

r? @varkor

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 9, 2019
Comment threadsrc/librustc_typeck/astconv.rs Outdated
@davidtwco
davidtwcoforce-pushed the ice-const-generic-length branch from 0efc78c to cdcb7e6CompareJune 9, 2019 21:00
Comment threadsrc/librustc_typeck/astconv.rs Outdated
@davidtwco
davidtwcoforce-pushed the ice-const-generic-length branch from cdcb7e6 to 2a3e004CompareJune 10, 2019 07:24
Comment threadsrc/librustc_typeck/check/mod.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we also have a test where we make sure that this does the right thing? E.g. pass in N explicitly and check the return value.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I've added another test. It will error later in the compiler with a "array lengths can't depend on generic parameters" error, emitted when creating the HAIR. From a quick look, it appears that the MIR/HAIR data structures all contain a u64 for the count, so it isn't trivial to change one or two lines and make this work, probably best left for a follow-up (which I'd be interested in trying to tackle). It's an improvement over an ICE in any case.

@varkorvarkorJun 10, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, okay. Yes, this is certainly better than an ICE, and this gives us a good minimal example to fix. Let's open an issue for it after this is merged.

Comment threadsrc/librustc_typeck/check/mod.rs Outdated
This commit fixes an ICE that occured when a const generic was used in
a repeat expression. This was due to the code expecting the length of
the repeat expression to be const evaluatable to a constant, but a const
generic parameter is not (however, it can be made into a constant).
@davidtwco
davidtwcoforce-pushed the ice-const-generic-length branch from 2a3e004 to 9ed4674CompareJune 10, 2019 15:59
@varkor

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jun 10, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 9ed4674 has been approved by varkor

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 10, 2019
Centril added a commit to Centril/rust that referenced this pull request Jun 11, 2019
… r=varkor
typeck: Fix const generic in repeat param ICE.
Fixesrust-lang#61336. Turns out this wasn't related to rust-lang#49147 after all.
r? @varkor
@CentrilCentril mentioned this pull request Jun 11, 2019
Centril added a commit to Centril/rust that referenced this pull request Jun 11, 2019
… r=varkor
typeck: Fix const generic in repeat param ICE.
Fixesrust-lang#61336. Turns out this wasn't related to rust-lang#49147 after all.
r? @varkor
@CentrilCentril mentioned this pull request Jun 11, 2019
Centril added a commit to Centril/rust that referenced this pull request Jun 11, 2019
… r=varkor
typeck: Fix const generic in repeat param ICE.
Fixesrust-lang#61336. Turns out this wasn't related to rust-lang#49147 after all.
r? @varkor
@CentrilCentril mentioned this pull request Jun 11, 2019
bors added a commit that referenced this pull request Jun 11, 2019
Rollup of 11 pull requests
Successful merges:
- #61518 (Add loops to doc list of things not stable in const fn)
- #61526 (move some tests into subfolders)
- #61550 (Windows 10 SDK is also required now.)
- #61606 (Remove some legacy proc macro flavors)
- #61652 (Mention slice patterns in array)
- #61686 (librustc_errors: Add some more documentation)
- #61698 (typeck: Fix const generic in repeat param ICE.)
- #61707 (Azure: retry failed awscli installs)
- #61715 (make sure make_ascii_lowercase actually leaves upper-case non-ASCII characters alone)
- #61724 (core: use memcmp optimization for 128 bit integer slices)
- #61726 (Use `for_each` in `Iterator::partition`)
Failed merges:
r? @ghost
bors added a commit that referenced this pull request Jun 11, 2019
Rollup of 11 pull requests
Successful merges:
- #61518 (Add loops to doc list of things not stable in const fn)
- #61526 (move some tests into subfolders)
- #61550 (Windows 10 SDK is also required now.)
- #61606 (Remove some legacy proc macro flavors)
- #61652 (Mention slice patterns in array)
- #61686 (librustc_errors: Add some more documentation)
- #61698 (typeck: Fix const generic in repeat param ICE.)
- #61707 (Azure: retry failed awscli installs)
- #61715 (make sure make_ascii_lowercase actually leaves upper-case non-ASCII characters alone)
- #61724 (core: use memcmp optimization for 128 bit integer slices)
- #61726 (Use `for_each` in `Iterator::partition`)
Failed merges:
r? @ghost
@bors
bors merged commit 9ed4674 into rust-lang:masterJun 12, 2019
@davidtwco
davidtwco deleted the ice-const-generic-length branch June 12, 2019 06:26
davidtwco added a commit to davidtwco/rust that referenced this pull request Jun 13, 2019
This commit extends the work in rust-lang#61698 to get the `DefId` of const
parameters from block that resolve to a const parameter (as well as
const parameters directly, as it was previously).
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Broken MIR" ICE while creating array with const generic length from single value

6 participants

@davidtwco@varkor@bors@Centril@jonas-schievink@rust-highfive