rust-lang / rust

Empowering everyone to build reliable and efficient software.

Home Page:https://www.rust-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

expected type for `b/#0` (b/0) but found Lifetime(ReStatic) when substituting, substs=[ReStatic]

dwrensha opened this issue · comments

rustc crashes on the following input, found by fuzz_rustc:

Code

trait A{type B<'b>;}
struct C;
impl A for C {
    type B<b> =impl;
    fn a() -> Self::B<'a>;
}
error: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:674:9: expected type for `b/#0` (b/0) but found Lifetime(ReStatic) when substituting, substs=[ReStatic]

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/432abd86f231c908f6df3cdd779e83f35084be90/compiler/rustc_errors/src/lib.rs:1462:9
stack backtrace:
   0:     0x7f83bc70dd50 - std::backtrace_rs::backtrace::libunwind::trace::h22157d54c25d05ad
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f83bc70dd50 - std::backtrace_rs::backtrace::trace_unsynchronized::hf9a98b3986ed5962
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f83bc70dd50 - std::sys_common::backtrace::_print_fmt::h44f8a801ddb575b4
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f83bc70dd50 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h306abe8d5f5fb26d
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f83bc768aae - core::fmt::write::h5a3c14feb177cc6f
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f83bc6fe865 - std::io::Write::write_fmt::h2fac6c752c3fce7e
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/io/mod.rs:1679:15
   6:     0x7f83bc710a03 - std::sys_common::backtrace::_print::h17490259a7578aec
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f83bc710a03 - std::sys_common::backtrace::print::h6dba4ce5923cf00b
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f83bc710a03 - std::panicking::default_hook::{{closure}}::h25daedc6802fa9d1
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/panicking.rs:295:22
   9:     0x7f83bc7106ef - std::panicking::default_hook::hffec061dc0fa1a5a
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/panicking.rs:314:9
  10:     0x7f83bb17f951 - <rustc_driver[2817d6214121e090]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[7a17016bf310e64d]::ops::function::FnOnce<(&core[7a17016bf310e64d]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f83bc71123d - std::panicking::rust_panic_with_hook::h74e697c31d32505c
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/panicking.rs:702:17
  12:     0x7f83bc109061 - std[7414053366649774]::panicking::begin_panic::<rustc_errors[aa542ed4628157d3]::ExplicitBug>::{closure#0}
  13:     0x7f83bc106b66 - std[7414053366649774]::sys_common::backtrace::__rust_end_short_backtrace::<std[7414053366649774]::panicking::begin_panic<rustc_errors[aa542ed4628157d3]::ExplicitBug>::{closure#0}, !>
  14:     0x7f83bc15f5d6 - std[7414053366649774]::panicking::begin_panic::<rustc_errors[aa542ed4628157d3]::ExplicitBug>
  15:     0x7f83bc1051e6 - std[7414053366649774]::panic::panic_any::<rustc_errors[aa542ed4628157d3]::ExplicitBug>
  16:     0x7f83bc1002ef - <rustc_errors[aa542ed4628157d3]::HandlerInner>::bug::<&alloc[e7766d434969df5]::string::String>
  17:     0x7f83bc0ffd20 - <rustc_errors[aa542ed4628157d3]::Handler>::bug::<&alloc[e7766d434969df5]::string::String>
  18:     0x7f83bc1bd14d - rustc_middle[e9ef365c3785ee8]::ty::context::tls::with_context_opt::<rustc_middle[e9ef365c3785ee8]::ty::context::tls::with_opt<rustc_middle[e9ef365c3785ee8]::util::bug::opt_span_bug_fmt<rustc_span[8a07e301efc44469]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  19:     0x7f83bc1bed66 - rustc_middle[e9ef365c3785ee8]::util::bug::opt_span_bug_fmt::<rustc_span[8a07e301efc44469]::span_encoding::Span>
  20:     0x7f83b9be4e63 - rustc_middle[e9ef365c3785ee8]::util::bug::bug_fmt
  21:     0x7f83bc1dc13d - <rustc_middle[e9ef365c3785ee8]::ty::subst::SubstFolder>::type_param_expected
  22:     0x7f83b9abef60 - <rustc_middle[e9ef365c3785ee8]::ty::subst::SubstFolder as rustc_middle[e9ef365c3785ee8]::ty::fold::FallibleTypeFolder>::try_fold_ty
  23:     0x7f83b9abbb84 - <&rustc_middle[e9ef365c3785ee8]::ty::list::List<rustc_middle[e9ef365c3785ee8]::ty::subst::GenericArg> as rustc_middle[e9ef365c3785ee8]::ty::fold::TypeFoldable>::try_fold_with::<rustc_middle[e9ef365c3785ee8]::ty::subst::SubstFolder>
  24:     0x7f83b9b0b30d - <rustc_middle[e9ef365c3785ee8]::ty::Ty as rustc_middle[e9ef365c3785ee8]::ty::fold::TypeSuperFoldable>::super_fold_with::<rustc_middle[e9ef365c3785ee8]::ty::subst::SubstFolder>
  25:     0x7f83ba0df2c1 - rustc_trait_selection[df340bb754643847]::traits::project::opt_normalize_projection_type
  26:     0x7f83ba0dacf6 - <rustc_trait_selection[df340bb754643847]::traits::project::AssocTypeNormalizer as rustc_middle[e9ef365c3785ee8]::ty::fold::TypeFolder>::fold_ty
  27:     0x7f83ba8f8708 - <rustc_trait_selection[df340bb754643847]::traits::engine::ObligationCtxt>::assumed_wf_types
  28:     0x7f83ba8f3992 - <rustc_infer[b37a4aeb4f547260]::infer::InferCtxtBuilder>::enter::<(), rustc_typeck[3375101d568ff0f8]::check::wfcheck::enter_wf_checking_ctxt<rustc_typeck[3375101d568ff0f8]::check::wfcheck::check_associated_item::{closure#0}>::{closure#0}>
  29:     0x7f83ba8f2ad7 - rustc_typeck[3375101d568ff0f8]::check::wfcheck::check_associated_item
  30:     0x7f83ba8ef604 - rustc_typeck[3375101d568ff0f8]::check::wfcheck::check_well_formed
  31:     0x7f83ba121f26 - rustc_query_system[64e6e6746f0d4f91]::query::plumbing::try_execute_query::<rustc_query_impl[33edb96cb03c9964]::plumbing::QueryCtxt, rustc_query_system[64e6e6746f0d4f91]::query::caches::DefaultCache<rustc_span[8a07e301efc44469]::def_id::LocalDefId, ()>>
  32:     0x7f83bb0c815b - <rustc_query_impl[33edb96cb03c9964]::Queries as rustc_middle[e9ef365c3785ee8]::ty::query::QueryEngine>::check_well_formed
  33:     0x7f83bac5fccf - rustc_data_structures[7efd42249ed2c6e9]::sync::par_for_each_in::<&[rustc_hir[3f2e5423ae034c14]::hir::ImplItemId], <rustc_middle[e9ef365c3785ee8]::hir::ModuleItems>::par_impl_items<rustc_typeck[3375101d568ff0f8]::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>
  34:     0x7f83bb0299b9 - rustc_typeck[3375101d568ff0f8]::check::wfcheck::check_mod_type_wf
  35:     0x7f83ba121f26 - rustc_query_system[64e6e6746f0d4f91]::query::plumbing::try_execute_query::<rustc_query_impl[33edb96cb03c9964]::plumbing::QueryCtxt, rustc_query_system[64e6e6746f0d4f91]::query::caches::DefaultCache<rustc_span[8a07e301efc44469]::def_id::LocalDefId, ()>>
  36:     0x7f83bac05f99 - rustc_query_system[64e6e6746f0d4f91]::query::plumbing::get_query::<rustc_query_impl[33edb96cb03c9964]::queries::check_mod_type_wf, rustc_query_impl[33edb96cb03c9964]::plumbing::QueryCtxt>
  37:     0x7f83ba51fe08 - rustc_data_structures[7efd42249ed2c6e9]::sync::par_for_each_in::<&[rustc_span[8a07e301efc44469]::def_id::LocalDefId], <rustc_middle[e9ef365c3785ee8]::hir::map::Map>::par_for_each_module<rustc_typeck[3375101d568ff0f8]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  38:     0x7f83ba51fc13 - <rustc_session[920c8e110a6e000f]::session::Session>::track_errors::<rustc_typeck[3375101d568ff0f8]::check_crate::{closure#5}, ()>
  39:     0x7f83ba51d080 - rustc_typeck[3375101d568ff0f8]::check_crate
  40:     0x7f83ba51c6c7 - rustc_interface[2d255db050a36d31]::passes::analysis
  41:     0x7f83baf569d4 - rustc_query_system[64e6e6746f0d4f91]::query::plumbing::try_execute_query::<rustc_query_impl[33edb96cb03c9964]::plumbing::QueryCtxt, rustc_query_system[64e6e6746f0d4f91]::query::caches::DefaultCache<(), core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>>>
  42:     0x7f83baf56707 - rustc_query_system[64e6e6746f0d4f91]::query::plumbing::get_query::<rustc_query_impl[33edb96cb03c9964]::queries::analysis, rustc_query_impl[33edb96cb03c9964]::plumbing::QueryCtxt>
  43:     0x7f83b9f1ab77 - <rustc_interface[2d255db050a36d31]::passes::QueryContext>::enter::<rustc_driver[2817d6214121e090]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>>
  44:     0x7f83b9f0e6dc - rustc_interface[2d255db050a36d31]::interface::create_compiler_and_run::<core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>, rustc_driver[2817d6214121e090]::run_compiler::{closure#1}>
  45:     0x7f83b9f0d012 - <scoped_tls[f167104904068c68]::ScopedKey<rustc_span[8a07e301efc44469]::SessionGlobals>>::set::<rustc_interface[2d255db050a36d31]::interface::run_compiler<core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>, rustc_driver[2817d6214121e090]::run_compiler::{closure#1}>::{closure#0}, core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>>
  46:     0x7f83b9f0ccff - std[7414053366649774]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2d255db050a36d31]::util::run_in_thread_pool_with_globals<rustc_interface[2d255db050a36d31]::interface::run_compiler<core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>, rustc_driver[2817d6214121e090]::run_compiler::{closure#1}>::{closure#0}, core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>>::{closure#0}, core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>>
  47:     0x7f83bafe7fe0 - <<std[7414053366649774]::thread::Builder>::spawn_unchecked_<rustc_interface[2d255db050a36d31]::util::run_in_thread_pool_with_globals<rustc_interface[2d255db050a36d31]::interface::run_compiler<core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>, rustc_driver[2817d6214121e090]::run_compiler::{closure#1}>::{closure#0}, core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>>::{closure#0}, core[7a17016bf310e64d]::result::Result<(), rustc_errors[aa542ed4628157d3]::ErrorGuaranteed>>::{closure#1} as core[7a17016bf310e64d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  48:     0x7f83bc71b013 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h59c19dbfda82d3be
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/alloc/src/boxed.rs:1940:9
  49:     0x7f83bc71b013 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5cc1cabf17fe5922
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/alloc/src/boxed.rs:1940:9
  50:     0x7f83bc71b013 - std::sys::unix::thread::Thread::new::thread_start::h8f3eeb92c9304ef6
                               at /rustc/432abd86f231c908f6df3cdd779e83f35084be90/library/std/src/sys/unix/thread.rs:108:17
  51:     0x7f83b8694b43 - start_thread
                               at ./nptl/./nptl/pthread_create.c:442:8
  52:     0x7f83b8726a00 - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  53:                0x0 - <unknown>

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.66.0-nightly (432abd86f 2022-09-20) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `<impl at bug.rs:3:1: 3:13>::a` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 7 previous errors; 1 warning emitted

cargo-bisect-rustc says:

Regression in nightly-2019-12-21

found 5 bors merge commits in the specified range
commit[0] 2019-12-19UTC: Auto merge of #67419 - Centril:rollup-v7b0ypv, r=Centril
commit[1] 2019-12-19UTC: Auto merge of #67440 - Mark-Simulacrum:rollup-z59a7ky, r=Mark-Simulacrum
commit[2] 2019-12-20UTC: Auto merge of #67443 - Mark-Simulacrum:toolstate-no-commit-newline, r=Mark-Simulacrum
commit[3] 2019-12-20UTC: Auto merge of #67449 - Centril:rollup-04hvg57, r=Centril
commit[4] 2019-12-20UTC: Auto merge of #67455 - Centril:rollup-mf0yc81, r=Centril

Minimized:

trait A {
    type B<'b>;
    fn a() -> Self::B<'static>;
}

struct C;

struct Wrapper<T>(T);

impl A for C {
    type B<T> = Wrapper<T>;
    fn a() -> Self::B<'static> {}
}