Skip to content

Clarify ty::List#154648

Merged
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
nnethercote:clarify-ty-List
Apr 1, 2026
Merged

Clarify ty::List#154648
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
nnethercote:clarify-ty-List

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

ty::List is an unusual type. This commit clarifies some things about it. Details in individual commits.

r? @cuviper

Checking that they really do use thin pointers.
- Add some explanatory comments.
- Rename `OpaqueListContents` as `ExternTy`. I've always found both the
  "opaque" and "contents" parts of this name to be confusing. Calling it
  `ExternTy` makes it clear that all that matters is it's an extern
  type.
- Merge the `List` and `ListWithCachedTypeInfo` impls by referring to
  the shared underlying type, `RawList`. This required increasing the
  visibility of `RawList`.

- Explain why a separate impl is needed for `RawList`.

- Remove an incorrect FIXME comment. Fat reference types will always
  need a separate impl. (To be sure, one could use `T: ?Sized` to merge
  the impls for `&T` and `&[T]` and it would compile but it would behave
  incorrectly because `&T` needs one word of storage and `&[T]` needs
  two words of storage. I tried it and it did not go well.)
@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 Mar 31, 2026
@cuviper
Copy link
Copy Markdown
Member

cuviper commented Apr 1, 2026

Works for me!

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 1, 2026

📌 Commit 64cf1ec has been approved by cuviper

It is now in the queue for this repository.

@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 Apr 1, 2026
Comment on lines -112 to -113
// FIXME(#151565): Using `T: ?Sized` here should let us remove the separate
// impls for fat reference types.
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.

Here I was thinking we could replace size_of::<&'_ ()>() with size_of::<&'_ T>() and just get the correct size automatically, but that appears to not actually work smoothly since it then complains about needing #![feature(generic_const_exprs)].

So removing this FIXME is probably the right call.

rust-bors bot pushed a commit that referenced this pull request Apr 1, 2026
Rollup of 5 pull requests

Successful merges:

 - #152935 (c-variadic: error when we can't guarantee that the backend does the right thing)
 - #153207 (std::net: clamp linger timeout value to prevent silent truncation.)
 - #154592 (Fix `mismatched_lifetime_syntaxes` suggestions for hidden path lifetimes)
 - #154643 (fix pin docs)
 - #154648 (Clarify `ty::List`)
rust-timer added a commit that referenced this pull request Apr 1, 2026
Rollup merge of #154648 - nnethercote:clarify-ty-List, r=cuviper

Clarify `ty::List`

`ty::List` is an unusual type. This commit clarifies some things about it. Details in individual commits.

r? @cuviper
@rust-bors rust-bors bot merged commit 18f8cd2 into rust-lang:main Apr 1, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 1, 2026
@nnethercote nnethercote deleted the clarify-ty-List branch April 1, 2026 09:29
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants