rust-lang / rust-lang/rust

Regression: source code location is bad in nightly (doctests)

Open
#134,532 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-doctests C-bug E-needs-mcve regression-from-stable-to-stable regression-untriaged T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code

I tried this code in xso/src/from_xml_doc.md :

Example without codec
# // extern crate alloc;
# use xso::FromXml;
#[derive(FromXml, Debug, PartialEq)]
#[xml(namespace = "urn:example", name = "foo")]
struct Foo {
    #[xml(text)]
    a: String,
};

let foo: Foo = xso::from_bytes(b"<foo xmlns='urn:example'>hello</foo>").unwrap();
assert_eq!(foo, Foo {
    a: "hello".to_string(),
});

(i commented extern crate alloc but in start it was just not there)

I expected to see this happen: reporting error produced in xso/src/from_xml_doc.md line ~600

Instead, this happened: reported error produced in xso/src/lib.rs line ~600 (does not exist)

failures:

---- xso/src/lib.rs - FromXml (line 648) stdout ----
error[E0433]: failed to resolve: could not find `alloc` in the list of imported crates
 --> xso/src/lib.rs:652:10
  |
7 | #[derive(FromXml, Debug, PartialEq)]
  |          ^^^^^^^ could not find `alloc` in the list of imported crates
  |
  = note: this error originates in the derive macro `FromXml` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this module
  |
3 + use std::string;
  |

error[E0433]: failed to resolve: could not find `alloc` in the list of imported crates
 --> xso/src/lib.rs:652:10
  |
7 | #[derive(FromXml, Debug, PartialEq)]
  |          ^^^^^^^ could not find `alloc` in the list of imported crates
  |
  = note: this error originates in the derive macro `FromXml` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
  |
3 + use std::string::String;
  |

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.

failures:
    xso/src/lib.rs - FromXml (line 648)

test result: FAILED. 9 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.39s

error: doctest failed, to rerun pass `--doc`
Version it worked on

Works on stable:

---- xso/src/from_xml_doc.md - FromXml (line 590) stdout ----
error[E0433]: failed to resolve: could not find `alloc` in the list of imported crates
 --> xso/src/from_xml_doc.md:594:10
  |
7 | #[derive(FromXml, Debug, PartialEq)]
  |          ^^^^^^^ could not find `alloc` in the list of imported crates
  |
  = note: this error originates in the derive macro `FromXml` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this module
  |
3 + use std::string;
  |

error[E0433]: failed to resolve: could not find `alloc` in the list of imported crates
 --> xso/src/from_xml_doc.md:594:10
  |
7 | #[derive(FromXml, Debug, PartialEq)]
  |          ^^^^^^^ could not find `alloc` in the list of imported crates
  |
  = note: this error originates in the derive macro `FromXml` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
  |
3 + use std::string::String;
  |

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0433`.
Couldn't compile the test.

failures:
    xso/src/from_xml_doc.md - FromXml (line 590)

test result: FAILED. 9 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.04s

error: doctest failed, to rerun pass `--doc`
Version with regression

rustc --version --verbose:

rustc 1.85.0-nightly (4ba4ac612 2024-12-18)
binary: rustc
commit-hash: 4ba4ac612d36e3409e8e1e31e12acc028808f85f
commit-date: 2024-12-18
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the doctest in xso/src/from_xml_doc.md on the reported nightly and compare its diagnostics with stable. Trace the nightly doctest source-location handling that reports xso/src/lib.rs instead of xso/src/from_xml_doc.md; done means the diagnostic points to the original Markdown source again.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.