//! and use that to decide when one free region outlives another, and so forth.
use rustc_data_structures::transitive_relation::TransitiveRelation;
-use rustc_hir::def_id::DefId;
-use rustc_middle::ty::{self, Lift, Region, TyCtxt};
+use rustc_middle::ty::{Lift, Region, TyCtxt};
/// Combines a `FreeRegionMap` and a `TyCtxt`.
///
pub(crate) struct RegionRelations<'a, 'tcx> {
pub tcx: TyCtxt<'tcx>,
- /// The context used for debug messages
- pub context: DefId,
-
/// Free-region relationships.
pub free_regions: &'a FreeRegionMap<'tcx>,
}
impl<'a, 'tcx> RegionRelations<'a, 'tcx> {
- pub fn new(tcx: TyCtxt<'tcx>, context: DefId, free_regions: &'a FreeRegionMap<'tcx>) -> Self {
- Self { tcx, context, free_regions }
+ pub fn new(tcx: TyCtxt<'tcx>, free_regions: &'a FreeRegionMap<'tcx>) -> Self {
+ Self { tcx, free_regions }
}
pub fn lub_free_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
// (with the exception that `'static: 'x` is not notable)
pub fn relate_regions(&mut self, sub: Region<'tcx>, sup: Region<'tcx>) {
debug!("relate_regions(sub={:?}, sup={:?})", sub, sup);
- if self.is_free_or_static(sub) && self.is_free(sup) {
+ if sub.is_free_or_static() && sup.is_free() {
self.relation.add(sub, sup)
}
}
r_a: Region<'tcx>,
r_b: Region<'tcx>,
) -> bool {
- assert!(self.is_free_or_static(r_a) && self.is_free_or_static(r_b));
+ assert!(r_a.is_free_or_static() && r_b.is_free_or_static());
let re_static = tcx.lifetimes.re_static;
if self.check_relation(re_static, r_b) {
// `'a <= 'static` is always true, and not stored in the
r_a == r_b || self.relation.contains(r_a, r_b)
}
- /// True for free regions other than `'static`.
- pub fn is_free(&self, r: Region<'_>) -> bool {
- matches!(*r, ty::ReEarlyBound(_) | ty::ReFree(_))
- }
-
- /// True if `r` is a free region or static of the sort that this
- /// free region map can be used with.
- pub fn is_free_or_static(&self, r: Region<'_>) -> bool {
- match *r {
- ty::ReStatic => true,
- _ => self.is_free(r),
- }
- }
-
/// Computes the least-upper-bound of two free regions. In some
/// cases, this is more conservative than necessary, in order to
/// avoid making arbitrary choices. See
r_b: Region<'tcx>,
) -> Region<'tcx> {
debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
- assert!(self.is_free(r_a));
- assert!(self.is_free(r_b));
+ assert!(r_a.is_free());
+ assert!(r_b.is_free());
let result = if r_a == r_b {
r_a
} else {