Implement arbitrary casts in custom mir - #160860
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
bb0a712 to
a596f67
Compare
|
I am on vacation this week, so this will have to wait a bit. Or maybe @saethlin has time to look at it earlier. |
|
This is not done yet anyway, I still gotta figure out how to unflatten the enum and write some tests. But thanks for letting me know :) |
|
I completely forgot about this thing, I'll get back to it later or tomorrow. |
a596f67 to
48141ff
Compare
This comment has been minimized.
This comment has been minimized.
1b4e3de to
a85dda1
Compare
| ClosureFnPointer(Safety), | ||
| MutToConstPointer, | ||
| ArrayToPointer, | ||
| UnsizePointee, |
There was a problem hiding this comment.
Note: If this is named Unsize, then std::marker::Unsized doesn't get abbreviated to Unsize in diagnostics anymore.
There was a problem hiding this comment.
then std::marker::Unsized doesn't get abbreviated to Unsize in diagnostics anymore.
Did you mean "abbreviated to Unsized"?
Please file an issue for this... it is strange how adding unstable items changes diagnostics for stable code.
There was a problem hiding this comment.
to my knowledge we already do this correctly, it affects nightly code, but a stable compiler will not consider unstable items in the diagnostics
|
I'm afraid this is a bit too much for me right now, sorry. |
Implement arbitrary casts in custom mir [See zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/extending.20custom.20MIR/with/613727602) Implement custom casts using an enum in `intrinsics::mir` that closely matches the `CastKind` enum in the compiler. We have 5 different ways to cast in custom MIR, 3 with functions (which hard code a cast kind), 1 implicit coerce (which only does subtyping i think), 1 with `as` (which does a few more). They are all different and the error messages don't tell you what to do. Some are (i think) not possible at all. This came up [while testing miri](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Valdity.20checks.20for.20references/near/613662285). We currently have to guess the casting syntax until we find the one that generates the MIR we want. This PR changes that by adding a custom mir operation that allows picking an arbitrary cast. r? RalfJung
|
💔 I suspect this PR failed tests as part of a rollup After fixing the problem, consider running a try job for the failed job before re-approving. Link to failure: #162596 (comment) |
|
This pull request was unapproved. This PR was contained in a rollup (#162596), which was unapproved. |
|
Yeah, the symbol numbering stuff again... |
|
So this is the same thing as what happened earlier: #160860 (comment) For some reason, adding symbols sometimes causes the output on that test to gain an extra line break (at least that's what I think is happening) |
a85dda1 to
676862d
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
I just blessed the output, idk what else I can do about this /shrug |
|
That test has So there's a lot more that changes in that test and it gets normalized away so we don't see it. The normalization is incomplete however so we see the newline change. |
|
@bors r+ |
Implement arbitrary casts in custom mir [See zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/extending.20custom.20MIR/with/613727602) Implement custom casts using an enum in `intrinsics::mir` that closely matches the `CastKind` enum in the compiler. We have 5 different ways to cast in custom MIR, 3 with functions (which hard code a cast kind), 1 implicit coerce (which only does subtyping i think), 1 with `as` (which does a few more). They are all different and the error messages don't tell you what to do. Some are (i think) not possible at all. This came up [while testing miri](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Valdity.20checks.20for.20references/near/613662285). We currently have to guess the casting syntax until we find the one that generates the MIR we want. This PR changes that by adding a custom mir operation that allows picking an arbitrary cast. r? RalfJung
…uwer Rollup of 11 pull requests Successful merges: - #162520 (Refactor `HygieneEncodeContext`) - #154373 (Skip linting unused braces for FunctionArg and MethodArg context for 2024 later ) - #160023 (Refactor the way cg_ssa handles indirect returns (returns via `sret`) — Take 2) - #160860 (Implement arbitrary casts in custom mir) - #161482 (Use attribute parser for `#[non_exhaustive]` attribute check) - #161867 (deeper `rustc_builtin_macros` cleanups) - #162099 (small refactor of doc attribute arguments warnings) - #162541 (split `macroless_generic_const_args` in two) - #162549 (The fuchsia team maintains `riscv64gc-unknown-fuchsia`) - #162577 (Fix `i686-pc-windows-msvc` platform support docs and target spec metadata) - #162624 (regression test for opaque field projection in closure capture)
Rollup merge of #160860 - maxdexh:custom-mir-casts, r=oli-obk Implement arbitrary casts in custom mir [See zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/extending.20custom.20MIR/with/613727602) Implement custom casts using an enum in `intrinsics::mir` that closely matches the `CastKind` enum in the compiler. We have 5 different ways to cast in custom MIR, 3 with functions (which hard code a cast kind), 1 implicit coerce (which only does subtyping i think), 1 with `as` (which does a few more). They are all different and the error messages don't tell you what to do. Some are (i think) not possible at all. This came up [while testing miri](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/Valdity.20checks.20for.20references/near/613662285). We currently have to guess the casting syntax until we find the one that generates the MIR we want. This PR changes that by adding a custom mir operation that allows picking an arbitrary cast. r? RalfJung
View all comments
See zulip
Implement custom casts using an enum in
intrinsics::mirthat closely matches theCastKindenum in the compiler.We have 5 different ways to cast in custom MIR, 3 with functions (which hard code a cast kind), 1 implicit coerce (which only does subtyping i think), 1 with
as(which does a few more). They are all different and the error messages don't tell you what to do. Some are (i think) not possible at all.This came up while testing miri. We currently have to guess the casting syntax until we find the one that generates the MIR we want. This PR changes that by adding a custom mir operation that allows picking an arbitrary cast.
r? RalfJung