Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE on experimental feature fn delegation (reuse) in associated item position #6513

Open
fmease opened this issue Mar 18, 2025 · 1 comment
Labels
bug Panic, non-idempotency, invalid code, etc. p-low

Comments

@fmease
Copy link
Member

fmease commented Mar 18, 2025

Disclaimer: This has a very low priority given feature fn_delegation (rust-lang/rust#118212) is highly experimental and since it's not guaranteed that this feature will persist. Still, for the sake of coverage, I've decided to report it.

Reproducers

#![feature(fn_delegation)]

struct Ty;
impl Ty {
    reuse std::convert::identity;
}
rustfmt output
thread 'main' panicked at src/tools/rustfmt/src/visitor.rs:677:18:
internal error: entered unreachable code
stack backtrace:
   0:     0x74ee55bbea64 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd9fc6a39ec3df3d1
   1:     0x74ee564057e2 - core::fmt::write::h73a1e37ddefe0a4f
   2:     0x74ee57427c91 - std::io::Write::write_fmt::h12f84d1a8e648b12
   3:     0x74ee55bbe8c2 - std::sys::backtrace::BacktraceLock::print::h91fc82fbc6b056a6
   4:     0x74ee55bc11a2 - std::panicking::default_hook::{{closure}}::hebc0ecceade2cd26
   5:     0x74ee55bc0d94 - std::panicking::default_hook::h82ddd3fdf5856794
   6:     0x74ee54d19277 - std[20d29db3e999c305]::panicking::update_hook::<alloc[e1570dfcc331507b]::boxed::Box<rustc_driver_impl[633be37e059aaf16]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x74ee55bc1a13 - std::panicking::rust_panic_with_hook::hb92b3172308f4e8b
   8:     0x74ee55bc16d6 - std::panicking::begin_panic_handler::{{closure}}::hbf0e4f1d78818dec
   9:     0x74ee55bbef39 - std::sys::backtrace::__rust_end_short_backtrace::hfc58a21f6afae4ae
  10:     0x74ee55bc13cd - rust_begin_unwind
  11:     0x74ee5285be40 - core::panicking::panic_fmt::h52a3de72b5c008c5
  12:     0x74ee532ebf7c - core::panicking::panic::h968935f54951f8e4
  13:     0x60e9f23eaa7f - <rustfmt_nightly[8bef2c5348bbd989]::visitor::FmtVisitor>::visit_assoc_item
  14:     0x60e9f23764c4 - <rustfmt_nightly[8bef2c5348bbd989]::visitor::FmtVisitor>::visit_impl_items
  15:     0x60e9f23e8109 - <rustfmt_nightly[8bef2c5348bbd989]::visitor::FmtVisitor>::visit_item
  16:     0x60e9f23bdd58 - <rustfmt_nightly[8bef2c5348bbd989]::visitor::FmtVisitor>::visit_items_with_reordering
  17:     0x60e9f23ede2b - <rustfmt_nightly[8bef2c5348bbd989]::visitor::FmtVisitor>::format_separate_mod
  18:     0x60e9f224e7c9 - <scoped_tls[bb4943a609257807]::ScopedKey<rustc_span[142d3b94b336956b]::SessionGlobals>>::with::<<rustfmt_nightly[8bef2c5348bbd989]::Session<std[20d29db3e999c305]::io::stdio::Stdout>>::format_input_inner::{closure#0}, core[7509374bb9bacf81]::result::Result<rustfmt_nightly[8bef2c5348bbd989]::FormatReport, rustfmt_nightly[8bef2c5348bbd989]::ErrorKind>>
  19:     0x60e9f2267067 - rustfmt[ce1aaa3c9c957e5c]::format_and_emit_report::<std[20d29db3e999c305]::io::stdio::Stdout>
  20:     0x60e9f2264bb9 - rustfmt[ce1aaa3c9c957e5c]::execute
  21:     0x60e9f2260bdf - rustfmt[ce1aaa3c9c957e5c]::main
  22:     0x60e9f2257443 - std[20d29db3e999c305]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  23:     0x60e9f22579b9 - std[20d29db3e999c305]::rt::lang_start::<()>::{closure#0}
  24:     0x74ee5732699e - std::rt::lang_start_internal::h71fef5e5f25ac3f5
  25:     0x60e9f2268278 - main
  26:     0x74ee512f1e08 - <unknown>
  27:     0x74ee512f1ecc - __libc_start_main
  28:     0x60e9f2248cf9 - <unknown>
  29:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rustfmt/issues/new?labels=bug

note: please make sure that you have updated to the latest nightly

note: rustc 1.87.0-nightly (e16a049ad 2025-03-03) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
#![feature(fn_delegation)]

trait Trait {
    reuse std::convert::identity;
}
rustfmt output
thread 'main' panicked at src/tools/rustfmt/src/visitor.rs:677:18:
internal error: entered unreachable code
stack backtrace:
   0:     0x775a063bea64 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hd9fc6a39ec3df3d1
   1:     0x775a06c057e2 - core::fmt::write::h73a1e37ddefe0a4f
   2:     0x775a07c27c91 - std::io::Write::write_fmt::h12f84d1a8e648b12
   3:     0x775a063be8c2 - std::sys::backtrace::BacktraceLock::print::h91fc82fbc6b056a6
   4:     0x775a063c11a2 - std::panicking::default_hook::{{closure}}::hebc0ecceade2cd26
   5:     0x775a063c0d94 - std::panicking::default_hook::h82ddd3fdf5856794
   6:     0x775a05519277 - std[20d29db3e999c305]::panicking::update_hook::<alloc[e1570dfcc331507b]::boxed::Box<rustc_driver_impl[633be37e059aaf16]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x775a063c1a13 - std::panicking::rust_panic_with_hook::hb92b3172308f4e8b
   8:     0x775a063c16d6 - std::panicking::begin_panic_handler::{{closure}}::hbf0e4f1d78818dec
   9:     0x775a063bef39 - std::sys::backtrace::__rust_end_short_backtrace::hfc58a21f6afae4ae
  10:     0x775a063c13cd - rust_begin_unwind
  11:     0x775a0305be40 - core::panicking::panic_fmt::h52a3de72b5c008c5
  12:     0x775a03aebf7c - core::panicking::panic::h968935f54951f8e4
  13:     0x6132bd533a7f - <rustfmt_nightly[8bef2c5348bbd989]::visitor::FmtVisitor>::visit_assoc_item
  14:     0x6132bd5306cf - <rustfmt_nightly[8bef2c5348bbd989]::visitor::FmtVisitor>::visit_item
  15:     0x6132bd506d58 - <rustfmt_nightly[8bef2c5348bbd989]::visitor::FmtVisitor>::visit_items_with_reordering
  16:     0x6132bd536e2b - <rustfmt_nightly[8bef2c5348bbd989]::visitor::FmtVisitor>::format_separate_mod
  17:     0x6132bd3977c9 - <scoped_tls[bb4943a609257807]::ScopedKey<rustc_span[142d3b94b336956b]::SessionGlobals>>::with::<<rustfmt_nightly[8bef2c5348bbd989]::Session<std[20d29db3e999c305]::io::stdio::Stdout>>::format_input_inner::{closure#0}, core[7509374bb9bacf81]::result::Result<rustfmt_nightly[8bef2c5348bbd989]::FormatReport, rustfmt_nightly[8bef2c5348bbd989]::ErrorKind>>
  18:     0x6132bd3b0067 - rustfmt[ce1aaa3c9c957e5c]::format_and_emit_report::<std[20d29db3e999c305]::io::stdio::Stdout>
  19:     0x6132bd3adbb9 - rustfmt[ce1aaa3c9c957e5c]::execute
  20:     0x6132bd3a9bdf - rustfmt[ce1aaa3c9c957e5c]::main
  21:     0x6132bd3a0443 - std[20d29db3e999c305]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  22:     0x6132bd3a09b9 - std[20d29db3e999c305]::rt::lang_start::<()>::{closure#0}
  23:     0x775a07b2699e - std::rt::lang_start_internal::h71fef5e5f25ac3f5
  24:     0x6132bd3b1278 - main
  25:     0x775a01b45e08 - <unknown>
  26:     0x775a01b45ecc - __libc_start_main
  27:     0x6132bd391cf9 - <unknown>
  28:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rustfmt/issues/new?labels=bug

note: please make sure that you have updated to the latest nightly

note: rustc 1.87.0-nightly (e16a049ad 2025-03-03) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

Meta

rustfmt -V:

rustfmt 1.8.0-nightly (e16a049adb 2025-03-03)
@ytmimi ytmimi added bug Panic, non-idempotency, invalid code, etc. p-low labels Mar 18, 2025
@ytmimi
Copy link
Contributor

ytmimi commented Mar 18, 2025

@fmease looks like we're not handling the AssocItemKind::Delegation and AssocItemKind::DelegationMac variants here:

_ => unreachable!(),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. p-low
Projects
None yet
Development

No branches or pull requests

2 participants