Closed
Description
File: /tmp/F/491D45FF6373EF099BE38CA3B5E5458695A8A45DABFC75AABDAC9D34FE1EC1BC.rs
reduced:
trait Callable {
type Output;
fn call(x: Self) -> Self::Output;
}
trait PlusOne {}
impl<'a> PlusOne for &'a mut i32 {}
impl<T: PlusOne> Callable for T {
type Output = impl PlusOne;
}
fn test<'a>(y: &'a mut i32) -> impl PlusOne {
<&mut i32 as Callable>::call(y)
}
original:
#![feature(impl_trait_in_assoc_type)]
trait Callable {
type Output;
fn call(x: Self) -> Self::Output;
}
trait PlusOne {
fn plus_one(&mut self);
}
impl<'a> PlusOne for &'a mut i32 {
fn plus_one(&mut self) {
**self += 1;
}
}
impl<T: PlusOne> Callable for T {
type Output = impl PlusOne;
fn call(t: T) -> Self::Output {
t
}
}
fn test<'a>(y: &'a mut i32) -> impl PlusOne {
<&'unused_assignments mut i32 as Callable>::call(y)
//~^ ERROR hidden type for `impl PlusOne` captures lifetime that does not appear in bounds
}
fn main() {
let mut z = 42;
let mut thing = test(&mut z);
let mut thing2 = test(&mut z);
thing.plus_one();
assert_eq!(z, 43);
thing2.plus_one();
assert_eq!(z, 44);
thing.plus_one();
assert_eq!(z, 45);
}
Version information
rustc 1.75.0-nightly (c1691db36 2023-10-11)
binary: rustc
commit-hash: c1691db366c0f2e2341c60377c248ca2d9335076
commit-date: 2023-10-11
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.2
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zpolonius=next
Program output:
error[E0261]: use of undeclared lifetime name `'unused_assignments`
--> /tmp/F/491D45FF6373EF099BE38CA3B5E5458695A8A45DABFC75AABDAC9D34FE1EC1BC.rs:26:7
|
25 | fn test<'a>(y: &'a mut i32) -> impl PlusOne {
| - help: consider introducing lifetime `'unused_assignments` here: `'unused_assignments,`
26 | <&'unused_assignments mut i32 as Callable>::call(y)
| ^^^^^^^^^^^^^^^^^^^ undeclared lifetime
thread 'rustc' panicked at compiler/rustc_borrowck/src/dataflow.rs:425:13:
assertion `left == right` failed: the loans out of scope must be the same as the borrows out of scope
left: {bb2[0]: [bw0], bb1[0]: [bw0]}
right: {}
stack backtrace:
0: 0x7ff9acb6291c - std::backtrace_rs::backtrace::libunwind::trace::h1a396f4229b95b89
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7ff9acb6291c - std::backtrace_rs::backtrace::trace_unsynchronized::had22ccd71191bcf5
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7ff9acb6291c - std::sys_common::backtrace::_print_fmt::h6327fff1763299f2
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/sys_common/backtrace.rs:67:5
3: 0x7ff9acb6291c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5c308bc33123b3c6
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7ff9acbca370 - core::fmt::rt::Argument::fmt::hef0d41e90575ec4b
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/core/src/fmt/rt.rs:142:9
5: 0x7ff9acbca370 - core::fmt::write::h9e48193d66acdcfa
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/core/src/fmt/mod.rs:1117:17
6: 0x7ff9acb55bdf - std::io::Write::write_fmt::h28ef69c5512926cf
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/io/mod.rs:1763:15
7: 0x7ff9acb62704 - std::sys_common::backtrace::_print::h55d64ccf5cbdab6d
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7ff9acb62704 - std::sys_common::backtrace::print::h2df81292c2f87861
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7ff9acb65517 - std::panicking::default_hook::{{closure}}::ha7e6872e55317a45
10: 0x7ff9acb6525a - std::panicking::default_hook::hb6ef52fce67e4118
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/panicking.rs:292:9
11: 0x7ff9af715295 - std[f742926918452c50]::panicking::update_hook::<alloc[f677c22cdd567b61]::boxed::Box<rustc_driver_impl[13831840ef09002e]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7ff9acb65cb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h9b42aa266f672cfd
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/alloc/src/boxed.rs:2021:9
13: 0x7ff9acb65cb8 - std::panicking::rust_panic_with_hook::h69579898fe8322bc
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/panicking.rs:735:13
14: 0x7ff9acb65a11 - std::panicking::begin_panic_handler::{{closure}}::h4923080684a4f0a3
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/panicking.rs:609:13
15: 0x7ff9acb62e36 - std::sys_common::backtrace::__rust_end_short_backtrace::h4bb44302fa0e2d37
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/sys_common/backtrace.rs:170:18
16: 0x7ff9acb65742 - rust_begin_unwind
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/panicking.rs:597:5
17: 0x7ff9acbc6995 - core::panicking::panic_fmt::h27c06cc7c9e72203
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/core/src/panicking.rs:72:14
18: 0x7ff9acbc6ff1 - core::panicking::assert_failed_inner::h733991948e48ad54
19: 0x7ff9af499ab7 - core[95fcb21667417300]::panicking::assert_failed::<indexmap[fc43bc717b77442a]::map::IndexMap<rustc_middle[75501c6963a0c8e6]::mir::Location, alloc[f677c22cdd567b61]::vec::Vec<rustc_borrowck[806a826476d2135f]::dataflow::BorrowIndex>, core[95fcb21667417300]::hash::BuildHasherDefault<rustc_hash[9187fb2c08beaffe]::FxHasher>>, indexmap[fc43bc717b77442a]::map::IndexMap<rustc_middle[75501c6963a0c8e6]::mir::Location, alloc[f677c22cdd567b61]::vec::Vec<rustc_borrowck[806a826476d2135f]::dataflow::BorrowIndex>, core[95fcb21667417300]::hash::BuildHasherDefault<rustc_hash[9187fb2c08beaffe]::FxHasher>>>
20: 0x7ff9ae01d832 - rustc_borrowck[806a826476d2135f]::do_mir_borrowck
21: 0x7ff9ae006967 - rustc_borrowck[806a826476d2135f]::mir_borrowck
22: 0x7ff9ada16e09 - rustc_query_impl[1ffb7affbb03209e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1ffb7affbb03209e]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 8usize]>>
23: 0x7ff9adddb722 - rustc_query_system[c3767f58cc42410a]::query::plumbing::try_execute_query::<rustc_query_impl[1ffb7affbb03209e]::DynamicConfig<rustc_query_system[c3767f58cc42410a]::query::caches::VecCache<rustc_span[afe2d1e5c4333398]::def_id::LocalDefId, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1ffb7affbb03209e]::plumbing::QueryCtxt, false>
24: 0x7ff9af1df4f4 - rustc_query_impl[1ffb7affbb03209e]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
25: 0x7ff9af11b47b - rustc_hir_analysis[f8382607e94a3f7b]::collect::type_of::type_of_opaque
26: 0x7ff9aee23807 - rustc_query_impl[1ffb7affbb03209e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1ffb7affbb03209e]::query_impl::type_of_opaque::dynamic_query::{closure#2}::{closure#0}, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 8usize]>>
27: 0x7ff9addd9591 - rustc_query_system[c3767f58cc42410a]::query::plumbing::try_execute_query::<rustc_query_impl[1ffb7affbb03209e]::DynamicConfig<rustc_query_system[c3767f58cc42410a]::query::caches::DefaultCache<rustc_span[afe2d1e5c4333398]::def_id::DefId, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1ffb7affbb03209e]::plumbing::QueryCtxt, false>
28: 0x7ff9af1d3db2 - rustc_query_impl[1ffb7affbb03209e]::query_impl::type_of_opaque::get_query_non_incr::__rust_end_short_backtrace
29: 0x7ff9ada3cb4c - rustc_middle[75501c6963a0c8e6]::query::plumbing::query_get_at::<rustc_query_system[c3767f58cc42410a]::query::caches::DefaultCache<rustc_span[afe2d1e5c4333398]::def_id::DefId, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 8usize]>>>
30: 0x7ff9ae0be95d - rustc_hir_analysis[f8382607e94a3f7b]::collect::type_of::type_of
31: 0x7ff9adce0bb5 - rustc_query_impl[1ffb7affbb03209e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1ffb7affbb03209e]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 8usize]>>
32: 0x7ff9addd9591 - rustc_query_system[c3767f58cc42410a]::query::plumbing::try_execute_query::<rustc_query_impl[1ffb7affbb03209e]::DynamicConfig<rustc_query_system[c3767f58cc42410a]::query::caches::DefaultCache<rustc_span[afe2d1e5c4333398]::def_id::DefId, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1ffb7affbb03209e]::plumbing::QueryCtxt, false>
33: 0x7ff9af1d3a4f - rustc_query_impl[1ffb7affbb03209e]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
34: 0x7ff9ada3cb4c - rustc_middle[75501c6963a0c8e6]::query::plumbing::query_get_at::<rustc_query_system[c3767f58cc42410a]::query::caches::DefaultCache<rustc_span[afe2d1e5c4333398]::def_id::DefId, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 8usize]>>>
35: 0x7ff9aecbf6a9 - rustc_hir_analysis[f8382607e94a3f7b]::check::check::check_mod_item_types
36: 0x7ff9adcad8d7 - rustc_query_impl[1ffb7affbb03209e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1ffb7affbb03209e]::query_impl::check_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 0usize]>>
37: 0x7ff9ae9d3e04 - rustc_query_system[c3767f58cc42410a]::query::plumbing::try_execute_query::<rustc_query_impl[1ffb7affbb03209e]::DynamicConfig<rustc_query_system[c3767f58cc42410a]::query::caches::DefaultCache<rustc_span[afe2d1e5c4333398]::def_id::LocalModDefId, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1ffb7affbb03209e]::plumbing::QueryCtxt, false>
38: 0x7ff9af1dda77 - rustc_query_impl[1ffb7affbb03209e]::query_impl::check_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
39: 0x7ff9aed87167 - rustc_hir_analysis[f8382607e94a3f7b]::check_crate
40: 0x7ff9aed7cc3a - rustc_interface[eddcebe151d82f7d]::passes::analysis
41: 0x7ff9aefca1d7 - rustc_query_impl[1ffb7affbb03209e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1ffb7affbb03209e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 1usize]>>
42: 0x7ff9aefc9dc6 - rustc_query_system[c3767f58cc42410a]::query::plumbing::try_execute_query::<rustc_query_impl[1ffb7affbb03209e]::DynamicConfig<rustc_query_system[c3767f58cc42410a]::query::caches::SingleCache<rustc_middle[75501c6963a0c8e6]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1ffb7affbb03209e]::plumbing::QueryCtxt, false>
43: 0x7ff9aefc9b7d - rustc_query_impl[1ffb7affbb03209e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
44: 0x7ff9aeee4d5d - std[f742926918452c50]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[eddcebe151d82f7d]::util::run_in_thread_with_globals<rustc_interface[eddcebe151d82f7d]::interface::run_compiler<core[95fcb21667417300]::result::Result<(), rustc_span[afe2d1e5c4333398]::ErrorGuaranteed>, rustc_driver_impl[13831840ef09002e]::run_compiler::{closure#1}>::{closure#0}, core[95fcb21667417300]::result::Result<(), rustc_span[afe2d1e5c4333398]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[95fcb21667417300]::result::Result<(), rustc_span[afe2d1e5c4333398]::ErrorGuaranteed>>
45: 0x7ff9aeee4013 - <<std[f742926918452c50]::thread::Builder>::spawn_unchecked_<rustc_interface[eddcebe151d82f7d]::util::run_in_thread_with_globals<rustc_interface[eddcebe151d82f7d]::interface::run_compiler<core[95fcb21667417300]::result::Result<(), rustc_span[afe2d1e5c4333398]::ErrorGuaranteed>, rustc_driver_impl[13831840ef09002e]::run_compiler::{closure#1}>::{closure#0}, core[95fcb21667417300]::result::Result<(), rustc_span[afe2d1e5c4333398]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[95fcb21667417300]::result::Result<(), rustc_span[afe2d1e5c4333398]::ErrorGuaranteed>>::{closure#1} as core[95fcb21667417300]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
46: 0x7ff9acb70c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h725394f575a3e436
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/alloc/src/boxed.rs:2007:9
47: 0x7ff9acb70c25 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h657091e5671149c6
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/alloc/src/boxed.rs:2007:9
48: 0x7ff9acb70c25 - std::sys::unix::thread::Thread::new::thread_start::h51f0a69447f1c1c5
at /rustc/c1691db366c0f2e2341c60377c248ca2d9335076/library/std/src/sys/unix/thread.rs:108:17
49: 0x7ff9ac9139eb - <unknown>
50: 0x7ff9ac9977cc - <unknown>
51: 0x0 - <unknown>
error: 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.75.0-nightly (c1691db36 2023-10-11) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z polonius=next -Z dump-mir-dir=dir
query stack during panic:
#0 [mir_borrowck] borrow-checking `test`
#1 [type_of_opaque] computing type of opaque `test::{opaque#0}`
#2 [type_of] computing type of `test::{opaque#0}`
#3 [check_mod_item_types] checking item types in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
For more information about this error, try `rustc --explain E0261`.