Skip to content
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

rustdoc --test that passes with Rust 1.31.0 and fails with Rust 1.32.0, involving use paths #57767

Closed
carols10cents opened this issue Jan 20, 2019 · 2 comments
Labels
regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@carols10cents
Copy link
Member

I'm not sure what changed in here, but a contributor to the book just discovered we have a doctest that passed with stable 1.31.0 and fails to compile with stable 1.32.0.

If I extract the code into a library and remove the rustdoc specific bits (the code hiding #s), it compiles successfully with both Rust 1.31.0 and Rust 1.32.0, so I suspect something with rustdoc to be the cause? I'm not entirely sure though.

I looked for recent PRs and issues and didn't find anything that looked relevant, other than uniform path stabilization, and I hope it's not that.

This is the one test from the book extracted for reproduction (but still within a markdown file as it is in the book because that seems important):

# Rustdoc Weirdness Example

Here is the doc test that passes with Rust 1.31.0 and fails with Rust 1.32.0:

```rust
//! # Art
//!
//! A library for modeling artistic concepts.

pub mod kinds {
    /// The primary colors according to the RYB color model.
    pub enum PrimaryColor {
        Red,
        Yellow,
        Blue,
    }

    /// The secondary colors according to the RYB color model.
    pub enum SecondaryColor {
        Orange,
        Green,
        Purple,
    }
}

pub mod utils {
    use crate::kinds::*;

    /// Combines two primary colors in equal amounts to create
    /// a secondary color.
    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
        // --snip--
#         SecondaryColor::Orange
    }
}
# fn main() {}
```

Weird, right???

To reproduce, put this text into something.md. If you use Rust 1.31.0 and run rustdoc --test something.md, it results in 1 test passing. If you use Rust 1.32.0 and run rustdoc --test something.md, it can't compile the test and results in these compiler errors:

---- src/ch14-02-publishing-to-crates-io.md - Rustdoc_Weirdness_Example (line 5) stdout ----
error[E0432]: unresolved import `crate::kinds`
  --> src/ch14-02-publishing-to-crates-io.md:27:16
   |
24 |     use crate::kinds::*;
   |                ^^^^^ maybe a missing `extern crate kinds;`?

error[E0433]: failed to resolve: use of undeclared type or module `SecondaryColor`
  --> src/ch14-02-publishing-to-crates-io.md:33:9
   |
30 |         SecondaryColor::Orange
   |         ^^^^^^^^^^^^^^ use of undeclared type or module `SecondaryColor`

error[E0412]: cannot find type `PrimaryColor` in this scope
  --> src/ch14-02-publishing-to-crates-io.md:31:20
   |
28 |     pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
   |                    ^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `PrimaryColor` in this scope
  --> src/ch14-02-publishing-to-crates-io.md:31:38
   |
28 |     pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
   |                                      ^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `SecondaryColor` in this scope
  --> src/ch14-02-publishing-to-crates-io.md:31:55
   |
28 |     pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
   |                                                       ^^^^^^^^^^^^^^ not found in this scope

thread 'src/ch14-02-publishing-to-crates-io.md - Rustdoc_Weirdness_Example (line 5)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:323:13
@carols10cents carols10cents added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Jan 20, 2019
@ehuss
Copy link
Contributor

ehuss commented Jan 20, 2019

This was regressed by #54861 and has been fixed by #56793.

@carols10cents
Copy link
Member Author

Aha. I don't know why I didn't think to check beta last night, but is indeed not an issue in 1.33.0-beta.1.

I don't think the fix is significant enough for a point release in and of itself, but if one ends up happening (i don't see anything nominated right now) I think it'd be worth considering including the fix.

Going to close this but tag the fixed PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants