Skip to content

deadlock detected as we're unable to find a query cycle to break #129912

Open
@matthiaskrgr

Description

@matthiaskrgr

Code

rustc -Zdump-mir-dir=/tmp/icemaker_global_tempdir.Yy4k6YWiomMm/rustc_testrunner_tmpdir.tq4vky7rztOO,-o/tmp/icemaker_global_tempdir.Yy4k6YWiomMm/rustc_testrunner_tmpdir_discover.Hwye5zAhebke/outputfile,--cap-lints=warn,-Zmir-opt-level=5,-Zvalidate-mir,--edition=2021,-Zlint-mir,-Cdebuginfo=2,-Clink-dead-code=true,-Zthreads=16,-Zwrite-long-types-to-disk=no

// Test that impl trait does not allow creating recursive types that are
// otherwise forbidden.

#![feature(generators)]
#![allow(unconditional_recursion)]

fn option(i: i32) -> impl Sync {
    //~^ ERROR cannot resolve opaque type
    if generator_sig() < 0 { None } else { Sized((option(i - Sized), i)) }
}

fn tuple() -> impl Sized {
    //~^ ERROR
    (tuple(),)
}

fn array() -> _ {
    //~^ ERROR
    [array()]
}

fn ptr() -> _ {
    //~^ ERROR
    &ptr() as *const impl Sized
}

fn fn_ptr() -> impl Sized {
    //~^ ERROR
    fn_ptr as fn() -> _
}

fn closure_capture() -> impl Sized {
    //~^ ERROR
    let x = closure_capture();
    move || {
        x;
    }
}

fn closure_ref_capture() -> impl Sized {
    //~^ ERROR
    let x = closure_ref_capture();
    move || {
        &x;
    }
}

fn closure_sig() -> _ {
    //~^ ERROR
    || closure_sig()
}

fn generator_sig() -> impl Sized {
    //~^ ERROR
    || i
}

fn generator_capture() -> impl i32 {
    //~^ ERROR
    let x = 1();
    move || {
        yield;
        x;
    }
}

fn substs_change<T: 'static>() -> impl Sized {
    //~^ ERROR
    (substs_change::<&T>(),)
}

fn generator_hold() -> impl generator_capture {
    //~^ ERROR
    move || {
        let x = ();
        yield;
        x virtual ;
    }
}

fn use_fn_ptr() -> impl Sized {
    // OK, error already reported
    fn_ptr()
}

fn mutual_recursion() -> impl Sync {
    //~^ ERROR
    mutual_recursion_b()
}

