Closed
Description
Code
use std::marker::PhantomData;
struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>)
where
Foo<'short, 'out, T>: Convert<'a, 'b>;
trait Convert<'a, 'b>: Sized {
fn cast(&'a self) -> &'b Self;
}
impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
fn cast(&'long self) -> &'short Foo<'short, 'out, T> {
self
}
}
fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
sadness.cast()
}
fn main() {}
Affected release channels
- Previous Stable
- Current Stable
- Current Beta
- Current Nightly
Rust Version
rustc 1.68.0-nightly (333ee6c46 2023-01-18)
binary: rustc
commit-hash: 333ee6c466972185973d5097f8b5fb0f9fb13fa5
commit-date: 2023-01-18
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6
Current error output
error[E0261]: use of undeclared lifetime name `'short`
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:4:9
|
4 | Foo<'short, 'out, T>: Convert<'a, 'b>;
| ^^^^^^ undeclared lifetime
|
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'short` lifetime
|
4 | for<'short> Foo<'short, 'out, T>: Convert<'a, 'b>;
| +++++++++++
help: consider introducing lifetime `'short` here
|
2 | struct Foo<'short, 'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>)
| +++++++
error[E0261]: use of undeclared lifetime name `'out`
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:4:17
|
4 | Foo<'short, 'out, T>: Convert<'a, 'b>;
| ^^^^ undeclared lifetime
|
help: consider making the bound lifetime-generic with a new `'out` lifetime
|
4 | for<'out> Foo<'short, 'out, T>: Convert<'a, 'b>;
| +++++++++
help: consider introducing lifetime `'out` here
|
2 | struct Foo<'out, 'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>)
| +++++
error[E0261]: use of undeclared lifetime name `'b`
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:9:47
|
9 | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'b` here: `'b,`
error[E0261]: use of undeclared lifetime name `'out`
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:9:67
|
9 | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
| - help: consider introducing lifetime `'out` here: `'out,` ^^^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'out`
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:10:49
|
10 | fn cast(&'long self) -> &'short Foo<'short, 'out, T> {
| ^^^^ undeclared lifetime
|
help: consider introducing lifetime `'out` here
|
10 | fn cast<'out>(&'long self) -> &'short Foo<'short, 'out, T> {
| ++++++
help: consider introducing lifetime `'out` here
|
9 | impl<'out, 'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
| +++++
error[E0261]: use of undeclared lifetime name `'short`
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:15:68
|
15 | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
| - ^^^^^^ undeclared lifetime
| |
| help: consider introducing lifetime `'short` here: `'short,`
error[E0308]: mismatched types
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:4:27
|
4 | Foo<'short, 'out, T>: Convert<'a, 'b>;
| ^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected trait `Convert<'static, 'static>`
found trait `Convert<'a, 'b>`
note: the lifetime `'a` as defined here...
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:2:12
|
2 | struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>)
| ^^
= note: ...does not necessarily outlive the static lifetime
error[E0308]: mismatched types
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:4:27
|
4 | Foo<'short, 'out, T>: Convert<'a, 'b>;
| ^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected trait `Convert<'static, 'static>`
found trait `Convert<'a, 'b>`
note: the lifetime `'b` as defined here...
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:2:16
|
2 | struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>)
| ^^
= note: ...does not necessarily outlive the static lifetime
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'long` due to conflicting requirements
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:9:55
|
9 | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
| ^^^^^^^^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the lifetime `'short` as defined here...
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:9:21
|
9 | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
| ^^^^^^
= note: ...but the lifetime must also be valid for the static lifetime...
note: ...so that the types are compatible
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:9:55
|
9 | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
| ^^^^^^^^^^^^^^^^^^^^
= note: expected `Convert<'short, 'static>`
found `Convert<'_, 'static>`
error: incompatible lifetime on type
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:15:29
|
15 | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
| ^^^^^^^^^^^^^^^^^^
|
note: because this has an unmet lifetime requirement
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:4:27
|
4 | Foo<'short, 'out, T>: Convert<'a, 'b>;
| ^^^^^^^^^^^^^^^ introduces a `'static` lifetime requirement
note: the lifetime `'out` as defined here...
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:15:17
|
15 | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
| ^^^^
note: ...does not necessarily outlive the static lifetime introduced by the compatible `impl`
--> 9a9e332c96226e79b2da9996763c392cd802a0e7.rs:9:1
|
9 | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Backtrace
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: failed while formatting fluent string `infer_but_needs_to_satisfy`:
the fluent string has an argument `has_param_name` that was not found.
help: the arguments `has_lifetime`, `lifetime` and `spans_empty` are available
', compiler/rustc_errors/src/emitter.rs:1391:84
stack backtrace:
0: 0x7f84a1e5a3ca - std::backtrace_rs::backtrace::libunwind::trace::h50542de70121e929
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f84a1e5a3ca - std::backtrace_rs::backtrace::trace_unsynchronized::hae0fad0188b638fb
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f84a1e5a3ca - std::sys_common::backtrace::_print_fmt::h0db5adad57c4bf89
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/sys_common/backtrace.rs:65:5
3: 0x7f84a1e5a3ca - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h00bcafe34ad7431d
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f84a1ebd67e - core::fmt::write::hac51cd027be97ada
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/core/src/fmt/mod.rs:1213:17
5: 0x7f84a1e4aa15 - std::io::Write::write_fmt::h3d0d4a9f33ed60b4
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/io/mod.rs:1682:15
6: 0x7f84a1e5a195 - std::sys_common::backtrace::_print::h91a5e2dc0c5534c6
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/sys_common/backtrace.rs:47:5
7: 0x7f84a1e5a195 - std::sys_common::backtrace::print::hf5bbf2aee1aca335
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/sys_common/backtrace.rs:34:9
8: 0x7f84a1e5cf5f - std::panicking::default_hook::{{closure}}::hb617088b31f5607b
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/panicking.rs:267:22
9: 0x7f84a1e5cc9b - std::panicking::default_hook::h8aabc36d33777a9f
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/panicking.rs:286:9
10: 0x7f84a0c482e4 - <rustc_driver[3007fa38fe7f0954]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[830d3b100652ecaa]::ops::function::FnOnce<(&core[830d3b100652ecaa]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
11: 0x7f84a1e5d79a - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h73dc741209159f0b
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/alloc/src/boxed.rs:2002:9
12: 0x7f84a1e5d79a - std::panicking::rust_panic_with_hook::ha64a2ebee15afbaf
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/panicking.rs:692:13
13: 0x7f84a1e5d519 - std::panicking::begin_panic_handler::{{closure}}::h0e260611a29c4e4b
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/panicking.rs:579:13
14: 0x7f84a1e5a87c - std::sys_common::backtrace::__rust_end_short_backtrace::he6832640d64ae3e0
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/sys_common/backtrace.rs:137:18
15: 0x7f84a1e5d222 - rust_begin_unwind
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/panicking.rs:575:5
16: 0x7f84a1eba023 - core::panicking::panic_fmt::hab8eca7df403fce4
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/core/src/panicking.rs:64:14
17: 0x7f84a1eba5b3 - core::result::unwrap_failed::h3fb434f504c80690
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/core/src/result.rs:1790:5
18: 0x7f84a027dade - <rustc_errors[24ae80d350ed6ef3]::emitter::EmitterWriter>::emit_message_default::{closure#0}
19: 0x7f84a026b731 - <rustc_errors[24ae80d350ed6ef3]::emitter::EmitterWriter as rustc_errors[24ae80d350ed6ef3]::emitter::Emitter>::emit_diagnostic
20: 0x7f84a03d7928 - <rustc_errors[24ae80d350ed6ef3]::HandlerInner>::emit_diagnostic::{closure#2}
21: 0x7f84a03da7f1 - rustc_interface[a3bd2224478d897e]::callbacks::track_diagnostic
22: 0x7f849f5baf98 - <rustc_errors[24ae80d350ed6ef3]::HandlerInner>::emit_diagnostic
23: 0x7f849fc03091 - <rustc_errors[24ae80d350ed6ef3]::Handler>::emit_diagnostic
24: 0x7f849fbaa80d - <rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed as rustc_errors[24ae80d350ed6ef3]::diagnostic_builder::EmissionGuarantee>::diagnostic_builder_emit_producing_guarantee
25: 0x7f84a0f2bd26 - <rustc_infer[1a24f95b14ffce22]::infer::error_reporting::nice_region_error::NiceRegionError>::try_report
26: 0x7f84a0fa176f - <rustc_infer[1a24f95b14ffce22]::infer::error_reporting::TypeErrCtxt>::try_report_nice_region_error
27: 0x7f849fdb972f - <rustc_infer[1a24f95b14ffce22]::infer::error_reporting::TypeErrCtxt>::check_region_obligations_and_report_errors
28: 0x7f849fda2864 - rustc_hir_analysis[4242f85aba23ed]::check::wfcheck::check_item_fn
29: 0x7f849fd9cf34 - rustc_hir_analysis[4242f85aba23ed]::check::wfcheck::check_well_formed
30: 0x7f849f3d732b - rustc_query_system[1c311a51d396ff65]::query::plumbing::get_query::<rustc_query_impl[d3da972c3560dd09]::queries::check_well_formed, rustc_query_impl[d3da972c3560dd09]::plumbing::QueryCtxt, rustc_middle[6fc96dfead90d7a7]::dep_graph::dep_node::DepKind>
31: 0x7f84a0098f98 - rustc_data_structures[40cf6b83e186d66c]::sync::par_for_each_in::<&[rustc_hir[d2c3ee4b02f7e273]::hir::ItemId], <rustc_middle[6fc96dfead90d7a7]::hir::ModuleItems>::par_items<rustc_hir_analysis[4242f85aba23ed]::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>
32: 0x7f84a0098da7 - rustc_hir_analysis[4242f85aba23ed]::check::wfcheck::check_mod_type_wf
33: 0x7f84a01ff861 - rustc_query_system[1c311a51d396ff65]::query::plumbing::try_execute_query::<rustc_query_impl[d3da972c3560dd09]::queries::check_mod_type_wf, rustc_query_impl[d3da972c3560dd09]::plumbing::QueryCtxt>
34: 0x7f84a01ff26d - <rustc_query_impl[d3da972c3560dd09]::Queries as rustc_middle[6fc96dfead90d7a7]::ty::query::QueryEngine>::check_mod_type_wf
35: 0x7f849f27b818 - rustc_data_structures[40cf6b83e186d66c]::sync::par_for_each_in::<&[rustc_hir[d2c3ee4b02f7e273]::hir_id::OwnerId], <rustc_middle[6fc96dfead90d7a7]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[4242f85aba23ed]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
36: 0x7f849f27b603 - <rustc_session[d9021b7531949cab]::session::Session>::track_errors::<rustc_hir_analysis[4242f85aba23ed]::check_crate::{closure#5}, ()>
37: 0x7f849f27ad7d - rustc_hir_analysis[4242f85aba23ed]::check_crate
38: 0x7f849f27aa1b - rustc_interface[a3bd2224478d897e]::passes::analysis
39: 0x7f84a03b57ee - rustc_query_system[1c311a51d396ff65]::query::plumbing::try_execute_query::<rustc_query_impl[d3da972c3560dd09]::queries::analysis, rustc_query_impl[d3da972c3560dd09]::plumbing::QueryCtxt>
40: 0x7f84a0637c1a - <rustc_query_impl[d3da972c3560dd09]::Queries as rustc_middle[6fc96dfead90d7a7]::ty::query::QueryEngine>::analysis
41: 0x7f849fed6a53 - <rustc_interface[a3bd2224478d897e]::passes::QueryContext>::enter::<rustc_driver[3007fa38fe7f0954]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>>
42: 0x7f849fed54a8 - <rustc_interface[a3bd2224478d897e]::interface::Compiler>::enter::<rustc_driver[3007fa38fe7f0954]::run_compiler::{closure#1}::{closure#2}, core[830d3b100652ecaa]::result::Result<core[830d3b100652ecaa]::option::Option<rustc_interface[a3bd2224478d897e]::queries::Linker>, rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>>
43: 0x7f849fed3328 - rustc_span[8b627345fe9560b3]::with_source_map::<core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>, rustc_interface[a3bd2224478d897e]::interface::run_compiler<core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>, rustc_driver[3007fa38fe7f0954]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
44: 0x7f849fed2e01 - <scoped_tls[919fbd9b743d1ab7]::ScopedKey<rustc_span[8b627345fe9560b3]::SessionGlobals>>::set::<rustc_interface[a3bd2224478d897e]::interface::run_compiler<core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>, rustc_driver[3007fa38fe7f0954]::run_compiler::{closure#1}>::{closure#0}, core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>>
45: 0x7f849fed23e2 - std[d57f0b25e837618f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a3bd2224478d897e]::util::run_in_thread_pool_with_globals<rustc_interface[a3bd2224478d897e]::interface::run_compiler<core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>, rustc_driver[3007fa38fe7f0954]::run_compiler::{closure#1}>::{closure#0}, core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>>
46: 0x7f849fed218c - <<std[d57f0b25e837618f]::thread::Builder>::spawn_unchecked_<rustc_interface[a3bd2224478d897e]::util::run_in_thread_pool_with_globals<rustc_interface[a3bd2224478d897e]::interface::run_compiler<core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>, rustc_driver[3007fa38fe7f0954]::run_compiler::{closure#1}>::{closure#0}, core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[830d3b100652ecaa]::result::Result<(), rustc_errors[24ae80d350ed6ef3]::ErrorGuaranteed>>::{closure#1} as core[830d3b100652ecaa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
47: 0x7f84a1e67bd3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7ba1652ef014411c
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/alloc/src/boxed.rs:1988:9
48: 0x7f84a1e67bd3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb86249b0355c08e6
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/alloc/src/boxed.rs:1988:9
49: 0x7f84a1e67bd3 - std::sys::unix::thread::Thread::new::thread_start::h7258c93114561772
at /rustc/333ee6c466972185973d5097f8b5fb0f9fb13fa5/library/std/src/sys/unix/thread.rs:108:17
50: 0x7f849d86a8fd - <unknown>
51: 0x7f849d8eca60 - <unknown>
52: 0x0 - <unknown>
error: internal compiler error: unexpected panic
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 (333ee6c46 2023-01-18) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [check_well_formed] checking that `badboi` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 10 previous errors
Some errors have detailed explanations: E0261, E0308, E0495, E0759.
For more information about an error, try `rustc --explain E0261`.
Anything else?
No response