Keyword as a return type doesn't silence "no method found" errors
Open
@inkreasing is already working on this.
Since Sep 18, 2026.
A-diagnostics
D-verbose
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
struct A;
impl A {
fn a() -> true {}
fn b(&self) {}
fn c(&self) {}
}
fn main() {
let a = A;
a.b();
a.c();
}
Current output
Compiling playground v0.0.1 (/playground)
error: expected type, found keyword `true`
--> src/lib.rs:4:15
|
3 | impl A {
| - while parsing this item list starting here
4 | fn a() -> true {}
| ^^^^ expected type
...
9 | }
| - the item list ends here
error[E0599]: no method named `b` found for struct `A` in the current scope
--> src/lib.rs:14:7
|
1 | struct A;
| -------- method `b` not found for this struct
...
14 | a.b();
| ^ method not found in `A`
error[E0599]: no method named `c` found for struct `A` in the current scope
--> src/lib.rs:15:7
|
1 | struct A;
| -------- method `c` not found for this struct
...
15 | a.c();
| ^ method not found in `A`
For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground` (lib) due to 3 previous errors
Desired output
Compiling playground v0.0.1 (/playground)
error: expected type, found keyword `true`
--> src/lib.rs:4:15
|
3 | impl A {
| - while parsing this item list starting here
4 | fn a() -> true {}
| ^^^^ expected type
...
9 | }
| - the item list ends here
error: could not compile `playground` (lib) due to 1 previous errors
Rationale and extra context
It is not useful to have the errors about the missing functions, because those are just caused by the previous error.
I sometimes write true instead of bool, so this sometimes happens to me and is not a unrealistic mistake.
@rustbot label +D-verbose
Other cases
Rust Version
rustc 1.100.0-nightly (330d31712 2026-09-17)
binary: rustc
commit-hash: 330d317121e16b5db8e5adc63595910528ff2ee7
commit-date: 2026-09-17
host: aarch64-apple-darwin
release: 1.100.0-nightly
LLVM version: 23.1.1
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.