Skip to content

ICE when triggering a malformed diagnostic::on_unimplemented across crate boundaries (DefId(20:3 ~ ice_lib_test[60d0]::Test) isn't local) #124651

Closed
@13ros27

Description

Code

The simplest version uses tests/benches however I have also tested this via a sub-crate.
lib.rs:

#[diagnostic::on_unimplemented(aa = "broken")]
pub trait Test {}

tests/test.rs:

use ice_lib_test::*;

fn breakage<T: Test>(test: T) {}

#[test]
fn test() {
    breakage(1);
}

Meta

rustc --version --verbose:

rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-unknown-linux-gnu
release: 1.78.0
LLVM version: 18.1.2

I can also reproduce this on 1.79.0-beta.2 and 1.80.0-nightly on debug and release.

Error output

When running cargo test

warning: malformed `on_unimplemented` attribute
 --> src/lib.rs:1:32
  |
1 | #[diagnostic::on_unimplemented(aa = "broken")]
  |                                ^^^^^^^^^^^^^ invalid option found here
  |
  = help: only `message`, `note` and `label` are allowed as options
  = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default

warning: `ice-lib-test` (lib) generated 1 warning
   Compiling ice-lib-test v0.1.0 (/home/<me>/Documents/Programming/Rust/ice-lib-test)
warning: `ice-lib-test` (lib test) generated 1 warning (1 duplicate)
thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs:503:60:                                                                         
DefId::expect_local: `DefId(20:3 ~ ice_lib_test[60d0]::Test)` isn't local
stack backtrace: <see below>
Backtrace

   0:     0x7942adf8c892 - std::backtrace_rs::backtrace::libunwind::trace::he4ee80166a02c846                                                                                             
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5                                       
   1:     0x7942adf8c892 - std::backtrace_rs::backtrace::trace_unsynchronized::h476faccf57e88641
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7942adf8c892 - std::sys_common::backtrace::_print_fmt::h430c922a77e7a59c                                                                                                     
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7942adf8c892 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hffecb437d922f988                                                          
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7942adfdda6c - core::fmt::rt::Argument::fmt::hf3df69369399bfa9                                                                                                               
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/rt.rs:142:9                                                                       
   5:     0x7942adfdda6c - core::fmt::write::hd9a8d7d029f9ea1a
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/fmt/mod.rs:1153:17                                                                    
   6:     0x7942adf8178f - std::io::Write::write_fmt::h0e1226b2b8d973fe                                                                                                                  
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/io/mod.rs:1843:15
   7:     0x7942adf8c664 - std::sys_common::backtrace::_print::hd2df4a083f6e69b8                                                                                                         
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7942adf8c664 - std::sys_common::backtrace::print::he907f6ad7eee41cb
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7942adf8f35b - std::panicking::default_hook::{{closure}}::h3926193b61c9ca9b                                                                                                  
  10:     0x7942adf8f0b3 - std::panicking::default_hook::h25ba2457dea68e65                                                                                                               
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:292:9                                                                     
  11:     0x7942b0e2845d - std[e4dfbc2c3f4b09f1]::panicking::update_hook::<alloc[1adba907b9db1888]::boxed::Box<rustc_driver_impl[24a943716c49befe]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7942adf8fac0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h022ca2c0d8c21c9e                                                                            
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9                                                                      
  13:     0x7942adf8fac0 - std::panicking::rust_panic_with_hook::h0ad14d90dcf5224f
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:783:13                                                                    
  14:     0x7942adf8f802 - std::panicking::begin_panic_handler::{{closure}}::h4a1838a06f542647                                                                                           
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:657:13                                                                    
  15:     0x7942adf8cd66 - std::sys_common::backtrace::__rust_end_short_backtrace::h77cc4dc3567ca904                                                                                     
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:171:18                                                         
  16:     0x7942adf8f534 - rust_begin_unwind
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5                                                                     
  17:     0x7942adfd9f85 - core::panicking::panic_fmt::h940d4fd01a4b4fd1                                                                                                                 
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
  18:     0x7942b18a29ae - <rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::on_unimplemented::OnUnimplementedDirective>::parse                                         
  19:     0x7942b090c044 - <rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::on_unimplemented::OnUnimplementedDirective>::parse_attribute                               
  20:     0x7942b2127a94 - <rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::on_unimplemented::OnUnimplementedDirective>::of_item                                       
  21:     0x7942b18c756d - <rustc_infer[eccaaca0001de028]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::on_unimplemented::TypeErrCtxtExt>::on_unimplemented_note
  22:     0x7942b18e9f4c - <rustc_infer[eccaaca0001de028]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_selection_error
  23:     0x7942b18fe090 - <rustc_infer[eccaaca0001de028]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::type_err_ctxt_ext::InferCtxtPrivExt>::report_fulfillment_error
  24:     0x7942b18e70a1 - <rustc_infer[eccaaca0001de028]::infer::error_reporting::TypeErrCtxt as rustc_trait_selection[50b41c8253db3482]::traits::error_reporting::type_err_ctxt_ext::TypeErrCtxtExt>::report_fulfillment_errors
  25:     0x7942aefd0503 - <rustc_hir_typeck[bd9e9ef04feb2a99]::fn_ctxt::FnCtxt>::check_call                                                                                             
  26:     0x7942b2a71d24 - <rustc_hir_typeck[bd9e9ef04feb2a99]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args                                                                   
  27:     0x7942b2a6d68e - <rustc_hir_typeck[bd9e9ef04feb2a99]::fn_ctxt::FnCtxt>::check_block_with_expected                                                                              
  28:     0x7942b2a7220c - <rustc_hir_typeck[bd9e9ef04feb2a99]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:     0x7942b27c980a - rustc_hir_typeck[bd9e9ef04feb2a99]::check::check_fn                                                                                                           
  30:     0x7942b27bf6b7 - rustc_hir_typeck[bd9e9ef04feb2a99]::typeck                                                                                                                    
  31:     0x7942b27be90b - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4152ad88c3d6c78]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 8usize]>>
  32:     0x7942b213deed - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::<rustc_query_impl[e4152ad88c3d6c78]::DynamicConfig<rustc_query_system[475239fef39bf53f]::query::caches::VecCache<rustc_span[a4517f2b2e65298c]::def_id::LocalDefId, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e4152ad88c3d6c78]::plumbing::QueryCtxt, false>
  33:     0x7942b213d80c - rustc_query_impl[e4152ad88c3d6c78]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace                                                        
  34:     0x7942b213b995 - rustc_hir_analysis[7e49c3c0c7bed18]::check_crate                                                                                                              
  35:     0x7942b2911ef2 - rustc_interface[ba2b6dc4c96cb491]::passes::analysis                                                                                                           
  36:     0x7942b29118e5 - rustc_query_impl[e4152ad88c3d6c78]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4152ad88c3d6c78]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7942b2d7f3a2 - rustc_query_system[475239fef39bf53f]::query::plumbing::try_execute_query::<rustc_query_impl[e4152ad88c3d6c78]::DynamicConfig<rustc_query_system[475239fef39bf53f]::query::caches::SingleCache<rustc_middle[fda44fdb505d3e7f]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e4152ad88c3d6c78]::plumbing::QueryCtxt, false>
  38:     0x7942b2d7f149 - rustc_query_impl[e4152ad88c3d6c78]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace                                                      
  39:     0x7942b2bfc814 - rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler::<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}
  40:     0x7942b2f3eb6e - std[e4dfbc2c3f4b09f1]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ba2b6dc4c96cb491]::util::run_in_thread_with_globals<rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>
  41:     0x7942b2f3e9ca - <<std[e4dfbc2c3f4b09f1]::thread::Builder>::spawn_unchecked_<rustc_interface[ba2b6dc4c96cb491]::util::run_in_thread_with_globals<rustc_interface[ba2b6dc4c96cb491]::interface::run_compiler<core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>, rustc_driver_impl[24a943716c49befe]::run_compiler::{closure#0}>::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[836963c7c1decc11]::result::Result<(), rustc_span[a4517f2b2e65298c]::ErrorGuaranteed>>::{closure#1} as core[836963c7c1decc11]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7942adf99145 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h19b9e642d37e7272                                                                   
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
  43:     0x7942adf99145 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h97265befc434d3ae                                                                   
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
  44:     0x7942adf99145 - std::sys::pal::unix::thread::Thread::new::thread_start::h420dad5cf01a9f35
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys/pal/unix/thread.rs:108:17
  45:     0x7942adc94ac3 - start_thread                                                                                                                                                  
                               at ./nptl/pthread_create.c:442:8
  46:     0x7942add26850 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  47:                0x0 - <unknown>

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.F-on_unimplementedError messages that can be tackled with `#[rustc_on_unimplemented]`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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions