E0277 on complex tuple omits essential info and is duplicated
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
use nom::{
character::complete::anychar,
combinator::recognize,
bytes::tag,
IResult,
Parser,
};
pub fn parse(s: &str) -> IResult<&str, &str> {
recognize((
anychar,
anychar,
anychar,
tag,
anychar,
)).parse(s)
}
Current output
error[E0277]: the trait bound `(..., ..., ..., ..., ...): Parser<_>` is not satisfied
--> src/lib.rs:11:15
|
11 | recognize((
| _____---------_^
| | |
| | required by a bound introduced by this call
12 | | anychar,
13 | | anychar,
14 | | anychar,
15 | | tag,
16 | | anychar,
17 | | )).parse(s)
| |_____^ the trait `Parser<_>` is not implemented for `(fn(_) -> ... {anychar::<_, _>}, ..., ..., ..., ...)`
|
= help: the following other types implement trait `Parser<Input>`:
(P1, P2)
(P1, P2, P3)
(P1, P2, P3, P4)
(P1, P2, P3, P4, P5)
(P1, P2, P3, P4, P5, P6)
(P1, P2, P3, P4, P5, P6, P7)
(P1, P2, P3, P4, P5, P6, P7, P8)
(P1, P2, P3, P4, P5, P6, P7, P8, P9)
and 13 others
note: required by a bound in `recognize`
--> /home/binarycat/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nom-8.0.0/src/combinator/mod.rs:635:6
|
631 | pub fn recognize<I: Clone + Offset + Input, E: ParseError<I>, F>(
| --------- required by a bound in this function
...
635 | F: Parser<I, Error = E>,
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `recognize`
= note: the full name for the type has been written to '/tmp/bug-repro/target/debug/deps/bug_repro-39cf7f6b883a22b4.long-type-13436936027012102670.txt'
= note: consider using `--verbose` to print the full type name to the console
error[E0277]: the trait bound `(..., ..., ..., ..., ...): Parser<_>` is not satisfied
--> src/lib.rs:11:5
|
11 | / recognize((
12 | | anychar,
13 | | anychar,
14 | | anychar,
15 | | tag,
16 | | anychar,
17 | | )).parse(s)
| |______^ the trait `Parser<_>` is not implemented for `(fn(_) -> ... {anychar::<_, _>}, ..., ..., ..., ...)`
|
= help: the following other types implement trait `Parser<Input>`:
(P1, P2)
(P1, P2, P3)
(P1, P2, P3, P4)
(P1, P2, P3, P4, P5)
(P1, P2, P3, P4, P5, P6)
(P1, P2, P3, P4, P5, P6, P7)
(P1, P2, P3, P4, P5, P6, P7, P8)
(P1, P2, P3, P4, P5, P6, P7, P8, P9)
and 13 others
note: required by a bound in `recognize`
--> /home/binarycat/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nom-8.0.0/src/combinator/mod.rs:635:6
|
631 | pub fn recognize<I: Clone + Offset + Input, E: ParseError<I>, F>(
| --------- required by a bound in this function
...
635 | F: Parser<I, Error = E>,
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `recognize`
= note: the full name for the type has been written to '/tmp/bug-repro/target/debug/deps/bug_repro-39cf7f6b883a22b4.long-type-13436936027012102670.txt'
= note: consider using `--verbose` to print the full type name to the console
error[E0277]: the trait bound `(..., ..., ..., ..., ...): Parser<_>` is not satisfied
--> src/lib.rs:11:5
|
11 | / recognize((
12 | | anychar,
13 | | anychar,
14 | | anychar,
15 | | tag,
16 | | anychar,
17 | | )).parse(s)
| |_______________^ the trait `Parser<_>` is not implemented for `(fn(_) -> ... {anychar::<_, _>}, ..., ..., ..., ...)`
|
= help: the following other types implement trait `Parser<Input>`:
(P1, P2)
(P1, P2, P3)
(P1, P2, P3, P4)
(P1, P2, P3, P4, P5)
(P1, P2, P3, P4, P5, P6)
(P1, P2, P3, P4, P5, P6, P7)
(P1, P2, P3, P4, P5, P6, P7, P8)
(P1, P2, P3, P4, P5, P6, P7, P8, P9)
and 13 others
note: required by a bound in `recognize`
--> /home/binarycat/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nom-8.0.0/src/combinator/mod.rs:635:6
|
631 | pub fn recognize<I: Clone + Offset + Input, E: ParseError<I>, F>(
| --------- required by a bound in this function
...
635 | F: Parser<I, Error = E>,
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `recognize`
= note: the full name for the type has been written to '/tmp/bug-repro/target/debug/deps/bug_repro-39cf7f6b883a22b4.long-type-13436936027012102670.txt'
= note: consider using `--verbose` to print the full type name to the console
For more information about this error, try `rustc --explain E0277`.
Desired output
error[E0277]: the trait bound `(..., ..., ..., ..., ...): Parser<_>` is not satisfied
--> src/lib.rs:11:15
|
11 | recognize((
| _____---------_^
| | |
| | required by a bound introduced by this call
12 | | anychar,
13 | | anychar,
14 | | anychar,
15 | | tag,
16 | | anychar,
17 | | )).parse(s)
| |_____^ the trait `Parser<_>` is not implemented for `(fn(_) -> ... {anychar::<_, _>}, ..., ..., ..., ...)`
|
= help: the 4th element of this tuple does not implement Parser<_>
= note: the full name for the type has been written to '/tmp/bug-repro/target/debug/deps/bug_repro-39cf7f6b883a22b4.long-type-13436936027012102670.txt'
= note: consider using `--verbose` to print the full type name to the console
note: required by a bound in `recognize`
--> /home/binarycat/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/nom-8.0.0/src/combinator/mod.rs:635:6
|
631 | pub fn recognize<I: Clone + Offset + Input, E: ParseError<I>, F>(
| --------- required by a bound in this function
...
635 | F: Parser<I, Error = E>,
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `recognize`
Rationale and extra context
I initially didn't even see the long type disclaimer, since there was so much noise and because it was targeting the span of the function definition, not the main error span.
It would be very handy to know which element of the tuple is actually causing the problem.
nice ordinals (eg. 4th) should be possible since we're already using fluent.
Also confusing is that cargo --verbose does not set rustc --verbose.
Other cases
Rust Version
rustc 1.86.0 (05f9846f8 2025-03-31)
binary: rustc
commit-hash: 05f9846f893b09a1be1fc8560e33fc3c815cfecb
commit-date: 2025-03-31
host: x86_64-unknown-linux-gnu
release: 1.86.0
LLVM version: 19.1.7
Anything else?
latest nightly isn't any better
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.
Research direction
Reproduce the diagnostic from the supplied example in src/lib.rs, then start at rustc's E0277 diagnostic handling and its fluent messages. Compare the current and desired spans, tuple-element explanation, duplicate suppression, and long-type note; done means the reported output matches the requested form and regression coverage exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100