Skip to content

ICE: need_type_info unexpected path #97806

Closed
@TheIronBorn

Description

@TheIronBorn

Code

struct TestErr<T> {
     field: std::marker::PhantomData<T>,
}

impl<T> TestErr<T> {
    fn func_a() {}

    fn func_b() {
        Self::func_a();

        let variable = None;
    }
}

This may be related to #97698

Meta

rustc --version --verbose:

rustc 1.63.0-nightly (fee3a459d 2022-06-05)
binary: rustc
commit-hash: fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401
commit-date: 2022-06-05
host: x86_64-pc-windows-msvc
release: 1.63.0-nightly
LLVM version: 14.0.5

Error output

error: internal compiler error: compiler\rustc_infer\src\infer\error_reporting\need_type_info.rs:856:33: unexpected path
: def=TestErr substs=[_] path=Path { span: src\lib.rs:9:9: 9:13 (#0), res: SelfTy { trait_: None, alias_to: Some((DefId(
0:6 ~ test2[211d]::{impl#0}), false)) }, segments: [PathSegment { ident: Self#0, hir_id: Some(HirId { owner: DefId(0:9 ~
 test2[211d]::{impl#0}::func_b), local_id: 3 }), res: Some(SelfTy { trait_: None, alias_to: Some((DefId(0:6 ~ test2[211d
]::{impl#0}), false)) }), args: None, infer_args: true }] }

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/fee3a459dd6aba8e34a5b99f0fbcb4218a1e2401\compiler\rustc_errors\src\lib
.rs:1335:9

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler
&template=ice.md

note: rustc 1.63.0-nightly (fee3a459d 2022-06-05) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental -C target-cpu=native

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `<impl at src\lib.rs:5:1: 13:2>::func_b`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `test2`
Backtrace

stack backtrace:
   0:     0x7ffbf81d9d1f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf9140f961
aae3bca
   1:     0x7ffbf8214d1a - core::fmt::write::h83e4325296b41ee9
   2:     0x7ffbf81cc119 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h3cbc46f9c04c9110
   3:     0x7ffbf81dd60b - std::panicking::default_hook::h4ed310d63b7aad19
   4:     0x7ffbf81dd28b - std::panicking::default_hook::h4ed310d63b7aad19
   5:     0x7ffbdecfa0f6 - rustc_driver[5ceae6c45f539b20]::pretty::print_after_hir_lowering
   6:     0x7ffbf81dddb2 - std::panicking::rust_panic_with_hook::hb7db12ea91edbe64
   7:     0x7ffbe3313bc5 - <rustc_middle[b17ff1f261c866a1]::mir::visit::PlaceContext as core[2f4fddafc238f4ec]::fmt::Deb
ug>::fmt
   8:     0x7ffbe33120d9 - <rustc_middle[b17ff1f261c866a1]::mir::visit::PlaceContext as core[2f4fddafc238f4ec]::fmt::Deb
ug>::fmt
   9:     0x7ffbe3801c09 - rustc_middle[b17ff1f261c866a1]::util::bug::bug_fmt
  10:     0x7ffbe32b19e9 - <rustc_middle[b17ff1f261c866a1]::ty::sty::TypeAndMut as rustc_middle[b17ff1f261c866a1]::ty::c
ontext::Lift>::lift_to_tcx
  11:     0x7ffbe3298083 - <rustc_middle[b17ff1f261c866a1]::ty::sty::TypeAndMut as rustc_middle[b17ff1f261c866a1]::ty::c
ontext::Lift>::lift_to_tcx
  12:     0x7ffbe3295db2 - <rustc_middle[b17ff1f261c866a1]::ty::sty::TypeAndMut as rustc_middle[b17ff1f261c866a1]::ty::c
ontext::Lift>::lift_to_tcx
  13:     0x7ffbe331fbc9 - <rustc_middle[b17ff1f261c866a1]::ty::consts::int::ScalarInt as core[2f4fddafc238f4ec]::fmt::D
isplay>::fmt
  14:     0x7ffbe331fc4c - <rustc_middle[b17ff1f261c866a1]::ty::consts::int::ScalarInt as core[2f4fddafc238f4ec]::fmt::D
isplay>::fmt
  15:     0x7ffbe3801bb8 - rustc_middle[b17ff1f261c866a1]::util::bug::bug_fmt
  16:     0x7ffbe3152219 - <rustc_infer[6954ca37551801a9]::infer::error_reporting::need_type_info::TypeAnnotationNeeded
as core[2f4fddafc238f4ec]::convert::Into<rustc_errors[62a8d79a6ebe4f2c]::diagnostic::DiagnosticId>>::into
  17:     0x7ffbe315296a - <rustc_infer[6954ca37551801a9]::infer::error_reporting::need_type_info::FindInferSourceVisito
r as rustc_hir[329a2e92ed33dca0]::intravisit::Visitor>::visit_expr
  18:     0x7ffbe3152720 - <rustc_infer[6954ca37551801a9]::infer::error_reporting::need_type_info::FindInferSourceVisito
r as rustc_hir[329a2e92ed33dca0]::intravisit::Visitor>::visit_expr
  19:     0x7ffbe3179c0d - <rustc_middle[b17ff1f261c866a1]::ty::sty::ProjectionTy as rustc_infer[6954ca37551801a9]::infe
r::at::ToTrace>::to_trace
  20:     0x7ffbe3152734 - <rustc_infer[6954ca37551801a9]::infer::error_reporting::need_type_info::FindInferSourceVisito
r as rustc_hir[329a2e92ed33dca0]::intravisit::Visitor>::visit_expr
  21:     0x7ffbe309df11 - <rustc_infer[6954ca37551801a9]::infer::InferCtxt>::emit_inference_failure_err
  22:     0x7ffbe3054dac - <rustc_infer[6954ca37551801a9]::infer::InferCtxt as rustc_trait_selection[2cc1a302a0c8a46f]::
traits::error_reporting::InferCtxtPrivExt>::maybe_report_ambiguity
  23:     0x7ffbe3041115 - <rustc_infer[6954ca37551801a9]::infer::InferCtxt as rustc_trait_selection[2cc1a302a0c8a46f]::
traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  24:     0x7ffbe16a6514 - <rustc_typeck[1da886d7d77884b0]::check::fn_ctxt::FnCtxt>::apply_adjustments
  25:     0x7ffbe173401b - <rustc_typeck[1da886d7d77884b0]::collect::type_of::find_opaque_ty_constraints::ConstraintLoca
tor as rustc_hir[329a2e92ed33dca0]::intravisit::Visitor>::visit_trait_item
  26:     0x7ffbe16fbe02 - rustc_typeck[1da886d7d77884b0]::check::provide
  27:     0x7ffbe227b628 - <rustc_query_impl[4eb9394896c41b4e]::queries::generator_diagnostic_data as rustc_query_system
[93ec4419bf33f6fc]::query::config::QueryDescription<rustc_query_impl[4eb9394896c41b4e]::plumbing::QueryCtxt>>::describe
  28:     0x7ffbe25a6222 - <&[rustc_span[f3561307c7d48550]::def_id::LocalDefId] as rustc_serialize[d89fb95351769db2]::se
rialize::Decodable<rustc_query_impl[4eb9394896c41b4e]::on_disk_cache::CacheDecoder>>::decode
  29:     0x7ffbe241bbb7 - <&[rustc_span[f3561307c7d48550]::def_id::LocalDefId] as rustc_serialize[d89fb95351769db2]::se
rialize::Decodable<rustc_query_impl[4eb9394896c41b4e]::on_disk_cache::CacheDecoder>>::decode
  30:     0x7ffbe2562e08 - <&[rustc_span[f3561307c7d48550]::def_id::LocalDefId] as rustc_serialize[d89fb95351769db2]::se
rialize::Decodable<rustc_query_impl[4eb9394896c41b4e]::on_disk_cache::CacheDecoder>>::decode
  31:     0x7ffbe1561521 - <rustc_typeck[1da886d7d77884b0]::check::upvar::InferBorrowKind as rustc_typeck[1da886d7d77884
b0]::expr_use_visitor::Delegate>::mutate
  32:     0x7ffbe17022a3 - <rustc_typeck[1da886d7d77884b0]::check::MaybeInProgressTables>::borrow_mut
  33:     0x7ffbe227d41e - <rustc_query_impl[4eb9394896c41b4e]::queries::generator_diagnostic_data as rustc_query_system
[93ec4419bf33f6fc]::query::config::QueryDescription<rustc_query_impl[4eb9394896c41b4e]::plumbing::QueryCtxt>>::describe
  34:     0x7ffbe25ce68f - <&[rustc_span[f3561307c7d48550]::def_id::LocalDefId] as rustc_serialize[d89fb95351769db2]::se
rialize::Decodable<rustc_query_impl[4eb9394896c41b4e]::on_disk_cache::CacheDecoder>>::decode
  35:     0x7ffbe24b44b9 - <&[rustc_span[f3561307c7d48550]::def_id::LocalDefId] as rustc_serialize[d89fb95351769db2]::se
rialize::Decodable<rustc_query_impl[4eb9394896c41b4e]::on_disk_cache::CacheDecoder>>::decode
  36:     0x7ffbe252d599 - <&[rustc_span[f3561307c7d48550]::def_id::LocalDefId] as rustc_serialize[d89fb95351769db2]::se
rialize::Decodable<rustc_query_impl[4eb9394896c41b4e]::on_disk_cache::CacheDecoder>>::decode
  37:     0x7ffbe157d8cf - <rustc_typeck[1da886d7d77884b0]::expr_use_visitor::ExprUseVisitor>::consume_body
  38:     0x7ffbe155bdd6 - rustc_typeck[1da886d7d77884b0]::check_crate
  39:     0x7ffbdede960f - rustc_interface[6179e6dd00003194]::passes::analysis
  40:     0x7ffbe227cf0e - <rustc_query_impl[4eb9394896c41b4e]::queries::generator_diagnostic_data as rustc_query_system
[93ec4419bf33f6fc]::query::config::QueryDescription<rustc_query_impl[4eb9394896c41b4e]::plumbing::QueryCtxt>>::describe
  41:     0x7ffbe25c503f - <&[rustc_span[f3561307c7d48550]::def_id::LocalDefId] as rustc_serialize[d89fb95351769db2]::se
rialize::Decodable<rustc_query_impl[4eb9394896c41b4e]::on_disk_cache::CacheDecoder>>::decode
  42:     0x7ffbe249e3bb - <&[rustc_span[f3561307c7d48550]::def_id::LocalDefId] as rustc_serialize[d89fb95351769db2]::se
rialize::Decodable<rustc_query_impl[4eb9394896c41b4e]::on_disk_cache::CacheDecoder>>::decode
  43:     0x7ffbe2563216 - <&[rustc_span[f3561307c7d48550]::def_id::LocalDefId] as rustc_serialize[d89fb95351769db2]::se
rialize::Decodable<rustc_query_impl[4eb9394896c41b4e]::on_disk_cache::CacheDecoder>>::decode
  44:     0x7ffbdecaf6af - <rustc_driver[5ceae6c45f539b20]::args::Error as core[2f4fddafc238f4ec]::fmt::Debug>::fmt
  45:     0x7ffbdec87370 - <rustc_lint[88f370ff989524bb]::BuiltinCombinedLateLintPass as rustc_lint[88f370ff989524bb]::p
asses::LateLintPass>::check_local
  46:     0x7ffbded08895 - <rustc_driver[5ceae6c45f539b20]::Compilation as core[2f4fddafc238f4ec]::fmt::Debug>::fmt
  47:     0x7ffbdec885cd - <rustc_lint[88f370ff989524bb]::BuiltinCombinedLateLintPass as rustc_lint[88f370ff989524bb]::p
asses::LateLintPass>::check_local
  48:     0x7ffbdecef5c6 - <rustc_metadata[bf9ab9df0d2c4d9d]::rmeta::encoder::EncodeContext as rustc_serialize[d89fb9535
1769db2]::serialize::Encoder>::emit_raw_bytes
  49:     0x7ffbdecb2798 - <rustc_driver[5ceae6c45f539b20]::args::Error as core[2f4fddafc238f4ec]::fmt::Debug>::fmt
  50:     0x7ffbf81eef5c - std::sys::windows::thread::Thread::new::hf6581a2a4a7d3e64
  51:     0x7ffc34017034 - BaseThreadInitThunk
  52:     0x7ffc34942651 - RtlUserThreadStart

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions