Skip to content

[debuginfo] Emit usize and isize as typedefs - #163104

Open
Walnut356 wants to merge 1 commit into
rust-lang:mainfrom
Walnut356:i_usize_typedef
Open

Walnut356 wants to merge 1 commit into
rust-lang:mainfrom
Walnut356:i_usize_typedef

Conversation

@Walnut356

@Walnut356 Walnut356 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

See: llvm/llvm-project#196812

TL;DR sidesteps a name collision issue that affects generics, e.g. S<u64> and S<usize> resolving as the same type.

This is accomplished by wrapping an existing primitive node in a usize/isize typedef instead.

I'd love to output typedefs for all the primitive types too, so LLDB displays the type names rust-style, but I've got a couple worries with that. Firstly, GDB doesn't seem to like it w.r.t. enums? IIRC it's because of a small difference in how GDB treats typedefs compared to LLDB. I'm like 80% sure it's hard-coded in GDB itself, so it's not something I want to touch atm.

Breakpoint 1, borrowed_enum::main () at tests/debuginfo/borrowed-enum.rs:67
67          zzz(); // #break
$1 = <error reading variable: Could not find active enum variant>
$2 = borrowed_enum::ABC::TheB(0, 286331153, 286331153)
$3 = borrowed_enum::Univariant::TheOnlyCase(4820353753753434)

Secondly, I'm not entirely sure it's a good idea to have both a type and a typedef with the exact same name in the first place. I could easily imagine that causing some similar issues to the one we're trying to solve.

This also includes a small extention to the Rc test to ensure we can read both Rc<u64> and Rc<usize>. Without this change, the second v command would fail to materialize any value:

...
(lldb) v rc_u64
(alloc::rc::Rc<unsigned long, alloc::alloc::Global>) rc_u64 = strong=1, weak=0 { value = 10 } 
(lldb) v rc_usize

error: Invalid type: Cannot determine size

(lldb) quit

@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Sep 21, 2026
@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 Sep 21, 2026
@rustbot

rustbot commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

r? @chenyukang

rustbot has assigned @chenyukang.
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 77 candidates
  • Random selection from 18 candidates

@chenyukang

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned mati865 and unassigned chenyukang Sep 25, 2026
@Walnut356

Copy link
Copy Markdown
Contributor Author

(#163098 means i need to modify the tests again before this gets merged)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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