Skip to content

find_opaque_ty_constraints_for_rpit ICE for stranded opaques #235

@lcnr

Description

@lcnr
  • tests/ui/impl-trait/opt-out-bound-not-satisfied.rs
  • tests/ui/impl-trait/stranded-opaque.rs
use std::future::Future;
fn foo() -> impl ?Future<Output = impl Send> {
    //~^ ERROR: bound modifier `?` can only be applied to `Sized`
    //~| ERROR: bound modifier `?` can only be applied to `Sized`
    ()
}

results in

error: bound modifier `?` can only be applied to `Sized`
 --> src/main.rs:5:18
  |
5 | fn foo() -> impl ?Future<Output = impl Send> {
  |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs:253:17:
assertion failed: !tcx.next_trait_solver_globally()
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/std/src/panicking.rs:697:5
   1: core::panicking::panic_fmt
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panicking.rs:75:14
   2: core::panicking::panic
             at /rustc/788da80fcfcef3f34c90def5baa32813e39a1a41/library/core/src/panicking.rs:145:5
   3: find_opaque_ty_constraints_for_rpit
             at /home/lcnr/rust/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs:253:17
   4: type_of_opaque_hir_typeck
             at /home/lcnr/rust/compiler/rustc_hir_analysis/src/collect/type_of.rs:415:13

so does

trait Trait {}
impl Trait for i32 {}

// Since `Assoc` doesn't actually exist, it's "stranded", and won't show up in
// the list of opaques that may be defined by the function. Make sure we don't
// ICE in this case.
fn produce<T>() -> impl Trait<Assoc = impl Trait> {
    //~^ ERROR associated type `Assoc` not found for `Trait`
    //~| ERROR associated type `Assoc` not found for `Trait`
    16
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions