Skip to content

Regression in 1.62.0 with macro exports in doctests #98735

Closed
@jonhoo

Description

@jonhoo

Code

I tried this code (in a crate called foo):

/// ```
/// # #[macro_use] extern crate foo;
///
/// mockable! {}
/// ```
macro_rules! mockable {
    () => {};
}

and run

$ cargo t --doc

I expected to see this happen: the doctest passes

Instead, this happened: the doctest fails to build with

running 1 test
test src/lib.rs - mockable (line 1) ... FAILED

failures:

---- src/lib.rs - mockable (line 1) stdout ----
error: cannot find macro `mockable` in this scope
 --> src/lib.rs:4:1
  |
5 | mockable! {}
  | ^^^^^^^^

error: aborting due to previous error

Version it worked on

It most recently worked on: Rust 1.61.0

Version with regression

rustc --version --verbose:

rustc 1.62.0 (a8314ef7d 2022-06-27)
binary: rustc
commit-hash: a8314ef7d0ec7b75c336af2c9857bfaf43002bfc
commit-date: 2022-06-27
host: aarch64-unknown-linux-gnu
release: 1.62.0
LLVM version: 14.0.5

Notes

It works if I add #[macro_export] above the macro_rules!. If intended, this feels like it should be listed in the compatibility notes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions