Broken MIR in DefId (TerminatorKind::Call with GATs)
Open
Nobody has claimed this yet.
A-GATs
C-bug
fixed-by-next-solver
I-ICE
S-bug-has-test
T-compiler
T-types
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
struct Ref<T>(T);
trait Reference: 'static {
type Ref<'a>;
fn get_ref(&self) -> Self::Ref<'_>;
}
trait Lock: 'static {
type Locked<'a>;
fn locked(&self) -> Self::Locked<'_>;
}
struct SliceRef<'a, T: ?Sized> {
inner: &'a T
}
impl<'a, 'b, T: ?Sized, SR: Reference> IntoIterator for &'b SliceRef<'a, T> where &'a T: IntoIterator<Item=&'a SR> {
type Item = SR::Ref<'a>;
type IntoIter = std::iter::Map<<&'a T as IntoIterator>::IntoIter, for<'c> fn(&'c SR) -> SR::Ref<'c>>;
fn into_iter(self) -> Self::IntoIter {
self.inner.into_iter().map(|cr| { cr.get_ref() })
}
}
impl<SR: Reference> Reference for Vec<SR> {
type Ref<'a> = SliceRef<'a, [SR]>;
fn get_ref(&self) -> Self::Ref<'_> {
SliceRef {
inner: &**self,
}
}
}
impl<SR: Reference> Lock for Ref<SR> {
type Locked<'a> = SR::Ref<'a>;
fn locked(&self) -> Self::Locked<'_> {
self.0.get_ref()
}
}
impl Reference for () {
type Ref<'a> = &'a ();
fn get_ref(&self) -> Self::Ref<'_> {
unimplemented!()
}
}
fn main() {
let data = Ref(Vec::<()>::new());
let _ = (&data.locked()).into_iter();
}
Meta
rustc --version --verbose:
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-pc-windows-msvc
release: 1.81.0
LLVM version: 18.1.7
Error output
error: internal compiler error: broken MIR in DefId(0:43 ~ tester[0e95]::main) (Terminator { source_info: SourceInfo { span: src/main.rs:50:13: 50:41 (#0), scope: scope[1] }, kind: _3 = <&SliceRef<'_, [()]> as IntoIterator>::into_iter(move _4) -> [return: bb4, unwind: bb6] }): call dest mismatch (std::iter::Map<std::slice::Iter<'?7, ()>, Binder { value: fn(&'^0.Named(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), "'c") ()) -> &'^0.Named(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), "'c") (), bound_vars: [Region(BrNamed(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), 'c))] }> <- std::iter::Map<std::slice::Iter<'?6, ()>, Binder { value: fn(&'^0.Named(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), "'c") ()) -> Alias(Projection, AliasTy { args: [(), '^0.Named(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), "'c")], def_id: DefId(0:8 ~ tester[0e95]::Reference::Ref) }), bound_vars: [Region(BrNamed(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), 'c))] }>): NoSolution
--> src/main.rs:50:13
|
50 | let _ = (&data.locked()).into_iter();
| ^^^^^^^^^^^^^^^^
|
note: delayed at compiler\rustc_borrowck\src\type_check\mod.rs:1571:21
0: std::backtrace_rs::backtrace::dbghelp64::trace
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
1: std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: std::backtrace::Backtrace::create
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\backtrace.rs:331
3: std::backtrace::Backtrace::capture
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\backtrace.rs:296
4: <rustc_errors::DiagCtxtHandle>::steal_fulfilled_expectation_ids
5: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
6: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
7: <rustc_pattern_analysis::errors::NonExhaustiveOmittedPatternLintOnArm as rustc_errors::diagnostic::LintDiagnostic<()>>::decorate_lint
8: <rustc_borrowck::type_check::TypeChecker>::push_region_constraints
9: rustc_borrowck::dataflow::calculate_borrows_out_of_scope_at_location
10: rustc_borrowck::dataflow::calculate_borrows_out_of_scope_at_location
11: <rustc_borrowck::type_check::TypeChecker>::push_region_constraints
12: rustc_borrowck::mir_borrowck
13: rustc_query_impl::plumbing::query_key_hash_verify_all
14: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
15: rustc_query_impl::plumbing::query_key_hash_verify_all
16: rustc_interface::passes::analysis
17: rustc_ty_utils::ty::adt_sized_constraint
18: rustc_ty_utils::ty::adt_sized_constraint
19: rustc_query_impl::query_system
20: _LNan_C
21: _LNan_C
22: _LNan_C
23: alloc::boxed::impl$48::call_once
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\alloc\src\boxed.rs:2070
24: alloc::boxed::impl$48::call_once
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\alloc\src\boxed.rs:2070
25: std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\sys\pal\windows\thread.rs:58
26: BaseThreadInitThunk
27: RtlUserThreadStart
--> src/main.rs:50:13
|
50 | let _ = (&data.locked()).into_iter();
| ^^^^^^^^^^^^^^^^
Backtrace
Compiling tester v0.1.0 (C:\Users\BLUEM\rust\tester)
note: no errors encountered even though delayed bugs were created
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error: broken MIR in DefId(0:43 ~ tester[0e95]::main) (Terminator { source_info: SourceInfo { span: src/main.rs:50:13: 50:41 (#0), scope: scope[1] }, kind: _3 = <&SliceRef<'_, [()]> as IntoIterator>::int
o_iter(move _4) -> [return: bb4, unwind: bb6] }): call dest mismatch (std::iter::Map<std::slice::Iter<'?7, ()>, Binder { value: fn(&'^0.Named(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), "'c") ()) -> &'^0.Named(DefId(0:26
~ tester[0e95]::{impl#0}::IntoIter::'c), "'c") (), bound_vars: [Region(BrNamed(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), 'c))] }> <- std::iter::Map<std::slice::Iter<'?6, ()>, Binder { value: fn(&'^0.Named(DefId(0:26 ~
tester[0e95]::{impl#0}::IntoIter::'c), "'c") ()) -> Alias(Projection, AliasTy { args: [(), '^0.Named(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), "'c")], def_id: DefId(0:8 ~ tester[0e95]::Reference::Ref) }), bound_vars: [Region(BrNamed(DefId(0:26 ~ tester[0e95]::{impl#0}::IntoIter::'c), 'c))] }>): NoSolution
--> src/main.rs:50:13
|
50 | let _ = (&data.locked()).into_iter();
| ^^^^^^^^^^^^^^^^
|
note: delayed at compiler\rustc_borrowck\src\type_check\mod.rs:1571:21
0: std::backtrace_rs::backtrace::dbghelp64::trace
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
1: std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: std::backtrace::Backtrace::create
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\backtrace.rs:331
3: std::backtrace::Backtrace::capture
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\backtrace.rs:296
4: <rustc_errors::DiagCtxtHandle>::steal_fulfilled_expectation_ids
5: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
6: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
7: <rustc_pattern_analysis::errors::NonExhaustiveOmittedPatternLintOnArm as rustc_errors::diagnostic::LintDiagnostic<()>>::decorate_lint
8: <rustc_borrowck::type_check::TypeChecker>::push_region_constraints
9: rustc_borrowck::dataflow::calculate_borrows_out_of_scope_at_location
10: rustc_borrowck::dataflow::calculate_borrows_out_of_scope_at_location
11: <rustc_borrowck::type_check::TypeChecker>::push_region_constraints
12: rustc_borrowck::mir_borrowck
13: rustc_query_impl::plumbing::query_key_hash_verify_all
14: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
15: rustc_query_impl::plumbing::query_key_hash_verify_all
16: rustc_interface::passes::analysis
17: rustc_ty_utils::ty::adt_sized_constraint
18: rustc_ty_utils::ty::adt_sized_constraint
19: rustc_query_impl::query_system
20: _LNan_C
21: _LNan_C
22: _LNan_C
23: alloc::boxed::impl$48::call_once
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\alloc\src\boxed.rs:2070
24: alloc::boxed::impl$48::call_once
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\alloc\src\boxed.rs:2070
25: std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\sys\pal\windows\thread.rs:58
26: BaseThreadInitThunk
27: RtlUserThreadStart
--> src/main.rs:50:13
|
50 | let _ = (&data.locked()).into_iter();
| ^^^^^^^^^^^^^^^^
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.81.0 (eeb90cda1 2024-09-04) running on x86_64-pc-windows-msvc
note: compiler flags: --crate-type bin -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:
end of query stack
error: could not compile `tester` (bin "tester")
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer in src/main.rs and compile it with the reported rustc 1.81.0 configuration to confirm the internal compiler error. Then read the delayed diagnostic location in compiler/rustc_borrowck/src/type_check/mod.rs:1571 and trace the broken MIR report. Done means the reproducer no longer produces broken MIR or an internal compiler error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100