diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-02-10 21:46:44 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-02-12 09:43:09 +0000 |
| commit | 90a43f14063c601fa6a3791aac092bfc2e094911 (patch) | |
| tree | e9ad1fe9fa3960c58b4e4d34dca5feed0dd97e84 | |
| parent | 916951efcc51bb7c225a0dba676c34adef620f1d (diff) | |
| download | rust-90a43f14063c601fa6a3791aac092bfc2e094911.tar.gz rust-90a43f14063c601fa6a3791aac092bfc2e094911.zip | |
Use a struct instead of a tuple
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/query/erase.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/parameterized.rs | 1 |
8 files changed, 19 insertions, 10 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 0f0facdca65..67d5064ff02 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -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) + }) }) } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 361c0a3f87e..5630566676b 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -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( diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index f2d4ae11105..88a749da156 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -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>>>, diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index e15a051b33f..6bd73e9b203 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -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<'_>>> { diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 59fb198a3da..2f947f96c26 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -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 diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index c3b69cee9ed..7c91da292cb 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -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)) } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index c9137f374a2..e41368957c7 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -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>), diff --git a/compiler/rustc_middle/src/ty/parameterized.rs b/compiler/rustc_middle/src/ty/parameterized.rs index 47f9d9e61ad..045856dd9cd 100644 --- a/compiler/rustc_middle/src/ty/parameterized.rs +++ b/compiler/rustc_middle/src/ty/parameterized.rs @@ -134,4 +134,5 @@ parameterized_over_tcx! { ty::Predicate, ty::Clause, ty::ClauseKind, + ty::ImplTraitHeader } |
