1 use rustc_data_structures::fx::FxHashMap;
2 use rustc_hir::def_id::DefIndex;
3 use rustc_index::vec::{Idx, IndexVec};
7 pub trait ParameterizedOverTcx: 'static {
11 impl<T: ParameterizedOverTcx> ParameterizedOverTcx for &'static [T] {
12 type Value<'tcx> = &'tcx [T::Value<'tcx>];
15 impl<T: ParameterizedOverTcx> ParameterizedOverTcx for Option<T> {
16 type Value<'tcx> = Option<T::Value<'tcx>>;
19 impl<A: ParameterizedOverTcx, B: ParameterizedOverTcx> ParameterizedOverTcx for (A, B) {
20 type Value<'tcx> = (A::Value<'tcx>, B::Value<'tcx>);
23 impl<I: Idx + 'static, T: ParameterizedOverTcx> ParameterizedOverTcx for IndexVec<I, T> {
24 type Value<'tcx> = IndexVec<I, T::Value<'tcx>>;
27 impl<I: 'static, T: ParameterizedOverTcx> ParameterizedOverTcx for FxHashMap<I, T> {
28 type Value<'tcx> = FxHashMap<I, T::Value<'tcx>>;
31 impl<T: ParameterizedOverTcx> ParameterizedOverTcx for ty::Binder<'static, T> {
32 type Value<'tcx> = ty::Binder<'tcx, T::Value<'tcx>>;
35 impl<T: ParameterizedOverTcx> ParameterizedOverTcx for ty::EarlyBinder<T> {
36 type Value<'tcx> = ty::EarlyBinder<T::Value<'tcx>>;
40 macro_rules! trivially_parameterized_over_tcx {
41 ($($ty:ty),+ $(,)?) => {
43 impl $crate::ty::ParameterizedOverTcx for $ty {
44 #[allow(unused_lifetimes)]
45 type Value<'tcx> = $ty;
51 trivially_parameterized_over_tcx! {
56 crate::metadata::ModChild,
57 crate::middle::codegen_fn_attrs::CodegenFnAttrs,
58 crate::middle::exported_symbols::SymbolExportInfo,
59 crate::middle::resolve_lifetime::ObjectLifetimeDefault,
60 crate::mir::ConstQualifs,
61 ty::AssocItemContainer,
62 ty::DeducedParamAttrs,
67 ty::UnusedGenericParams,
68 ty::Visibility<DefIndex>,
69 ty::adjustment::CoerceUnsizedInfo,
70 ty::fast_reject::SimplifiedType,
73 rustc_attr::ConstStability,
74 rustc_attr::DefaultBodyStability,
75 rustc_attr::Deprecation,
76 rustc_attr::Stability,
78 rustc_hir::Defaultness,
79 rustc_hir::GeneratorKind,
82 rustc_hir::def::DefKind,
83 rustc_hir::def_id::DefIndex,
84 rustc_hir::definitions::DefKey,
85 rustc_index::bit_set::BitSet<u32>,
86 rustc_index::bit_set::FiniteBitSet<u32>,
87 rustc_session::cstore::ForeignModule,
88 rustc_session::cstore::LinkagePreference,
89 rustc_session::cstore::NativeLib,
90 rustc_span::DebuggerVisualizerFile,
94 rustc_span::SourceFile,
97 rustc_span::def_id::DefPathHash,
98 rustc_span::hygiene::SyntaxContextData,
99 rustc_span::symbol::Ident,
100 rustc_type_ir::Variance,
103 // HACK(compiler-errors): This macro rule can only take a fake path,
104 // not a real, due to parsing ambiguity reasons.
106 macro_rules! parameterized_over_tcx {
107 ($($($fake_path:ident)::+),+ $(,)?) => {
109 impl $crate::ty::ParameterizedOverTcx for $($fake_path)::+<'static> {
110 type Value<'tcx> = $($fake_path)::+<'tcx>;
116 parameterized_over_tcx! {
117 crate::middle::exported_symbols::ExportedSymbol,
121 ty::GenericPredicates,
126 ty::GeneratorDiagnosticData,