Skip to content

Implement AsMut<T> and AsRef<T> for !. - #161253

Open
kpreid wants to merge 1 commit into
rust-lang:mainfrom
kpreid:neverref
Open

Implement AsMut<T> and AsRef<T> for !.#161253
kpreid wants to merge 1 commit into
rust-lang:mainfrom
kpreid:neverref

Conversation

@kpreid

@kpreid kpreid commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

This will allow e.g. &[!] to satisfy &[T] where T: AsRef<str>. It follows the recommendation from the never documentation:

When writing your own traits, ! should have an impl whenever there is an obvious impl which doesn’t panic!.

https://doc.rust-lang.org/1.97.1/std/primitive.never.html#-and-traits

Tracking issue for never: #35121
(This change has no ACP or tracking issue of its own; I assume it is simple enough that T-libs-api can just accept or reject this PR, and the implementation will be stable when ! is stable.)

@rustbot label -T-libs +T-libs-api +F-never_type

This will allow e.g. `&[!]` to satisfy `&[T] where T: AsRef<str>`.
It follows the recommendation from the never documentation:

> When writing your own traits, `!` should have an `impl` whenever
> there is an obvious `impl` which doesn’t `panic!`.

-- <https://doc.rust-lang.org/1.97.1/std/primitive.never.html#-and-traits>
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. F-never_type `#![feature(never_type)]` T-libs-api [DEPRECATED; DO NOT USE] and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-never_type `#![feature(never_type)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api [DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants