Closed
Description
Code
Current output
Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `build` found for struct `Builder<false, true>` in the current scope
--> src/main.rs:44:42
|
9 | struct Builder<const AINIT: bool, const BINIT: bool> {
| ---------------------------------------------------- method `build` not found for this struct
...
44 | let item = Builder::new().with_b(()).build();
| -------------- ^^^^^ method not found in `Builder<false, true>`
| |
| method `build` is available on `Builder<false, false>`
|
= note: the method was found for
- `Builder<true, true>`
For more information about this error, try `rustc --explain E0599`.
Desired output
Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `build` found for struct `Builder<false, true>` in the current scope
--> src/main.rs:44:42
|
9 | struct Builder<const AINIT: bool, const BINIT: bool> {
| ---------------------------------------------------- method `build` not found for this struct
...
44 | let item = Builder::new().with_b(()).build();
| -------------- ^^^^^ method not found in `Builder<false, true>`
| |
| method `build` is available on `Builder<true, true>`
|
= note: the method was found for
- `Builder<true, true>`
For more information about this error, try `rustc --explain E0599`.
or
Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `build` found for struct `Builder<false, true>` in the current scope
--> src/main.rs:44:42
|
9 | struct Builder<const AINIT: bool, const BINIT: bool> {
| ---------------------------------------------------- method `build` not found for this struct
...
44 | let item = Builder::new().with_b(()).build();
| ^^^^^ method not found in `Builder<false, true>`
|
= note: the method was found for
- `Builder<true, true>`
For more information about this error, try `rustc --explain E0599`.
Rationale and extra context
The diagnostic says "method build
is available on Builder<false, false>
", which is not true; it is available on Builder<true, true>
, though.
The note does say that it is found for Builder<true, true>
, though. This makes me wonder whether the former is even necessary or if it means something else that I do not understand (e.g., is there a difference between "is available on" and "was found for"?).
Other cases
If we call `Builder::new().build();`, we get a correct diagnostic:
Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `build` found for struct `Builder<false, false>` in the current scope
--> src/main.rs:44:31
|
9 | struct Builder<const AINIT: bool, const BINIT: bool> {
| ---------------------------------------------------- method `build` not found for this struct
...
44 | let item = Builder::new().build();
| ^^^^^ method not found in `Builder<false, false>`
|
= note: the method was found for
- `Builder<true, true>`
For more information about this error, try `rustc --explain E0599`.
Rust Version
cargo 1.78.0 (54d8815d0 2024-03-26)
release: 1.78.0
commit-hash: 54d8815d04fa3816edc207bbc4dd36bf18014dbc
commit-date: 2024-03-26
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w 11 Sep 2023
os: Arch Linux [64-bit]
Anything else?
No response