Use a struct instead of a tuple
This commit is contained in:
parent
916951efcc
commit
90a43f1406
@ -1326,7 +1326,7 @@ fn suggest_impl_trait<'tcx>(
|
||||
fn impl_trait_header(
|
||||
tcx: TyCtxt<'_>,
|
||||
def_id: LocalDefId,
|
||||
) -> Option<(ty::EarlyBinder<ty::TraitRef<'_>>, ty::ImplPolarity)> {
|
||||
) -> Option<ty::EarlyBinder<ty::ImplTraitHeader<'_>>> {
|
||||
let icx = ItemCtxt::new(tcx, def_id);
|
||||
let item = tcx.hir().expect_item(def_id);
|
||||
let impl_ = item.expect_impl();
|
||||
@ -1336,7 +1336,7 @@ fn impl_trait_header(
|
||||
.map(|ast_trait_ref| {
|
||||
let selfty = tcx.type_of(def_id).instantiate_identity();
|
||||
|
||||
let impl_trait_ref = if let Some(ErrorGuaranteed { .. }) = check_impl_constness(
|
||||
let trait_ref = if let Some(ErrorGuaranteed { .. }) = check_impl_constness(
|
||||
tcx,
|
||||
tcx.is_const_trait_impl_raw(def_id.to_def_id()),
|
||||
ast_trait_ref,
|
||||
@ -1362,7 +1362,10 @@ fn impl_trait_header(
|
||||
} else {
|
||||
icx.astconv().instantiate_mono_trait_ref(ast_trait_ref, selfty)
|
||||
};
|
||||
(ty::EarlyBinder::bind(impl_trait_ref), polarity_of_impl(tcx, def_id, impl_, item.span))
|
||||
ty::EarlyBinder::bind(ty::ImplTraitHeader {
|
||||
trait_ref,
|
||||
polarity: polarity_of_impl(tcx, def_id, impl_, item.span)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1973,7 +1973,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
|
||||
if of_trait && let Some(header) = tcx.impl_trait_header(def_id) {
|
||||
record!(self.tables.impl_trait_header[def_id] <- header);
|
||||
let (trait_ref, _polarity) = header;
|
||||
let trait_ref = header.map_bound(|h| h.trait_ref);
|
||||
|
||||
let trait_ref = trait_ref.instantiate_identity();
|
||||
let simplified_self_ty = fast_reject::simplify_type(
|
||||
|
@ -423,7 +423,7 @@ define_tables! {
|
||||
variances_of: Table<DefIndex, LazyArray<ty::Variance>>,
|
||||
fn_sig: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::PolyFnSig<'static>>>>,
|
||||
codegen_fn_attrs: Table<DefIndex, LazyValue<CodegenFnAttrs>>,
|
||||
impl_trait_header: Table<DefIndex, LazyValue<(ty::EarlyBinder<ty::TraitRef<'static>>, ty::ImplPolarity)>>,
|
||||
impl_trait_header: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::ImplTraitHeader<'static>>>>,
|
||||
const_param_default: Table<DefIndex, LazyValue<ty::EarlyBinder<rustc_middle::ty::Const<'static>>>>,
|
||||
object_lifetime_default: Table<DefIndex, LazyValue<ObjectLifetimeDefault>>,
|
||||
optimized_mir: Table<DefIndex, LazyValue<mir::Body<'static>>>,
|
||||
|
@ -177,9 +177,8 @@ impl EraseType for Option<mir::DestructuredConstant<'_>> {
|
||||
type Result = [u8; size_of::<Option<mir::DestructuredConstant<'static>>>()];
|
||||
}
|
||||
|
||||
impl EraseType for Option<(ty::EarlyBinder<ty::TraitRef<'_>>, ty::ImplPolarity)> {
|
||||
type Result =
|
||||
[u8; size_of::<Option<(ty::EarlyBinder<ty::TraitRef<'static>>, ty::ImplPolarity)>>()];
|
||||
impl EraseType for Option<ty::EarlyBinder<ty::ImplTraitHeader<'_>>> {
|
||||
type Result = [u8; size_of::<Option<ty::EarlyBinder<ty::ImplTraitHeader<'static>>>>()];
|
||||
}
|
||||
|
||||
impl EraseType for Option<ty::EarlyBinder<Ty<'_>>> {
|
||||
|
@ -848,7 +848,7 @@ rustc_queries! {
|
||||
|
||||
/// Given an `impl_id`, return the trait it implements along with some header information.
|
||||
/// Return `None` if this is an inherent impl.
|
||||
query impl_trait_header(impl_id: DefId) -> Option<(ty::EarlyBinder<ty::TraitRef<'tcx>>, ty::ImplPolarity)> {
|
||||
query impl_trait_header(impl_id: DefId) -> Option<ty::EarlyBinder<ty::ImplTraitHeader<'tcx>>> {
|
||||
desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
|
||||
cache_on_disk_if { impl_id.is_local() }
|
||||
separate_provide_extern
|
||||
|
@ -2315,7 +2315,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
self,
|
||||
def_id: impl IntoQueryParam<DefId>,
|
||||
) -> Option<ty::EarlyBinder<ty::TraitRef<'tcx>>> {
|
||||
Some(self.impl_trait_header(def_id)?.0)
|
||||
Some(self.impl_trait_header(def_id)?.map_bound(|h| h.trait_ref))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,6 +248,12 @@ pub struct ImplHeader<'tcx> {
|
||||
pub predicates: Vec<Predicate<'tcx>>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable, TyEncodable, TyDecodable, HashStable)]
|
||||
pub struct ImplTraitHeader<'tcx> {
|
||||
pub trait_ref: ty::TraitRef<'tcx>,
|
||||
pub polarity: ImplPolarity,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, TypeFoldable, TypeVisitable)]
|
||||
pub enum ImplSubject<'tcx> {
|
||||
Trait(TraitRef<'tcx>),
|
||||
|
@ -134,4 +134,5 @@ parameterized_over_tcx! {
|
||||
ty::Predicate,
|
||||
ty::Clause,
|
||||
ty::ClauseKind,
|
||||
ty::ImplTraitHeader
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user