Skip to content

compiler panics when function self is &(impl Deref<Target=Self> + Clone + Send + 'static) #111536

Closed
@faucct

Description

@faucct

Code

#![feature(arbitrary_self_types)]
#![feature(async_fn_in_trait)]
use std::{ops::Deref, sync::Arc};

use anyhow::Result;

pub trait ByteStorage {
    async fn get(self: &(impl Deref<Target=Self> + Clone + Send + 'static), key: String) -> Result<Option<Vec<u8>>>;
}

Meta

rustc --version --verbose:

note: rustc 1.71.0-nightly (fec9adcdb 2023-04-21) running on aarch64-apple-darwin

Error output

<output>
Backtrace

thread 'rustc' panicked at 'DefId(94:65 ~ factor_service[3174]::byte_storage::ByteStorage::get::{opaque#1}) does not have a "def_span"', compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:205:1
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::def_span::{closure#2}
   3: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::def_span
   4: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::queries::def_span, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}, (rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
   5: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::def_span, rustc_query_impl::plumbing::QueryCtxt>
   6: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::def_span
   7: <rustc_infer::infer::InferCtxt>::infer_projection
   8: rustc_trait_selection::traits::project::normalize_projection_type
   9: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
  10: rustc_middle::ty::util::fold_list::<rustc_trait_selection::traits::project::AssocTypeNormalizer, rustc_middle::ty::Ty, <&rustc_middle::ty::list::List<rustc_middle::ty::Ty> as rustc_type_ir::fold::TypeFoldable<rustc_middle::ty::context::TyCtxt>>::try_fold_with<rustc_trait_selection::traits::project::AssocTypeNormalizer>::{closure#0}>
  11: <rustc_trait_selection::traits::project::AssocTypeNormalizer>::fold::<(rustc_middle::ty::sty::FnSig, rustc_middle::ty::InstantiatedPredicates)>
  12: rustc_trait_selection::traits::project::normalize_with_depth::<(rustc_middle::ty::sty::FnSig, rustc_middle::ty::InstantiatedPredicates)>
  13: <rustc_infer::infer::at::At as rustc_trait_selection::traits::project::NormalizeExt>::normalize::<(rustc_middle::ty::sty::FnSig, rustc_middle::ty::InstantiatedPredicates)>
  14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::normalize::<(rustc_middle::ty::sty::FnSig, rustc_middle::ty::InstantiatedPredicates)>
  15: <rustc_hir_typeck::method::confirm::ConfirmContext>::confirm
  16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::lookup_method
  17: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  18: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types
  20: <rustc_hir_typeck::fn_ctxt::FnCtxt>::confirm_builtin_call
  21: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_call
  22: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  23: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_match::{closure#0}
  25: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  26: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  28: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  30: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  31: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  32: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  33: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  34: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  35: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  36: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  37: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  38: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  39: <rustc_middle::ty::Ty as rustc_type_ir::CollectAndApply<rustc_middle::ty::Ty, rustc_middle::ty::Ty>>::collect_and_apply::<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::slice::iter::Iter<rustc_hir::hir::Expr>>, <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_tuple::{closure#1}>, <rustc_middle::ty::context::TyCtxt>::mk_tup_from_iter<core::iter::adapters::map::Map<core::iter::adapters::enumerate::Enumerate<core::slice::iter::Iter<rustc_hir::hir::Expr>>, <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_tuple::{closure#1}>, rustc_middle::ty::Ty>::{closure#0}>
  40: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  41: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  42: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_match::{closure#0}
  43: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  44: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  45: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_stmt
  46: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
  47: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  48: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  49: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
  50: rustc_hir_typeck::check::check_fn
  51: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_closure
  52: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  53: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  54: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_decl
  55: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_stmt
  56: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_block_with_expected
  57: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind
  58: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  59: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_expr
  60: rustc_hir_typeck::check::check_fn
  61: rustc_hir_typeck::typeck
  62: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}, (rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
  63: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
  64: rustc_query_system::query::plumbing::force_query::<rustc_query_impl::queries::typeck, rustc_query_impl::plumbing::QueryCtxt>
  65: <rustc_query_impl::plumbing::query_callback<rustc_query_impl::queries::typeck>::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind>)>>::call_once
  66: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  67: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_green::<rustc_query_impl::plumbing::QueryCtxt>
  68: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>::{closure#1}, core::option::Option<(rustc_middle::query::erase::Erased<[u8; 0]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>>::{closure#0}, core::option::Option<(rustc_middle::query::erase::Erased<[u8; 0]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>>
  69: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
  70: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  71: rustc_hir_analysis::check_crate
  72: rustc_interface::passes::analysis
  73: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}, (rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
  74: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  75: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  76: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  77: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  78: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  79: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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

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.71.0-nightly (fec9adcdb 2023-04-21) running on aarch64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [def_span] looking up span for `factor_service::byte_storage::ByteStorage::get::{opaque#1}`
#1 [typeck] type-checking `cassandra`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 typeck_item_bodies(0-0)
end of try_mark_green dep node stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-arbitrary_self_types`#![feature(arbitrary_self_types)]`F-async_fn_in_traitStatic async fn in traitsI-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.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions