Skip to content

ICE: E0391 #120241

Closed

Description

@matthiaskrgr

¯\ (ツ)/¯

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`.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Jan 22, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 22, 2024
  3. matthiaskrgr commented on Jan 22, 2024

    @matthiaskrgr
    MemberAuthor

    probably the same problem:

    #![feature(object_safe_for_dispatch)]
    #![feature(unsized_fn_params)]
    
    fn guard(_s: Copy) -> bool {
        panic!()
    }
    
    fn main() {}
  4. matthiaskrgr commented on Jan 22, 2024

    @matthiaskrgr
    MemberAuthor

    Seems to be another regression of #119148 cc @estebank

  5. added
    F-dyn_compatible_for_dispatch`#![feature(dyn_compatible_for_dispatch)]`; formerly `object_safe_for_dispatch`
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 22, 2024
  6. fmease commented on Jan 22, 2024

    @fmease
    Member

    Found another one that has the same backtrace as #120241 (comment):

    #![feature(object_safe_for_dispatch)]
    
    trait B {
        fn f(a: A);
    }
    
    trait A {
        fn g(b: ());
    }
    
    fn main() {}
    stderr w/ backtrace
    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[E0782]: trait objects must include the `dyn` keyword
     --> src/main.rs:4:13
      |
    4 |     fn f(a: A);
      |             ^
      |
      = note: `A` it is not object safe, so it can't be `dyn`
    note: delayed at compiler/rustc_hir_analysis/src/astconv/lint.rs:226:21
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxtInner>::emit_stashed_diagnostics
             2: <rustc_errors::DiagCtxt>::print_error_count
             3: <rustc_session::session::Session>::finish_diagnostics
             4: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
             5: 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>>
             6: <<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}
             7: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/ef71f1047e04438181d7cb925a833e2ada6ab390/library/alloc/src/boxed.rs:2016:9
             8: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/ef71f1047e04438181d7cb925a833e2ada6ab390/library/alloc/src/boxed.rs:2016:9
             9: std::sys::pal::unix::thread::Thread::new::thread_start
                       at /rustc/ef71f1047e04438181d7cb925a833e2ada6ab390/library/std/src/sys/pal/unix/thread.rs:108:17
            10: start_thread
            11: clone
     --> src/main.rs:4:13
      |
    4 |     fn f(a: A);
      |             ^
    help: use a new generic type parameter, constrained by `A`
      |
    4 |     fn f<T: A>(a: T);
      |         ++++++    ~
    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);
      |             ++++
    
    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: please attach the file at `/playground/rustc-ice-2024-01-22T16_11_23-69.txt` to your bug report
    
    note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2
    
    note: some of the compiler flags provided by cargo are hidden
    
    query stack during panic:
    end of query stack
    
  7. fmease commented on Jan 22, 2024

    @fmease
    Member

    Hmm, I was worried about mutual recursion but I didn't know that it needed object_safe_for_dispatch to trigger.

  8. compiler-errors commented on Jan 22, 2024

    @compiler-errors
    Contributor

    I believe this is fixed by #120164

  9. fmease commented on Jan 23, 2024

    @fmease
    Member

    I believe this is fixed by [the now merged] #120164

    Still crashes on the latest master (e35a56d).

  10. estebank commented on Jan 23, 2024

    @estebank
    Contributor

    Ok. I have the smallest possible patch that keeps the nice suggestions in edition >2018 while avoiding most of the problems we are seeing:

    https://github.com/rust-lang/rust/pull/119148/files#diff-6811606406d5d02f325d966b59934814111edf12cb48ddd5564448074533c76aR238

    Removing that line and unconditionally suggest using dyn in 2015/2018 in the lint (as we did before this change, which is incorrect in some cases) will avoid most of the problems we were seeing because we are assured that an error will emit. Even the delayed recursive query error will not be a problem in that case either.

    Edit: #120275

  11. added 3 commits that reference this issue on Jan 23, 2024
    c6db42f
    f562032
    3d9cb5e
  12. added
    I-cycleIssue: A query cycle occurred while none was expected
    on Jan 25, 2024
  13. added a commit that references this issue on Jan 27, 2024
    3022c76
  14. added 3 commits that reference this issue on Jan 27, 2024
    a58ce1e
    4ada5ef
    60a72b6
  15. added a commit that references this issue on Jan 29, 2024
    09f16b5
  16. added a commit that references this issue on Jan 29, 2024
    af08c64
  17. added 3 commits that reference this issue on Oct 12, 2024
  18. added a commit that references this issue on Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-dyn_compatible_for_dispatch`#![feature(dyn_compatible_for_dispatch)]`; formerly `object_safe_for_dispatch`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-cycleIssue: A query cycle occurred while none was expectedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions