Skip to content

Ungreat change to doctest test names #70090

Closed
@ehuss

Description

@ehuss
Contributor

Doctest test names have changed due to #66364. Doc comments that pass through a macro defined in another crate now seem to report a different span.

lazy_static::lazy_static! {
    /// Comments
    /// ```
    /// assert!(true);
    /// ```
    static ref FOO: bool = true;
}

running with cargo test --doc previously looked like this:

test <::lazy_static::__lazy_static_internal macros> - FOO (line 26) ... ok

Now the test names look like this:

test /Users/eric/.cargo/registry/src/github.tiyicn.workers.dev-1ecc6299db9ec823/lazy_static-1.4.0/src/lib.rs - FOO (line 159) ... ok

Frankly, neither are particularly great. It would be nice if the test name used the span from where the macro was invoked, not where it was defined.

rustc 1.43.0-nightly (c20d7eecb 2020-03-11)

Activity

matthiaskrgr

matthiaskrgr commented on Mar 18, 2020

@matthiaskrgr
added
A-doctestsArea: Documentation tests, run by rustdoc
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
on Mar 18, 2020
Centril

Centril commented on Mar 18, 2020

@Centril
Contributor
eddyb

eddyb commented on Mar 18, 2020

@eddyb
Member

@matthiaskrgr What you're describing is entirely in the opposite direction, <::std::macros::panic macros> is the old (and arguably bad) kind of Span that's impossible to get anymore.
I've hidden your comment to focus on the reported issue.

eddyb

eddyb commented on Mar 18, 2020

@eddyb
Member

@ehuss That makes sense, we have a way to get the outermost invocation, that is used by file!()/line! and #[track_caller]:

span.ctxt().outer_expn().expansion_cause().unwrap_or(span)

We'd just need to use this in rustdoc.

Centril

Centril commented on Mar 18, 2020

@Centril
Contributor
removed
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Mar 18, 2020
Centril

Centril commented on Mar 18, 2020

@Centril
Contributor

cc @rust-lang/rustdoc

spastorino

spastorino commented on Mar 18, 2020

@spastorino
Member

Removed T-compiler label, left nomination for T-rustdoc to decide about this issue.

7 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: Documentation tests, run by rustdocA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.T-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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ehuss@spastorino@eddyb@matthiaskrgr@Centril

      Issue actions

        Ungreat change to doctest test names · Issue #70090 · rust-lang/rust