Open ItzShiney opened 5 months ago
probably duplicate of #122704
proly related to https://github.com/rust-lang/rust/issues/122704
I tried to minimize this, and I can't go smaller than this:
trait IsStatic: 'static {}
impl<T: 'static> IsStatic for T {}
fn foo<T>(x: Box<T>) -> impl for<'a> FnOnce(&'a ()) -> Box<dyn IsStatic + 'a> {
move |_| x
}
Note that the code is invalid, since it should have a T: 'static
bound on foo
.
Seems identical to the aforementioned #122704 except for having impl
instead of dyn
I'm not sure if this is a minimal example, but I couldn't shrink it any more.
Generic
T
is necessary,A
can be any type.Code
Meta
The bug exists in both the latest stable and the latest nightly.
rustc --version --verbose
:Error output
Backtrace
``` stack backtrace: 0: 0x7ffd6322d623 - std::backtrace_rs::backtrace::dbghelp64::trace at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91 1: 0x7ffd6322d623 - std::backtrace_rs::backtrace::trace_unsynchronized at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66 2: 0x7ffd6322d623 - std::backtrace::Backtrace::create at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\backtrace.rs:331 3: 0x7ffd6322d56a - std::backtrace::Backtrace::force_capture at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\backtrace.rs:312 4: 0x7ffd5f276140 - memchr 5: 0x7ffd63247187 - alloc::boxed::impl$50::call at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\alloc\src\boxed.rs:2077 6: 0x7ffd63247187 - std::panicking::rust_panic_with_hook at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\panicking.rs:799 7: 0x7ffd63246fd9 - std::panicking::begin_panic_handler::closure$0 at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\panicking.rs:656 8: 0x7ffd6324450f - std::sys_common::backtrace::__rust_end_short_backtrace
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\sys_common\backtrace.rs:171
9: 0x7ffd63246cc8 - std::panicking::begin_panic_handler
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\panicking.rs:652
10: 0x7ffd6329e054 - core::panicking::panic_fmt
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\core\src\panicking.rs:72
11: 0x7ffd5f9a01c6 - ::eval_equal
12: 0x7ffd5e41001e - rustc_borrowck[47dc6bdb74f71e32]::dataflow::calculate_borrows_out_of_scope_at_location
13: 0x7ffd5e4f66e1 - ::regions
14: 0x7ffd5e45b7fc - rustc_borrowck[47dc6bdb74f71e32]::mir_borrowck
15: 0x7ffd5e91619a - rustc_query_impl[f6e26b53264cdf7d]::plumbing::query_key_hash_verify_all
16: 0x7ffd5e860989 - rustc_ty_utils[2e11d027a4d062f9]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
17: 0x7ffd5e91fc2f - rustc_query_impl[f6e26b53264cdf7d]::plumbing::query_key_hash_verify_all
18: 0x7ffd5d8b01d8 - ::lint_non_contiguous_range_endpoints
19: 0x7ffd5d8ca93a - ::register_obligations
20: 0x7ffd5e4b2e87 - ::regions
21: 0x7ffd5e435c3f - <&mut rustc_borrowck[47dc6bdb74f71e32]::type_check::constraint_conversion::ConstraintConversion as rustc_infer[97ab8c565f63bbbc]::infer::outlives::obligations::TypeOutlivesDelegate>::push_verify
22: 0x7ffd5e403ee7 - rustc_borrowck[47dc6bdb74f71e32]::dataflow::calculate_borrows_out_of_scope_at_location
23: 0x7ffd5e4f66e1 - ::regions
24: 0x7ffd5e45b7fc - rustc_borrowck[47dc6bdb74f71e32]::mir_borrowck
25: 0x7ffd5e91619a - rustc_query_impl[f6e26b53264cdf7d]::plumbing::query_key_hash_verify_all
26: 0x7ffd5e860989 - rustc_ty_utils[2e11d027a4d062f9]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
27: 0x7ffd5e91fc2f - rustc_query_impl[f6e26b53264cdf7d]::plumbing::query_key_hash_verify_all
28: 0x7ffd5e0d6245 - ::borrow
29: 0x7ffd5d829b13 - rustc_hir_analysis[fa2df6f2e5566255]::collect::type_of::type_of_opaque
30: 0x7ffd5da99a4a - ::write_str
31: 0x7ffd5e809f2f - rustc_ty_utils[2e11d027a4d062f9]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
32: 0x7ffd5daa0a55 - rustc_query_impl[f6e26b53264cdf7d]::query_system
33: 0x7ffd5f601bef - ::mutate
34: 0x7ffd5e13b958 - rustc_hir_analysis[fa2df6f2e5566255]::collect::type_of::type_of
35: 0x7ffd5e91759f - rustc_query_impl[f6e26b53264cdf7d]::plumbing::query_key_hash_verify_all
36: 0x7ffd5e809f2f - rustc_ty_utils[2e11d027a4d062f9]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
37: 0x7ffd5e918c56 - rustc_query_impl[f6e26b53264cdf7d]::plumbing::query_key_hash_verify_all
38: 0x7ffd5f601bef - ::mutate
39: 0x7ffd5e1026a4 - rustc_hir_analysis[fa2df6f2e5566255]::check::wfcheck::check_well_formed
40: 0x7ffd5e91685a - rustc_query_impl[f6e26b53264cdf7d]::plumbing::query_key_hash_verify_all
41: 0x7ffd5e866e35 - rustc_ty_utils[2e11d027a4d062f9]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
42: 0x7ffd5e926039 - rustc_query_impl[f6e26b53264cdf7d]::plumbing::query_key_hash_verify_all
43: 0x7ffd5e11498e - rustc_hir_analysis[fa2df6f2e5566255]::check::wfcheck::check_mod_type_wf
44: 0x7ffd5da9a64a - ::write_str
45: 0x7ffd5d9e5f45 - rustc_ty_utils[2e11d027a4d062f9]::ty::adt_sized_constraint
46: 0x7ffd5daabbc2 - rustc_query_impl[f6e26b53264cdf7d]::query_system
47: 0x7ffd5e1562df - rustc_hir_analysis[fa2df6f2e5566255]::check_crate
48: 0x7ffd5deb27f2 - ::pre_expansion_lint
49: 0x7ffd5b0f7517 - rustc_interface[3972c3fa63dc4815]::passes::create_global_ctxt
50: 0x7ffd5da9c0ba - ::write_str
51: 0x7ffd5d9bbfc9 - rustc_ty_utils[2e11d027a4d062f9]::ty::adt_sized_constraint
52: 0x7ffd5daa1623 - rustc_query_impl[f6e26b53264cdf7d]::query_system
53: 0x7ffd5b0b4d8d - _LNan_C
54: 0x7ffd5b0b214f - _LNan_C
55: 0x7ffd5b0b9e49 - _LNan_C
56: 0x7ffd6325838d - alloc::boxed::impl$48::call_once
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\alloc\src\boxed.rs:2063
57: 0x7ffd6325838d - alloc::boxed::impl$48::call_once
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\alloc\src\boxed.rs:2063
58: 0x7ffd6325838d - std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\sys\pal\windows\thread.rs:52
59: 0x7ffddef27344 - BaseThreadInitThunk
60: 0x7ffddf8226b1 - RtlUserThreadStart
rustc version: 1.80.0-nightly (f67a1acc0 2024-06-01)
platform: x86_64-pc-windows-msvc
query stack during panic:
#0 [mir_borrowck] borrow-checking `f::{closure#0}`
#1 [mir_borrowck] borrow-checking `f`
#2 [type_of_opaque] computing type of opaque `f::{opaque#0}`
#3 [type_of] computing type of `f::{opaque#0}`
#4 [check_well_formed] checking that `f::{opaque#0}` is well-formed
#5 [check_mod_type_wf] checking that types are well-formed in top-level module
#6 [analysis] running analysis passes on this crate
end of query stack
delayed bug: {OpaqueTypeKey { def_id: DefId(0:10 ~ testing[c4fb]::f::{opaque#0}), args: [T/#0, impl FnOnce(&A) -> T/#1] }: OpaqueTypeDecl { hidden_type: OpaqueHiddenType { span: src\lib.rs:4:5: 4:28 (#0), ty: Closure(DefId(0:7 ~ testing[c4fb]::f::{closure#0}), [T/#0, impl FnOnce(&A) -> T/#1, i32, Binder(extern "RustCall" fn((&'^0 (),)) -> std::boxed::Box, [Region(BrAnon)]), (impl FnOnce(&A) -> T/#1,)]) } }}
0: std::backtrace_rs::backtrace::dbghelp64::trace
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
1: std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: std::backtrace::Backtrace::create
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\backtrace.rs:331
3: std::backtrace::Backtrace::capture
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\backtrace.rs:296
4: ::emit_future_breakage_report
5: ::emit_diagnostic
6: ::emit_producing_guarantee
7: ::drop
8: rustc_pattern_analysis::analyze_match
9: >::decorate_lint
10: ::regions
11: _CallSettingFrame
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\amd64\handlers.asm:49
12: __FrameHandler3::FrameUnwindToState
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp:1222
13: __FrameHandler3::FrameUnwindToEmptyState
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\risctrnsctrl.cpp:255
14: __InternalCxxFrameHandler<__FrameHandler3>
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp:355
15: __CxxFrameHandler3
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\risctrnsctrl.cpp:281
16: _chkstk
17: RtlUnwindEx
18: __FrameHandler3::UnwindNestedFrames
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\risctrnsctrl.cpp:759
19: CatchIt<__FrameHandler3>
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp:1326
20: FindHandler<__FrameHandler3>
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp:670
21: __InternalCxxFrameHandler<__FrameHandler3>
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp:396
22: __CxxFrameHandler3
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\risctrnsctrl.cpp:281
23: _chkstk
24: RtlRaiseException
25: RtlRaiseException
26: RaiseException
27: _CxxThrowException
at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\throw.cpp:81
28: panic_unwind::real_imp::panic
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\panic_unwind\src\seh.rs:353
29: panic_unwind::__rust_start_panic
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\panic_unwind\src\lib.rs:108
30: std::panicking::rust_panic
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\panicking.rs:847
31: std::panicking::rust_panic_with_hook
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\panicking.rs:817
32: std::panicking::begin_panic_handler::closure$0
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\panicking.rs:656
33: std::sys_common::backtrace::__rust_end_short_backtrace
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\sys_common\backtrace.rs:171
34: std::panicking::begin_panic_handler
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\panicking.rs:652
35: core::panicking::panic_fmt
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\core\src\panicking.rs:72
36: ::eval_equal
37: rustc_borrowck::dataflow::calculate_borrows_out_of_scope_at_location
38: ::regions
39: rustc_borrowck::mir_borrowck
40: rustc_query_impl::plumbing::query_key_hash_verify_all
41: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
42: rustc_query_impl::plumbing::query_key_hash_verify_all
43: ::lint_non_contiguous_range_endpoints
44: ::register_obligations
45: ::regions
46: <&mut rustc_borrowck::type_check::constraint_conversion::ConstraintConversion as rustc_infer::infer::outlives::obligations::TypeOutlivesDelegate>::push_verify
47: rustc_borrowck::dataflow::calculate_borrows_out_of_scope_at_location
48: ::regions
49: rustc_borrowck::mir_borrowck
50: rustc_query_impl::plumbing::query_key_hash_verify_all
51: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
52: rustc_query_impl::plumbing::query_key_hash_verify_all
53: ::borrow
54: rustc_hir_analysis::collect::type_of::type_of_opaque
55: ::write_str
56: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
57: rustc_query_impl::query_system
58: ::mutate
59: rustc_hir_analysis::collect::type_of::type_of
60: rustc_query_impl::plumbing::query_key_hash_verify_all
61: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
62: rustc_query_impl::plumbing::query_key_hash_verify_all
63: ::mutate
64: rustc_hir_analysis::check::wfcheck::check_well_formed
65: rustc_query_impl::plumbing::query_key_hash_verify_all
66: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
67: rustc_query_impl::plumbing::query_key_hash_verify_all
68: rustc_hir_analysis::check::wfcheck::check_mod_type_wf
69: ::write_str
70: rustc_ty_utils::ty::adt_sized_constraint
71: rustc_query_impl::query_system
72: rustc_hir_analysis::check_crate
73: ::pre_expansion_lint
74: rustc_interface::passes::create_global_ctxt
75: ::write_str
76: rustc_ty_utils::ty::adt_sized_constraint
77: rustc_query_impl::query_system
78: _LNan_C
79: _LNan_C
80: _LNan_C
81: alloc::boxed::impl$48::call_once
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\alloc\src\boxed.rs:2063
82: alloc::boxed::impl$48::call_once
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\alloc\src\boxed.rs:2063
83: std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/f67a1acc04c7ecbf05751b17592dd8d245b75256/library\std\src\sys\pal\windows\thread.rs:52
84: BaseThreadInitThunk
85: RtlUserThreadStart
```