Skip to content

unwrap_usize should at least try to evaluate the underlying constant - #59369

Merged
bors merged 10 commits into
rust-lang:masterfrom
oli-obk:unwrap_usICE
Aug 5, 2019
Merged

unwrap_usize should at least try to evaluate the underlying constant#59369
bors merged 10 commits into
rust-lang:masterfrom
oli-obk:unwrap_usICE

Conversation

@oli-obk

Copy link
Copy Markdown
Contributor

r? @eddyb

fixes#59016

I know that I'm still using ParamEnv wrongly, but that's a preexisting issue not amplified by this PR.

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 22, 2019
@oli-obk

Copy link
Copy Markdown
ContributorAuthor

cc @nikomatsakis this is related to lazy normalization. I could probably run the regular opportunistic normalization on the types (and thus the array lengths inside the array types) obtained in

let expected_ty = self.structurally_resolved_type(pat.span, expected);
but I'm not sure if we'd ever catch all the cases (the linked issue shows other similar ICEs)

Comment threadsrc/librustc/ty/sty.rs Outdated
Comment threadsrc/librustc/ty/sty.rs Outdated
@rust-highfive

This comment has been minimized.

@bors

This comment has been minimized.

@oli-obk

Copy link
Copy Markdown
ContributorAuthor

@eddyb is 1650513 what you had in mind?

@eddyb

Copy link
Copy Markdown
Contributor

I was thinking of tcx.lift_to_global(&substs).unwrap(), but it makes sense if the type also contains inference variables...
The code is confusing, maybe split the ParamEnvAnd before doing anything to it?

But really, you're calling .unwrap_or_else(|| bug!(...)) - my point was to not panic in those cases, but rather... I don't even know what's happening anymore :(

Your error says this is what can't be lifted:

ParamEnvAnd{ param_env:ParamEnv{
caller_bounds:[Binder(OutlivesPredicate('_#0r,'_#1r
))],
reveal:UserFacing,
def_id:None},
value: usize
}

But this can't really exist? Ohhh, you need to convert it to a RevealAllParamEnv and then call .and(ty) on it, to pass it to layout_of. That will clear all the irrelevant bounds!

Comment threadsrc/librustc/ty/sty.rs Outdated
Comment threadsrc/librustc/ty/sty.rs Outdated
@bors

bors commented Apr 2, 2019

Copy link
Copy Markdown
Collaborator

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

@bors

bors commented Apr 13, 2019

Copy link
Copy Markdown
Collaborator

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

@Dylan-DPC-zz

Copy link
Copy Markdown

ping from triage @eddyb waiting for your review on this

@oli-obk

Copy link
Copy Markdown
ContributorAuthor

Nope, I still have things to address, sorry about that

@oli-obkoli-obk 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 Apr 23, 2019
@eddyb

Copy link
Copy Markdown
Contributor

This is also waiting on @nikomatsakis for a few questions.

@nikomatsakisnikomatsakis self-assigned this Apr 30, 2019
@pnkfelix

Copy link
Copy Markdown
Contributor

cc #60471 since this is "related to lazy normalization"

Comment threadsrc/test/ui/consts/self_normalization.rs Outdated
@oli-obk

oli-obk commented May 17, 2019

Copy link
Copy Markdown
ContributorAuthor

@nikomatsakis this is ready for review again.

The big question related to lazy normalization is whether it's ok that this evalutes (some) constants at the point where someone is trying to act upon the actual value of the constant.

Eager normalization happens in

fnfold_const(&mutself,constant:&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>{
and
fnfold_const(&mutself,constant:&'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx>{

EDIT for clarity: this PR does not change eager normalization. We just do lazy normalization of some constants that were never eagerly normalized.

@oli-obkoli-obk added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 17, 2019
@eddyb

Copy link
Copy Markdown
Contributor

@oli-obk I would expect that for now eager normalization would still resolve at least everything which evaluates successfully, right?
I mean, that is the case for associated type projections, I don't see why consts would be different.

@bors

bors commented May 25, 2019

Copy link
Copy Markdown
Collaborator

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

@wirelessringo

Copy link
Copy Markdown

Ping from triage, @eddyb@Centril any updates on this? Thanks

@oli-obk

Copy link
Copy Markdown
ContributorAuthor

@bors r=eddyb,nikomatsakis

@bors

bors commented Aug 5, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit bd57498 has been approved by eddyb,nikomatsakis

@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 Aug 5, 2019
@bors

bors commented Aug 5, 2019

Copy link
Copy Markdown
Collaborator

⌛ Testing commit bd57498 with merge c471519...

bors added a commit that referenced this pull request Aug 5, 2019
`unwrap_usize` should at least try to evaluate the underlying constant
r? @eddybfixes#59016
I know that I'm still using `ParamEnv` wrongly, but that's a preexisting issue not amplified by this PR.
@bors

bors commented Aug 5, 2019

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-azure
Approved by: eddyb,nikomatsakis
Pushing c471519 to master...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Aug 5, 2019
@bors
bors merged commit bd57498 into rust-lang:masterAug 5, 2019
@tesujitesuji mentioned this pull request Aug 6, 2019
tesuji added a commit to tesuji/rust-clippy that referenced this pull request Aug 6, 2019
tesuji added a commit to tesuji/rust-clippy that referenced this pull request Aug 6, 2019
tesuji added a commit to tesuji/rust-clippy that referenced this pull request Aug 6, 2019
bors added a commit to rust-lang/rust-clippy that referenced this pull request Aug 7, 2019
@oli-obk
oli-obk deleted the unwrap_usICE branch March 16, 2021 12:14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)merged-by-borsThis PR was explicitly merged by bors.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.

Compiler panic when using a slice pattern

10 participants

@oli-obk@rust-highfive@bors@eddyb@Dylan-DPC-zz@pnkfelix@nikomatsakis@wirelessringo@Centril@varkor