Skip to content

E0277 on complex tuple omits essential info and is duplicated #142592

Open
@lolbinarycat

Description

@lolbinarycat

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions