Skip to content

Compiler crash when calling a method of an impl with an associated type #26299

Closed
@kornelski

Description

@kornelski

playpen

pub trait Tr {
    type A = ();
}

pub struct S<T, U> {
    data: T,
    more_data: U,
}

impl<T: Tr + Copy> S<T, <T as Tr>::A> {
    pub fn it_exists(&self) {
    }
}

#[test]
fn test() {
    let x = S {
        data: (),
        more_data: (),
    };
    x.it_exists();
}

:23:7: 23:18 error: no method named it_exists found for type S<(), ()> in the current scope
:23 x.it_exists();
^~~~~~~~~~~
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.

thread 'rustc' panicked at 'index out of bounds: the len is 6 but the index is 6', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libcollections/vec.rs:1360

stack backtrace:
   1:        0x11207a7a5 - sys::backtrace::write::h29ef8ae2ab6f0002jbs
   2:        0x112082fc0 - panicking::on_panic::hfbadaf349a878dcdyvw
   3:        0x11203d948 - rt::unwind::begin_unwind_inner::hfdee7d48e374f632Qdw
   4:        0x11203e74c - rt::unwind::begin_unwind_fmt::h3343ff9b52ac6df8Wcw
   5:        0x112082b1c - rust_begin_unwind
   6:        0x1120d8395 - panicking::panic_fmt::h77445f1832864594i5B
   7:        0x1120d3128 - panicking::panic_bounds_check::h33c5d541561a6da1o4B
   8:        0x10f280dfa - middle::infer::InferCtxt<'a, 'tcx>::shallow_resolve::hec4d196f2c799057xDB
   9:        0x10f249ba7 - middle::infer::resolve::OpportunisticTypeResolver<'a, 'tcx>.ty_fold..TypeFolder<'tcx>::fold_ty::h2541942639a2619atBz
  10:        0x10f24a6ee - middle::ty_fold::TypeFolder::fold_substs::h3224040725562002305
  11:        0x10f309b87 - middle::traits::project::opt_normalize_projection_type::h5d4aae783bf615df0YR
  12:        0x10f30626b - middle::traits::project::project_and_unify_type::hbd03945bb6618251VHR
  13:        0x10f304077 - middle::infer::InferCtxt<'a, 'tcx>::commit_if_ok::h8565990550079113657
  14:        0x10f2ffbfa - middle::traits::fulfill::FulfillmentContext<'tcx>::select::h759bfc9f06b00812AhR
  15:        0x10f2ff95b - middle::traits::fulfill::FulfillmentContext<'tcx>::select_new_obligations::h35a7d27f6260a3dafgR
  16:        0x10edfe833 - check::FnCtxt<'a, 'tcx>::select_new_obligations::h4a992210d28aa452nJp
  17:        0x10ee24b3a - check::check_argument_types::h66437fbdecf2dddf9cq
  18:        0x10ee265d4 - check::check_method_argument_types::h81b2e6032a5a41b3yaq
  19:        0x10ee538fc - check::check_expr_with_unifier::check_method_call::hcb47f87ab6e4e6dcFMq
  20:        0x10ee7eb48 - check::check_expr_with_unifier::h13869274471355282472
  21:        0x10ee8fe18 - check::check_stmt::hbf2fba58f2402ce9Nms
  22:        0x10ee3dae1 - check::check_block_with_expected::h5328c1bd4122b704Yqs
  23:        0x10ee1ee88 - check::check_fn::hb8743989b71a8061yZn
  24:        0x10ee37c36 - check::check_bare_fn::h7a4176e04b21d21a8On
  25:        0x10ee35ac7 - check::check_item_body::h2e895edb8ec2cd0dZfo
  26:        0x10ee37803 - check::check_item_types::hc3786f7c3f819a18FMn
  27:        0x10eef828c - check_crate::h3859ff1cffe5ee82D8C
  28:        0x10e7310ae - driver::phase_3_run_analysis_passes::h17aa11005a47f3a3HGa
  29:        0x10e713cc3 - driver::compile_input::h7b180598a8644ea5Sba
  30:        0x10e7d0094 - run_compiler::h47ece7857b98d974p6b

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions