-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
layout computation: gracefully handle unsized types in unexpected locations #129970
Conversation
The Miri subtree was changed cc @rust-lang/miri rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r-a side
1427108
to
10aabc4
Compare
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri |
☔ The latest upstream changes (presumably #130415) made this pull request unmergeable. Please resolve the merge conflicts. |
10aabc4
to
6974501
Compare
For structs that cannot be unsized, the layout algorithm sometimes moves unsized fields to the end of the struct, which circumvented the error for unexpected unsized fields and returned an unsized layout anyway. This commit makes it so that the unexpected unsized error is always returned for structs that cannot be unsized, allowing us to remove an old hack and fixing some old ICE.
4edbd93
to
20d2414
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
r=me when green |
@bors r+ rollup=never |
☀️ Test successful - checks-actions |
Finished benchmarking commit (e2dc1a1): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -2.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary -0.6%, secondary 5.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 760.616s -> 760.716s (0.01%) |
This PR reworks the layout computation to eagerly return an error when encountering an unsized field where a sized field was expected, rather than delaying a bug and attempting to recover a layout. This is required, because with trivially false where clauses like
[T]: Sized
, any field can possible be an unsized type, without causing a compile error.Since this PR removes the
delayed_bug
method from theLayoutCalculator
trait, it essentially becomes the same as theHasDataLayout
trait, so I've also refactored theLayoutCalculator
to be a simple wrapper struct around a type that implementsHasDataLayout
.The majority of the diff is whitespace changes, so viewing with whitespace ignored is advised.
implements #123169 (comment)
r? @compiler-errors or compiler
fixes #123134
fixes #124182
fixes #126939
fixes #127737