Make BoundRegion have a kind of BoungRegionKind
This commit is contained in:
parent
6340607aca
commit
328fcee4af
47 changed files with 183 additions and 181 deletions
|
@ -625,7 +625,8 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
|||
r: ty::Region<'tcx>,
|
||||
) -> ty::Region<'tcx> {
|
||||
let var = self.canonical_var(info, r.into());
|
||||
let region = ty::ReLateBound(self.binder_index, ty::BoundRegion::BrAnon(var.as_u32()));
|
||||
let br = ty::BoundRegion { kind: ty::BrAnon(var.as_u32()) };
|
||||
let region = ty::ReLateBound(self.binder_index, br);
|
||||
self.tcx().mk_region(region)
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,6 @@ where
|
|||
c => bug!("{:?} is a const but value is {:?}", bound_ct, c),
|
||||
};
|
||||
|
||||
tcx.replace_escaping_bound_vars(value, fld_r, fld_t, fld_c).0
|
||||
tcx.replace_escaping_bound_vars(value, fld_r, fld_t, fld_c)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,9 @@ fn msg_span_from_early_bound_and_free_regions(
|
|||
}
|
||||
(format!("the lifetime `{}` as defined on", br.name), sp)
|
||||
}
|
||||
ty::ReFree(ty::FreeRegion { bound_region: ty::BoundRegion::BrNamed(_, name), .. }) => {
|
||||
ty::ReFree(ty::FreeRegion {
|
||||
bound_region: ty::BoundRegionKind::BrNamed(_, name), ..
|
||||
}) => {
|
||||
let mut sp = sm.guess_head_span(tcx.hir().span(node));
|
||||
if let Some(param) =
|
||||
tcx.hir().get_generics(scope).and_then(|generics| generics.get_named(name))
|
||||
|
@ -2279,7 +2281,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
&self,
|
||||
var_origin: RegionVariableOrigin,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
let br_string = |br: ty::BoundRegion| {
|
||||
let br_string = |br: ty::BoundRegionKind| {
|
||||
let mut s = match br {
|
||||
ty::BrNamed(_, name) => name.to_string(),
|
||||
_ => String::new(),
|
||||
|
|
|
@ -25,7 +25,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
pub(super) fn find_anon_type(
|
||||
&self,
|
||||
region: Region<'tcx>,
|
||||
br: &ty::BoundRegion,
|
||||
br: &ty::BoundRegionKind,
|
||||
) -> Option<(&hir::Ty<'tcx>, &hir::FnDecl<'tcx>)> {
|
||||
if let Some(anon_reg) = self.tcx().is_suitable_region(region) {
|
||||
let hir_id = self.tcx().hir().local_def_id_to_hir_id(anon_reg.def_id);
|
||||
|
@ -56,7 +56,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
fn find_component_for_bound_region(
|
||||
&self,
|
||||
arg: &'tcx hir::Ty<'tcx>,
|
||||
br: &ty::BoundRegion,
|
||||
br: &ty::BoundRegionKind,
|
||||
) -> Option<&'tcx hir::Ty<'tcx>> {
|
||||
let mut nested_visitor = FindNestedTypeVisitor {
|
||||
tcx: self.tcx(),
|
||||
|
@ -80,7 +80,7 @@ struct FindNestedTypeVisitor<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
// The bound_region corresponding to the Refree(freeregion)
|
||||
// associated with the anonymous region we are looking for.
|
||||
bound_region: ty::BoundRegion,
|
||||
bound_region: ty::BoundRegionKind,
|
||||
// The type where the anonymous lifetime appears
|
||||
// for e.g., Vec<`&u8`> and <`&u8`>
|
||||
found_type: Option<&'tcx hir::Ty<'tcx>>,
|
||||
|
@ -207,7 +207,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
|||
struct TyPathVisitor<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
found_it: bool,
|
||||
bound_region: ty::BoundRegion,
|
||||
bound_region: ty::BoundRegionKind,
|
||||
current_index: ty::DebruijnIndex,
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ pub(super) struct AnonymousParamInfo<'tcx> {
|
|||
pub param: &'tcx hir::Param<'tcx>,
|
||||
/// The type corresponding to the anonymous region parameter.
|
||||
pub param_ty: Ty<'tcx>,
|
||||
/// The ty::BoundRegion corresponding to the anonymous region.
|
||||
pub bound_region: ty::BoundRegion,
|
||||
/// The ty::BoundRegionKind corresponding to the anonymous region.
|
||||
pub bound_region: ty::BoundRegionKind,
|
||||
/// The `Span` of the parameter type.
|
||||
pub param_ty_span: Span,
|
||||
/// Signals that the argument is the first parameter in the declaration.
|
||||
|
@ -43,7 +43,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
ty::ReFree(ref free_region) => (free_region.scope, free_region.bound_region),
|
||||
ty::ReEarlyBound(ebr) => (
|
||||
self.tcx().parent(ebr.def_id).unwrap(),
|
||||
ty::BoundRegion::BrNamed(ebr.def_id, ebr.name),
|
||||
ty::BoundRegionKind::BrNamed(ebr.def_id, ebr.name),
|
||||
),
|
||||
_ => return None, // not a free region
|
||||
};
|
||||
|
@ -145,7 +145,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
pub(super) fn is_return_type_anon(
|
||||
&self,
|
||||
scope_def_id: LocalDefId,
|
||||
br: ty::BoundRegion,
|
||||
br: ty::BoundRegionKind,
|
||||
decl: &hir::FnDecl<'_>,
|
||||
) -> Option<Span> {
|
||||
let ret_ty = self.tcx().type_of(scope_def_id);
|
||||
|
|
|
@ -77,10 +77,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
// (i.e., if there are no placeholders).
|
||||
let next_universe = self.universe().next_universe();
|
||||
|
||||
let fld_r = |br| {
|
||||
let fld_r = |br: ty::BoundRegion| {
|
||||
self.tcx.mk_region(ty::RePlaceholder(ty::PlaceholderRegion {
|
||||
universe: next_universe,
|
||||
name: br,
|
||||
name: br.kind,
|
||||
}))
|
||||
};
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ pub enum RegionVariableOrigin {
|
|||
|
||||
/// Region variables created for bound regions
|
||||
/// in a function or method that is called
|
||||
LateBoundRegion(Span, ty::BoundRegion, LateBoundRegionConversionTime),
|
||||
LateBoundRegion(Span, ty::BoundRegionKind, LateBoundRegionConversionTime),
|
||||
|
||||
UpvarRegion(ty::UpvarId, Span),
|
||||
|
||||
|
@ -1421,7 +1421,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
||||
let fld_r = |br| self.next_region_var(LateBoundRegion(span, br, lbrct));
|
||||
let fld_r =
|
||||
|br: ty::BoundRegion| self.next_region_var(LateBoundRegion(span, br.kind, lbrct));
|
||||
let fld_t = |_| {
|
||||
self.next_ty_var(TypeVariableOrigin {
|
||||
kind: TypeVariableOriginKind::MiscVariable,
|
||||
|
|
|
@ -176,7 +176,7 @@ where
|
|||
universe
|
||||
});
|
||||
|
||||
let placeholder = ty::PlaceholderRegion { universe, name: br };
|
||||
let placeholder = ty::PlaceholderRegion { universe, name: br.kind };
|
||||
delegate.next_placeholder_region(placeholder)
|
||||
} else {
|
||||
delegate.next_existential_region_var(true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue