Skip to content

Fix a splat legacy demangling display bug - #160050

Open
teor2345 wants to merge 4 commits into
rust-lang:mainfrom
teor2345:splat-legacy-demangle
Open

Fix a splat legacy demangling display bug#160050
teor2345 wants to merge 4 commits into
rust-lang:mainfrom
teor2345:splat-legacy-demangle

Conversation

@teor2345

@teor2345 teor2345 commented Jul 28, 2026

Copy link
Copy Markdown
Member

View all comments

Tracking issue: #153629

This PR fixes a splat legacy demangling display bug, where the comma is in the wrong place in the argument list.

It also does a cleanup from @folkertdev's PR #159643 review:

@rustbot label +F-splat +C-bug +A-name-mangling

Edit: this PR now accepts 8-16 character crate hashes in normalisation regexes, so it no longer depends on rust-lang/rustc-demangle#94 being reviewed, merged, and updated in rustc's deps

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 28, 2026
@rustbot

rustbot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

r? @camelid

rustbot has assigned @camelid.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 19 candidates

@rustbot rustbot added A-name-mangling Area: Name mangling / decoration aka symbol mangling C-bug Category: This is a bug. F-splat `#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629 labels Jul 28, 2026
Comment thread compiler/rustc_middle/src/ty/print/pretty.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 28, 2026
@rustbot

This comment was marked as resolved.

@teor2345
teor2345 force-pushed the splat-legacy-demangle branch from c82af0a to 980ae5d Compare July 29, 2026 01:15
@rustbot

This comment has been minimized.

@teor2345

Copy link
Copy Markdown
Member Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 29, 2026
@rust-log-analyzer

This comment has been minimized.

@teor2345
teor2345 force-pushed the splat-legacy-demangle branch from 980ae5d to 1099c87 Compare July 29, 2026 05:42
// there are arguments before the splat.
// FIXME(splat): if splatting becomes part of the type, we can remove this hack
if index > 0 {
write!(self, ",")?;

@camelid camelid Jul 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a space after the comma too.

Suggested change
write!(self, ",")?;
write!(self, ", ")?;

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing unfortunately depends on the pretty-printing context, so I think I'll need to modify the trait definition and implementers. But it should be less code overall, which is nice.

/// Prints comma-separated elements.
fn comma_sep<T>(&mut self, mut elems: impl Iterator<Item = T>) -> Result<(), PrintError>
where
T: Print<Self>,
{
if let Some(first) = elems.next() {
first.print(self)?;
for elem in elems {
self.write_str(", ")?;

// Identical to `PrettyPrinter::comma_sep` except there is no space after each comma.
fn comma_sep<T>(&mut self, mut elems: impl Iterator<Item = T>) -> Result<(), PrintError>
where
T: Print<Self>,
{
if let Some(first) = elems.next() {
first.print(self)?;
for elem in elems {
self.write_str(",")?;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up adding a comma_sep_has_space method, refactoring the near-duplicate comma_sep methods, and adding comments where we might want to do a similar fix in future.

(We don't currently have non-mangling pretty-printing tests for splat, and that's ok, it's an incomplete feature.)

@rustbot ready

Comment thread compiler/rustc_middle/src/ty/print/pretty.rs Outdated
@camelid camelid added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 29, 2026
@teor2345
teor2345 force-pushed the splat-legacy-demangle branch from 1099c87 to 149a65c Compare July 30, 2026 00:52
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 30, 2026
@teor2345
teor2345 force-pushed the splat-legacy-demangle branch from 149a65c to 9f6099c Compare July 31, 2026 03:28
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@teor2345
teor2345 force-pushed the splat-legacy-demangle branch from 8db7925 to 511d292 Compare July 31, 2026 05:30
@rust-log-analyzer

This comment has been minimized.

@teor2345

teor2345 commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

Failed due to a 15 digit crate hash in v0 demangling, which might be a bug to fix in demangling. This failure isn't splat related, it might happen on 1/16 of PRs (or changes to this test) anyway.

Asked for advice here:
https://rust-lang.zulipchat.com/#narrow/channel/386786-rustc-codegen-gcc/topic/crate.20hash.20drops.20leading.20zeroes/with/613817866

@teor2345

This comment was marked as resolved.

@camelid camelid added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 31, 2026
@teor2345

Copy link
Copy Markdown
Member Author

It looks like we're stalled on the rustc-demangle side here, so I might redesign these tests so they're not blocked on it.

@rustbot

This comment was marked as resolved.

@teor2345
teor2345 force-pushed the splat-legacy-demangle branch from 2a26add to 707e045 Compare September 3, 2026 19:26
@rustbot

rustbot commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

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.

@rust-log-analyzer

This comment has been minimized.

@teor2345
teor2345 force-pushed the splat-legacy-demangle branch from 707e045 to e578f5c Compare September 3, 2026 20:13
@rust-log-analyzer

This comment has been minimized.

@teor2345
teor2345 force-pushed the splat-legacy-demangle branch from e578f5c to 2a313d7 Compare September 3, 2026 20:56
@teor2345

teor2345 commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@rustbot ready

I changed this PR to accept 8-16 character crate hashes in normalisation regexes, so it no longer depends on rust-lang/rustc-demangle#94 being reviewed, merged, and updated in rustc's deps. This is consistent with the normalisation approach taken in the UI test framework.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-name-mangling Area: Name mangling / decoration aka symbol mangling C-bug Category: This is a bug. F-splat `#![feature(splat)]` https://github.com/rust-lang/rust/issues/153629 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants