Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ICE]: Region parameter out of range when substituting in region 'a (index=2, substs = ['_#1r, '_#1r]) #107036

Closed
1 of 4 tasks
dlon opened this issue Jan 18, 2023 · 2 comments · Fixed by #107038
Closed
1 of 4 tasks
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dlon
Copy link

dlon commented Jan 18, 2023

Code

//
// crate1/src/lib.rs
//

pub trait T {}
impl T for () {}

pub struct S {}

impl S {
    pub async fn f<'a>(&self) -> impl T + 'a {
        ()
    }
}

//
// crate2/src/lib.rs
//

use crate1::S;

async fn f() {
    S{}.f().await;
}

Affected release channels

  • Previous Stable
  • Current Stable
  • Current Beta
  • Current Nightly

Rust Version

rustc 1.68.0-nightly (3984bc583 2023-01-17)
binary: rustc
commit-hash: 3984bc5833db8bfb0acc522c9775383e4171f3de
commit-date: 2023-01-17
host: x86_64-pc-windows-msvc
release: 1.68.0-nightly
LLVM version: 15.0.6

Current error output

No response

Backtrace

error: internal compiler error: compiler\rustc_middle\src\ty\subst.rs:794:13: Region parameter out of range when substituting in region 'a (index=2, substs = ['_#1r, '_#1r])

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/3984bc5833db8bfb0acc522c9775383e4171f3de\compiler\rustc_errors\src\lib.rs:1609:9
stack backtrace:
   0:     0x7ffdc5e99cc2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h60a70252d856bd46
   1:     0x7ffdc5ed637b - core::fmt::write::h49075516e1cb5709
   2:     0x7ffdc5e8cc8a - <std::io::IoSlice as core::fmt::Debug>::fmt::h19762f7eafdc2925
   3:     0x7ffdc5e99a0b - std::sys::common::alloc::realloc_fallback::h0dd47069a25a560c
   4:     0x7ffdc5e9d3b9 - std::panicking::default_hook::h49984910299ea3cd
   5:     0x7ffdc5e9d03b - std::panicking::default_hook::h49984910299ea3cd
   6:     0x7ffdac78e37f - rustc_driver[7a77046e146b4f29]::describe_lints
   7:     0x7ffdc5e9dd1f - std::panicking::rust_panic_with_hook::h475d8178a36dbde4
   8:     0x7ffdacc8d1a3 - <rustc_middle[852c0ea678a80eaa]::ty::instance::InstanceDef as rustc_middle[852c0ea678a80eaa]::ty::context::Lift>::lift_to_tcx
   9:     0x7ffdacc8d129 - <rustc_middle[852c0ea678a80eaa]::ty::instance::InstanceDef as rustc_middle[852c0ea678a80eaa]::ty::context::Lift>::lift_to_tcx
  10:     0x7ffdacd0d4c9 - <rustc_middle[852c0ea678a80eaa]::ty::print::pretty::TraitRefPrintOnlyTraitPath as rustc_middle[852c0ea678a80eaa]::ty::context::Lift>::lift_to_tcx
  11:     0x7ffdaccc5259 - <rustc_middle[852c0ea678a80eaa]::ty::subst::UserSubsts as rustc_middle[852c0ea678a80eaa]::ty::context::Lift>::lift_to_tcx
  12:     0x7ffdaccc3a00 - <rustc_middle[852c0ea678a80eaa]::ty::subst::UserSubsts as rustc_middle[852c0ea678a80eaa]::ty::context::Lift>::lift_to_tcx
  13:     0x7ffdaccc3212 - <rustc_middle[852c0ea678a80eaa]::ty::subst::UserSubsts as rustc_middle[852c0ea678a80eaa]::ty::context::Lift>::lift_to_tcx
  14:     0x7ffdaccee33a - rustc_middle[852c0ea678a80eaa]::util::bug::bug_fmt
  15:     0x7ffdaccedcbd - <rustc_middle[852c0ea678a80eaa]::ty::consts::kind::UnevaluatedConst as rustc_errors[713f76e651ed9de9]::diagnostic::IntoDiagnosticArg>::into_diagnostic_arg
  16:     0x7ffdaccedc81 - <rustc_middle[852c0ea678a80eaa]::ty::consts::kind::UnevaluatedConst as rustc_errors[713f76e651ed9de9]::diagnostic::IntoDiagnosticArg>::into_diagnostic_arg
  17:     0x7ffdaccee278 - rustc_middle[852c0ea678a80eaa]::util::bug::bug_fmt
  18:     0x7ffdaccee1f5 - rustc_middle[852c0ea678a80eaa]::util::bug::bug_fmt
  19:     0x7ffdaccb6f23 - <rustc_middle[852c0ea678a80eaa]::ty::subst::GenericArg as rustc_middle[852c0ea678a80eaa]::ty::context::Lift>::lift_to_tcx
  20:     0x7ffdaaf3e025 - <rustc_middle[852c0ea678a80eaa]::ty::generics::GenericPredicates>::instantiate_identity
  21:     0x7ffdab6e0f16 - rustc_trait_selection[88b1e147c41b03db]::traits::wf::predicate_obligations
  22:     0x7ffdab6de8f2 - rustc_trait_selection[88b1e147c41b03db]::traits::wf::predicate_obligations
  23:     0x7ffdab70f912 - <rustc_trait_selection[88b1e147c41b03db]::traits::fulfill::FulfillProcessor as rustc_data_structures[a3cb96cea1ba54ce]::obligation_forest::ObligationProcessor>::process_obligation
  24:     0x7ffdab769e94 - <rustc_infer[b8df4eaaa31c36d3]::infer::InferCtxt as rustc_trait_selection[88b1e147c41b03db]::traits::outlives_bounds::InferCtxtExt>::implied_outlives_bounds
  25:     0x7ffdab70c8cf - <rustc_trait_selection[88b1e147c41b03db]::traits::fulfill::FulfillmentContext as rustc_infer[b8df4eaaa31c36d3]::traits::engine::TraitEngine>::select_where_possible
  26:     0x7ffdaac27bfe - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::try_coerce
  27:     0x7ffdaaca5e7a - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::resolve_type_vars_in_body
  28:     0x7ffdaac32573 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  29:     0x7ffdaac9154d - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::check_struct_path
  30:     0x7ffdaac34b47 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  31:     0x7ffdaaca5a38 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::resolve_type_vars_in_body
  32:     0x7ffdaac32573 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  33:     0x7ffdaac8fcff - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::check_struct_path
  34:     0x7ffdaac30aa9 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  35:     0x7ffdaac32b08 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  36:     0x7ffdaac8fe6d - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::check_struct_path
  37:     0x7ffdaac30aa9 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  38:     0x7ffdaac55891 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  39:     0x7ffdaad0bbc5 - <rustc_hir_typeck[da3e56a72a260ac8]::inherited::Inherited>::build
  40:     0x7ffda9a1649b - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::check_expr_closure
  41:     0x7ffdaac3430d - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  42:     0x7ffdaac7cc4e - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::probe_instantiate_query_response
  43:     0x7ffdaabf3e01 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::check_call
  44:     0x7ffdaac30652 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  45:     0x7ffdaac55891 - <rustc_hir_typeck[da3e56a72a260ac8]::fn_ctxt::FnCtxt>::demand_coerce
  46:     0x7ffdaad0bbc5 - <rustc_hir_typeck[da3e56a72a260ac8]::inherited::Inherited>::build
  47:     0x7ffdaacfff77 - <rustc_hir_typeck[da3e56a72a260ac8]::inherited::Inherited>::build
  48:     0x7ffdaad217a0 - <rustc_hir_typeck[da3e56a72a260ac8]::gather_locals::GatherLocalsVisitor as rustc_hir[108e8bcf66bd93db]::intravisit::Visitor>::visit_pat
  49:     0x7ffda9eca1a5 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_raw_bytes
  50:     0x7ffdab478299 - <rustc_middle[852c0ea678a80eaa]::ty::Visibility as rustc_privacy[1256a66fe85f6ffd]::VisibilityLike>::new_min
  51:     0x7ffdab5488b3 - <rustc_query_impl[ee87962b7b8b59b]::Queries as rustc_middle[852c0ea678a80eaa]::ty::query::QueryEngine>::as_any
  52:     0x7ffdab0a84dd - <rustc_mir_build[167d3f106e23a8ce]::thir::pattern::usefulness::PatStack>::head
  53:     0x7ffda9ec06c8 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_raw_bytes
  54:     0x7ffdab482c59 - <rustc_middle[852c0ea678a80eaa]::ty::Visibility as rustc_privacy[1256a66fe85f6ffd]::VisibilityLike>::new_min
  55:     0x7ffdab02b49c - <rustc_middle[852c0ea678a80eaa]::lint::ShallowLintLevelMap>::lint_level_id_at_node
  56:     0x7ffda9ec0e09 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_raw_bytes
  57:     0x7ffdab47e609 - <rustc_middle[852c0ea678a80eaa]::ty::Visibility as rustc_privacy[1256a66fe85f6ffd]::VisibilityLike>::new_min
  58:     0x7ffdab1e5895 - <rustc_mir_transform[b24cd75b40599810]::check_unsafety::UnsafetyChecker as rustc_middle[852c0ea678a80eaa]::mir::visit::Visitor>::visit_place
  59:     0x7ffdab1d9118 - <rustc_mir_transform[b24cd75b40599810]::shim::DropShimElaborator as rustc_mir_dataflow[c5db10d3eb5ed1b6]::elaborate_drops::DropElaborator>::drop_style
  60:     0x7ffda9eca1a5 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_raw_bytes
  61:     0x7ffdab449f4f - <rustc_middle[852c0ea678a80eaa]::ty::Visibility as rustc_privacy[1256a66fe85f6ffd]::VisibilityLike>::new_min
  62:     0x7ffda9cf1a8b - rustc_privacy[1256a66fe85f6ffd]::provide
  63:     0x7ffda9f05441 - <&[rustc_span[9a32fcdfb560e918]::def_id::DefId] as rustc_serialize[fb2cd6d42a10ac66]::serialize::Decodable<rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheDecoder>>::decode
  64:     0x7ffdab57fe54 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_u32
  65:     0x7ffdab57fdf4 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_u32
  66:     0x7ffdab57fdf4 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_u32
  67:     0x7ffdab57fdf4 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_u32
  68:     0x7ffdab57fdf4 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_u32
  69:     0x7ffda9cf4a56 - rustc_privacy[1256a66fe85f6ffd]::provide
  70:     0x7ffda9e8c051 - <rustc_query_impl[ee87962b7b8b59b]::Queries as rustc_middle[852c0ea678a80eaa]::ty::query::QueryEngine>::try_mark_green
  71:     0x7ffda99b6e20 - rustc_hir_analysis[5f44298b84aa60ac]::hir_wf_check::provide
  72:     0x7ffda99964b0 - rustc_hir_analysis[5f44298b84aa60ac]::check_crate
  73:     0x7ffda9ac573d - rustc_interface[296d29f5832b901f]::passes::analysis
  74:     0x7ffda9eeb6e9 - <rustc_query_impl[ee87962b7b8b59b]::on_disk_cache::CacheEncoder as rustc_serialize[fb2cd6d42a10ac66]::serialize::Encoder>::emit_raw_bytes
  75:     0x7ffda9e0c5c6 - rustc_privacy[1256a66fe85f6ffd]::provide
  76:     0x7ffda9e89a5f - <rustc_query_impl[ee87962b7b8b59b]::Queries as rustc_middle[852c0ea678a80eaa]::ty::query::QueryEngine>::try_mark_green
  77:     0x7ffda98ad2e5 - <core[4e164737ea2805f4]::ops::range::Range<usize> as core[4e164737ea2805f4]::convert::From<regex[96286c4a5f387064]::re_unicode::Match>>::from
  78:     0x7ffda98bee58 - rustc_driver[7a77046e146b4f29]::args::arg_expand_all
  79:     0x7ffda98a31e2 - <core[4e164737ea2805f4]::ops::range::Range<usize> as core[4e164737ea2805f4]::convert::From<regex[96286c4a5f387064]::re_unicode::Match>>::from
  80:     0x7ffda98be303 - rustc_driver[7a77046e146b4f29]::args::arg_expand_all
  81:     0x7ffda98ae463 - <core[4e164737ea2805f4]::ops::range::Range<usize> as core[4e164737ea2805f4]::convert::From<regex[96286c4a5f387064]::re_unicode::Match>>::from
  82:     0x7ffda98a6fdd - <core[4e164737ea2805f4]::ops::range::Range<usize> as core[4e164737ea2805f4]::convert::From<regex[96286c4a5f387064]::re_unicode::Match>>::from
  83:     0x7ffdc5eb087c - std::sys::windows::thread::Thread::new::h0e77efb359f7341a
  84:     0x7ffe45ec26bd - BaseThreadInitThunk
  85:     0x7ffe479adfb8 - RtlUserThreadStart

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.68.0-nightly (3984bc583 2023-01-17) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [typeck] type-checking `f`
#1 [thir_body] building THIR for `f`
#2 [mir_built] building MIR for `f`
#3 [unsafety_check_result] unsafety-checking `f`
#4 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `crate2`

Anything else?

I cannot get this to fail unless S is imported from another crate.

This might be a duplicate of #105519.

@dlon dlon added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 18, 2023
@compiler-errors compiler-errors self-assigned this Jan 18, 2023
@compiler-errors
Copy link
Member

I think this regressed in #106759 😓

@compiler-errors
Copy link
Member

searched nightlies: from nightly-2023-01-01 to nightly-2023-01-18
regressed nightly: nightly-2023-01-14
searched commit range: 61a415b...0b90256
regressed commit: 86ad69d

bisected with cargo-bisect-rustc v0.6.5

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2023-01-01 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants