Skip to content

Duplicate extern crate in doc tests (2021-11-21 Nightly Regression) #91134

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
TheBlueMatt opened this issue Nov 22, 2021 · 7 comments · Fixed by #91149
Closed

Duplicate extern crate in doc tests (2021-11-21 Nightly Regression) #91134

TheBlueMatt opened this issue Nov 22, 2021 · 7 comments · Fixed by #91149
Labels
C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@TheBlueMatt
Copy link

We have a Rust-2015 doc test which has an extern crate $CRATE_DOC_TEST_IS_IN which started failing to build on nightly 2021-11-21 (but passes on stable/2021-11-20).

It now fails with

---- src/chain/transaction.rs - chain::transaction::TransactionData (line 22) stdout ----
error[E0259]: the name `lightning` is defined multiple times
 --> src/chain/transaction.rs:24:1
  |
3 | extern crate lightning;
  | ----------------------- previous import of the extern crate `lightning` here
4 | 
5 | extern crate r#lightning;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ `lightning` reimported here
  |
  = note: `lightning` must be defined only once in the type namespace of this module

error: aborting due to previous error
@TheBlueMatt TheBlueMatt added the C-bug Category: This is a bug. label Nov 22, 2021
@mathstuf
Copy link
Contributor

mathstuf commented Nov 22, 2021

Probably caused by 331465a (#91066; no rollup?). @camelid

@jyn514
Copy link
Member

jyn514 commented Nov 22, 2021

That seems unlikely, #91026 is more plausible. #91066 doesn't affect doctests.

@mathstuf
Copy link
Contributor

Oh, I think I got misled by the "rustdoc" bit.

@jyn514 jyn514 added E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 22, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 22, 2021
@jyn514
Copy link
Member

jyn514 commented Nov 22, 2021

I can't reproduce this. I tried

/// ```
/// extern crate inner;
/// ```
pub trait Trait {
    type Item;
}

and running cargo test --doc, but all the tests passed fine. @TheBlueMatt can you link the original code?

@jyn514 jyn514 added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Nov 22, 2021
@TheBlueMatt
Copy link
Author

@ehuss
Copy link
Contributor

ehuss commented Nov 22, 2021

The following seems like a minimal reproduction when used with 2015:

/// ```
/// extern crate mycrate;
/// mycrate::foo();
/// ```
pub fn foo() {}

Bisected to #91026.

@jyn514
Copy link
Member

jyn514 commented Nov 22, 2021

cc @notriddle , I think it might make sense to revert #91026 temporarily unless you already have an idea for a fix.

@jyn514 jyn514 removed E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Nov 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 23, 2021
…emicolon, r=jyn514

fix(doctest): detect extern crate items in statement doctests

This partially reverts rust-lang#91026, because rustdoc needs to detect the extern statements, even when they appear inside implicit `main()`. It does not entirely revert it, so the old bug is still fixed, by duplicating some of the logic from `parse_mod` instead of trying to use it directly.

Fixes rust-lang#91134
@bors bors closed this as completed in bff1645 Nov 24, 2021
@jyn514 jyn514 removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 24, 2021
197g added a commit to 197g/image that referenced this issue Nov 25, 2021
Strictly speaking this is motivated by a nightly compile failure.
Tracked at: (rust-lang/rust#91134).

However, it is no longer the style in Rust 2018 and not in 2021 either
so it's better to remove it from the newbie targeted resources.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants