提交 497a3b4f 编写于 作者: E Eh2406

fix typo and tidy

上级 e2c0378a
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
use rustc_data_structures::fx::FxHashSet;
use rustc::ty::RegionVid;
......@@ -14,7 +24,10 @@
impl ConstraintSet {
pub fn push(&mut self, outlives_constraint: OutlivesConstraint) {
debug!("add_outlives({:?}: {:?} @ {:?}", outlives_constraint.sup, outlives_constraint.sub, outlives_constraint.point);
debug!("add_outlives({:?}: {:?} @ {:?}",
outlives_constraint.sup,
outlives_constraint.sub,
outlives_constraint.point);
if outlives_constraint.sup == outlives_constraint.sub {
// 'a: 'a is pretty uninteresting
return;
......@@ -24,12 +37,14 @@ pub fn push(&mut self, outlives_constraint: OutlivesConstraint) {
}
}
pub fn iner(&self) -> &IndexVec<ConstraintIndex, OutlivesConstraint> {
pub fn inner(&self) -> &IndexVec<ConstraintIndex, OutlivesConstraint> {
&self.constraints
}
/// Do Not use this to add nor remove items to the Vec, nor change the `sup`, nor `sub` of the data.
pub fn iner_mut(&mut self) -> &mut IndexVec<ConstraintIndex, OutlivesConstraint> {
/// Do Not use this to add nor remove items to the Vec,
/// nor change the `sup`,
/// nor `sub` of the data.
pub fn inner_mut(&mut self) -> &mut IndexVec<ConstraintIndex, OutlivesConstraint> {
&mut self.constraints
}
}
......
......@@ -76,7 +76,7 @@ fn for_each_constraint(
}
}
let mut constraints: Vec<_> = self.constraints.iner().iter().collect();
let mut constraints: Vec<_> = self.constraints.inner().iter().collect();
constraints.sort();
for constraint in &constraints {
let OutlivesConstraint {
......
......@@ -57,7 +57,7 @@ fn nodes(&'this self) -> dot::Nodes<'this, RegionVid> {
vids.into_cow()
}
fn edges(&'this self) -> dot::Edges<'this, OutlivesConstraint> {
(&self.constraints.iner().raw[..]).into_cow()
(&self.constraints.inner().raw[..]).into_cow()
}
// Render `a: b` as `a <- b`, indicating the flow
......
......@@ -216,7 +216,7 @@ pub(crate) fn new(
type_tests: Vec<TypeTest<'tcx>>,
) -> Self {
// The `next` field should not yet have been initialized:
debug_assert!(outlives_constraints.iner().iter().all(|c| c.next.is_none()));
debug_assert!(outlives_constraints.inner().iter().all(|c| c.next.is_none()));
let num_region_variables = var_infos.len();
let num_universal_regions = universal_regions.len();
......@@ -438,7 +438,7 @@ fn propagate_constraints(&mut self, mir: &Mir<'tcx>) {
fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
debug!("compute_region_values()");
debug!("compute_region_values: constraints={:#?}", {
let mut constraints: Vec<_> = self.constraints.iner().iter().collect();
let mut constraints: Vec<_> = self.constraints.inner().iter().collect();
constraints.sort();
constraints
});
......@@ -450,7 +450,7 @@ fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
let dependency_map = self.dependency_map.as_ref().unwrap();
// Constraints that may need to be repropagated (initially all):
let mut dirty_list: Vec<_> = self.constraints.iner().indices().collect();
let mut dirty_list: Vec<_> = self.constraints.inner().indices().collect();
// Set to 0 for each constraint that is on the dirty list:
let mut clean_bit_vec = BitVector::new(dirty_list.len());
......@@ -459,7 +459,7 @@ fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
while let Some(constraint_idx) = dirty_list.pop() {
clean_bit_vec.insert(constraint_idx.index());
let constraint = &self.constraints.iner()[constraint_idx];
let constraint = &self.constraints.inner()[constraint_idx];
debug!("propagate_constraints: constraint={:?}", constraint);
if inferred_values.add_region(constraint.sup, constraint.sub) {
......@@ -471,7 +471,7 @@ fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
if clean_bit_vec.remove(dep_idx.index()) {
dirty_list.push(dep_idx);
}
opt_dep_idx = self.constraints.iner()[dep_idx].next;
opt_dep_idx = self.constraints.inner()[dep_idx].next;
}
}
......@@ -488,7 +488,7 @@ fn compute_region_values(&self, _mir: &Mir<'tcx>) -> RegionValues {
fn build_dependency_map(&mut self) -> IndexVec<RegionVid, Option<ConstraintIndex>> {
let mut map = IndexVec::from_elem(None, &self.definitions);
for (idx, constraint) in self.constraints.iner_mut().iter_enumerated_mut().rev() {
for (idx, constraint) in self.constraints.inner_mut().iter_enumerated_mut().rev() {
let mut head = &mut map[constraint.sub];
debug_assert!(constraint.next.is_none());
constraint.next = *head;
......@@ -936,7 +936,7 @@ fn check_universal_region<'gcx>(
);
let blame_index = self.blame_constraint(longer_fr, shorter_fr);
let blame_span = self.constraints.iner()[blame_index].span;
let blame_span = self.constraints.inner()[blame_index].span;
if let Some(propagated_outlives_requirements) = propagated_outlives_requirements {
// Shrink `fr` until we find a non-local region (if we do).
......@@ -1027,7 +1027,7 @@ fn report_error(
// - `fr1: X` transitively
// - and `Y` is live at `elem`
let index = self.blame_constraint(fr1, elem);
let region_sub = self.constraints.iner()[index].sub;
let region_sub = self.constraints.inner()[index].sub;
// then return why `Y` was live at `elem`
self.liveness_constraints.cause(region_sub, elem)
......@@ -1048,7 +1048,7 @@ fn blame_constraint(&self, fr1: RegionVid, elem: impl ToElementIndex) -> Constra
// of dependencies, which doesn't account for the locations of
// contraints at all. But it will do for now.
let relevant_constraint = self.constraints
.iner()
.inner()
.iter_enumerated()
.filter_map(|(i, constraint)| {
if !self.liveness_constraints.contains(constraint.sub, elem) {
......@@ -1084,7 +1084,7 @@ fn dependencies(&self, r0: RegionVid) -> IndexVec<RegionVid, Option<usize>> {
while changed {
changed = false;
for constraint in self.constraints.iner() {
for constraint in self.constraints.inner() {
if let Some(n) = result_set[constraint.sup] {
let m = n + 1;
if result_set[constraint.sub]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册