Skip to content

Don't convert deserializer erros into custom errors #2

Open
@epage

Description

@epage

rust-lang/cargo#12581 originally included updating some of the code paths to use this package but ran into error problems.

Originally, the following error was reported

  TOML parse error at line 7, column 41
    |
  7 |             description = { workspace = false }
    |                                         ^^^^^
  `workspace` cannot be false

and now

  TOML parse error at line 7, column 27
    |
  7 |             description = { workspace = false }
    |                           ^^^^^^^^^^^^^^^^^^^^^
  `workspace` cannot be false
  in `workspace`

This is because the deserializer reports

  `workspace` cannot be false
  in `workspace`

and then gets passed through Error::custom, capturing that as-is. The deserializer sees this error, captures the span as of Error::custom, and then bubbles that up the stack. At the top, the rest of the context is added so the following gets prefixed to it

  TOML parse error at line 7, column 27
    |
  7 |             description = { workspace = false }
    |                           ^^^^^^^^^^^^^^^^^^^^^

Another "in ..." isn't added because that is only rendered when the source context isn't there to render the line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions