Skip to content

Ungreat change to doctest test names #70090

Closed

Description

@ehuss

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.com-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

  1. matthiaskrgr commented on Mar 18, 2020

    @matthiaskrgr
  2. 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
  3. Centril commented on Mar 18, 2020

    @Centril
    Contributor
  4. eddyb commented on Mar 18, 2020

    @eddyb
    Contributor

    @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.

  5. eddyb commented on Mar 18, 2020

    @eddyb
    Contributor

    @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.

  6. Centril commented on Mar 18, 2020

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

    @Centril
    Contributor

    cc @rust-lang/rustdoc

  9. spastorino commented on Mar 18, 2020

    @spastorino
    Member

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

  10. GuillaumeGomez commented on Mar 19, 2020

    @GuillaumeGomez
    Member

    Well, using what @eddyb suggested seems like the best thing to do.

  11. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on May 21, 2020
  12. added a commit that references this issue on Jun 28, 2020
    6088079
  13. added a commit that references this issue on Aug 7, 2020
    1e0e618
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

      No branches or pull requests

      Issue actions