Skip to content

Commit 1ac7eb8

Browse files
committed
allow maps to be made private or public
Didn't get around to removing all public access.
1 parent d26a7a4 commit 1ac7eb8

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

src/librustc/ty/maps.rs

+38-38
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ impl<'tcx> QueryDescription for queries::describe_def<'tcx> {
274274
macro_rules! define_maps {
275275
(<$tcx:tt>
276276
$($(#[$attr:meta])*
277-
pub $name:ident: $node:ident($K:ty) -> $V:ty),*) => {
277+
[$($pub:tt)*] $name:ident: $node:ident($K:ty) -> $V:ty),*) => {
278278
pub struct Maps<$tcx> {
279279
providers: IndexVec<CrateNum, Providers<$tcx>>,
280280
query_stack: RefCell<Vec<(Span, Query<$tcx>)>>,
281-
$($(#[$attr])* pub $name: RefCell<DepTrackingMap<queries::$name<$tcx>>>),*
281+
$($(#[$attr])* $($pub)* $name: RefCell<DepTrackingMap<queries::$name<$tcx>>>),*
282282
}
283283

284284
impl<$tcx> Maps<$tcx> {
@@ -441,52 +441,52 @@ macro_rules! define_maps {
441441
// the driver creates (using several `rustc_*` crates).
442442
define_maps! { <'tcx>
443443
/// Records the type of every item.
444-
pub type_of: ItemSignature(DefId) -> Ty<'tcx>,
444+
[pub] type_of: ItemSignature(DefId) -> Ty<'tcx>,
445445

446446
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
447447
/// associated generics and predicates.
448-
pub generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
449-
pub predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
448+
[] generics_of: ItemSignature(DefId) -> &'tcx ty::Generics,
449+
[] predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
450450

451451
/// Maps from the def-id of a trait to the list of
452452
/// super-predicates. This is a subset of the full list of
453453
/// predicates. We store these in a separate map because we must
454454
/// evaluate them even during type conversion, often before the
455455
/// full predicates are available (note that supertraits have
456456
/// additional acyclicity requirements).
457-
pub super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
457+
[] super_predicates_of: ItemSignature(DefId) -> ty::GenericPredicates<'tcx>,
458458

459459
/// To avoid cycles within the predicates of a single item we compute
460460
/// per-type-parameter predicates for resolving `T::AssocTy`.
461-
pub type_param_predicates: TypeParamPredicates((DefId, DefId))
461+
[] type_param_predicates: TypeParamPredicates((DefId, DefId))
462462
-> ty::GenericPredicates<'tcx>,
463463

464-
pub trait_def: ItemSignature(DefId) -> &'tcx ty::TraitDef,
465-
pub adt_def: ItemSignature(DefId) -> &'tcx ty::AdtDef,
466-
pub adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
467-
pub adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
468-
pub adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
464+
[] trait_def: ItemSignature(DefId) -> &'tcx ty::TraitDef,
465+
[] adt_def: ItemSignature(DefId) -> &'tcx ty::AdtDef,
466+
[] adt_destructor: AdtDestructor(DefId) -> Option<ty::Destructor>,
467+
[] adt_sized_constraint: SizedConstraint(DefId) -> &'tcx [Ty<'tcx>],
468+
[] adt_dtorck_constraint: DtorckConstraint(DefId) -> ty::DtorckConstraint<'tcx>,
469469

470470
/// True if this is a foreign item (i.e., linked via `extern { ... }`).
471-
pub is_foreign_item: IsForeignItem(DefId) -> bool,
471+
[] is_foreign_item: IsForeignItem(DefId) -> bool,
472472

473473
/// Maps from def-id of a type or region parameter to its
474474
/// (inferred) variance.
475-
pub variances_of: ItemSignature(DefId) -> Rc<Vec<ty::Variance>>,
475+
[pub] variances_of: ItemSignature(DefId) -> Rc<Vec<ty::Variance>>,
476476

477477
/// Maps from an impl/trait def-id to a list of the def-ids of its items
478-
pub associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
478+
[] associated_item_def_ids: AssociatedItemDefIds(DefId) -> Rc<Vec<DefId>>,
479479

480480
/// Maps from a trait item to the trait item "descriptor"
481-
pub associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
481+
[] associated_item: AssociatedItems(DefId) -> ty::AssociatedItem,
482482

483-
pub impl_trait_ref: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
484-
pub impl_polarity: ItemSignature(DefId) -> hir::ImplPolarity,
483+
[pub] impl_trait_ref: ItemSignature(DefId) -> Option<ty::TraitRef<'tcx>>,
484+
[] impl_polarity: ItemSignature(DefId) -> hir::ImplPolarity,
485485

486486
/// Maps a DefId of a type to a list of its inherent impls.
487487
/// Contains implementations of methods that are inherent to a type.
488488
/// Methods in these implementations don't need to be exported.
489-
pub inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
489+
[] inherent_impls: InherentImpls(DefId) -> Rc<Vec<DefId>>,
490490

491491
/// Maps from the def-id of a function/method or const/static
492492
/// to its MIR. Mutation is done at an item granularity to
@@ -495,59 +495,59 @@ define_maps! { <'tcx>
495495
///
496496
/// Note that cross-crate MIR appears to be always borrowed
497497
/// (in the `RefCell` sense) to prevent accidental mutation.
498-
pub mir: Mir(DefId) -> &'tcx RefCell<mir::Mir<'tcx>>,
498+
[pub] mir: Mir(DefId) -> &'tcx RefCell<mir::Mir<'tcx>>,
499499

500500
/// Maps DefId's that have an associated Mir to the result
501501
/// of the MIR qualify_consts pass. The actual meaning of
502502
/// the value isn't known except to the pass itself.
503-
pub mir_const_qualif: Mir(DefId) -> u8,
503+
[] mir_const_qualif: Mir(DefId) -> u8,
504504

505505
/// Records the type of each closure. The def ID is the ID of the
506506
/// expression defining the closure.
507-
pub closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
507+
[] closure_kind: ItemSignature(DefId) -> ty::ClosureKind,
508508

509509
/// Records the type of each closure. The def ID is the ID of the
510510
/// expression defining the closure.
511-
pub closure_type: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
511+
[] closure_type: ItemSignature(DefId) -> ty::PolyFnSig<'tcx>,
512512

513513
/// Caches CoerceUnsized kinds for impls on custom types.
514-
pub coerce_unsized_info: ItemSignature(DefId)
514+
[] coerce_unsized_info: ItemSignature(DefId)
515515
-> ty::adjustment::CoerceUnsizedInfo,
516516

517-
pub typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
517+
[] typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
518518

519-
pub typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
519+
[] typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
520520

521-
pub coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
521+
[] coherent_trait: coherent_trait_dep_node((CrateNum, DefId)) -> (),
522522

523-
pub borrowck: BorrowCheck(DefId) -> (),
523+
[] borrowck: BorrowCheck(DefId) -> (),
524524

525525
/// Gets a complete map from all types to their inherent impls.
526526
/// Not meant to be used directly outside of coherence.
527527
/// (Defined only for LOCAL_CRATE)
528-
pub crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
528+
[] crate_inherent_impls: crate_inherent_impls_dep_node(CrateNum) -> CrateInherentImpls,
529529

530530
/// Checks all types in the krate for overlap in their inherent impls. Reports errors.
531531
/// Not meant to be used directly outside of coherence.
532532
/// (Defined only for LOCAL_CRATE)
533-
pub crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (),
533+
[] crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (),
534534

535535
/// Results of evaluating const items or constants embedded in
536536
/// other items (such as enum variant explicit discriminants).
537-
pub const_eval: const_eval_dep_node((DefId, &'tcx Substs<'tcx>))
537+
[] const_eval: const_eval_dep_node((DefId, &'tcx Substs<'tcx>))
538538
-> const_val::EvalResult<'tcx>,
539539

540540
/// Performs the privacy check and computes "access levels".
541-
pub privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
541+
[] privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Rc<AccessLevels>,
542542

543-
pub reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
543+
[] reachable_set: reachability_dep_node(CrateNum) -> Rc<NodeSet>,
544544

545-
pub mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx RefCell<mir::Mir<'tcx>>,
545+
[] mir_shims: mir_shim_dep_node(ty::InstanceDef<'tcx>) -> &'tcx RefCell<mir::Mir<'tcx>>,
546546

547-
pub def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
548-
pub symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
547+
[] def_symbol_name: SymbolName(DefId) -> ty::SymbolName,
548+
[] symbol_name: symbol_name_dep_node(ty::Instance<'tcx>) -> ty::SymbolName,
549549

550-
pub describe_def: meta_data_node(DefId) -> Option<Def>
550+
[] describe_def: meta_data_node(DefId) -> Option<Def>
551551
}
552552

553553
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
@@ -582,4 +582,4 @@ fn const_eval_dep_node((def_id, _): (DefId, &Substs)) -> DepNode<DefId> {
582582

583583
fn meta_data_node(def_id: DefId) -> DepNode<DefId> {
584584
DepNode::MetaData(def_id)
585-
}
585+
}

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
21462146
_ => false,
21472147
}
21482148
} else {
2149-
match self.sess.cstore.describe_def(def_id).expect("no def for def-id") {
2149+
match self.describe_def(def_id).expect("no def for def-id") {
21502150
Def::AssociatedConst(_) | Def::Method(_) | Def::AssociatedTy(_) => true,
21512151
_ => false,
21522152
}

0 commit comments

Comments
 (0)