Skip to content

RFC #1733 (Trait Aliases): compilation crash when putting "diagnostic::on_unimplemented" on alias #130627

@andrzejressel

Description

@andrzejressel

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=7b59ad99144e849738f87583bb664c44

Code

#![feature(trait_alias)] trait Test { } #[diagnostic::on_unimplemented(  message="message",  label="label",  note="note" )] trait Alias = Test; // Use trait alias as bound on type parameter. fn foo<T: Alias>(v: &T) { } pub fn main() { foo(&1); }

Meta

rustc --version --verbose:

nightly 2024-09-19 506f22b4663f3e756e1e 

Error output

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect.rs:1689:22: $ident: found Item { ident: Alias#0, owner_id: DefId(0:7 ~ playground[b3b9]::Alias), kind: TraitAlias(Generics { params: [], predicates: [], has_where_clause_predicates: false, where_clause_span: src/main.rs:13:19: 13:19 (#0), span: src/main.rs:13:12: 13:12 (#0) }, [Trait(PolyTraitRef { bound_generic_params: [], trait_ref: TraitRef { path: Path { span: src/main.rs:13:15: 13:19 (#0), res: Def(Trait, DefId(0:3 ~ playground[b3b9]::Test)), segments: [PathSegment { ident: Test#0, hir_id: HirId(DefId(0:7 ~ playground[b3b9]::Alias).1), res: Def(Trait, DefId(0:3 ~ playground[b3b9]::Test)), args: None, infer_args: false }] }, hir_ref_id: HirId(DefId(0:7 ~ playground[b3b9]::Alias).2) }, span: src/main.rs:13:15: 13:19 (#0) }, None)]), span: src/main.rs:13:1: 13:20 (#0), vis_span: src/main.rs:13:1: 13:1 (#0) } stack backtrace: 0: 0x7ffb9d1c3c9a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h931fa8a693ee76bf 1: 0x7ffb9d9577d7 - core::fmt::write::ha344a87a3011b8f5 2: 0x7ffb9e8608b3 - std::io::Write::write_fmt::ha4f1ac9a9087f93c 3: 0x7ffb9d1c3af2 - std::sys::backtrace::BacktraceLock::print::h2930c514ae5653cd 4: 0x7ffb9d1c6271 - std::panicking::default_hook::{{closure}}::hc7a5b0b766fd5663 5: 0x7ffb9d1c60a4 - std::panicking::default_hook::h9d542ef7bbd51eed 6: 0x7ffb9c2c3a4f - std[ee7033f0ed262c3b]::panicking::update_hook::<alloc[3af4d0b46ca260e8]::boxed::Box<rustc_driver_impl[2bd8fe8419d4e53d]::install_ice_hook::{closure#0}>>::{closure#0} 7: 0x7ffb9d1c6988 - std::panicking::rust_panic_with_hook::h426e85c59c56abd7 8: 0x7ffb9d1c675a - std::panicking::begin_panic_handler::{{closure}}::hdbed8eca2a1d0322 9: 0x7ffb9d1c4149 - std::sys::backtrace::__rust_end_short_backtrace::hfaec60235a9405e1 10: 0x7ffb9d1c641c - rust_begin_unwind 11: 0x7ffb99fe10b0 - core::panicking::panic_fmt::he0c447514557f5eb 12: 0x7ffb9c37b861 - rustc_hir[9aec883c6500dd0e]::hir::expect_failed::<&rustc_hir[9aec883c6500dd0e]::hir::Item> 13: 0x7ffb9e05b3af - rustc_hir_analysis[6076d6bf04e2ff00]::collect::impl_trait_header 14: 0x7ffb9dbbb08e - rustc_query_impl[3b3b44733218f5bc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b3b44733218f5bc]::query_impl::impl_trait_header::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99c6bed041f57f4c]::query::erase::Erased<[u8; 24usize]>> 15: 0x7ffb9dbba4b6 - rustc_query_system[52f0d79d68908be]::query::plumbing::try_execute_query::<rustc_query_impl[3b3b44733218f5bc]::DynamicConfig<rustc_query_system[52f0d79d68908be]::query::caches::DefIdCache<rustc_middle[99c6bed041f57f4c]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[3b3b44733218f5bc]::plumbing::QueryCtxt, false> 16: 0x7ffb9dbba1a8 - rustc_query_impl[3b3b44733218f5bc]::query_impl::impl_trait_header::get_query_non_incr::__rust_end_short_backtrace 17: 0x7ffb9dba8d31 - <rustc_middle[99c6bed041f57f4c]::ty::context::TyCtxt>::trait_id_of_impl 18: 0x7ffb9d017f3d - <rustc_trait_selection[921af4f56dbc3556]::error_reporting::traits::on_unimplemented::OnUnimplementedFormatString>::try_parse 19: 0x7ffb9d016c8c - <rustc_trait_selection[921af4f56dbc3556]::error_reporting::traits::on_unimplemented::OnUnimplementedDirective>::parse 20: 0x7ffb9bc3ddc2 - <rustc_trait_selection[921af4f56dbc3556]::error_reporting::traits::on_unimplemented::OnUnimplementedDirective>::parse_attribute 21: 0x7ffb9dc66e9e - <rustc_trait_selection[921af4f56dbc3556]::error_reporting::traits::on_unimplemented::OnUnimplementedDirective>::of_item 22: 0x7ffb9d0153af - <rustc_trait_selection[921af4f56dbc3556]::error_reporting::TypeErrCtxt>::on_unimplemented_note 23: 0x7ffb9cffe812 - <rustc_trait_selection[921af4f56dbc3556]::error_reporting::TypeErrCtxt>::report_selection_error 24: 0x7ffb9d07c0cb - <rustc_trait_selection[921af4f56dbc3556]::error_reporting::TypeErrCtxt>::report_fulfillment_error 25: 0x7ffb9d0444c7 - <rustc_trait_selection[921af4f56dbc3556]::error_reporting::TypeErrCtxt>::report_fulfillment_errors 26: 0x7ffb9a56e063 - <rustc_hir_typeck[30566531c8d8333f]::fn_ctxt::FnCtxt>::confirm_builtin_call 27: 0x7ffb9e4ae7b9 - <rustc_hir_typeck[30566531c8d8333f]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args 28: 0x7ffb9e4a81fe - <rustc_hir_typeck[30566531c8d8333f]::fn_ctxt::FnCtxt>::check_block_with_expected 29: 0x7ffb9e4af01d - <rustc_hir_typeck[30566531c8d8333f]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args 30: 0x7ffb9d9f4b15 - rustc_hir_typeck[30566531c8d8333f]::check::check_fn 31: 0x7ffb9dcef2fe - rustc_hir_typeck[30566531c8d8333f]::typeck 32: 0x7ffb9dceed49 - rustc_query_impl[3b3b44733218f5bc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b3b44733218f5bc]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99c6bed041f57f4c]::query::erase::Erased<[u8; 8usize]>> 33: 0x7ffb9dce16fd - rustc_query_system[52f0d79d68908be]::query::plumbing::try_execute_query::<rustc_query_impl[3b3b44733218f5bc]::DynamicConfig<rustc_query_system[52f0d79d68908be]::query::caches::VecCache<rustc_span[d9e8be537ef50d77]::def_id::LocalDefId, rustc_middle[99c6bed041f57f4c]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[3b3b44733218f5bc]::plumbing::QueryCtxt, false> 34: 0x7ffb9dce044d - rustc_query_impl[3b3b44733218f5bc]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace 35: 0x7ffb9dce00c7 - <rustc_middle[99c6bed041f57f4c]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[6076d6bf04e2ff00]::check_crate::{closure#4}>::{closure#0} 36: 0x7ffb9dcddf6e - rustc_hir_analysis[6076d6bf04e2ff00]::check_crate 37: 0x7ffb9dcda8c5 - rustc_interface[7c2e5611e1eae4f6]::passes::run_required_analyses 38: 0x7ffb9e504ade - rustc_interface[7c2e5611e1eae4f6]::passes::analysis 39: 0x7ffb9e504ab1 - rustc_query_impl[3b3b44733218f5bc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3b3b44733218f5bc]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99c6bed041f57f4c]::query::erase::Erased<[u8; 1usize]>> 40: 0x7ffb9e7eb06e - rustc_query_system[52f0d79d68908be]::query::plumbing::try_execute_query::<rustc_query_impl[3b3b44733218f5bc]::DynamicConfig<rustc_query_system[52f0d79d68908be]::query::caches::SingleCache<rustc_middle[99c6bed041f57f4c]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3b3b44733218f5bc]::plumbing::QueryCtxt, false> 41: 0x7ffb9e7eadcf - rustc_query_impl[3b3b44733218f5bc]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 42: 0x7ffb9e65c25e - rustc_interface[7c2e5611e1eae4f6]::interface::run_compiler::<core[60b858db6614a1bf]::result::Result<(), rustc_span[d9e8be537ef50d77]::ErrorGuaranteed>, rustc_driver_impl[2bd8fe8419d4e53d]::run_compiler::{closure#0}>::{closure#1} 43: 0x7ffb9e714a10 - std[ee7033f0ed262c3b]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[7c2e5611e1eae4f6]::util::run_in_thread_with_globals<rustc_interface[7c2e5611e1eae4f6]::util::run_in_thread_pool_with_globals<rustc_interface[7c2e5611e1eae4f6]::interface::run_compiler<core[60b858db6614a1bf]::result::Result<(), rustc_span[d9e8be537ef50d77]::ErrorGuaranteed>, rustc_driver_impl[2bd8fe8419d4e53d]::run_compiler::{closure#0}>::{closure#1}, core[60b858db6614a1bf]::result::Result<(), rustc_span[d9e8be537ef50d77]::ErrorGuaranteed>>::{closure#0}, core[60b858db6614a1bf]::result::Result<(), rustc_span[d9e8be537ef50d77]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[60b858db6614a1bf]::result::Result<(), rustc_span[d9e8be537ef50d77]::ErrorGuaranteed>> 44: 0x7ffb9e71507a - <<std[ee7033f0ed262c3b]::thread::Builder>::spawn_unchecked_<rustc_interface[7c2e5611e1eae4f6]::util::run_in_thread_with_globals<rustc_interface[7c2e5611e1eae4f6]::util::run_in_thread_pool_with_globals<rustc_interface[7c2e5611e1eae4f6]::interface::run_compiler<core[60b858db6614a1bf]::result::Result<(), rustc_span[d9e8be537ef50d77]::ErrorGuaranteed>, rustc_driver_impl[2bd8fe8419d4e53d]::run_compiler::{closure#0}>::{closure#1}, core[60b858db6614a1bf]::result::Result<(), rustc_span[d9e8be537ef50d77]::ErrorGuaranteed>>::{closure#0}, core[60b858db6614a1bf]::result::Result<(), rustc_span[d9e8be537ef50d77]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[60b858db6614a1bf]::result::Result<(), rustc_span[d9e8be537ef50d77]::ErrorGuaranteed>>::{closure#1} as core[60b858db6614a1bf]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 45: 0x7ffb9e71546b - std::sys::pal::unix::thread::Thread::new::thread_start::h172f6b61f4e28e39 46: 0x7ffb98d25609 - start_thread 47: 0x7ffb98c4a353 - clone 48: 0x0 - <unknown> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-on_unimplementedError messages that can be tackled with `#[rustc_on_unimplemented]`F-trait_alias`#![feature(trait_alias)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.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