Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
47256b8
Remove private methods from TyCtxt impl block: rustc::infer::error_re…
cjgillot Jan 5, 2020
811adb5
Remove private methods from TyCtxt impl block: rustc::middle::stability.
cjgillot Jan 5, 2020
c1afe6a
Remove private methods from TyCtxt impl block: rustc::trait::object_s…
cjgillot Jan 5, 2020
0d9f4fb
Remove trivial function.
cjgillot Jan 5, 2020
640cae2
Remove private methods from TyCtxt impl block: rustc::ty::outlives.
cjgillot Jan 5, 2020
7118e33
Remove private methods from TyCtxt impl block: rustc::ty::print::pretty.
cjgillot Jan 5, 2020
d53bf7a
Make rustc::infer::error_reporting::{note_and_explain_free_region, no…
cjgillot Jan 5, 2020
0b1521e
Make rustc::traits::error_reporting::{recursive_type_with_infinite_si…
cjgillot Jan 5, 2020
7770bce
Make rustc::traits::object_safety::{astconv_object_safety_violations,…
cjgillot Jan 5, 2020
a80bff8
Move normalize_erasing_regions to rustc::ty.
cjgillot Jan 5, 2020
56a0aec
Move subst_and_normalize_erasing_regionsto rustc::ty.
cjgillot Jan 5, 2020
787cd54
Make traits::util::* free functions.
cjgillot Jan 5, 2020
73667af
Move ty::wf to traits.
cjgillot Jan 5, 2020
e905d5d
Move structural_match to rustc::traits.
cjgillot Jan 5, 2020
24d09c7
Move free_region_map to rustc::ty.
cjgillot Jan 5, 2020
86ec4b5
Move required_region_bounds to rustc::infer::opaque_types.
cjgillot Jan 5, 2020
f629baf
Move magic traits queries to rustc::traits::drop.
cjgillot Jan 5, 2020
700ac84
Rename traits::drop -> traits::misc.
cjgillot Jan 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove private methods from TyCtxt impl block: rustc::ty::outlives.
  • Loading branch information
cjgillot committed Jan 7, 2020
commit 640cae257b5c3cbc4b4588e1112b604da1f4c341
50 changes: 23 additions & 27 deletions src/librustc/ty/outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,29 @@ pub enum Component<'tcx> {
impl<'tcx> TyCtxt<'tcx> {
/// Push onto `out` all the things that must outlive `'a` for the condition
/// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
pub fn push_outlives_components(
&self,
ty0: Ty<'tcx>,
out: &mut SmallVec<[Component<'tcx>; 4]>,
) {
self.compute_components(ty0, out);
pub fn push_outlives_components(self, ty0: Ty<'tcx>, out: &mut SmallVec<[Component<'tcx>; 4]>) {
compute_components(self, ty0, out);
debug!("components({:?}) = {:?}", ty0, out);
}
}

fn compute_components(&self, ty: Ty<'tcx>, out: &mut SmallVec<[Component<'tcx>; 4]>) {
// Descend through the types, looking for the various "base"
// components and collecting them into `out`. This is not written
// with `collect()` because of the need to sometimes skip subtrees
// in the `subtys` iterator (e.g., when encountering a
// projection).
match ty.kind {
fn compute_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, out: &mut SmallVec<[Component<'tcx>; 4]>) {
// Descend through the types, looking for the various "base"
// components and collecting them into `out`. This is not written
// with `collect()` because of the need to sometimes skip subtrees
// in the `subtys` iterator (e.g., when encountering a
// projection).
match ty.kind {
ty::Closure(def_id, ref substs) => {
for upvar_ty in substs.as_closure().upvar_tys(def_id, *self) {
self.compute_components(upvar_ty, out);
for upvar_ty in substs.as_closure().upvar_tys(def_id, tcx) {
compute_components(tcx, upvar_ty, out);
}
}

ty::Generator(def_id, ref substs, _) => {
// Same as the closure case
for upvar_ty in substs.as_generator().upvar_tys(def_id, *self) {
self.compute_components(upvar_ty, out);
for upvar_ty in substs.as_generator().upvar_tys(def_id, tcx) {
compute_components(tcx, upvar_ty, out);
}

// We ignore regions in the generator interior as we don't
Expand Down Expand Up @@ -110,7 +107,7 @@ impl<'tcx> TyCtxt<'tcx> {
// fallback case: hard code
// OutlivesProjectionComponents. Continue walking
// through and constrain Pi.
let subcomponents = self.capture_components(ty);
let subcomponents = capture_components(tcx, ty);
out.push(Component::EscapingProjection(subcomponents));
}
}
Expand Down Expand Up @@ -159,20 +156,19 @@ impl<'tcx> TyCtxt<'tcx> {

push_region_constraints(ty, out);
for subty in ty.walk_shallow() {
self.compute_components(subty, out);
compute_components(tcx, subty, out);
}
}
}
}
}

fn capture_components(&self, ty: Ty<'tcx>) -> Vec<Component<'tcx>> {
let mut temp = smallvec![];
push_region_constraints(ty, &mut temp);
for subty in ty.walk_shallow() {
self.compute_components(subty, &mut temp);
}
temp.into_iter().collect()
fn capture_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Vec<Component<'tcx>> {
let mut temp = smallvec![];
push_region_constraints(ty, &mut temp);
for subty in ty.walk_shallow() {
compute_components(tcx, subty, &mut temp);
}
temp.into_iter().collect()
}

fn push_region_constraints<'tcx>(ty: Ty<'tcx>, out: &mut SmallVec<[Component<'tcx>; 4]>) {
Expand Down