Skip to content

Commit

Permalink
Update privacy_access_levels
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed May 23, 2019
1 parent 5751fcc commit fb57879
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ macro_rules! arena_types {
[few] stability_index: rustc::middle::stability::Index<'tcx>,
[few] features: syntax::feature_gate::Features,
[few] all_traits: Vec<rustc::hir::def_id::DefId>,
[few] privacy_access_levels: rustc::middle::privacy::AccessLevels,
], $tcx);
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ rustc_queries! {
query check_match(_: DefId) -> () {}

/// Performs part of the privacy check and computes "access levels".
query privacy_access_levels(_: CrateNum) -> Lrc<AccessLevels> {
query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels {
eval_always
desc { "privacy access levels" }
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use rustc::ty::query::Providers;
use rustc::ty::subst::InternalSubsts;
use rustc::util::nodemap::HirIdSet;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
use syntax::ast::Ident;
use syntax::attr;
use syntax::symbol::{kw, sym};
Expand Down Expand Up @@ -1851,7 +1850,7 @@ fn check_mod_privacy<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
fn privacy_access_levels<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
krate: CrateNum,
) -> Lrc<AccessLevels> {
) -> &'tcx AccessLevels {
assert_eq!(krate, LOCAL_CRATE);

// Build up a set of all exported items in the AST. This is a set of all
Expand All @@ -1872,7 +1871,7 @@ fn privacy_access_levels<'tcx>(
}
visitor.update(hir::CRATE_HIR_ID, Some(AccessLevel::Public));

Lrc::new(visitor.access_levels)
tcx.arena.alloc(visitor.access_levels)
}

fn check_private_in_public<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, krate: CrateNum) {
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use rustc::session::config::{CrateType, Input, OutputType};
use rustc::ty::{self, DefIdTree, TyCtxt};
use rustc::{bug, span_bug};
use rustc_codegen_utils::link::{filename_for_metadata, out_filename};
use rustc_data_structures::sync::Lrc;

use std::cell::Cell;
use std::default::Default;
Expand Down Expand Up @@ -1120,7 +1119,7 @@ pub fn process_crate<'l, 'tcx, H: SaveHandler>(
// fallback in case the access levels couldn't have been correctly computed.
let access_levels = match tcx.sess.compile_status() {
Ok(..) => tcx.privacy_access_levels(LOCAL_CRATE),
Err(..) => Lrc::new(AccessLevels::default()),
Err(..) => tcx.arena.alloc(AccessLevels::default()),
};

let save_ctxt = SaveContext {
Expand Down

0 comments on commit fb57879

Please sign in to comment.