ICE: `cannot relate bound region: ReError <= ReLateBound(DebruijnIndex(0), BoundRegion { .. }`
matthiaskrgr opened this issue · 8 comments
Code
trait Document {
fn cursor(&self) -> Lexer::Cursor<'_>;
}
struct Lexer<'d> {
cursor: (),
_phantom: std::marker::PhantomData<&'d ()>,
}
impl<'cursor> Lexer<'d> {
type Cursor<'a> = DocCursorImpl<'a>;
}
Meta
rustc --version --verbose
:
rustc 1.70.0-nightly (13afbdaa0 2023-03-17)
binary: rustc
commit-hash: 13afbdaa0655dda23d7129e59ac48f1ec88b2084
commit-date: 2023-03-17
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7
Error output
some
Backtrace
error: internal compiler error: compiler/rustc_infer/src/infer/region_constraints/mod.rs:568:17: cannot relate bound region: ReError <= ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:32 ~ 21719089E87B4DC2F26447D67DC99251BCF5E8F5235B79C1D8484F9BBFA8BC24[896f]::Document::cursor::'_), '_) })
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/compiler/rustc_errors/src/lib.rs:995:33
stack backtrace:
0: 0x7f001d56739a - std::backtrace_rs::backtrace::libunwind::trace::h84d2711f38e4d049
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f001d56739a - std::backtrace_rs::backtrace::trace_unsynchronized::h07f6ebc5344709db
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f001d56739a - std::sys_common::backtrace::_print_fmt::h05a29271ab24b307
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/sys_common/backtrace.rs:65:5
3: 0x7f001d56739a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2badcaa62266c6d2
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f001d5ca9be - core::fmt::write::h029bd029dcf67de1
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/core/src/fmt/mod.rs:1254:17
5: 0x7f001d55a225 - std::io::Write::write_fmt::h80e1934b9bd451b8
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/io/mod.rs:1684:15
6: 0x7f001d567165 - std::sys_common::backtrace::_print::hd15e10f9274c89b0
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/sys_common/backtrace.rs:47:5
7: 0x7f001d567165 - std::sys_common::backtrace::print::h170965e4e66b5ee4
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/sys_common/backtrace.rs:34:9
8: 0x7f001d569edf - std::panicking::default_hook::{{closure}}::h0164004bb09e0366
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/panicking.rs:271:22
9: 0x7f001d569c1b - std::panicking::default_hook::h5e2940911ec5582f
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/panicking.rs:290:9
10: 0x7f00207f2415 - rustc_driver_impl[bad2ed848d64dbdc]::DEFAULT_HOOK::{closure#0}::{closure#0}
11: 0x7f001d56a71d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h0f3cc38fa49d6ba4
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/alloc/src/boxed.rs:2002:9
12: 0x7f001d56a71d - std::panicking::rust_panic_with_hook::h591d1df500c4db69
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/panicking.rs:696:13
13: 0x7f0020b25831 - std[b4247acdb72724ff]::panicking::begin_panic::<rustc_errors[48bb1377a0478866]::ExplicitBug>::{closure#0}
14: 0x7f0020b24a36 - std[b4247acdb72724ff]::sys_common::backtrace::__rust_end_short_backtrace::<std[b4247acdb72724ff]::panicking::begin_panic<rustc_errors[48bb1377a0478866]::ExplicitBug>::{closure#0}, !>
15: 0x7f0020b24856 - std[b4247acdb72724ff]::panicking::begin_panic::<rustc_errors[48bb1377a0478866]::ExplicitBug>
16: 0x7f0020b13466 - std[b4247acdb72724ff]::panic::panic_any::<rustc_errors[48bb1377a0478866]::ExplicitBug>
17: 0x7f0020b0dd52 - <rustc_errors[48bb1377a0478866]::HandlerInner>::span_bug::<rustc_span[4d522547309d7b79]::span_encoding::Span, &alloc[c5857ad37805d36e]::string::String>
18: 0x7f0020b0db17 - <rustc_errors[48bb1377a0478866]::Handler>::span_bug::<rustc_span[4d522547309d7b79]::span_encoding::Span, &alloc[c5857ad37805d36e]::string::String>
19: 0x7f0020b46f6b - rustc_middle[eaf6378de1cdbfa8]::util::bug::opt_span_bug_fmt::<rustc_span[4d522547309d7b79]::span_encoding::Span>::{closure#0}
20: 0x7f0020b4708a - rustc_middle[eaf6378de1cdbfa8]::ty::context::tls::with_opt::<rustc_middle[eaf6378de1cdbfa8]::util::bug::opt_span_bug_fmt<rustc_span[4d522547309d7b79]::span_encoding::Span>::{closure#0}, !>::{closure#0}
21: 0x7f0020b458b6 - rustc_middle[eaf6378de1cdbfa8]::ty::context::tls::with_context_opt::<rustc_middle[eaf6378de1cdbfa8]::ty::context::tls::with_opt<rustc_middle[eaf6378de1cdbfa8]::util::bug::opt_span_bug_fmt<rustc_span[4d522547309d7b79]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
22: 0x7f0020b457d6 - rustc_middle[eaf6378de1cdbfa8]::util::bug::opt_span_bug_fmt::<rustc_span[4d522547309d7b79]::span_encoding::Span>
23: 0x7f0020b45794 - rustc_middle[eaf6378de1cdbfa8]::util::bug::span_bug_fmt::<rustc_span[4d522547309d7b79]::span_encoding::Span>
24: 0x7f001eed39c6 - <rustc_infer[4fc335a583559fa2]::infer::sub::Sub as rustc_middle[eaf6378de1cdbfa8]::ty::relate::TypeRelation>::relate::<rustc_middle[eaf6378de1cdbfa8]::ty::sty::Region>
25: 0x7f001eed066e - <core[9847d4a2e8a02df2]::result::Result<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg, rustc_middle[eaf6378de1cdbfa8]::ty::error::TypeError> as rustc_type_ir[ebb4b6c2800c0907]::CollectAndApply<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg, &rustc_middle[eaf6378de1cdbfa8]::ty::list::List<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg>>>::collect_and_apply::<core[9847d4a2e8a02df2]::iter::adapters::map::Map<core[9847d4a2e8a02df2]::iter::adapters::enumerate::Enumerate<core[9847d4a2e8a02df2]::iter::adapters::zip::Zip<core[9847d4a2e8a02df2]::iter::adapters::copied::Copied<core[9847d4a2e8a02df2]::slice::iter::Iter<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg>>, core[9847d4a2e8a02df2]::iter::adapters::copied::Copied<core[9847d4a2e8a02df2]::slice::iter::Iter<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg>>>>, rustc_middle[eaf6378de1cdbfa8]::ty::relate::relate_substs_with_variances<rustc_infer[4fc335a583559fa2]::infer::sub::Sub>::{closure#0}>, <rustc_middle[eaf6378de1cdbfa8]::ty::context::TyCtxt>::mk_substs_from_iter<core[9847d4a2e8a02df2]::iter::adapters::map::Map<core[9847d4a2e8a02df2]::iter::adapters::enumerate::Enumerate<core[9847d4a2e8a02df2]::iter::adapters::zip::Zip<core[9847d4a2e8a02df2]::iter::adapters::copied::Copied<core[9847d4a2e8a02df2]::slice::iter::Iter<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg>>, core[9847d4a2e8a02df2]::iter::adapters::copied::Copied<core[9847d4a2e8a02df2]::slice::iter::Iter<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg>>>>, rustc_middle[eaf6378de1cdbfa8]::ty::relate::relate_substs_with_variances<rustc_infer[4fc335a583559fa2]::infer::sub::Sub>::{closure#0}>, core[9847d4a2e8a02df2]::result::Result<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg, rustc_middle[eaf6378de1cdbfa8]::ty::error::TypeError>>::{closure#0}>
26: 0x7f001e8f2391 - rustc_middle[eaf6378de1cdbfa8]::ty::relate::super_relate_tys::<rustc_infer[4fc335a583559fa2]::infer::sub::Sub>
27: 0x7f001e8f00fc - <rustc_infer[4fc335a583559fa2]::infer::sub::Sub as rustc_middle[eaf6378de1cdbfa8]::ty::relate::TypeRelation>::tys
28: 0x7f001fd708d5 - <rustc_infer[4fc335a583559fa2]::infer::InferCtxt>::commit_if_ok::<rustc_infer[4fc335a583559fa2]::infer::InferOk<()>, rustc_middle[eaf6378de1cdbfa8]::ty::error::TypeError, <rustc_infer[4fc335a583559fa2]::infer::at::Trace>::sub<rustc_middle[eaf6378de1cdbfa8]::ty::Ty>::{closure#0}>
29: 0x7f001fd706fd - <rustc_trait_selection[4b4d59406d7aac09]::traits::engine::ObligationCtxt>::sup::<rustc_middle[eaf6378de1cdbfa8]::ty::Ty>
30: 0x7f002097c46f - <rustc_infer[4fc335a583559fa2]::infer::InferCtxt>::probe::<core[9847d4a2e8a02df2]::option::Option<(rustc_span[4d522547309d7b79]::def_id::DefId, rustc_span[4d522547309d7b79]::def_id::DefId, &rustc_middle[eaf6378de1cdbfa8]::ty::list::List<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg>)>, <dyn rustc_hir_analysis[7035f0189d3c093a]::astconv::AstConv>::lookup_inherent_assoc_ty::{closure#1}::{closure#0}>
31: 0x7f00209174e6 - <&mut <dyn rustc_hir_analysis[7035f0189d3c093a]::astconv::AstConv>::lookup_inherent_assoc_ty::{closure#1} as core[9847d4a2e8a02df2]::ops::function::FnMut<(&(rustc_span[4d522547309d7b79]::def_id::DefId, (rustc_span[4d522547309d7b79]::def_id::DefId, rustc_span[4d522547309d7b79]::def_id::DefId)),)>>::call_mut
32: 0x7f002095b10e - <alloc[c5857ad37805d36e]::vec::Vec<(rustc_span[4d522547309d7b79]::def_id::DefId, rustc_span[4d522547309d7b79]::def_id::DefId, &rustc_middle[eaf6378de1cdbfa8]::ty::list::List<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg>)> as alloc[c5857ad37805d36e]::vec::spec_from_iter::SpecFromIter<(rustc_span[4d522547309d7b79]::def_id::DefId, rustc_span[4d522547309d7b79]::def_id::DefId, &rustc_middle[eaf6378de1cdbfa8]::ty::list::List<rustc_middle[eaf6378de1cdbfa8]::ty::subst::GenericArg>), core[9847d4a2e8a02df2]::iter::adapters::filter_map::FilterMap<core[9847d4a2e8a02df2]::slice::iter::Iter<(rustc_span[4d522547309d7b79]::def_id::DefId, (rustc_span[4d522547309d7b79]::def_id::DefId, rustc_span[4d522547309d7b79]::def_id::DefId))>, <dyn rustc_hir_analysis[7035f0189d3c093a]::astconv::AstConv>::lookup_inherent_assoc_ty::{closure#1}>>>::from_iter
33: 0x7f001f4312d6 - <dyn rustc_hir_analysis[7035f0189d3c093a]::astconv::AstConv>::associated_path_to_ty::{closure#0}
34: 0x7f001f415773 - <dyn rustc_hir_analysis[7035f0189d3c093a]::astconv::AstConv>::ast_ty_to_ty_inner::{closure#0}
35: 0x7f001f7d8264 - <dyn rustc_hir_analysis[7035f0189d3c093a]::astconv::AstConv>::ty_of_fn::{closure#0}
36: 0x7f001f85be05 - rustc_hir_analysis[7035f0189d3c093a]::collect::fn_sig
37: 0x7f001f85a08f - rustc_query_system[3b264ab6e948b942]::query::plumbing::try_execute_query::<rustc_query_impl[1cc93b35ef872c79]::queries::fn_sig, rustc_query_impl[1cc93b35ef872c79]::plumbing::QueryCtxt>
38: 0x7f001f859801 - <rustc_query_impl[1cc93b35ef872c79]::Queries as rustc_middle[eaf6378de1cdbfa8]::ty::query::QueryEngine>::fn_sig
39: 0x7f001ef5cee3 - <rustc_hir_analysis[7035f0189d3c093a]::collect::CollectItemTypesVisitor as rustc_hir[f188a593009d666f]::intravisit::Visitor>::visit_trait_item
40: 0x7f001ef558e1 - <rustc_middle[eaf6378de1cdbfa8]::hir::map::Map>::visit_item_likes_in_module::<rustc_hir_analysis[7035f0189d3c093a]::collect::CollectItemTypesVisitor>
41: 0x7f001ef557ac - rustc_hir_analysis[7035f0189d3c093a]::collect::collect_mod_item_types
42: 0x7f001fe561c5 - rustc_query_system[3b264ab6e948b942]::query::plumbing::try_execute_query::<rustc_query_impl[1cc93b35ef872c79]::queries::collect_mod_item_types, rustc_query_impl[1cc93b35ef872c79]::plumbing::QueryCtxt>
43: 0x7f001fe55dc3 - <rustc_query_impl[1cc93b35ef872c79]::Queries as rustc_middle[eaf6378de1cdbfa8]::ty::query::QueryEngine>::collect_mod_item_types
44: 0x7f001eb52f63 - <rustc_session[8656a7a78cf578e4]::session::Session>::track_errors::<rustc_hir_analysis[7035f0189d3c093a]::check_crate::{closure#0}, ()>
45: 0x7f001eb4f832 - rustc_hir_analysis[7035f0189d3c093a]::check_crate
46: 0x7f001eb46742 - rustc_interface[dde792dfc5bb5edd]::passes::analysis
47: 0x7f0020011aec - rustc_query_system[3b264ab6e948b942]::query::plumbing::try_execute_query::<rustc_query_impl[1cc93b35ef872c79]::queries::analysis, rustc_query_impl[1cc93b35ef872c79]::plumbing::QueryCtxt>
48: 0x7f00200117e0 - <rustc_query_impl[1cc93b35ef872c79]::Queries as rustc_middle[eaf6378de1cdbfa8]::ty::query::QueryEngine>::analysis
49: 0x7f001fe6e109 - <rustc_middle[eaf6378de1cdbfa8]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[bad2ed848d64dbdc]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[9847d4a2e8a02df2]::result::Result<(), rustc_span[4d522547309d7b79]::ErrorGuaranteed>>
50: 0x7f001f9f852d - <rustc_interface[dde792dfc5bb5edd]::interface::Compiler>::enter::<rustc_driver_impl[bad2ed848d64dbdc]::run_compiler::{closure#1}::{closure#2}, core[9847d4a2e8a02df2]::result::Result<core[9847d4a2e8a02df2]::option::Option<rustc_interface[dde792dfc5bb5edd]::queries::Linker>, rustc_span[4d522547309d7b79]::ErrorGuaranteed>>
51: 0x7f001f9f6630 - rustc_span[4d522547309d7b79]::with_source_map::<core[9847d4a2e8a02df2]::result::Result<(), rustc_span[4d522547309d7b79]::ErrorGuaranteed>, rustc_interface[dde792dfc5bb5edd]::interface::run_compiler<core[9847d4a2e8a02df2]::result::Result<(), rustc_span[4d522547309d7b79]::ErrorGuaranteed>, rustc_driver_impl[bad2ed848d64dbdc]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
52: 0x7f001f9f5bd9 - std[b4247acdb72724ff]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dde792dfc5bb5edd]::util::run_in_thread_pool_with_globals<rustc_interface[dde792dfc5bb5edd]::interface::run_compiler<core[9847d4a2e8a02df2]::result::Result<(), rustc_span[4d522547309d7b79]::ErrorGuaranteed>, rustc_driver_impl[bad2ed848d64dbdc]::run_compiler::{closure#1}>::{closure#0}, core[9847d4a2e8a02df2]::result::Result<(), rustc_span[4d522547309d7b79]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9847d4a2e8a02df2]::result::Result<(), rustc_span[4d522547309d7b79]::ErrorGuaranteed>>
53: 0x7f00200e6afa - <<std[b4247acdb72724ff]::thread::Builder>::spawn_unchecked_<rustc_interface[dde792dfc5bb5edd]::util::run_in_thread_pool_with_globals<rustc_interface[dde792dfc5bb5edd]::interface::run_compiler<core[9847d4a2e8a02df2]::result::Result<(), rustc_span[4d522547309d7b79]::ErrorGuaranteed>, rustc_driver_impl[bad2ed848d64dbdc]::run_compiler::{closure#1}>::{closure#0}, core[9847d4a2e8a02df2]::result::Result<(), rustc_span[4d522547309d7b79]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9847d4a2e8a02df2]::result::Result<(), rustc_span[4d522547309d7b79]::ErrorGuaranteed>>::{closure#1} as core[9847d4a2e8a02df2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
54: 0x7f001d5745f3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h51bca2043facf7d3
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/alloc/src/boxed.rs:1988:9
55: 0x7f001d5745f3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h365da710d54db7ab
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/alloc/src/boxed.rs:1988:9
56: 0x7f001d5745f3 - std::sys::unix::thread::Thread::new::thread_start::hb322f3a535acf0fe
at /rustc/13afbdaa0655dda23d7129e59ac48f1ec88b2084/library/std/src/sys/unix/thread.rs:108:17
57: 0x7f001d306bb5 - <unknown>
58: 0x7f001d388d90 - <unknown>
59: 0x0 - <unknown>
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.70.0-nightly (13afbdaa0 2023-03-17) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [fn_sig] computing function signature of `Document::cursor`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 13 previous errors; 1 warning emitted
Some errors have detailed explanations: E0106, E0107, E0191, E0261, E0412, E0637, E0658.
For more information about an error, try `rustc --explain E0106`.
searched nightlies: from nightly-2023-02-17 to nightly-2023-03-18
regressed nightly: nightly-2023-02-21
searched commit range: 7aa413d...5243ea5
regressed commit: 7b55296
bisected with cargo-bisect-rustc v0.6.5
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc --script=/home/matthias/vcs/github/rust_bisect/script.sh --test-dir=/home/matthias/vcs/github/rust_bisect/foo
cc @fmease is this fixed by your branch?
@compiler-errors No, it's not. The stacktrace does indeed contain lookup_inherent_associated_type
but that's not the root cause of the problem. It just calls ObligationCtxt::sup
which ices (changing it to ::eq
doesn't help either). The actual (?) bug is probably inside of the relate
code I assume.
Ah, wait. If it's a bug to pass ReError
s to the type relating functions then it is the fault of lookup_inherent_associated_type
and it should probably return early if a type references_errors
. Edit: But it that case?
Hm, actually I think we should just fix the relate code instead.
Sure. I also feel like I've seen this ICE message pop up several times already on this issue tracker. I might be mistaken tho.
More minimal:
struct Lexer<'d>(&'d ());
impl Lexer<'d> {
type Cursor = ();
}
fn test(_: Lexer::Cursor) {}
@compiler-errors Reassigning to myself since the approach involving region erasure during selection we talked about fixes this issue (obviously) and since I'd like to integrate this into my AliasKind::Inherent
PR to be able to write UI tests that exercise the bound region code used during IAT confirmation (otherwise we would never go past selection in those cases).