Skip to content

Remove remaining mentions of Unique - #164573

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
maxdexh:unique-cleanup
Oct 24, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
maxdexh:unique-cleanup

Conversation

@maxdexh

@maxdexh maxdexh commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

View all comments

Removes the remaining mentions of Unique from the codebase

I didn't touch the standalone core_mini codegen examples that declare their own struct Unique because I don't know what they are intended to show, and also some of them have a very outdated version of the layout of Box (no allocators).

The only mentions of Unique I touched were the ones actually referring to core::ptr::unique::Unique.

cc #164146 (comment)

r? hanna-kruppe

@rustbot

rustbot commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/etc/gdb_providers.py

cc @Walnut356

Some changes occurred in src/etc/lldb_providers.py

cc @Walnut356

Some changes occurred in src/etc/natvis

cc @Walnut356

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 19, 2026
@rustbot

rustbot commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

hanna-kruppe is currently at their maximum review capacity.
They may take a while to respond.

Comment thread library/alloc/src/boxed.rs Outdated
// It's not possible to extract the inner Uniq directly from the Box,
// instead we cast it to a *const which aliases the Unique
// It's not possible to extract the inner pointer directly from the Box,
// instead we cast it to a *const which aliases it

@maxdexh maxdexh Oct 19, 2026 •

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.

Not entirely sure what this is saying (is it unsound to access the pointer of Box directly outside the destructor?) I'll just leave the comment's phrasing as-is for now, unless someone has a better idea.

View changes since the review

@asquared31415 asquared31415 Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The ptr field of Unique was inaccessible due to privacy, so this code uses the builtin box deref to get a pointer to the contents of the box.

(did some git history, this is ancient code from pre 1.0)

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.

Still a bit strange, Unique implemented Pointer too, but idk how this looked pre 1.0. Thanks! ^^

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like the original reason for this comment was #24144 (comment) which shouldn't be an issue any more. Let's just remove this comment entirely.

@maxdexh

maxdexh commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

@bors try jobs=test-aarch64-apple-1,test-x86_64-msvc-1

rust-bors Bot pushed a commit that referenced this pull request Oct 19, 2026
Remove remaining mentions of `Unique`


try-job: test-aarch64-apple-1
try-job: test-x86_64-msvc-1
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: aabcf41 (aabcf41e69b197cbaaac3e6117b5414020b1b0d9)
Base parent: 588c7e9 (588c7e92f931498b1552ee64cad77fb0344cabfa)

Comment thread src/etc/natvis/libcore.natvis

@hanna-kruppe hanna-kruppe left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread library/alloc/src/boxed.rs Outdated
// It's not possible to extract the inner Uniq directly from the Box,
// instead we cast it to a *const which aliases the Unique
// It's not possible to extract the inner pointer directly from the Box,
// instead we cast it to a *const which aliases it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like the original reason for this comment was #24144 (comment) which shouldn't be an issue any more. Let's just remove this comment entirely.

Comment thread src/etc/gdb_providers.py Outdated


def unwrap_unique_or_non_null(unique_or_nonnull):
def unwrap_boxraw_or_non_null(boxraw_or_nonnull):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm a bit worried that this change as-is trades one kind of confusing (what's "unique"?) for another (why BoxRaw mentions in String, VecDeque, etc.?). Also, it's debatable if we should even purge mentions of Unique from the debug providers as long as they're making an effort to be backwards compatible with versions where Unique still existed.

How about calling this unwrap_non_null_or_wrapper and leave a doc comment to the effect of this also handles BoxRaw and the previous Unique type, both of which have a pointer: NonNull field.
Plus a FIXME that functions + callers can be simplified once we no longer care about backcompat with Rust < 1.101 (or whatever it was where Unique was removed).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, it's debatable if we should even purge mentions of Unique from the debug providers as long as they're making an effort to be backwards compatible with versions where Unique still existed

I'd have to check again, but wasnt backwards compatibility broken when the field-retrieval-path of the String/ Vec pointer was changed in the previous patch?

It's not a huge deal, we technically dont have any kind of firm policy on backwards compat for these. I've mostly been informally keeping some since debuggers (e.g. codelldb) will generally pull from the stable toolchain instead of whatever toolchain was actually used to compile. While that's technically not our problem, it's usually not too much hassle and saves on bug reports.

I'll try to gather some opinions about a deprecation window or whatever for changes in the future. There might also be a way for us to print a warning when using visualizers that dont match the version the binary was compiled with.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes to natvis are breaking, but I don't think that has any compatibility concerns because natvis is embedded in the binary when it's linked, so it should always match the toolchain version.

The change to lldb_providers in #162804 should be backwards compatible, it changed several direct accesses to foo.pointer.pointer to unwrap_unique_or_non_null(foo) where foo was Unique before and is now NonNull. The gdb providers were already doing the latter before. I didn't find any other change to the providers in the previous PRs.

I'll try to gather some opinions about a deprecation window or whatever for changes in the future. There might also be a way for us to print a warning when using visualizers that dont match the version the binary was compiled with.

Thanks, some guidance for how to navigate these kind of changes would be great!

@Walnut356 Walnut356 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think that has any compatibility concerns because natvis is embedded in the binary when it's linked, so it should always match the toolchain version.

There is one minor footgun with that (and GDB too, since it works the same way), which is that the "embedding" is just a filepath pointing to the file in the toolchain install e.g. (compiled with cargo +1.90-x86_64-pc-windows-msvc build)

llvm-pdbutil pdb2yaml --all ".\target\debug\sample.pdb" | rg natvis
  - 'C:\Users\ant_b\.rustup\toolchains\1.90-x86_64-pc-windows-msvc\lib\rustlib\etc\libstd.natvis'
...

If you compile with stable and then update stable, the stable folder stays the same, so you can end up having an old binary point to new scripts:

llvm-pdbutil pdb2yaml --all ".\target\debug\sample.pdb" | rg natvis
  - 'C:\Users\ant_b\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\libstd.natvis'
...

That should be rare enough though not to matter, since most of the time peoples' IDE's will recompile before running the debugger anyway.

(as an aside, that footgun doesn't affect anything that uses #![debugger_visualizer] since that attribute does literally copypaste the script contents into the binary)

...i really need to document that somewhere lmao

The change to lldb_providers in #162804 should be backwards compatible, it changed several direct accesses to foo.pointer.pointer to unwrap_unique_or_non_null(foo) where foo was Unique before and is now NonNull.

Ah, excellent. I misread that patch a little. Thanks for the clarification 😄 I tested it just to be sure and it definitely is backwards compatible

@maxdexh maxdexh Oct 24, 2026 •

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.

nice, accidental backwards compatibility.

what do we do with the Uniques in natvis now (and what needs to change in this PR wrt the function here)?

Comment thread tests/ui/functions-closures/nullable-pointer-opt-closures.rs Outdated
Comment thread tests/ui/print_type_sizes/niche-filling.rs Outdated
@maxdexh

maxdexh commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

Gonna get around to this later, gotta help someone move a boulder up a hill crater

@maxdexh

maxdexh commented Oct 24, 2026

Copy link
Copy Markdown
Member Author

@rustbot ready

@hanna-kruppe

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 43f527a has been tentatively approved by hanna-kruppe

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 24, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #163270 (Allow simd types in improper_ctypes lint)
 - #164855 (Stop mangling rust_eh_personality again for now)
 - #153679 (When multiple traits are applicable for method, do not specialize main message to the first one that applied)
 - #164248 (Retroactively add missing stabilized APIs to relnotes)
 - #164573 (Remove remaining mentions of `Unique`)
 - #164824 (PassWrapper: stop setting Options.ExceptionModel on LLVM 24)
 - #164844 (Add tracking issue for `#![feature(char_is_xid)]`)
@rust-bors
rust-bors Bot merged commit 55447fe into rust-lang:main Oct 24, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 24, 2026
Rollup merge of #164573 - maxdexh:unique-cleanup, r=hanna-kruppe

Remove remaining mentions of `Unique`

Removes the remaining mentions of `Unique` from the codebase

I didn't touch the standalone `core_mini` codegen examples that declare their own `struct Unique` because I don't know what they are intended to show, and also some of them have a very outdated version of the layout of `Box` (no allocators).

The only mentions of `Unique` I touched were the ones actually referring to `core::ptr::unique::Unique`.

cc #164146 (comment)

r? hanna-kruppe
@maxdexh
maxdexh deleted the unique-cleanup branch October 24, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants