Skip to content

Regression on doc-tests with statements and a main function #140162

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

Open
Darksonn opened this issue Apr 22, 2025 · 3 comments
Open

Regression on doc-tests with statements and a main function #140162

Darksonn opened this issue Apr 22, 2025 · 3 comments
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Darksonn
Copy link
Contributor

Code

I tried this code:

/// ```
/// # if cfg!(miri) { return; }
/// use playground::my_func;
///
/// fn main() {
///     println!("Hi!");
///     my_func();
/// }
/// ```
pub fn my_func() {
}

On stable, running this doctest succeeds. On beta, it triggers this error:

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

failures:

---- src/lib.rs - my_func (line 2) stdout ----
error: expected item, found keyword `if`
 --> src/lib.rs:4:1
  |
4 | if cfg!(miri) { return; }
  | ^^ expected item
  |
  = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>

error: aborting due to 1 previous error

Couldn't compile the test.

failures:
    src/lib.rs - my_func (line 2)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s

Version it worked on

It most recently worked on: Latest stable (i.e. rustc 1.86.0)

Version with regression

rustc --version --verbose:

rustc 1.87.0-beta.5 (386abeb93 2025-04-19)
binary: rustc
commit-hash: 386abeb93ab8e683357f54ffe76ae53861b2d984
commit-date: 2025-04-19
host: x86_64-unknown-linux-gnu
release: 1.87.0-beta.5
LLVM version: 20.1.1

@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged

@Darksonn Darksonn added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Apr 22, 2025
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-untriaged Untriaged performance or correctness regression. labels Apr 22, 2025
@jieyouxu jieyouxu added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 22, 2025
@apiraino
Copy link
Contributor

apiraino commented Apr 22, 2025

Bisecting by running rustdoc --test src/lib.rs (the file contains the reproducible code):

Regression in rust-lang-ci@cdcf730
#138104

cc @GuillaumeGomez @fmease for authoring #138104

bisected with cargo-bisect-rustc v0.6.9

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --without-cargo --preserve --start 2024-02-01 --script test.sh 

@GuillaumeGomez GuillaumeGomez removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 22, 2025
@GuillaumeGomez
Copy link
Member

Gonna try to take a look as soon as possible.

@fmease fmease added the A-doctests Area: Documentation tests, run by rustdoc label Apr 22, 2025
@cyrgani
Copy link
Contributor

cyrgani commented Apr 22, 2025

duplicate of #139651?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc C-bug Category: This is a bug. I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
Status: No status
Development

No branches or pull requests

7 participants