Skip to content

rustdoc reports diagnostics against very/../long/PATH.md instead of normalizing to PATH.md #130626

@fasterthanlime

Description

@fasterthanlime

The same repro as #130470 can be used here: https://github.com/fasterthanlime/readme-md-error-reporting

When running cargo +stage1 t, the output is:

---- src/../README.md - (line 5) stdout ----
error: expected `;`, found `}`
 --> src/../README.md:7:16
  |
3 |     let x = 234 // no semicolon here! oh no!
  |                ^ help: add `;` here
4 | }
  | - unexpected token

But I would argue it should be this:

---- README.md - (line 5) stdout ----
error: expected `;`, found `}`
 --> README.md:7:16
  |
3 |     let x = 234 // no semicolon here! oh no!
  |                ^ help: add `;` here
4 | }
  | - unexpected token

I would caution against using canonicalize — which resolves symbolic links etc. and requires the path to exist on disk right now, and rather advise that y'all simply have a state machine working on a stack of path elements, going through:

  • []
  • ["src"]
  • [] // just popped due to ".."
  • ["README.md"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.T-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