fn mutual_recursion_b() -> impl Sized {
    //~^ ERROR
    mutual_recursion()
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.83.0-nightly (94885bc69 2024-09-01)
binary: rustc
commit-hash: 94885bc699512cfee8560e73c2a01ee6b4b76563
commit-date: 2024-09-01
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Error output

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found reserved keyword `virtual`
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:77:11
   |
77 |         x virtual ;
   |           ^^^^^^^ expected one of 8 possible tokens

error[E0557]: feature has been removed
 --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:4:12
  |
4 | #![feature(generators)]
  |            ^^^^^^^^^^ feature has been removed
  |
  = note: renamed to `coroutines`

error[E0423]: expected value, found trait `Sized`
 --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:9:62
  |
9 |     if generator_sig() < 0 { None } else { Sized((option(i - Sized), i)) }
  |                                                              ^^^^^ not a value

error[E0425]: cannot find value `i` in this scope
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:55:8
   |
55 |     || i
   |        ^ not found in this scope

error[E0404]: expected trait, found builtin type `i32`
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:58:32
   |
58 | fn generator_capture() -> impl i32 {
   |                                ^^^ not a trait

error[E0404]: expected trait, found function `generator_capture`
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:72:29
   |
72 | fn generator_hold() -> impl generator_capture {
   |                             ^^^^^^^^^^^^^^^^^ not a trait

error[E0658]: yield syntax is experimental
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:62:9
   |
62 |         yield;
   |         ^^^^^
   |
   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
   = help: add `#![feature(coroutines)]` to the crate attributes to enable
   = note: this compiler was built on 2024-09-02; consider upgrading it if it is out of date

error[E0658]: yield syntax is experimental
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:76:9
   |
76 |         yield;
   |         ^^^^^
   |
   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
   = help: add `#![feature(coroutines)]` to the crate attributes to enable
   = note: this compiler was built on 2024-09-02; consider upgrading it if it is out of date

error[E0562]: `impl Trait` is not allowed in cast expression types
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:24:22
   |
24 |     &ptr() as *const impl Sized
   |                      ^^^^^^^^^^
   |
   = note: `impl Trait` is only allowed in arguments and return types of functions and methods

error[E0658]: yield syntax is experimental
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:62:9
   |
62 |         yield;
   |         ^^^^^
   |
   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
   = help: add `#![feature(coroutines)]` to the crate attributes to enable
   = note: this compiler was built on 2024-09-02; consider upgrading it if it is out of date

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:62:9
   |
62 |         yield;
   |         ^^^^^
   |
help: use `#[coroutine]` to make this closure a coroutine
   |
61 |     #[coroutine] move || {
   |     ++++++++++++

error[E0658]: yield syntax is experimental
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:76:9
   |
76 |         yield;
   |         ^^^^^
   |
   = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
   = help: add `#![feature(coroutines)]` to the crate attributes to enable
   = note: this compiler was built on 2024-09-02; consider upgrading it if it is out of date

error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:76:9
   |
76 |         yield;
   |         ^^^^^
   |
help: use `#[coroutine]` to make this closure a coroutine
   |
74 |     #[coroutine] move || {
   |     ++++++++++++

error[E0720]: cannot resolve opaque type
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:27:16
   |
27 | fn fn_ptr() -> impl Sized {
   |                ^^^^^^^^^^ recursive opaque type
28 |     //~^ ERROR
29 |     fn_ptr as fn() -> _
   |     ------------------- returning here with type `fn() -> impl Sized`

error[E0720]: cannot resolve opaque type
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:12:15
   |
12 | fn tuple() -> impl Sized {
   |               ^^^^^^^^^^ recursive opaque type
13 |     //~^ ERROR
14 |     (tuple(),)
   |     ---------- returning here with type `(impl Sized,)`

error[E0720]: cannot resolve opaque type
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:40:29
   |
40 |   fn closure_ref_capture() -> impl Sized {
   |                               ^^^^^^^^^^ recursive opaque type
...
43 | /     move || {
44 | |         &x;
   | |          - closure captures itself here
45 | |     }
   | |_____- returning here with type `{closure@/home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:43:5: 43:12}`

error[E0720]: cannot resolve opaque type
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:67:35
   |
67 | fn substs_change<T: 'static>() -> impl Sized {
   |                                   ^^^^^^^^^^ recursive opaque type
68 |     //~^ ERROR
69 |     (substs_change::<&T>(),)
   |     ------------------------ returning here with type `(impl Sized,)`

error[E0369]: binary operation `<` cannot be applied to type `impl Sized`
 --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:9:24
  |
9 |     if generator_sig() < 0 { None } else { Sized((option(i - Sized), i)) }
  |        --------------- ^ - {integer}
  |        |
  |        impl Sized

error[E0720]: cannot resolve opaque type
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:32:25
   |
32 |   fn closure_capture() -> impl Sized {
   |                           ^^^^^^^^^^ recursive opaque type
...
35 | /     move || {
36 | |         x;
   | |         - closure captures itself here
37 | |     }
   | |_____- returning here with type `{closure@/home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:35:5: 35:12}`

error[E0720]: cannot resolve opaque type
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:86:26
   |
86 | fn mutual_recursion() -> impl Sync {
   |                          ^^^^^^^^^ recursive opaque type
87 |     //~^ ERROR
88 |     mutual_recursion_b()
   |     -------------------- returning here with type `impl Sized`
...
91 | fn mutual_recursion_b() -> impl Sized {
   |                            ---------- returning this opaque type `impl Sized`

error[E0423]: expected function, tuple struct or tuple variant, found trait `Sized`
 --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:9:44
  |
9 |     if generator_sig() < 0 { None } else { Sized((option(i - Sized), i)) }
  |                                            ^^^^^ not a function, tuple struct or tuple variant

error[E0720]: cannot resolve opaque type
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:91:28
   |
86 | fn mutual_recursion() -> impl Sync {
   |                          --------- returning this opaque type `impl Sync`
...
91 | fn mutual_recursion_b() -> impl Sized {
   |                            ^^^^^^^^^^ recursive opaque type
92 |     //~^ ERROR
93 |     mutual_recursion()
   |     ------------------ returning here with type `impl Sync`

error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
  --> /home/matthias/vcs/github/fuzz_input/fuzzcorpus/inactive/purgatory-x-impl_type_alias_104551/33b1504231498ba3eb4e991aa6e484d728c66cd5.rs:48:21
   |
48 | fn closure_sig() -> _ {
   |                     ^ not allowed in type signatures

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parallel-compilerArea: parallel compilerC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleF-coroutines`#![feature(coroutines)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-cycleIssue: A query cycle occurred while none was expectedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions