Add suggestions for must_implement_one_of - #160106
Merged
rust-bors[bot] merged 3 commits intoJul 30, 2026
Merged
Conversation
…span `missing_items_err` has logic to figure out where in the impl to insert suggestions. Factor that logic out into a function to support reusing it.
`missing_items_err` has logic to compute a set of suggestions regarding the missing items. Factor that logic out into a function to support reusing it.
Collaborator
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
mejrs
requested changes
Jul 29, 2026
joshtriplett
force-pushed
the
must-implement-one-of-suggestions
branch
from
July 29, 2026 04:39
2e10c49 to
de1a020
Compare
This comment has been minimized.
This comment has been minimized.
As with the suggestions for mandatory trait methods, provide suggestions
for `must_implement_one_of`, which include the signatures of the trait
methods. This makes it easy to copy-paste the signatures into the impl
block.
Invoke the same logic from `check_drop_xor_pin_drop`, to provide
suggestions with the signatures of `drop` and `pin_drop`.
Without this change:
```
error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf`
--> src/main.rs:3:1
|
3 | impl std::io::Read for R {
| ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation
For more information about this error, try `rustc --explain E0046`.
```
With this change:
```
error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf`
--> src/main.rs:3:1
|
3 | impl std::io::Read for R {
| ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation
|
= help: implement the missing item: `fn read(&mut self, _: &mut [u8]) -> Result<usize, std::io::Error> { todo!() }`
= help: implement the missing item: `fn read_buf(&mut self, _: BorrowedCursor<'_, u8>) -> Result<(), std::io::Error> { todo!() }`
For more information about this error, try `rustc --explain E0046`.
```
joshtriplett
force-pushed
the
must-implement-one-of-suggestions
branch
from
July 29, 2026 08:42
de1a020 to
bf8708e
Compare
Contributor
Contributor
|
This pull request was unapproved. |
joshtriplett
force-pushed
the
must-implement-one-of-suggestions
branch
from
July 29, 2026 15:44
84087a8 to
bf8708e
Compare
Member
Author
|
(Sorry, pushed to the wrong branch.) |
Member
Author
|
@bors r=mejrs |
Contributor
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jul 29, 2026
…-suggestions, r=mejrs Add suggestions for `must_implement_one_of` As with the suggestions for mandatory trait methods, provide suggestions for `must_implement_one_of`, which include the signatures of the trait methods. This makes it easy to copy-paste the signatures into the impl block. Invoke the same logic from `check_drop_xor_pin_drop`, to provide suggestions with the signatures of `drop` and `pin_drop`. Using rust-lang#106643 (`read`/`read_buf`) as an example, without this change, the diagnostics look like this: ``` error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf` --> src/main.rs:3:1 | 3 | impl std::io::Read for R { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation For more information about this error, try `rustc --explain E0046`. ``` With this change, they include suggestions: ``` error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf` --> src/main.rs:3:1 | 3 | impl std::io::Read for R { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation | = help: implement the missing item: `fn read(&mut self, _: &mut [u8]) -> Result<usize, std::io::Error> { todo!() }` = help: implement the missing item: `fn read_buf(&mut self, _: BorrowedCursor<'_, u8>) -> Result<(), std::io::Error> { todo!() }` For more information about this error, try `rustc --explain E0046`. ```
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 29, 2026
Rollup of 17 pull requests Successful merges: - #159014 ([rustdoc] Do not take `doc(cfg())` into account when filtering doctests) - #159130 (a bit optimize four-digit chunks in integer formatting) - #159592 (core: implement bounded random sampling) - #159898 (Add intrinsic-test alias and set sample rate) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding)
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jul 29, 2026
…-suggestions, r=mejrs Add suggestions for `must_implement_one_of` As with the suggestions for mandatory trait methods, provide suggestions for `must_implement_one_of`, which include the signatures of the trait methods. This makes it easy to copy-paste the signatures into the impl block. Invoke the same logic from `check_drop_xor_pin_drop`, to provide suggestions with the signatures of `drop` and `pin_drop`. Using rust-lang#106643 (`read`/`read_buf`) as an example, without this change, the diagnostics look like this: ``` error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf` --> src/main.rs:3:1 | 3 | impl std::io::Read for R { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation For more information about this error, try `rustc --explain E0046`. ``` With this change, they include suggestions: ``` error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf` --> src/main.rs:3:1 | 3 | impl std::io::Read for R { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation | = help: implement the missing item: `fn read(&mut self, _: &mut [u8]) -> Result<usize, std::io::Error> { todo!() }` = help: implement the missing item: `fn read_buf(&mut self, _: BorrowedCursor<'_, u8>) -> Result<(), std::io::Error> { todo!() }` For more information about this error, try `rustc --explain E0046`. ```
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 29, 2026
Rollup of 18 pull requests Successful merges: - #159130 (a bit optimize four-digit chunks in integer formatting) - #159592 (core: implement bounded random sampling) - #159898 (Add intrinsic-test alias and set sample rate) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160139 (iter: specialize Take::count using advance_by) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding) - #160166 (Use correct feature gates for `f16`/`f128` `From` impls)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jul 29, 2026
…-suggestions, r=mejrs Add suggestions for `must_implement_one_of` As with the suggestions for mandatory trait methods, provide suggestions for `must_implement_one_of`, which include the signatures of the trait methods. This makes it easy to copy-paste the signatures into the impl block. Invoke the same logic from `check_drop_xor_pin_drop`, to provide suggestions with the signatures of `drop` and `pin_drop`. Using rust-lang#106643 (`read`/`read_buf`) as an example, without this change, the diagnostics look like this: ``` error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf` --> src/main.rs:3:1 | 3 | impl std::io::Read for R { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation For more information about this error, try `rustc --explain E0046`. ``` With this change, they include suggestions: ``` error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf` --> src/main.rs:3:1 | 3 | impl std::io::Read for R { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation | = help: implement the missing item: `fn read(&mut self, _: &mut [u8]) -> Result<usize, std::io::Error> { todo!() }` = help: implement the missing item: `fn read_buf(&mut self, _: BorrowedCursor<'_, u8>) -> Result<(), std::io::Error> { todo!() }` For more information about this error, try `rustc --explain E0046`. ```
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 29, 2026
…uwer Rollup of 18 pull requests Successful merges: - #159898 (Add intrinsic-test alias and set sample rate) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #158693 (Add type-check to offload intrinisc calls) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160139 (iter: specialize Take::count using advance_by) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding) - #160166 (Use correct feature gates for `f16`/`f128` `From` impls)
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 30, 2026
Rollup of 20 pull requests Successful merges: - #157669 (cfi: add diag mode support) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #158693 (Add type-check to offload intrinisc calls) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160101 (Add missing `needs-unwind` annotation to `add-spawn-hook-reentrancy-159923` test) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160139 (iter: specialize Take::count using advance_by) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding) - #160166 (Use correct feature gates for `f16`/`f128` `From` impls) - #160178 (Remove unused `va_start` intrinsic)
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 30, 2026
Rollup of 20 pull requests Successful merges: - #157669 (cfi: add diag mode support) - #158247 (hermit/fs: Return `unsupported()` instead of `from_raw_os_error(22)`) - #158649 (Hermit: fix `readdir()` ) - #158693 (Add type-check to offload intrinisc calls) - #159049 (Avoid ICE in From/TryFrom cast suggestion when encountering HRTBs) - #159411 ([rustdoc] Correctly handle output options with --show-coverage) - #160053 (test: add test suite for the 85681 issue) - #160087 (Add regression test for nested associated-type projection ICE) - #160090 (rustc_resolve: Further reduce mutability in resolver) - #160099 (Resolver: split module resolutions into local and external resolutions) - #160101 (Add missing `needs-unwind` annotation to `add-spawn-hook-reentrancy-159923` test) - #160106 (Add suggestions for `must_implement_one_of`) - #160117 (Remove unnecessary format usage) - #160134 (Work around Wine bug 60084 by calling WSAStartup at most once) - #160139 (iter: specialize Take::count using advance_by) - #160142 (bootstrap: remove use-lld config alias) - #160148 (Rename `errors.rs` file to `diagnostics.rs` (15/N)) - #160151 (Mark a doctest as requiring unwinding) - #160166 (Use correct feature gates for `f16`/`f128` `From` impls) - #160178 (Remove unused `va_start` intrinsic)
rust-timer
added a commit
that referenced
this pull request
Jul 30, 2026
Rollup merge of #160106 - joshtriplett:must-implement-one-of-suggestions, r=mejrs Add suggestions for `must_implement_one_of` As with the suggestions for mandatory trait methods, provide suggestions for `must_implement_one_of`, which include the signatures of the trait methods. This makes it easy to copy-paste the signatures into the impl block. Invoke the same logic from `check_drop_xor_pin_drop`, to provide suggestions with the signatures of `drop` and `pin_drop`. Using #106643 (`read`/`read_buf`) as an example, without this change, the diagnostics look like this: ``` error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf` --> src/main.rs:3:1 | 3 | impl std::io::Read for R { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation For more information about this error, try `rustc --explain E0046`. ``` With this change, they include suggestions: ``` error[E0046]: not all trait items implemented, missing one of: `read`, `read_buf` --> src/main.rs:3:1 | 3 | impl std::io::Read for R { | ^^^^^^^^^^^^^^^^^^^^^^^^ missing one of `read`, `read_buf` in implementation | = help: implement the missing item: `fn read(&mut self, _: &mut [u8]) -> Result<usize, std::io::Error> { todo!() }` = help: implement the missing item: `fn read_buf(&mut self, _: BorrowedCursor<'_, u8>) -> Result<(), std::io::Error> { todo!() }` For more information about this error, try `rustc --explain E0046`. ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As with the suggestions for mandatory trait methods, provide suggestions for
must_implement_one_of, which include the signatures of the trait methods. This makes it easy to copy-paste the signatures into the impl block.Invoke the same logic from
check_drop_xor_pin_drop, to provide suggestions with the signatures ofdropandpin_drop.Using #106643 (
read/read_buf) as an example, without this change, the diagnostics look like this:With this change, they include suggestions: