$ env RUSTC_LOG=rustc_trait_selection::traits::specialize cargo +stage1debug build
Compiling playground v0.1.0 (/opt/workspace/playground)
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert_blindly: impl_def_id=DefId(5:4335 ~ alloc[ac87]::string::{impl#40}) st=None
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert_blindly: impl_def_id=DefId(5:4339 ~ alloc[ac87]::string::{impl#41}) st=CharSimplifiedType
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert_blindly: impl_def_id=DefId(5:4342 ~ alloc[ac87]::string::{impl#42}) st=StrSimplifiedType
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert_blindly: impl_def_id=DefId(5:4344 ~ alloc[ac87]::string::{impl#43}) st=AdtSimplifiedType(DefId(5:405 ~ alloc[ac87]::borrow::Cow))
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert_blindly: impl_def_id=DefId(5:4346 ~ alloc[ac87]::string::{impl#44}) st=AdtSimplifiedType(DefId(5:5557 ~ alloc[ac87]::string::String))
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert(DefId(0:16 ~ playground[cc5d]::{impl#0})): inserting TraitRef <Cow<'_, str> as std::string::ToString> into specialization graph
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert(impl_def_id=DefId(0:16 ~ playground[cc5d]::{impl#0}), simplified_self=Some(AdtSimplifiedType(DefId(0:6 ~ playground[cc5d]::Cow))))
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert: impl_def_id=DefId(0:16 ~ playground[cc5d]::{impl#0}), simplified_self=Some(AdtSimplifiedType(DefId(0:6 ~ playground[cc5d]::Cow))), possible_sibling=DefId(5:4335 ~ alloc[ac87]::string::{impl#40})
DEBUG rustc_trait_selection::traits::specialize specializes(DefId(0:16 ~ playground[cc5d]::{impl#0}), DefId(5:4335 ~ alloc[ac87]::string::{impl#40}))
DEBUG rustc_trait_selection::traits::specialize translate_substs(ParamEnv { caller_bounds: [], reveal: UserFacing }, DefId(5:4093 ~ alloc[ac87]::str::{impl#4}), [], Impl(DefId(5:4093 ~ alloc[ac87]::str::{impl#4})))
DEBUG rustc_trait_selection::traits::specialize fulfill_implication(ParamEnv { caller_bounds: [], reveal: UserFacing }, trait_ref=<Cow<'_, str, std::string::String> as std::string::ToString> |- DefId(5:4335 ~ alloc[ac87]::string::{impl#40}) applies)
DEBUG rustc_trait_selection::traits::specialize fulfill_implication: an impl for <Cow<'_, str, std::string::String> as std::string::ToString> specializes <_ as std::string::ToString>
DEBUG rustc_trait_selection::traits::specialize specializes(DefId(5:4335 ~ alloc[ac87]::string::{impl#40}), DefId(0:16 ~ playground[cc5d]::{impl#0}))
DEBUG rustc_trait_selection::traits::specialize fulfill_implication(ParamEnv { caller_bounds: [TraitPredicate(<T as std::fmt::Display>)], reveal: UserFacing }, trait_ref=<T as std::string::ToString> |- DefId(0:16 ~ playground[cc5d]::{impl#0}) applies)
DEBUG rustc_trait_selection::traits::specialize translate_substs(ParamEnv { caller_bounds: [TraitPredicate(<T as std::fmt::Display>)], reveal: UserFacing }, DefId(5:4093 ~ alloc[ac87]::str::{impl#4}), [], Impl(DefId(5:4093 ~ alloc[ac87]::str::{impl#4})))
DEBUG rustc_trait_selection::traits::specialize fulfill_implication: <T as std::string::ToString> does not unify with <Cow<'_, str, std::string::String> as std::string::ToString>
DEBUG rustc_trait_selection::traits::specialize::specialization_graph descending as child of TraitRef <T as std::string::ToString>
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert(impl_def_id=DefId(0:16 ~ playground[cc5d]::{impl#0}), simplified_self=Some(AdtSimplifiedType(DefId(0:6 ~ playground[cc5d]::Cow))))
DEBUG rustc_trait_selection::traits::specialize::specialization_graph placing as new sibling
DEBUG rustc_trait_selection::traits::specialize::specialization_graph insert_blindly: impl_def_id=DefId(0:16 ~ playground[cc5d]::{impl#0}) st=AdtSimplifiedType(DefId(0:6 ~ playground[cc5d]::Cow))
DEBUG rustc_trait_selection::traits::specialize translate_substs(ParamEnv { caller_bounds: [], reveal: UserFacing }, DefId(0:16 ~ playground[cc5d]::{impl#0}), [ReEarlyBound(0, '_)], Impl(DefId(5:4335 ~ alloc[ac87]::string::{impl#40})))
DEBUG rustc_trait_selection::traits::specialize fulfill_implication(ParamEnv { caller_bounds: [], reveal: UserFacing }, trait_ref=<Cow<'_, str> as std::string::ToString> |- DefId(5:4335 ~ alloc[ac87]::string::{impl#40}) applies)
DEBUG rustc_trait_selection::traits::specialize translate_substs(ParamEnv { caller_bounds: [], reveal: UserFacing }, DefId(5:4093 ~ alloc[ac87]::str::{impl#4}), [], Impl(DefId(5:4093 ~ alloc[ac87]::str::{impl#4})))
DEBUG rustc_trait_selection::traits::specialize fulfill_implication: for impls on <Cow<'_, str> as std::string::ToString> and <_ as std::string::ToString>, could not fulfill: [FulfillmentError(Obligation(predicate=ProjectionPredicate(ProjectionTy { substs: [str], item_def_id: DefId(5:397 ~ alloc[ac87]::borrow::ToOwned::Owned) }, <str as std::borrow::ToOwned>::Owned), depth=2),MismatchedProjectionTypes(Sorts(ExpectedFound { expected: std::string::String, found: <str as std::borrow::ToOwned>::Owned })))] given []
error: internal compiler error: compiler/rustc_trait_selection/src/traits/specialize/mod.rs:101:21: When translating substitutions for specialization, the expected specialization failed to hold
thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:958:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I wanted to change
Cowto use the pattern in the code below (which changesCowvariance w.r.t to<B as ToOwned>::Owned),but got an ICE. I managed to reduce it the code below.
Code
The same code with the current definition of
Cowworks (same asstd):Meta
rustc --version --verbose:Error output
Backtrace
log with RUSTC_LOG=rustc_trait_selection::traits::specialize