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>>;
36 macro_rules! trivially_parameterized_over_tcx {
37 ($($ty:ty),+ $(,)?) => {
39 impl $crate::ty::ParameterizedOverTcx for $ty {
40 #[allow(unused_lifetimes)]
41 type Value<'tcx> = $ty;
47 trivially_parameterized_over_tcx! {
52 crate::metadata::ModChild,
53 crate::middle::codegen_fn_attrs::CodegenFnAttrs,
54 crate::middle::exported_symbols::SymbolExportInfo,
55 crate::middle::resolve_lifetime::ObjectLifetimeDefault,
56 crate::mir::ConstQualifs,
57 ty::AssocItemContainer,
58 ty::DeducedParamAttrs,
63 ty::UnusedGenericParams,
64 ty::Visibility<DefIndex>,
65 ty::adjustment::CoerceUnsizedInfo,
66 ty::fast_reject::SimplifiedType,
69 rustc_attr::ConstStability,
70 rustc_attr::DefaultBodyStability,
71 rustc_attr::Deprecation,
72 rustc_attr::Stability,
74 rustc_hir::Defaultness,
75 rustc_hir::GeneratorKind,
78 rustc_hir::def::DefKind,
79 rustc_hir::def_id::DefIndex,
80 rustc_hir::definitions::DefKey,
81 rustc_index::bit_set::BitSet<u32>,
82 rustc_index::bit_set::FiniteBitSet<u32>,
83 rustc_session::cstore::ForeignModule,
84 rustc_session::cstore::LinkagePreference,
85 rustc_session::cstore::NativeLib,
86 rustc_span::DebuggerVisualizerFile,
90 rustc_span::SourceFile,
93 rustc_span::def_id::DefPathHash,
94 rustc_span::hygiene::SyntaxContextData,
95 rustc_span::symbol::Ident,
96 rustc_type_ir::Variance,
99 // HACK(compiler-errors): This macro rule can only take a fake path,
100 // not a real, due to parsing ambiguity reasons.
102 macro_rules! parameterized_over_tcx {
103 ($($($fake_path:ident)::+),+ $(,)?) => {
105 impl $crate::ty::ParameterizedOverTcx for $($fake_path)::+<'static> {
106 type Value<'tcx> = $($fake_path)::+<'tcx>;
112 parameterized_over_tcx! {
113 crate::middle::exported_symbols::ExportedSymbol,
117 ty::GenericPredicates,
122 ty::GeneratorDiagnosticData,