Handle non-integer const generic parameters in debuginfo type names.#87082
Conversation
|
Do you think it makes sense to prefix the hash (e.g., even hx.... instead of 0x....)? That way we avoid it looking like an integer argument/const generic, which may be confusing to folks encountering this... Otherwise I likely don't have much insight into a good way to actually print out more types appropriately -- it seems like we'd either want to find something general (e.g., see if the Ty of the const implements Debug and try to const-eval that -- seems error prone at least until we have const trait impls)... I think it'd be interesting to see what C++ does here, do you know? |
|
Funnily enough this is pretty much what I suggested in #60705 (comment) - I do agree with @Mark-Simulacrum that they should not look like integers. One of the thoughts I had was |
|
Using a name that differentiates it from an integer is a good idea - both to avoid user confusion and prevent collisions. I'd prefer if we picked a name that somehow indicated that it is a const generic (and not a weirdly named type), maybe |
|
The hash is of the const value, so I wouldn't use "const generic", but sadly |
|
Not sure if I really have a ton of context here, but would it be helpful to also add the type? |
|
Thanks for all the feedback! I like
C++ doesn't really seem to allow complex constant values as template argument. It does support pointers and references to such objects. Here's an example: https://godbolt.org/z/718M69TGv. Unfortunately, I wasn't able to get godbolt to print debuginfo but when compiling this locally, I get So GCC does add the type (as @JulianKnodt suggests) while the others don't. Since the length of these names seems to affect performance during later compilation steps, I'd opt for not adding the type. |
Not really, see #61486 - tho my preferred design doesn't seem to be explained as part of the discussion. I also wish #83234 had more details, but I can try to explain these "(pure) value trees". We only want to ever allow type-level constants (such as those passed to
(cc @oli-obk - did I miss anything?) We already have the leaves, what's lacking in the mangling is the second part (the ADTs) - it's not that much design space, since e.g. |
7092618 to
da56618
Compare
I'm doing that in rust-lang/rustc-dev-guide#1097, but I should probably at least document the |
|
I've update the PR to emit integers and booleans directly and everything else gets emitted as |
|
r=me unless you want to wait on other reviews |
|
@bors r=oli-obk,wesleywiser rollup |
|
📌 Commit da56618 has been approved by |
…-type-names-fix, r=oli-obk,wesleywiser Handle non-integer const generic parameters in debuginfo type names. This PR fixes an ICE introduced by rust-lang#85269 which started emitting const generic arguments for debuginfo names but did not cover the case where such an argument could not be evaluated to a flat string of bits. The fix implemented in this PR is very basic: If `try_eval_bits()` fails for the constant in question, we fall back to generating a stable hash of the constant and emit that instead. This way we get a (virtually) unique name and side step the problem of generating a string representation of a potentially complex value. The downside is that the generated name will be rather opaque. E.g. the regression test adds a function `const_generic_fn_non_int<()>` which is then rendered as `const_generic_fn_non_int<{CONST#fe3cfa0214ac55c7}>`. I think it's an open question how to deal with this more gracefully. I'd be interested in ideas on how to do this better. r? `@wesleywiser` cc `@dpaoliello` (do you see any problems with this approach?) cc `@Mark-Simulacrum` & `@nagisa` (who I've seen comment on debuginfo issues recently -- anyone else?) Fixes rust-lang#86893
…-type-names-fix, r=oli-obk,wesleywiser Handle non-integer const generic parameters in debuginfo type names. This PR fixes an ICE introduced by rust-lang#85269 which started emitting const generic arguments for debuginfo names but did not cover the case where such an argument could not be evaluated to a flat string of bits. The fix implemented in this PR is very basic: If `try_eval_bits()` fails for the constant in question, we fall back to generating a stable hash of the constant and emit that instead. This way we get a (virtually) unique name and side step the problem of generating a string representation of a potentially complex value. The downside is that the generated name will be rather opaque. E.g. the regression test adds a function `const_generic_fn_non_int<()>` which is then rendered as `const_generic_fn_non_int<{CONST#fe3cfa0214ac55c7}>`. I think it's an open question how to deal with this more gracefully. I'd be interested in ideas on how to do this better. r? ``@wesleywiser`` cc ``@dpaoliello`` (do you see any problems with this approach?) cc ``@Mark-Simulacrum`` & ``@nagisa`` (who I've seen comment on debuginfo issues recently -- anyone else?) Fixes rust-lang#86893
…-type-names-fix, r=oli-obk,wesleywiser Handle non-integer const generic parameters in debuginfo type names. This PR fixes an ICE introduced by rust-lang#85269 which started emitting const generic arguments for debuginfo names but did not cover the case where such an argument could not be evaluated to a flat string of bits. The fix implemented in this PR is very basic: If `try_eval_bits()` fails for the constant in question, we fall back to generating a stable hash of the constant and emit that instead. This way we get a (virtually) unique name and side step the problem of generating a string representation of a potentially complex value. The downside is that the generated name will be rather opaque. E.g. the regression test adds a function `const_generic_fn_non_int<()>` which is then rendered as `const_generic_fn_non_int<{CONST#fe3cfa0214ac55c7}>`. I think it's an open question how to deal with this more gracefully. I'd be interested in ideas on how to do this better. r? ```@wesleywiser``` cc ```@dpaoliello``` (do you see any problems with this approach?) cc ```@Mark-Simulacrum``` & ```@nagisa``` (who I've seen comment on debuginfo issues recently -- anyone else?) Fixes rust-lang#86893
da56618 to
a4e24c6
Compare
|
Fixed the test case. @bors r=oli-obk,wesleywiser rollup=never |
|
📌 Commit a4e24c6149c47922dbb5e7cf345cd35c05881edf has been approved by |
|
⌛ Testing commit a4e24c6149c47922dbb5e7cf345cd35c05881edf with merge d2a86a10d3d68ade9ac91fae90b0a5dd57d13b9f... |
This comment has been minimized.
This comment has been minimized.
|
💔 Test failed - checks-actions |
|
Looks like CDB prints the functions in a different order now. |
a4e24c6 to
ac528ce
Compare
ac528ce to
28343be
Compare
|
@bors r=oli-obk,wesleywiser rollup=never |
|
📌 Commit 28343be has been approved by |
|
☀️ Test successful - checks-actions |
This PR fixes an ICE introduced by #85269 which started emitting const generic arguments for debuginfo names but did not cover the case where such an argument could not be evaluated to a flat string of bits.
The fix implemented in this PR is very basic: If
try_eval_bits()fails for the constant in question, we fall back to generating a stable hash of the constant and emit that instead. This way we get a (virtually) unique name and side step the problem of generating a string representation of a potentially complex value.The downside is that the generated name will be rather opaque. E.g. the regression test adds a function
const_generic_fn_non_int<()>which is then rendered asconst_generic_fn_non_int<{CONST#fe3cfa0214ac55c7}>. I think it's an open question how to deal with this more gracefully.I'd be interested in ideas on how to do this better.
r? @wesleywiser
cc @dpaoliello (do you see any problems with this approach?)
cc @Mark-Simulacrum & @nagisa (who I've seen comment on debuginfo issues recently -- anyone else?)
Fixes #86893