Repository: rust
Issue: Opaque type stopped working between Rust 1.61 and 1.64
Labels: A-diagnostics,T-compiler,C-bug,E-needs-mcve,F-type_alias_impl_trait,requires-nightly

https://github.com/obsidiansystems/ledger-app-pocket/commit/4aaf645d6a6b5602236fb44784d05cd68979a476 builds with Rust 1.61, but fails to build with newer Rust.

```
error[E0391]: cycle detected when computing type of `implementation::GetAddressImplT::{opaque#0}`
   --> src/implementation.rs:71:28
    |
71  | pub type GetAddressImplT = impl InterpParser<Bip32Key, Returning = ArrayVec<u8, 128>>;
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: ...which requires type-checking `implementation::get_sign_state`...
   --> src/implementation.rs:793:1
    |
793 | / pub fn get_sign_state(
794 | |     s: &mut ParsersState,
795 | | ) -> &mut <SignImplT as ParserCommon<DoubledSignParameters>>::State {
    | |___________________________________________________________________^
    = note: ...which requires computing layout of `*mut implementation::ParsersStateInner<<implementation::GetAddressImplT as ledger_parser_combinators::interp_parser::ParserCommon<ledger_parser_combinators::core_parsers::DArray<ledger_parser_combinators::core_parsers::Byte, ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, 10>>>::State, <implementation::SignImplT as ledger_parser_combinators::interp_parser::ParserCommon<(ledger_parser_combinators::core_parsers::DArray<ledger_parser_combinators::core_parsers::Byte, ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, 10>, (ledger_parser_combinators::core_parsers::LengthFallback<ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, ledger_parser_combinators::json::Json<interface::PoktCmdSchema>>, ledger_parser_combinators::core_parsers::LengthFallback<ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, ledger_parser_combinators::json::Json<interface::PoktCmdSchema>>))>>::State>`...
    = note: ...which requires normalizing `*mut implementation::ParsersStateInner<<implementation::GetAddressImplT as ledger_parser_combinators::interp_parser::ParserCommon<ledger_parser_combinators::core_parsers::DArray<ledger_parser_combinators::core_parsers::Byte, ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, 10>>>::State, <implementation::SignImplT as ledger_parser_combinators::interp_parser::ParserCommon<(ledger_parser_combinators::core_parsers::DArray<ledger_parser_combinators::core_parsers::Byte, ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, 10>, (ledger_parser_combinators::core_parsers::LengthFallback<ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, ledger_parser_combinators::json::Json<interface::PoktCmdSchema>>, ledger_parser_combinators::core_parsers::LengthFallback<ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, ledger_parser_combinators::json::Json<interface::PoktCmdSchema>>))>>::State>`...
    = note: ...which again requires computing type of `implementation::GetAddressImplT::{opaque#0}`, completing the cycle
note: cycle used when checking item types in module `implementation`
   --> src/lib.rs:28:1
    |
28  | pub mod implementation;
    | ^^^^^^^^^^^^^^^^^^^^^^

error[E0391]: cycle detected when type-checking `implementation::get_sign_state`
   --> src/implementation.rs:793:1
    |
793 | / pub fn get_sign_state(
794 | |     s: &mut ParsersState,
795 | | ) -> &mut <SignImplT as ParserCommon<DoubledSignParameters>>::State {
    | |___________________________________________________________________^
    |
    = note: ...which requires computing layout of `*mut implementation::ParsersStateInner<<implementation::GetAddressImplT as ledger_parser_combinators::interp_parser::ParserCommon<ledger_parser_combinators::core_parsers::DArray<ledger_parser_combinators::core_parsers::Byte, ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, 10>>>::State, <implementation::SignImplT as ledger_parser_combinators::interp_parser::ParserCommon<(ledger_parser_combinators::core_parsers::DArray<ledger_parser_combinators::core_parsers::Byte, ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, 10>, (ledger_parser_combinators::core_parsers::LengthFallback<ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, ledger_parser_combinators::json::Json<interface::PoktCmdSchema>>, ledger_parser_combinators::core_parsers::LengthFallback<ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, ledger_parser_combinators::json::Json<interface::PoktCmdSchema>>))>>::State>`...
    = note: ...which requires normalizing `*mut implementation::ParsersStateInner<<implementation::GetAddressImplT as ledger_parser_combinators::interp_parser::ParserCommon<ledger_parser_combinators::core_parsers::DArray<ledger_parser_combinators::core_parsers::Byte, ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, 10>>>::State, <implementation::SignImplT as ledger_parser_combinators::interp_parser::ParserCommon<(ledger_parser_combinators::core_parsers::DArray<ledger_parser_combinators::core_parsers::Byte, ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, 10>, (ledger_parser_combinators::core_parsers::LengthFallback<ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, ledger_parser_combinators::json::Json<interface::PoktCmdSchema>>, ledger_parser_combinators::core_parsers::LengthFallback<ledger_parser_combinators::core_parsers::U32<ledger_parser_combinators::endianness::Endianness::Little>, ledger_parser_combinators::json::Json<interface::PoktCmdSchema>>))>>::State>`...
note: ...which requires computing type of `implementation::SignImplT::{opaque#0}`...
   --> src/implementation.rs:348:22
    |
348 | pub type SignImplT = impl InterpParser<DoubledSignParameters, Returning = ArrayVec<u8, 128>>;
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: ...which again requires type-checking `implementation::get_sign_state`, completing the cycle
note: cycle used when computing type of `implementation::GetAddressImplT::{opaque#0}`
   --> src/implementation.rs:71:28
    |
71  | pub type GetAddressImplT = impl InterpParser<Bip32Key, Returning = ArrayVec<u8, 128>>;
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0391`.
```

https://github.com/obsidiansystems/ledger-app-pocket/commit/afb914a96b4aef24cd6bfecd4fe47fdb2b76a946 very slight fix back to the old higher level way of setting the enum (which didn't optimize well at least at one point) however fixes the error and gets the code to build again. This is quite odd!

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
<version>
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Backtrace</summary>
<p>

```
<backtrace>
```

</p>
</details>