Skip to content

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

@xmppftw

Description

@xmppftw

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: Documentation tests, run by rustdocC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions