Description
opened on Jan 22, 2024
¯\ (ツ)/¯
auto-reduced (treereduce-rust):
#![feature(object_safe_for_dispatch)]
trait B {
fn f(a: A) -> A;
}
trait A {
fn g(b: B) -> B;
}
fn main() {}
original:
#![feature(object_safe_for_dispatch)]
trait B { fn f(a: A) -> A; }
//~^ ERROR associated item referring to unboxed trait object for its own trait
//~| WARN trait objects without an explicit `dyn` are deprecated
//~| WARN trait objects without an explicit `dyn` are deprecated
//~| WARN this is accepted in the current edition
//~| WARN this is accepted in the current edition
//~| WARN this is accepted in the current edition
//~| ERROR the trait `A` cannot be made into an object
trait A { fn g(b: B) -> B; }
//~^ WARN trait objects without an explicit `dyn` are deprecated
//~| WARN trait objects without an explicit `dyn` are deprecated
//~| WARN trait objects without an explicit `dyn` are deprecated
// can't actually invoke it from an object (yet...?).
//~| WARN this is accepted in the current edition
//~| WARN this is accepted in the current edition
//~| ERROR the trait `B` cannot be made into an object
fn main() {}
Version information
rustc 1.77.0-nightly (a58ec8ff0 2024-01-22)
binary: rustc
commit-hash: a58ec8ff03b3269b20104eb7eae407be48ab95a7
commit-date: 2024-01-22
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: trait objects without an explicit `dyn` are deprecated
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:8:13
|
8 | fn g(b: B) -> B;
| ^
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: `B` it is not object safe, so it can't be `dyn`
= note: `#[warn(bare_trait_objects)]` on by default
help: use a new generic type parameter, constrained by `B`
|
8 | fn g<T: B>(b: T) -> B;
| ++++++ ~
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
8 | fn g(b: impl B) -> B;
| ++++
warning: trait objects without an explicit `dyn` are deprecated
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:8:19
|
8 | fn g(b: B) -> B;
| ^
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: `B` is not object safe, use `impl B` to return an opaque type, as long as you return a single underlying type
|
8 | fn g(b: B) -> impl B;
| ++++
warning: trait objects without an explicit `dyn` are deprecated
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:4:13
|
4 | fn f(a: A) -> A;
| ^
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: `A` it is not object safe, so it can't be `dyn`
help: use a new generic type parameter, constrained by `A`
|
4 | fn f<T: A>(a: T) -> A;
| ++++++ ~
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
4 | fn f(a: impl A) -> A;
| ++++
warning: trait objects without an explicit `dyn` are deprecated
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:4:19
|
4 | fn f(a: A) -> A;
| ^
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
help: `A` is not object safe, use `impl A` to return an opaque type, as long as you return a single underlying type
|
4 | fn f(a: A) -> impl A;
| ++++
note: no errors encountered even though `span_delayed_bug` issued
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error[E0391]: cycle detected when computing function signature of `B::f`
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:4:5
|
4 | fn f(a: A) -> A;
| ^^^^^^^^^^^^^^^^
|
note: ...which requires checking if trait `A` is object safe...
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:7:1
|
7 | trait A {
| ^^^^^^^
note: ...which requires determining object safety of trait `A`...
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:7:1
|
7 | trait A {
| ^^^^^^^
note: ...which requires computing function signature of `A::g`...
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:8:5
|
8 | fn g(b: B) -> B;
| ^^^^^^^^^^^^^^^^
note: ...which requires checking if trait `B` is object safe...
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:3:1
|
3 | trait B {
| ^^^^^^^
note: ...which requires determining object safety of trait `B`...
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:3:1
|
3 | trait B {
| ^^^^^^^
= note: ...which again requires computing function signature of `B::f`, completing the cycle
note: cycle used when collecting item types in top-level module
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:1:1
|
1 | / #![feature(object_safe_for_dispatch)]
2 | |
3 | | trait B {
4 | | fn f(a: A) -> A;
... |
10 | |
11 | | fn main() {}
| |____________^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
note: delayed at compiler/rustc_query_system/src/query/job.rs:605:16
0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
1: <rustc_errors::DiagCtxt>::emit_diagnostic
2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
3: rustc_query_system::query::plumbing::mk_cycle::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>
4: rustc_query_system::query::plumbing::cycle_error::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>
5: rustc_query_impl::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
6: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>>
7: rustc_trait_selection::traits::object_safety::virtual_call_violations_for_method
8: rustc_trait_selection::traits::object_safety::object_safety_violations_for_assoc_item
9: <core::iter::adapters::flatten::FlatMap<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::slice::iter::Iter<(rustc_span::symbol::Symbol, rustc_middle::ty::assoc::AssocItem)>, <rustc_data_structures::sorted_map::index_map::SortedIndexMultiMap<u32, rustc_span::symbol::Symbol, rustc_middle::ty::assoc::AssocItem>>::iter::{closure#0}>, <rustc_middle::ty::assoc::AssocItems>::in_definition_order::{closure#0}>, alloc::vec::Vec<rustc_middle::traits::ObjectSafetyViolation>, rustc_trait_selection::traits::object_safety::object_safety_violations_for_trait::{closure#0}> as core::iter::traits::iterator::Iterator>::next
10: <core::iter::adapters::flatten::FlatMap<rustc_trait_selection::traits::util::SupertraitDefIds, alloc::vec::Vec<rustc_middle::traits::ObjectSafetyViolation>, rustc_trait_selection::traits::object_safety::object_safety_violations::{closure#0}> as core::iter::traits::iterator::Iterator>::next
11: rustc_trait_selection::traits::object_safety::object_safety_violations
12: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::object_safety_violations::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
13: <rustc_query_impl::query_impl::object_safety_violations::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
15: rustc_query_impl::query_impl::object_safety_violations::get_query_non_incr::__rust_end_short_backtrace
16: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 16]>>>
17: rustc_trait_selection::traits::object_safety::check_is_object_safe
18: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_is_object_safe::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
20: rustc_query_impl::query_impl::check_is_object_safe::get_query_non_incr::__rust_end_short_backtrace
21: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 1]>>>
22: <dyn rustc_hir_analysis::astconv::AstConv>::maybe_lint_impl_trait
23: <<dyn rustc_hir_analysis::astconv::AstConv>::maybe_lint_bare_trait::{closure#1} as core::ops::function::FnOnce<(&mut rustc_errors::diagnostic_builder::DiagnosticBuilder<()>,)>>::call_once::{shim:vtable#0}
24: <alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnOnce<(&'a mut rustc_errors::diagnostic_builder::DiagnosticBuilder<'b, ()>,), Output = ()>> as core::ops::function::FnOnce<(&mut rustc_errors::diagnostic_builder::DiagnosticBuilder<()>,)>>::call_once
25: rustc_middle::lint::struct_lint_level::struct_lint_level_impl::<&str>
26: <dyn rustc_hir_analysis::astconv::AstConv>::maybe_lint_bare_trait
27: <dyn rustc_hir_analysis::astconv::AstConv>::ast_ty_to_ty_inner
28: <dyn rustc_hir_analysis::astconv::AstConv>::ty_of_fn
29: rustc_hir_analysis::collect::fn_sig
30: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
31: <rustc_query_impl::query_impl::fn_sig::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
32: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
33: rustc_query_impl::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
34: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>>
35: rustc_trait_selection::traits::object_safety::virtual_call_violations_for_method
36: rustc_trait_selection::traits::object_safety::object_safety_violations_for_assoc_item
37: <core::iter::adapters::flatten::FlatMap<core::iter::adapters::map::Map<core::iter::adapters::map::Map<core::slice::iter::Iter<(rustc_span::symbol::Symbol, rustc_middle::ty::assoc::AssocItem)>, <rustc_data_structures::sorted_map::index_map::SortedIndexMultiMap<u32, rustc_span::symbol::Symbol, rustc_middle::ty::assoc::AssocItem>>::iter::{closure#0}>, <rustc_middle::ty::assoc::AssocItems>::in_definition_order::{closure#0}>, alloc::vec::Vec<rustc_middle::traits::ObjectSafetyViolation>, rustc_trait_selection::traits::object_safety::object_safety_violations_for_trait::{closure#0}> as core::iter::traits::iterator::Iterator>::next
38: <core::iter::adapters::flatten::FlatMap<rustc_trait_selection::traits::util::SupertraitDefIds, alloc::vec::Vec<rustc_middle::traits::ObjectSafetyViolation>, rustc_trait_selection::traits::object_safety::object_safety_violations::{closure#0}> as core::iter::traits::iterator::Iterator>::next
39: rustc_trait_selection::traits::object_safety::object_safety_violations
40: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::object_safety_violations::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
41: <rustc_query_impl::query_impl::object_safety_violations::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
42: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
43: rustc_query_impl::query_impl::object_safety_violations::get_query_non_incr::__rust_end_short_backtrace
44: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 16]>>>
45: rustc_trait_selection::traits::object_safety::check_is_object_safe
46: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_is_object_safe::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
47: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
48: rustc_query_impl::query_impl::check_is_object_safe::get_query_non_incr::__rust_end_short_backtrace
49: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 1]>>>
50: <dyn rustc_hir_analysis::astconv::AstConv>::maybe_lint_impl_trait
51: <<dyn rustc_hir_analysis::astconv::AstConv>::maybe_lint_bare_trait::{closure#1} as core::ops::function::FnOnce<(&mut rustc_errors::diagnostic_builder::DiagnosticBuilder<()>,)>>::call_once::{shim:vtable#0}
52: <alloc::boxed::Box<dyn for<'a, 'b> core::ops::function::FnOnce<(&'a mut rustc_errors::diagnostic_builder::DiagnosticBuilder<'b, ()>,), Output = ()>> as core::ops::function::FnOnce<(&mut rustc_errors::diagnostic_builder::DiagnosticBuilder<()>,)>>::call_once
53: rustc_middle::lint::struct_lint_level::struct_lint_level_impl::<&str>
54: <dyn rustc_hir_analysis::astconv::AstConv>::maybe_lint_bare_trait
55: <dyn rustc_hir_analysis::astconv::AstConv>::ast_ty_to_ty_inner
56: <dyn rustc_hir_analysis::astconv::AstConv>::ty_of_fn
57: rustc_hir_analysis::collect::fn_sig
58: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::fn_sig::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
59: <rustc_query_impl::query_impl::fn_sig::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
60: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
61: rustc_query_impl::query_impl::fn_sig::get_query_non_incr::__rust_end_short_backtrace
62: <rustc_hir_analysis::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_trait_item
63: rustc_hir_analysis::collect::collect_mod_item_types
64: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
65: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
66: rustc_query_impl::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
67: rustc_hir_analysis::check_crate
68: rustc_interface::passes::analysis
69: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
70: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
71: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
72: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
73: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
74: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
75: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/a58ec8ff03b3269b20104eb7eae407be48ab95a7/library/alloc/src/boxed.rs:2016:9
76: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/a58ec8ff03b3269b20104eb7eae407be48ab95a7/library/alloc/src/boxed.rs:2016:9
77: std::sys::pal::unix::thread::Thread::new::thread_start
at /rustc/a58ec8ff03b3269b20104eb7eae407be48ab95a7/library/std/src/sys/pal/unix/thread.rs:108:17
78: <unknown>
79: <unknown>
--> /tmp/icemaker_global_tempdir.yPYGjh9iJjgj/rustc_testrunner_tmpdir_reporting.YjRXwTSsOKW4/mvce.rs:4:5
|
4 | fn f(a: A) -> A;
| ^^^^^^^^^^^^^^^^
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.77.0-nightly (a58ec8ff0 2024-01-22) running on x86_64-unknown-linux-gnu
query stack during panic:
end of query stack
error: aborting due to 1 previous error; 4 warnings emitted
For more information about this error, try `rustc --explain E0391`.
Metadata
Assignees
Labels
Category: This is a bug.`#![feature(dyn_compatible_for_dispatch)]`; formerly `object_safe_for_dispatch`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: A query cycle occurred while none was expectedRelevant to the compiler team, which will review and decide on the PR/issue.
Activity