Only encode RPITIT when trait method has default body
This commit is contained in:
parent
1463688700
commit
1335da9d48
@ -1036,7 +1036,6 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
|
||||
| DefKind::Static(..)
|
||||
| DefKind::TyAlias
|
||||
| DefKind::OpaqueTy
|
||||
| DefKind::ImplTraitPlaceholder
|
||||
| DefKind::ForeignTy
|
||||
| DefKind::Impl
|
||||
| DefKind::AssocFn
|
||||
@ -1047,6 +1046,19 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
|
||||
| DefKind::AnonConst
|
||||
| DefKind::InlineConst => true,
|
||||
|
||||
DefKind::ImplTraitPlaceholder => {
|
||||
let parent_def_id = tcx.impl_trait_in_trait_parent(def_id.to_def_id());
|
||||
let assoc_item = tcx.associated_item(parent_def_id);
|
||||
match assoc_item.container {
|
||||
// Always encode an RPIT in an impl fn, since it always has a body
|
||||
ty::AssocItemContainer::ImplContainer => true,
|
||||
ty::AssocItemContainer::TraitContainer => {
|
||||
// Encode an RPIT for a trait only if the trait has a default body
|
||||
assoc_item.defaultness(tcx).has_value()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DefKind::AssocTy => {
|
||||
let assoc_item = tcx.associated_item(def_id);
|
||||
match assoc_item.container {
|
||||
|
9
src/test/ui/impl-trait/in-trait/encode.rs
Normal file
9
src/test/ui/impl-trait/in-trait/encode.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// build-pass
|
||||
// compile-flags: --crate-type=lib
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
trait Foo {
|
||||
fn bar() -> impl Sized;
|
||||
}
|
Loading…
Reference in New Issue
Block a user