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

Don't ICE when trying to copy unsized value in const prop #102559

Merged
merged 1 commit into from
Oct 4, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Oct 2, 2022

When we have a trivially false where-clause predicate like Self: Sized where Self = dyn Trait, we sometimes don't throw an error during typeck for an illegal operation such as copying an unsized type.

This, unfortunately, cannot be made into an error (at least not without some migration -- see #95611 for example), but we should at least not ICE, since this function will never actually be reachable from main, for example.

r? @RalfJung since I think you added these assertions? but feel free to reassign.

Fixes #102553

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 2, 2022
@rustbot
Copy link
Collaborator

rustbot commented Oct 2, 2022

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 2, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Oct 2, 2022

I think #101168 will just take care of this, but that's a bit far off to being merged. Maybe we can avoid this function from being called at all from const prop by checking something in the const propagator instead of modifying the mir interpreter?

@RalfJung
Copy link
Member

RalfJung commented Oct 2, 2022

The better fix would be to change ConstProp to not hit this part of the interpreter. I am not a fan of compromising the interpreter to account for all the ways in which ConstProp is misusing its APIs...

But given that we already have SizeOfUnsizedType I guess this is okay. Please add FIXME comments explaining that this is only needed because of ConstProp misusing interpreter APIs.

@rustbot
Copy link
Collaborator

rustbot commented Oct 2, 2022

Some changes occurred in src/tools/cargo

cc @ehuss

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@compiler-errors
Copy link
Member Author

Oops, updated submodules by accident. 🤦

@compiler-errors
Copy link
Member Author

@oli-obk: This isn't fixed by #101168, or at least the draft version that's in that PR right now. We could alternatively check for any trivial predicates in a function's param-env that look like T: Sized where the layout of T is known to be unsized, and skip const-prop if so. Not sure if all that extra work is worth it, compared to just bailing during const eval like this PR is doing.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 4, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 4, 2022

📌 Commit c7d1ec0 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors 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 Oct 4, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 4, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#101189 (Implement `Ready::into_inner()`)
 - rust-lang#101642 (Fix in-place collection leak when remaining element destructor panic)
 - rust-lang#102489 (Normalize substs before resolving instance in `NoopMethodCall` lint)
 - rust-lang#102559 (Don't ICE when trying to copy unsized value in const prop)
 - rust-lang#102568 (Lint against nested opaque types that don't satisfy associated type bounds)
 - rust-lang#102633 (Fix rustdoc ICE in invalid_rust_codeblocks lint)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 32dde23 into rust-lang:master Oct 4, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 4, 2022
@compiler-errors compiler-errors deleted the issue-102553 branch November 2, 2022 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: 'cannot copy unsized immediates' creating Box of trait object with generics
6 participants