Rollup merge of #104239 - b-naber:sccs-info, r=jackh726
Better debug logs for borrowck constraint graph It's really cumbersome to work with `RegionVar`s when trying to debug borrowck code or when trying to understand how the borrowchecker works. This PR collects some region information (behind `cfg(debug_assertions)`) for created `RegionVar`s (NLL region vars, this PR doesn't touch canonicalization) and prints the nodes and edges of the strongly connected constraints graph using representatives that use that region information (either lifetime names, locations in MIR or spans).
This commit is contained in:
commit
314fe4d170
15 changed files with 438 additions and 68 deletions
|
@ -27,7 +27,7 @@ use rustc_middle::ty::fold::TypeFoldable;
|
|||
use rustc_middle::ty::relate::TypeRelation;
|
||||
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
|
||||
use rustc_middle::ty::{self, BoundVar, ToPredicate, Ty, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use std::fmt::Debug;
|
||||
use std::iter;
|
||||
|
||||
|
@ -683,7 +683,11 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
|
|||
self.infcx.create_next_universe()
|
||||
}
|
||||
|
||||
fn next_existential_region_var(&mut self, from_forall: bool) -> ty::Region<'tcx> {
|
||||
fn next_existential_region_var(
|
||||
&mut self,
|
||||
from_forall: bool,
|
||||
_name: Option<Symbol>,
|
||||
) -> ty::Region<'tcx> {
|
||||
let origin = NllRegionVariableOrigin::Existential { from_forall };
|
||||
self.infcx.next_nll_region_var(origin)
|
||||
}
|
||||
|
|
|
@ -1111,11 +1111,13 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}
|
||||
|
||||
/// Just a convenient wrapper of `next_region_var` for using during NLL.
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
pub fn next_nll_region_var(&self, origin: NllRegionVariableOrigin) -> ty::Region<'tcx> {
|
||||
self.next_region_var(RegionVariableOrigin::Nll(origin))
|
||||
}
|
||||
|
||||
/// Just a convenient wrapper of `next_region_var` for using during NLL.
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
pub fn next_nll_region_var_in_universe(
|
||||
&self,
|
||||
origin: NllRegionVariableOrigin,
|
||||
|
|
|
@ -31,7 +31,7 @@ use rustc_middle::ty::error::TypeError;
|
|||
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
|
||||
use rustc_middle::ty::visit::{ir::TypeVisitor, TypeSuperVisitable, TypeVisitable};
|
||||
use rustc_middle::ty::{self, InferConst, Ty, TyCtxt};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use std::fmt::Debug;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
|
@ -100,7 +100,11 @@ pub trait TypeRelatingDelegate<'tcx> {
|
|||
/// we will invoke this method to instantiate `'a` with an
|
||||
/// inference variable (though `'b` would be instantiated first,
|
||||
/// as a placeholder).
|
||||
fn next_existential_region_var(&mut self, was_placeholder: bool) -> ty::Region<'tcx>;
|
||||
fn next_existential_region_var(
|
||||
&mut self,
|
||||
was_placeholder: bool,
|
||||
name: Option<Symbol>,
|
||||
) -> ty::Region<'tcx>;
|
||||
|
||||
/// Creates a new region variable representing a
|
||||
/// higher-ranked region that is instantiated universally.
|
||||
|
@ -188,7 +192,7 @@ where
|
|||
let placeholder = ty::PlaceholderRegion { universe, name: br.kind };
|
||||
delegate.next_placeholder_region(placeholder)
|
||||
} else {
|
||||
delegate.next_existential_region_var(true)
|
||||
delegate.next_existential_region_var(true, br.kind.get_name())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue