Address review comments
- Add back `HirIdVec`, with a comment that it will soon be used. - Add back `*_region` functions, with a comment they may soon be used. - Remove `-Z borrowck_stats` completely. It didn't do anything. - Remove `make_nop` completely. - Add back `current_loc`, which is used by an out-of-tree tool. - Fix style nits - Remove `AtomicCell` with `cfg(parallel_compiler)` for consistency.
This commit is contained in:
parent
441dc3640a
commit
de0fda9558
10 changed files with 154 additions and 18 deletions
|
@ -703,6 +703,74 @@ pub mod coverageinfo {
|
|||
kind: RegionKind::CodeRegion,
|
||||
}
|
||||
}
|
||||
|
||||
// This function might be used in the future; the LLVM API is still evolving, as is coverage
|
||||
// support.
|
||||
#[allow(dead_code)]
|
||||
crate fn expansion_region(
|
||||
file_id: u32,
|
||||
expanded_file_id: u32,
|
||||
start_line: u32,
|
||||
start_col: u32,
|
||||
end_line: u32,
|
||||
end_col: u32,
|
||||
) -> Self {
|
||||
Self {
|
||||
counter: coverage_map::Counter::zero(),
|
||||
file_id,
|
||||
expanded_file_id,
|
||||
start_line,
|
||||
start_col,
|
||||
end_line,
|
||||
end_col,
|
||||
kind: RegionKind::ExpansionRegion,
|
||||
}
|
||||
}
|
||||
|
||||
// This function might be used in the future; the LLVM API is still evolving, as is coverage
|
||||
// support.
|
||||
#[allow(dead_code)]
|
||||
crate fn skipped_region(
|
||||
file_id: u32,
|
||||
start_line: u32,
|
||||
start_col: u32,
|
||||
end_line: u32,
|
||||
end_col: u32,
|
||||
) -> Self {
|
||||
Self {
|
||||
counter: coverage_map::Counter::zero(),
|
||||
file_id,
|
||||
expanded_file_id: 0,
|
||||
start_line,
|
||||
start_col,
|
||||
end_line,
|
||||
end_col,
|
||||
kind: RegionKind::SkippedRegion,
|
||||
}
|
||||
}
|
||||
|
||||
// This function might be used in the future; the LLVM API is still evolving, as is coverage
|
||||
// support.
|
||||
#[allow(dead_code)]
|
||||
crate fn gap_region(
|
||||
counter: coverage_map::Counter,
|
||||
file_id: u32,
|
||||
start_line: u32,
|
||||
start_col: u32,
|
||||
end_line: u32,
|
||||
end_col: u32,
|
||||
) -> Self {
|
||||
Self {
|
||||
counter,
|
||||
file_id,
|
||||
expanded_file_id: 0,
|
||||
start_line,
|
||||
start_col,
|
||||
end_line,
|
||||
end_col: ((1 as u32) << 31) | end_col,
|
||||
kind: RegionKind::GapRegion,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -236,8 +236,6 @@ cfg_if! {
|
|||
|
||||
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};
|
||||
|
||||
pub use crossbeam_utils::atomic::AtomicCell;
|
||||
|
||||
pub use std::sync::Arc as Lrc;
|
||||
pub use std::sync::Weak as Weak;
|
||||
|
||||
|
|
|
@ -157,8 +157,7 @@ impl<'a, 'b> RunCompiler<'a, 'b> {
|
|||
self
|
||||
}
|
||||
/// Used by RLS.
|
||||
pub fn set_emitter(&mut self, emitter: Option<Box<dyn Write + Send>>) -> &mut Self
|
||||
{
|
||||
pub fn set_emitter(&mut self, emitter: Option<Box<dyn Write + Send>>) -> &mut Self {
|
||||
self.emitter = emitter;
|
||||
self
|
||||
}
|
||||
|
|
|
@ -2206,7 +2206,7 @@ impl PrimTy {
|
|||
Self::Str,
|
||||
];
|
||||
|
||||
/// [`PrimTy::name`], but returns a &str instead of a symbol.
|
||||
/// Like [`PrimTy::name`], but returns a &str instead of a symbol.
|
||||
///
|
||||
/// Used by rustdoc.
|
||||
pub fn name_str(self) -> &'static str {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use crate::def_id::{LocalDefId, CRATE_DEF_INDEX};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use std::fmt;
|
||||
|
||||
/// Uniquely identifies a node in the HIR of the current crate. It is
|
||||
|
@ -61,3 +62,70 @@ pub const CRATE_HIR_ID: HirId = HirId {
|
|||
owner: LocalDefId { local_def_index: CRATE_DEF_INDEX },
|
||||
local_id: ItemLocalId::from_u32(0),
|
||||
};
|
||||
|
||||
/// N.B. This collection is currently unused, but will be used by #72015 and future PRs.
|
||||
#[derive(Clone, Default, Debug, Encodable, Decodable)]
|
||||
pub struct HirIdVec<T> {
|
||||
map: IndexVec<LocalDefId, IndexVec<ItemLocalId, T>>,
|
||||
}
|
||||
|
||||
impl<T> HirIdVec<T> {
|
||||
pub fn push_owner(&mut self, id: LocalDefId) {
|
||||
self.map.ensure_contains_elem(id, IndexVec::new);
|
||||
}
|
||||
|
||||
pub fn push(&mut self, id: HirId, value: T) {
|
||||
if id.local_id == ItemLocalId::from_u32(0) {
|
||||
self.push_owner(id.owner);
|
||||
}
|
||||
let submap = &mut self.map[id.owner];
|
||||
let _ret_id = submap.push(value);
|
||||
debug_assert_eq!(_ret_id, id.local_id);
|
||||
}
|
||||
|
||||
pub fn push_sparse(&mut self, id: HirId, value: T)
|
||||
where
|
||||
T: Default,
|
||||
{
|
||||
self.map.ensure_contains_elem(id.owner, IndexVec::new);
|
||||
let submap = &mut self.map[id.owner];
|
||||
let i = id.local_id.index();
|
||||
let len = submap.len();
|
||||
if i >= len {
|
||||
submap.extend(std::iter::repeat_with(T::default).take(i - len + 1));
|
||||
}
|
||||
submap[id.local_id] = value;
|
||||
}
|
||||
|
||||
pub fn get(&self, id: HirId) -> Option<&T> {
|
||||
self.map.get(id.owner)?.get(id.local_id)
|
||||
}
|
||||
|
||||
pub fn get_owner(&self, id: LocalDefId) -> &IndexVec<ItemLocalId, T> {
|
||||
&self.map[id]
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &T> {
|
||||
self.map.iter().flat_map(|la| la.iter())
|
||||
}
|
||||
|
||||
pub fn iter_enumerated(&self) -> impl Iterator<Item = (HirId, &T)> {
|
||||
self.map.iter_enumerated().flat_map(|(owner, la)| {
|
||||
la.iter_enumerated().map(move |(local_id, attr)| (HirId { owner, local_id }, attr))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::ops::Index<HirId> for HirIdVec<T> {
|
||||
type Output = T;
|
||||
|
||||
fn index(&self, id: HirId) -> &T {
|
||||
&self.map[id.owner][id.local_id]
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> std::ops::IndexMut<HirId> for HirIdVec<T> {
|
||||
fn index_mut(&mut self, id: HirId) -> &mut T {
|
||||
&mut self.map[id.owner][id.local_id]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ impl<'tcx> TypeVariableValue<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) struct Instantiate {}
|
||||
pub(crate) struct Instantiate;
|
||||
|
||||
pub(crate) struct Delegate;
|
||||
|
||||
|
@ -222,7 +222,7 @@ impl<'tcx> TypeVariableTable<'_, 'tcx> {
|
|||
// Hack: we only need this so that `types_escaping_snapshot`
|
||||
// can see what has been unified; see the Delegate impl for
|
||||
// more details.
|
||||
self.undo_log.push(Instantiate {});
|
||||
self.undo_log.push(Instantiate);
|
||||
}
|
||||
|
||||
/// Creates a new type variable.
|
||||
|
|
|
@ -471,7 +471,6 @@ fn test_debugging_options_tracking_hash() {
|
|||
untracked!(ast_json, true);
|
||||
untracked!(ast_json_noexpand, true);
|
||||
untracked!(borrowck, String::from("other"));
|
||||
untracked!(borrowck_stats, true);
|
||||
untracked!(deduplicate_diagnostics, true);
|
||||
untracked!(dep_tasks, true);
|
||||
untracked!(dont_buffer_diagnostics, true);
|
||||
|
|
|
@ -226,6 +226,18 @@ impl<'mir, 'tcx, Tag> Frame<'mir, 'tcx, Tag> {
|
|||
}
|
||||
|
||||
impl<'mir, 'tcx, Tag, Extra> Frame<'mir, 'tcx, Tag, Extra> {
|
||||
/// Get the current location within the Frame.
|
||||
///
|
||||
/// If this is `Err`, we are not currently executing any particular statement in
|
||||
/// this frame (can happen e.g. during frame initialization, and during unwinding on
|
||||
/// frames without cleanup code).
|
||||
/// We basically abuse `Result` as `Either`.
|
||||
///
|
||||
/// Used by priroda.
|
||||
pub fn current_loc(&self) -> Result<mir::Location, Span> {
|
||||
self.loc
|
||||
}
|
||||
|
||||
/// Return the `SourceInfo` of the current instruction.
|
||||
pub fn current_source_info(&self) -> Option<&mir::SourceInfo> {
|
||||
self.loc.ok().map(|loc| self.body.source_info(loc))
|
||||
|
|
|
@ -13,7 +13,6 @@ pub struct MirPatch<'tcx> {
|
|||
new_locals: Vec<LocalDecl<'tcx>>,
|
||||
resume_block: BasicBlock,
|
||||
next_local: usize,
|
||||
make_nop: Vec<Location>,
|
||||
}
|
||||
|
||||
impl<'tcx> MirPatch<'tcx> {
|
||||
|
@ -25,7 +24,6 @@ impl<'tcx> MirPatch<'tcx> {
|
|||
new_locals: vec![],
|
||||
next_local: body.local_decls.len(),
|
||||
resume_block: START_BLOCK,
|
||||
make_nop: vec![],
|
||||
};
|
||||
|
||||
// make sure the MIR we create has a resume block. It is
|
||||
|
@ -118,10 +116,6 @@ impl<'tcx> MirPatch<'tcx> {
|
|||
}
|
||||
|
||||
pub fn apply(self, body: &mut Body<'tcx>) {
|
||||
debug!("MirPatch: make nops at: {:?}", self.make_nop);
|
||||
for loc in self.make_nop {
|
||||
body.make_statement_nop(loc);
|
||||
}
|
||||
debug!(
|
||||
"MirPatch: {:?} new temps, starting from index {}: {:?}",
|
||||
self.new_locals.len(),
|
||||
|
|
|
@ -906,8 +906,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||
(default: no)"),
|
||||
borrowck: String = ("migrate".to_string(), parse_string, [UNTRACKED],
|
||||
"select which borrowck is used (`mir` or `migrate`) (default: `migrate`)"),
|
||||
borrowck_stats: bool = (false, parse_bool, [UNTRACKED],
|
||||
"gather borrowck statistics (default: no)"),
|
||||
cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||
"the codegen unit partitioning strategy to use"),
|
||||
chalk: bool = (false, parse_bool, [TRACKED],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue