The Wayback Machine - https://web.archive.org/web/20210827035958/https://github.com/rust-lang/rust/pull/87194
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

rustc_symbol_mangling: support structural constants and &str in v0. #87194

Merged
merged 10 commits into from Aug 26, 2021

Conversation

@eddyb
Copy link
Member

@eddyb eddyb commented Jul 16, 2021

This PR should unblock #85530 (except for float const generics, which AFAIK should've never worked).
(cc @tmiasko could the #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. #61486 (comment), tho this PR won't by itself finish #61486, before closing that we'd likely want to move to @oli-obk's "valtrees" (i.e. #83234 and other associated work).


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 #87194 (comment).

  2. rustc-demangle PR: alexcrichton/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)


r? @michaelwoerister

@michaelwoerister
Copy link
Member

@michaelwoerister michaelwoerister commented Jul 19, 2021

Nice! Thanks for moving on that so quickly, @eddyb! For reference, here is a link to the current grammar: https://github.com/rust-lang/rfcs/blob/master/text/2603-rust-symbol-name-mangling-v0.md#syntax-of-mangled-names

@michaelwoerister
Copy link
Member

@michaelwoerister michaelwoerister commented Jul 19, 2021

And here is the relevant part of the grammar that this PR will supersede:

<const> = <type> <const-data>
        | "p" // placeholder, shown as _
        | <backref>

// The encoding of a constant depends on its type. Integers use their value,
// in base 16 (0-9a-f), not their memory representation. Negative integer
// values are preceded with "n". The bool value false is encoded as `0_`, true
// value as `1_`. The char constants are encoded using their Unicode scalar
// value.
<const-data> = ["n"] {<hex-digit>} "_"

@michaelwoerister
Copy link
Member

@michaelwoerister michaelwoerister commented Jul 21, 2021

This looks great!

So now we just need support for this to land in rustc-demangle so that we can add test cases, right?

@tmiasko

This comment has been hidden.

@tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Jul 21, 2021

I extended LLVM Rust demangler with support for proposed grammar. Apart from issue with u in <const-fields>, everything else seems good to me. Special casing &str to avoid printing &*".." was easy enough.

Since you are also updating the test cases here. I remember having to change the src/test/codegen/vec-shrink-panic.rs when enabling v0 by default. Is this no longer the case?

@eddyb

This comment has been hidden.

@michaelwoerister
Copy link
Member

@michaelwoerister michaelwoerister commented Jul 22, 2021

The first and third production can start with u because of Punycode encoded identifiers.

Great catch, @tmiasko!

@tmiasko

This comment has been hidden.

@eddyb

This comment has been hidden.

@bors

This comment has been hidden.

@pcwalton
Copy link
Contributor

@pcwalton pcwalton commented Aug 4, 2021

What remains to be done here? Can I help move this along somehow?

@michaelwoerister
Copy link
Member

@michaelwoerister michaelwoerister commented Aug 9, 2021

If I understand correctly the sequence for making progress here is:

Does that sound right, @eddyb & @tmiasko?

EDIT: Only the first three steps are needed to merge this PR.

@eddyb
Copy link
Member Author

@eddyb eddyb commented Aug 9, 2021

Apologies for not leaving a comment with the status, I've had an in-progress rustc-demangle branch (with necessary prerequsites - though I've landed some of them separately already - and the hardest parts like str demangling) for the past week or two, I've only not submitted yet because a few other things came up. I'll try to wrap it up soon.

@eddyb
Copy link
Member Author

@eddyb eddyb commented Aug 10, 2021

Demangling PR up at alexcrichton/rustc-demangle#55 - next step is submitting the RFC amendment, I'll try to get to that later today.

@eddyb
Copy link
Member Author

@eddyb eddyb commented Aug 10, 2021

I've opened the RFC amendment PR (rust-lang/rfcs#3161 - should someone FCP it?) and just pushed a few commits with symbol-names tests.

We've already done a crater run through #85530, so I think we're only blocked on the RFC amendment (and reviews, I guess? if any are left).

@rust-log-analyzer

This comment has been hidden.

@eddyb

This comment has been hidden.

@eddyb eddyb force-pushed the eddyb:const-value-mangling branch from 27720a2 to b4fcf1b Aug 24, 2021
@eddyb eddyb marked this pull request as ready for review Aug 24, 2021
@oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Aug 24, 2021

Copy link
Member

@michaelwoerister michaelwoerister left a comment

From my point of view this looks good to go! Maybe @oli-obk wants to have a closer look at the interactions with const-eval?

@oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Aug 26, 2021

@bors r=michaelwoerister,oli-obk

@bors
Copy link
Contributor

@bors bors commented Aug 26, 2021

📌 Commit b4fcf1b has been approved by michaelwoerister,oli-obk

@eddyb
Copy link
Member Author

@eddyb eddyb commented Aug 26, 2021

@bors rollup=never

@bors
Copy link
Contributor

@bors bors commented Aug 26, 2021

Testing commit b4fcf1b with merge 707a1c4...

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 26, 2021
…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: alexcrichton/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`
@rust-log-analyzer

This comment has been hidden.

@bors
Copy link
Contributor

@bors bors commented Aug 26, 2021

💔 Test failed - checks-actions

@eddyb
Copy link
Member Author

@eddyb eddyb commented Aug 26, 2021

Hopefully #87194 (comment) is fixed by the new commit to compiletest.

@bors r=michaelwoerister,oli-obk

@bors
Copy link
Contributor

@bors bors commented Aug 26, 2021

📌 Commit 24526bb has been approved by michaelwoerister,oli-obk

@bors
Copy link
Contributor

@bors bors commented Aug 26, 2021

Testing commit 24526bb with merge ad02dc4...

@bors
Copy link
Contributor

@bors bors commented Aug 26, 2021

☀️ Test successful - checks-actions
Approved by: michaelwoerister,oli-obk
Pushing ad02dc4 to master...

@bors bors merged commit ad02dc4 into rust-lang:master Aug 26, 2021
11 checks passed
11 checks passed
@github-actions
PR (mingw-check, ubuntu-latest-xl)
Details
@github-actions
PR (x86_64-gnu-llvm-10, ubuntu-latest-xl)
Details
@github-actions
PR (x86_64-gnu-tools, 1, ubuntu-latest-xl)
Details
@github-actions
auto
Details
@github-actions
master
Details
@github-actions
bors build finished
Details
@github-actions
bors build finished
Details
@github-actions
bors build finished
Details
@github-actions
bors build finished
Details
@bors
homu Test successful
Details
@rustbot rustbot added this to the 1.56.0 milestone Aug 26, 2021
@eddyb eddyb deleted the eddyb:const-value-mangling branch Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet