Skip to content

subtype obligations drop nested WF obligations required due to bivariant args  #250

@lcnr

Description

@lcnr
enum State<S, T>
where
    S: Iterator<Item = T>,
{
    Active { upstream: S },
    WindDown,
    Complete,
}

impl<S, T> State<S, T>
where
    S: Iterator<Item = T>,
{
    fn foo(self) {
        let x = match self {
            State::Active { .. } => None,
            State::WindDown => None,
            State::Complete => Some(State::Complete),
        };
        let _: Option<State<S, T>> = x;
    }
}

results in

error: internal compiler error: unexpected inference variable after writeback: Binder { value: SubtypePredicate { a_is_expected: true, a: State<S/#0, ?46t>, b: State<S/#0, T/#1> }, bound_vars: [] }
  --> src/main.rs:17:32
   |
17 |             State::WindDown => None,
   |                                ^^^^
   |
note: delayed at compiler/rustc_hir_typeck/src/writeback.rs:794:36 - disabled backtrace
  --> src/main.rs:17:32
   |
17 |             State::WindDown => None,
   |                                ^^^^

error: internal compiler error: unexpected inference variable after writeback: Binder { value: SubtypePredicate { a_is_expected: false, a: State<S/#0, T/#1>, b: State<S/#0, ?46t> }, bound_vars: [] }
  --> src/main.rs:16:37
   |
16 |             State::Active { .. } => None,
   |                                     ^^^^
   |
note: delayed at compiler/rustc_hir_typeck/src/writeback.rs:794:36 - disabled backtrace
  --> src/main.rs:16:37
   |
16 |             State::Active { .. } => None,
   |                                     ^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    from-craterA regression found via a crater run, not part of our test suite

    Type

    No type

    Projects

    Status

    todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions