Skip to content

Commit da30284

Browse files
committed
add fn to syntax of rustc::ty::maps::define_maps
1 parent 890c87b commit da30284

File tree

1 file changed

+81
-80
lines changed

1 file changed

+81
-80
lines changed

src/librustc/ty/maps.rs

+81-80
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ macro_rules! profq_key {
593593
macro_rules! define_maps {
594594
(<$tcx:tt>
595595
$($(#[$attr:meta])*
596-
[$($modifiers:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
596+
[$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
597597
define_map_struct! {
598598
tcx: $tcx,
599599
input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
@@ -954,191 +954,192 @@ macro_rules! define_provider_struct {
954954
// the driver creates (using several `rustc_*` crates).
955955
define_maps! { <'tcx>
956956
/// Records the type of every item.
957-
[] type_of: TypeOfItem(DefId) -> Ty<'tcx>,
957+
[] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
958958

959959
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
960960
/// associated generics and predicates.
961-
[] generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
962-
[] predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
961+
[] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
962+
[] fn predicates_of: PredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
963963

964964
/// Maps from the def-id of a trait to the list of
965965
/// super-predicates. This is a subset of the full list of
966966
/// predicates. We store these in a separate map because we must
967967
/// evaluate them even during type conversion, often before the
968968
/// full predicates are available (note that supertraits have
969969
/// additional acyclicity requirements).
970-
[] super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
970+
[] fn super_predicates_of: SuperPredicatesOfItem(DefId) -> ty::GenericPredicates<'tcx>,
971971

972972
/// To avoid cycles within the predicates of a single item we compute
973973
/// per-type-parameter predicates for resolving `T::AssocTy`.
974-
[] type_param_predicates: type_param_predicates((DefId, DefId))
974+
[] fn type_param_predicates: type_param_predicates((DefId, DefId))
975975
-> ty::GenericPredicates<'tcx>,
976976

977-
[] trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
978-
[] adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
979-
[] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
980-
[] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
981-
[] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
977+
[] fn trait_def: TraitDefOfItem(DefId) -> &'tcx ty::TraitDef,
978+
[] fn adt_def: AdtDefOfItem(DefId) -> &'tcx ty::AdtDef,
979+
[] fn adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
980+
[] fn adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
981+
[] fn adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
982982

983983
/// True if this is a const fn
984-
[] is_const_fn: IsConstFn(DefId) -> bool,
984+
[] fn is_const_fn: IsConstFn(DefId) -> bool,
985985

986986
/// True if this is a foreign item (i.e., linked via `extern { ... }`).
987-
[] is_foreign_item: IsForeignItem(DefId) -> bool,
987+
[] fn is_foreign_item: IsForeignItem(DefId) -> bool,
988988

989989
/// True if this is a default impl (aka impl Foo for ..)
990-
[] is_default_impl: IsDefaultImpl(DefId) -> bool,
990+
[] fn is_default_impl: IsDefaultImpl(DefId) -> bool,
991991

992992
/// Get a map with the variance of every item; use `item_variance`
993993
/// instead.
994-
[] crate_variances: crate_variances(CrateNum) -> Rc<ty::CrateVariancesMap>,
994+
[] fn crate_variances: crate_variances(CrateNum) -> Rc<ty::CrateVariancesMap>,
995995

996996
/// Maps from def-id of a type or region parameter to its
997997
/// (inferred) variance.
998-
[] variances_of: ItemVariances(DefId) -> Rc<Vec<ty::Variance>>,
998+
[] fn variances_of: ItemVariances(DefId) -> Rc<Vec<ty::Variance>>,
999999

10001000
/// Maps from an impl/trait def-id to a list of the def-ids of its items
1001-
[] associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
1001+
[] fn associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
10021002

10031003
/// Maps from a trait item to the trait item "descriptor"
1004-
[] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
1004+
[] fn associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
10051005

1006-
[] impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
1007-
[] impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
1006+
[] fn impl_trait_ref: ImplTraitRef(DefId) -> Option<ty::TraitRef<'tcx>>,
1007+
[] fn impl_polarity: ImplPolarity(DefId) -> hir::ImplPolarity,
10081008

10091009
/// Maps a DefId of a type to a list of its inherent impls.
10101010
/// Contains implementations of methods that are inherent to a type.
10111011
/// Methods in these implementations don't need to be exported.
1012-
[] inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
1012+
[] fn inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
10131013

10141014
/// Set of all the def-ids in this crate that have MIR associated with
10151015
/// them. This includes all the body owners, but also things like struct
10161016
/// constructors.
1017-
[] mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
1017+
[] fn mir_keys: mir_keys(CrateNum) -> Rc<DefIdSet>,
10181018

10191019
/// Maps DefId's that have an associated Mir to the result
10201020
/// of the MIR qualify_consts pass. The actual meaning of
10211021
/// the value isn't known except to the pass itself.
1022-
[] mir_const_qualif: MirConstQualif(DefId) -> u8,
1022+
[] fn mir_const_qualif: MirConstQualif(DefId) -> u8,
10231023

10241024
/// Fetch the MIR for a given def-id up till the point where it is
10251025
/// ready for const evaluation.
10261026
///
10271027
/// See the README for the `mir` module for details.
1028-
[] mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
1028+
[] fn mir_const: MirConst(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
10291029

1030-
[] mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
1030+
[] fn mir_validated: MirValidated(DefId) -> &'tcx Steal<mir::Mir<'tcx>>,
10311031

10321032
/// MIR after our optimization passes have run. This is MIR that is ready
10331033
/// for trans. This is also the only query that can fetch non-local MIR, at present.
1034-
[] optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
1034+
[] fn optimized_mir: MirOptimized(DefId) -> &'tcx mir::Mir<'tcx>,
10351035

10361036
/// Type of each closure. The def ID is the ID of the
10371037
/// expression defining the closure.
1038-
[] closure_kind: ClosureKind(DefId) -> ty::ClosureKind,
1038+
[] fn closure_kind: ClosureKind(DefId) -> ty::ClosureKind,
10391039

10401040
/// The signature of functions and closures.
1041-
[] fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
1041+
[] fn fn_sig: FnSignature(DefId) -> ty::PolyFnSig<'tcx>,
10421042

10431043
/// Records the signature of each generator. The def ID is the ID of the
10441044
/// expression defining the closure.
1045-
[] generator_sig: GenSignature(DefId) -> Option<ty::PolyGenSig<'tcx>>,
1045+
[] fn generator_sig: GenSignature(DefId) -> Option<ty::PolyGenSig<'tcx>>,
10461046

10471047
/// Caches CoerceUnsized kinds for impls on custom types.
1048-
[] coerce_unsized_info: CoerceUnsizedInfo(DefId)
1048+
[] fn coerce_unsized_info: CoerceUnsizedInfo(DefId)
10491049
-> ty::adjustment::CoerceUnsizedInfo,
10501050

1051-
[] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
1051+
[] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
10521052

1053-
[] typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
1053+
[] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
10541054

1055-
[] has_typeck_tables: HasTypeckTables(DefId) -> bool,
1055+
[] fn has_typeck_tables: HasTypeckTables(DefId) -> bool,
10561056

1057-
[] coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
1057+
[] fn coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
10581058

1059-
[] borrowck: BorrowCheck(DefId) -> (),
1059+
[] fn borrowck: BorrowCheck(DefId) -> (),
10601060
// FIXME: shouldn't this return a `Result<(), BorrowckErrors>` instead?
1061-
[] mir_borrowck: MirBorrowCheck(DefId) -> (),
1061+
[] fn mir_borrowck: MirBorrowCheck(DefId) -> (),
10621062

10631063
/// Gets a complete map from all types to their inherent impls.
10641064
/// Not meant to be used directly outside of coherence.
10651065
/// (Defined only for LOCAL_CRATE)
1066-
[] crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
1066+
[] fn crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
10671067

10681068
/// Checks all types in the krate for overlap in their inherent impls. Reports errors.
10691069
/// Not meant to be used directly outside of coherence.
10701070
/// (Defined only for LOCAL_CRATE)
1071-
[] crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (),
1071+
[] fn crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (),
10721072

10731073
/// Results of evaluating const items or constants embedded in
10741074
/// other items (such as enum variant explicit discriminants).
1075-
[] const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
1075+
[] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>)
10761076
-> const_val::EvalResult<'tcx>,
10771077

10781078
/// Performs the privacy check and computes "access levels".
1079-
[] privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
1079+
[] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
10801080

1081-
[] reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
1081+
[] fn reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
10821082

10831083
/// Per-function `RegionMaps`. The `DefId` should be the owner-def-id for the fn body;
10841084
/// in the case of closures or "inline" expressions, this will be redirected to the enclosing
10851085
/// fn item.
1086-
[] region_maps: RegionMaps(DefId) -> Rc<RegionMaps>,
1087-
1088-
[] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
1089-
1090-
[] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
1091-
[] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
1092-
1093-
[] describe_def: DescribeDef(DefId) -> Option<Def>,
1094-
[] def_span: DefSpan(DefId) -> Span,
1095-
[] stability: Stability(DefId) -> Option<attr::Stability>,
1096-
[] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
1097-
[] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
1098-
[] fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
1099-
[] impl_parent: ImplParent(DefId) -> Option<DefId>,
1100-
[] trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
1101-
[] is_exported_symbol: IsExportedSymbol(DefId) -> bool,
1102-
[] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
1103-
[] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
1104-
[] is_mir_available: IsMirAvailable(DefId) -> bool,
1105-
1106-
[] trait_impls_of: TraitImpls(DefId) -> Rc<ty::trait_def::TraitImpls>,
1107-
[] specialization_graph_of: SpecializationGraph(DefId) -> Rc<specialization_graph::Graph>,
1108-
[] is_object_safe: ObjectSafety(DefId) -> bool,
1086+
[] fn region_maps: RegionMaps(DefId) -> Rc<RegionMaps>,
1087+
1088+
[] fn mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx mir::Mir<'tcx>,
1089+
1090+
[] fn def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
1091+
[] fn symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
1092+
1093+
[] fn describe_def: DescribeDef(DefId) -> Option<Def>,
1094+
[] fn def_span: DefSpan(DefId) -> Span,
1095+
[] fn stability: Stability(DefId) -> Option<attr::Stability>,
1096+
[] fn deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
1097+
[] fn item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
1098+
[] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
1099+
[] fn impl_parent: ImplParent(DefId) -> Option<DefId>,
1100+
[] fn trait_of_item: TraitOfItem(DefId) -> Option<DefId>,
1101+
[] fn is_exported_symbol: IsExportedSymbol(DefId) -> bool,
1102+
[] fn item_body_nested_bodies: ItemBodyNestedBodies(DefId)
1103+
-> Rc<BTreeMap<hir::BodyId, hir::Body>>,
1104+
[] fn const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
1105+
[] fn is_mir_available: IsMirAvailable(DefId) -> bool,
1106+
1107+
[] fn trait_impls_of: TraitImpls(DefId) -> Rc<ty::trait_def::TraitImpls>,
1108+
[] fn specialization_graph_of: SpecializationGraph(DefId) -> Rc<specialization_graph::Graph>,
1109+
[] fn is_object_safe: ObjectSafety(DefId) -> bool,
11091110

11101111
// Get the ParameterEnvironment for a given item; this environment
11111112
// will be in "user-facing" mode, meaning that it is suitabe for
11121113
// type-checking etc, and it does not normalize specializable
11131114
// associated types. This is almost always what you want,
11141115
// unless you are doing MIR optimizations, in which case you
11151116
// might want to use `reveal_all()` method to change modes.
1116-
[] param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
1117+
[] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
11171118

11181119
// Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
11191120
// `ty.is_copy()`, etc, since that will prune the environment where possible.
1120-
[] is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1121-
[] is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1122-
[] is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1123-
[] needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1124-
[] layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
1121+
[] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1122+
[] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1123+
[] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1124+
[] fn needs_drop_raw: needs_drop_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
1125+
[] fn layout_raw: layout_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
11251126
-> Result<&'tcx Layout, LayoutError<'tcx>>,
11261127

1127-
[] dylib_dependency_formats: DylibDepFormats(DefId)
1128+
[] fn dylib_dependency_formats: DylibDepFormats(DefId)
11281129
-> Rc<Vec<(CrateNum, LinkagePreference)>>,
11291130

1130-
[] is_allocator: IsAllocator(DefId) -> bool,
1131-
[] is_panic_runtime: IsPanicRuntime(DefId) -> bool,
1132-
[] is_compiler_builtins: IsCompilerBuiltins(DefId) -> bool,
1133-
[] has_global_allocator: HasGlobalAllocator(DefId) -> bool,
1131+
[] fn is_allocator: IsAllocator(DefId) -> bool,
1132+
[] fn is_panic_runtime: IsPanicRuntime(DefId) -> bool,
1133+
[] fn is_compiler_builtins: IsCompilerBuiltins(DefId) -> bool,
1134+
[] fn has_global_allocator: HasGlobalAllocator(DefId) -> bool,
11341135

1135-
[] extern_crate: ExternCrate(DefId) -> Rc<Option<ExternCrate>>,
1136+
[] fn extern_crate: ExternCrate(DefId) -> Rc<Option<ExternCrate>>,
11361137

1137-
[] lint_levels: lint_levels(CrateNum) -> Rc<lint::LintLevelMap>,
1138+
[] fn lint_levels: lint_levels(CrateNum) -> Rc<lint::LintLevelMap>,
11381139

1139-
[] specializes: specializes_node((DefId, DefId)) -> bool,
1140-
[] in_scope_traits: InScopeTraits(HirId) -> Option<Rc<Vec<TraitCandidate>>>,
1141-
[] module_exports: ModuleExports(HirId) -> Option<Rc<Vec<Export>>>,
1140+
[] fn specializes: specializes_node((DefId, DefId)) -> bool,
1141+
[] fn in_scope_traits: InScopeTraits(HirId) -> Option<Rc<Vec<TraitCandidate>>>,
1142+
[] fn module_exports: ModuleExports(HirId) -> Option<Rc<Vec<Export>>>,
11421143
}
11431144

11441145
fn type_param_predicates<'tcx>((item_id, param_id): (DefId, DefId)) -> DepConstructor<'tcx> {

0 commit comments

Comments
 (0)