Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fasterthanlime opened this issue Sep 20, 2024 · 2 comments · May be fixed by #130643
Open
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fasterthanlime
Copy link
Contributor

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"]
@fasterthanlime fasterthanlime added the C-bug Category: This is a bug. label Sep 20, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 20, 2024
@notriddle
Copy link
Contributor

I can reproduce this problem without involving rustdoc.

$ mkdir -p check-dir/subdir
$ cat > check-dir/bar.rs
fn unusual() {}
$ cat > check-dir/subdir/foo.rs
include! { "../bar.rs" }
$ rustc +nightly --crate-type=lib check-dir/subdir/foo.rs
 --> check-dir/subdir/../bar.rs:1:4
  |
1 | fn unusual() {}
  |    ^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

@jieyouxu jieyouxu added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-diagnostics Area: Messages for errors, warnings, and lints and removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Sep 20, 2024
@GuillaumeGomez GuillaumeGomez linked a pull request Sep 20, 2024 that will close this issue
@GuillaumeGomez
Copy link
Member

I still wrote a little path beautifier. ^^'

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants