Skip to content

endless loop by running cargo test with toolchain 2024-05-14 #125269

Closed

Description

@xMAC94x

I tried this code:

(sorry, i couldn't extract a minimal example and reproduce it)

git clone https://gitlab.com/veloren/veloren
cd veloren
git checkout e48fc4c2b235ceab3c1a551292c45c46d47e7130
cd common
cargo test

I expected to see this happen: ElimCase doctest in line 86 to finish after some time

Instead, this happened: the tests takes endless (i waited 2 hours in CI)

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (ab14f944a 2024-05-13)
binary: rustc
commit-hash: ab14f944afe4234db378ced3801e637eae6c0f30
commit-date: 2024-05-13
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4

cargo test:

   Doc-tests veloren_common

running 14 tests
test common/src/terrain/block.rs - terrain::block::Block (line 120) ... ignored
...
test common/src/typed.rs - typed::ElimCase (line 107) ... ok
...
test common/src/typed.rs - typed::ElimCase (line 86) has been running for over 60 seconds

code in the doc-test in question:

/// ```
/// veloren_common::make_case_elim!(
///     my_type_module,
///     #[repr(u32)]
///     #[derive(Clone,Copy)]
///     pub enum MyType {
///         Constr1 = 0,
///         #[typed(pure)] Constr2(arg : u8) = 1,
///         /* ..., */
///     }
/// );
/// ```

Workaround

As workaround we added a main function to the doctest, as the test doesnt execute code so far (only defines stuff) it then runs immediately again
https://gitlab.com/veloren/veloren/-/commit/3cc4b947ebd049dcdf82ca4a66a815d32d4d43f8

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 19, 2024
  2. lukas-code commented on May 19, 2024

    @lukas-code
    Contributor

    This regressed in #123594, where the new solver got enabled for the non_local_definitions lint.

    It looks like the core issue here is some kind of exponential runtime in the new solver when there are many bounds on associated types.

    Also, this is unrelated to rustdoc and can be reproduced with just rustc.

    "minimal" repro
    pub trait Typed {}
    
    pub struct SpeciesCases<Elim>(Elim);
    
    pub trait SpeciesPackedElim {
        type Ogre;
        type Cyclops;
        type Wendigo;
        type Cavetroll;
        type Mountaintroll;
        type Swamptroll;
        type Dullahan;
        type Werewolf;
        type Occultsaurok;
        type Mightysaurok;
        type Slysaurok;
        type Mindflayer;
        type Minotaur;
        type Tidalwarrior;
        type Yeti;
        type Harvester;
        type Blueoni;
        type Redoni;
        type Cultistwarlord;
        type Cultistwarlock;
        type Huskbrute;
        type Tursus;
        type Gigasfrost;
        type AdletElder;
        type SeaBishop;
        type HaniwaGeneral;
        type TerracottaBesieger;
        type TerracottaDemolisher;
        type TerracottaPunisher;
        type TerracottaPursuer;
        type Cursekeeper;
    }
    
    impl<'b, Elim: SpeciesPackedElim> Typed for &'b SpeciesCases<Elim>
    where
        &'b Elim::Ogre: Typed,
        &'b Elim::Cyclops: Typed,
        &'b Elim::Wendigo: Typed,
        &'b Elim::Cavetroll: Typed,
        &'b Elim::Mountaintroll: Typed,
        &'b Elim::Swamptroll: Typed,
        &'b Elim::Dullahan: Typed,
        &'b Elim::Werewolf: Typed,
        &'b Elim::Occultsaurok: Typed,
        &'b Elim::Mightysaurok: Typed,
        &'b Elim::Slysaurok: Typed,
        &'b Elim::Mindflayer: Typed,
        &'b Elim::Minotaur: Typed,
        &'b Elim::Tidalwarrior: Typed,
        &'b Elim::Yeti: Typed,
        &'b Elim::Harvester: Typed,
        &'b Elim::Blueoni: Typed,
        &'b Elim::Redoni: Typed,
        &'b Elim::Cultistwarlord: Typed,
        &'b Elim::Cultistwarlock: Typed,
        &'b Elim::Huskbrute: Typed,
        &'b Elim::Tursus: Typed,
        &'b Elim::Gigasfrost: Typed,
        &'b Elim::AdletElder: Typed,
        &'b Elim::SeaBishop: Typed,
        &'b Elim::HaniwaGeneral: Typed,
        &'b Elim::TerracottaBesieger: Typed,
        &'b Elim::TerracottaDemolisher: Typed,
        &'b Elim::TerracottaPunisher: Typed,
        &'b Elim::TerracottaPursuer: Typed,
        &'b Elim::Cursekeeper: Typed,
    {}
    
    fn main() {
        pub struct Cases;
        impl<'b> Typed for &'b Cases {}
    }
  3. added
    I-compiletimeIssue: Problems and improvements with respect to compile times.
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 19, 2024
  4. lqd commented on May 20, 2024

    @lqd
    Member

    cc @lcnr could the couple search graph PRs helping on fuchsia also help here?

  5. changed the title [-][rustdoc] endless loop by running `cargo test` with toolchain 2024-05-14[/-] [+]endless loop by running `cargo test` with toolchain 2024-05-14[/+] on May 20, 2024
  6. lcnr commented on May 20, 2024

    @lcnr
    Contributor

    looking into it, thanks @lukas-code for the minimization.

  7. apiraino commented on May 21, 2024

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-high

  8. added
    P-highHigh priority
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on May 21, 2024
  9. added a commit that references this issue on May 28, 2024
    22d7367
  10. added 2 commits that reference this issue on May 28, 2024
    d0b4316
    fb95fda
  11. added a commit that references this issue on May 28, 2024
    7e8b50b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.L-non_local_definitionsLint: non_local_definitionsP-highHigh priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions