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 TooGeneric variant to LayoutError and emit Unknown #135158

Closed
wants to merge 1 commit into from

Conversation

FedericoBruzzone
Copy link
Contributor

@FedericoBruzzone FedericoBruzzone commented Jan 6, 2025

What's in this PR?

  • Add TooGeneric variant to LayoutError and emit Unknown one

With this PR these issues and their respective ICEs are resolved:

@rustbot
Copy link
Collaborator

rustbot commented Jan 6, 2025

r? @cjgillot

rustbot has assigned @cjgillot.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jan 6, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 6, 2025

HIR ty lowering was modified

cc @fmease

@FedericoBruzzone
Copy link
Contributor Author

Feel free to ask me anything.
In particular, let me know if you would like the addition of a test within the tests/ui/layout/ folder.

@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

jieyouxu commented Jan 6, 2025

(The fluent slug needs to be sorted lexicographically)

@jieyouxu
Copy link
Member

jieyouxu commented Jan 6, 2025

error[E0080]: evaluation of constant value failed
 --> ice-135138.rs:7:16
  |
7 |     [(); { let _a: Option<str> = None; 0 }];
  |                ^^ cannot determine the layout of the type `Option<str>`

seems somewhat unfortunate diagnostics-wise because:

  • The error is quite generic and isn't super helpful to the user (e.g. why can't the compiler determine the layout?), because it doesn't actually point to the "root" problem, which is Option<str>.
  • The problem here is that Option<str> doesn't have a size known at, er, const-eval time?

Introducing this UnexpectedUnsized variant to LayoutError and removing the assertion seems a bit strange to me, won't this paper over genuine implementation bugs, even if this variant is only constructed under trivial_bounds? I do appreciate that the layout calculation is not trivial, so, not a blocker.

Anyway, cc @lukas-code.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@lukas-code lukas-code left a comment

Choose a reason for hiding this comment

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

In particular, let me know if you would like the addition of a test within the tests/ui/layout/ folder.

Yes, this definitely needs tests, for both of the issues. See here for a guide on adding tests.

compiler/rustc_ty_utils/src/layout.rs Outdated Show resolved Hide resolved
compiler/rustc_ty_utils/src/layout.rs Show resolved Hide resolved
compiler/rustc_middle/src/ty/layout.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@FedericoBruzzone FedericoBruzzone force-pushed the master branch 2 times, most recently from 3463d0f to 3d8a88a Compare January 6, 2025 23:58
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 8, 2025

Some changes occurred to the CTFE machinery

cc @rust-lang/wg-const-eval

@rust-log-analyzer

This comment has been minimized.

@FedericoBruzzone FedericoBruzzone changed the title Fix two ICEs by introducing a new layout error variant for unexpected unsized Fix two ICEs by introducing a new layout error variant Jan 8, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@oli-obk

This comment was marked as resolved.

@bors

This comment was marked as resolved.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@FedericoBruzzone
Copy link
Contributor Author

@oli-obk I don't want to sound pushy, but I think this PR may be merged. Currently I think Lukas doesn't have much time to do the last review. What can we do in this situation?

Copy link
Member

@lukas-code lukas-code left a comment

Choose a reason for hiding this comment

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

Thank you, the implementation LGTM now!

The PR description needs to be updated and I have a few minor remarks, then I think this is ready to merge.

tests/ui/const-generics/transmute-fail.stderr Outdated Show resolved Hide resolved
compiler/rustc_ty_utils/src/layout.rs Outdated Show resolved Hide resolved
tests/ui/layout/unknown-when-no-type-parameter.rs Outdated Show resolved Hide resolved
tests/ui/layout/unknown-when-ptr-metadata-is-1zst.rs Outdated Show resolved Hide resolved
@FedericoBruzzone FedericoBruzzone force-pushed the master branch 3 times, most recently from d61d19c to cef97bc Compare January 26, 2025 23:37
@lukas-code
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jan 27, 2025

📌 Commit cef97bc has been approved by lukas-code

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 Jan 27, 2025
fmease added a commit to fmease/rust that referenced this pull request Jan 27, 2025
Add `TooGeneric` variant to `LayoutError` and emit `Unknown`

What's in this PR?

- Add `TooGeneric` variant to `LayoutError` and emit `Unknown` one

With this PR these issues and their respective ICEs are resolved:
- fixes rust-lang#135020
- fixes rust-lang#135138
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 27, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang#126604 (Uplift `clippy::double_neg` lint as `double_negations`)
 - rust-lang#135158 (Add `TooGeneric` variant to `LayoutError` and emit `Unknown`)
 - rust-lang#135635 (Move `std::io::pipe` code into its own file)
 - rust-lang#136072 (add two old crash tests)
 - rust-lang#136079 (compiler_fence: fix example)
 - rust-lang#136091 (Add some tracing to core bootstrap logic)
 - rust-lang#136097 (rustc_ast: replace some len-checks + indexing with slice patterns etc.)
 - rust-lang#136101 (triagebot: set myself on vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
- `check-pass` test for a MRE of rust-lang#135020
- fail test for rust-lang#135138
- switch to `TooGeneric` for checking CMSE fn signatures
- switch to `TooGeneric` for compute `SizeSkeleton` (for transmute)
- fix broken tests
@lukas-code
Copy link
Member

@FedericoBruzzone please do not push after this has been approved! This is already being tested in #136116 and your new commit won't get merged.

@bors r- (but the rollup can continue for now)

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 27, 2025
@FedericoBruzzone
Copy link
Contributor Author

@FedericoBruzzone please do not push after this has been approved! This is already being tested in #136116 and your new commit won't get merged.

@bors r- (but the rollup can continue for now)

Unfortunately I had this commit on master, I am working on another PR and mistakenly pushed :/

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 27, 2025
Rollup merge of rust-lang#135158 - FedericoBruzzone:master, r=lukas-code

Add `TooGeneric` variant to `LayoutError` and emit `Unknown`

What's in this PR?

- Add `TooGeneric` variant to `LayoutError` and emit `Unknown` one

With this PR these issues and their respective ICEs are resolved:
- fixes rust-lang#135020
- fixes rust-lang#135138
@lukas-code
Copy link
Member

Closing as this has been merged in #136116.

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
8 participants