-
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
Value mangling #61486
Comments
cc #60705 |
bools work too, don't they? #61383 (comment) |
@est31: the current implementation of const generics supports more types than the mangle supports, which is something we need to address. |
It's unclear what "initial version of const generics" means at this point. We're not ready to talk about stabilisation yet. Hopefully we'll be able to discuss proper mangling soon. I know @eddyb already has some ideas. |
Quoting @eddyb from Discord channel #compiler for my own benefit if nothing else:
|
Such printing should probably share the walking logic with the const validator (https://github.com/rust-lang/rust/blob/master/src/librustc_mir/interpret/validity.rs), because both need to do the same thing. |
These tests fail with
Maybe we should start adding revisions that use More specifically, what I did to test this was replace rust/src/librustc_session/options.rs Line 953 in 42ce9b4
|
I've just noticed a potential issue with the syntax: As a type, But for a constant integer, we encode a similar situation (e.g. Now, But if we start including ADTs, we might need, for const generics of type How would you encode an erased The good news is we can still add a general placeholder, either just Speaking of which, the current syntax is also redundant in that we print all the integers the same, so we don't really need to encode which one it is, just that the hex nibbles should be printed as an integer. |
ty/print: pretty-print constant aggregates (arrays, tuples and ADTs). Oddly enough, we don't have any UI tests showing this off in types, only `mir-opt` tests. However, the pretty form should show up in the test output diff of rust-lang#71018, if this PR is merged first. <hr/> Examples of before/after: |`Option<bool>`| |:-:| |`{transmute(0x01): std::option::Option<bool>}`| | :sparkles: ↓↓↓ :sparkles: | |`std::option::Option::<bool>::Some(true)`| | `RawVec<u32>` | |:-:| | `ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>`| | :sparkles: ↓↓↓ :sparkles: | |`alloc::raw_vec::RawVec::<u32> { ptr: std::ptr::Unique::<u32> { pointer: {0x4 as *const u32}, _marker: std::marker::PhantomData::<u32> }, cap: 0usize, alloc: std::alloc::Global }`| <hr/> This PR is a prerequisite for rust-lang#61486, *sort of*, in that we need to be able to pretty-print values in order to even consider how we might mangle them. We still don't have pretty-printing for constants of reference types, @oli-obk has the necessary support logic in a PR but I didn't want to interfere with that. <hr/> Each commit should be reviewed separately, as I've fixed a couple deficiencies along the way. r? @oli-obk cc @rust-lang/wg-mir-opt @varkor @yodaldevoid
We're permitting signed integers for |
Signed integers and |
@michaelwoerister It's been resolved already (as part of #77554): rust/compiler/rustc_symbol_mangling/src/v0.rs Lines 541 to 550 in bcd696d
That EDIT: the grammar should be updated too. |
@michaelwoerister Actually, to answer the more interesting question: So the current implementation only supports Before I realized we'd more or less have to encode "a tree of ADT constructors" for more interesting values, I still thought we could generally do There are too many factors that make it almost impossible, and also quite undesireable, to have demanglers understand how data is laid out. So only |
In #87082 (comment) I wrote this, which seems like it would be useful to have in this thread:
|
First attempt at previously suggested constant value mangling approaches, is now up at #87194 (including grammar). |
…woerister,oli-obk rustc_symbol_mangling: support structural constants and &str in v0. This PR should unblock rust-lang#85530 (except for float `const` generics, which AFAIK should've never worked). (cc `@tmiasko` could the rust-lang#85530 (comment) failures be retried with a quick crater "subset" run of this PR + changing the default to `v0`? Just to make sure I didn't miss anything other than the floats) The encoding is the one suggested before in e.g. rust-lang#61486 (comment), tho this PR won't by itself finish rust-lang#61486, before closing that we'd likely want to move to `@oli-obk's` "valtrees" (i.e. rust-lang#83234 and other associated work). <hr> **EDITs**: 1. switched unit/tuple/braced-with-named-fields `<const-fields>` prefixes from `"u"`/`"T"`/`""` to `"U"`/`"T"`/`"S"` to avoid the ambiguity reported by `@tmiasko` in rust-lang#87194 (comment). 2. `rustc-demangle` PR: rust-lang/rustc-demangle#55 3. RFC amendment PR: rust-lang/rfcs#3161 * also removed the grammar changes included in that PR, from this description 4. added tests (temporarily using my fork of `rustc-demangle`) <hr> r? `@michaelwoerister`
to my knowledge this is now integrated in v0 mangling? @eddyb can this be closed? |
An implementation is complete, but I would block this on the RFC PR getting merged (see its discussion): |
For const generics, we will eventually allow arbitrary
structural_match
values as generic arguments. Thus, we need to figure out how to mangle them. At the moment, only unsigned integers are supported.min_const_generics
bool
(Permit ty::Bool in const generics for v0 mangling #77452)char
adt_const_params
cc @eddyb @yodaldevoid
The text was updated successfully, but these errors were encountered: