ty::BrK -> ty::BoundRegionKind::K
This commit is contained in:
parent
883f8705d4
commit
d458f850aa
@ -189,7 +189,7 @@ pub(super) fn to_error_region_vid(&self, r: RegionVid) -> Option<RegionVid> {
|
||||
/// Returns `true` if a closure is inferred to be an `FnMut` closure.
|
||||
fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
|
||||
if let Some(ty::ReLateParam(late_param)) = self.to_error_region(fr).as_deref()
|
||||
&& let ty::BoundRegionKind::BrEnv = late_param.bound_region
|
||||
&& let ty::BoundRegionKind::ClosureEnv = late_param.bound_region
|
||||
&& let DefiningTy::Closure(_, args) = self.regioncx.universal_regions().defining_ty
|
||||
{
|
||||
return args.as_closure().kind() == ty::ClosureKind::FnMut;
|
||||
|
@ -301,7 +301,7 @@ fn give_name_from_error_region(&self, fr: RegionVid) -> Option<RegionName> {
|
||||
}
|
||||
|
||||
ty::ReLateParam(late_param) => match late_param.bound_region {
|
||||
ty::BoundRegionKind::BrNamed(region_def_id, name) => {
|
||||
ty::BoundRegionKind::Named(region_def_id, name) => {
|
||||
// Get the span to point to, even if we don't use the name.
|
||||
let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP);
|
||||
debug!(
|
||||
@ -332,7 +332,7 @@ fn give_name_from_error_region(&self, fr: RegionVid) -> Option<RegionName> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::BoundRegionKind::BrEnv => {
|
||||
ty::BoundRegionKind::ClosureEnv => {
|
||||
let def_ty = self.regioncx.universal_regions().defining_ty;
|
||||
|
||||
let closure_kind = match def_ty {
|
||||
@ -369,7 +369,7 @@ fn give_name_from_error_region(&self, fr: RegionVid) -> Option<RegionName> {
|
||||
})
|
||||
}
|
||||
|
||||
ty::BoundRegionKind::BrAnon => None,
|
||||
ty::BoundRegionKind::Anon => None,
|
||||
},
|
||||
|
||||
ty::ReBound(..)
|
||||
|
@ -1375,9 +1375,9 @@ fn check_terminator(
|
||||
|
||||
let region_ctxt_fn = || {
|
||||
let reg_info = match br.kind {
|
||||
ty::BoundRegionKind::BrAnon => sym::anon,
|
||||
ty::BoundRegionKind::BrNamed(_, name) => name,
|
||||
ty::BoundRegionKind::BrEnv => sym::env,
|
||||
ty::BoundRegionKind::Anon => sym::anon,
|
||||
ty::BoundRegionKind::Named(_, name) => name,
|
||||
ty::BoundRegionKind::ClosureEnv => sym::env,
|
||||
};
|
||||
|
||||
RegionCtxt::LateBound(reg_info)
|
||||
|
@ -271,9 +271,9 @@ fn next_placeholder_region(&mut self, placeholder: ty::PlaceholderRegion) -> ty:
|
||||
.placeholder_region(self.type_checker.infcx, placeholder);
|
||||
|
||||
let reg_info = match placeholder.bound.kind {
|
||||
ty::BoundRegionKind::BrAnon => sym::anon,
|
||||
ty::BoundRegionKind::BrNamed(_, name) => name,
|
||||
ty::BoundRegionKind::BrEnv => sym::env,
|
||||
ty::BoundRegionKind::Anon => sym::anon,
|
||||
ty::BoundRegionKind::Named(_, name) => name,
|
||||
ty::BoundRegionKind::ClosureEnv => sym::env,
|
||||
};
|
||||
|
||||
if cfg!(debug_assertions) {
|
||||
|
@ -696,14 +696,13 @@ fn compute_inputs_and_output(
|
||||
let closure_sig = args.as_closure().sig();
|
||||
let inputs_and_output = closure_sig.inputs_and_output();
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
inputs_and_output
|
||||
.bound_vars()
|
||||
.iter()
|
||||
.chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||
inputs_and_output.bound_vars().iter().chain(iter::once(
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
)),
|
||||
);
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
|
||||
let closure_ty = tcx.closure_env_ty(
|
||||
@ -751,15 +750,13 @@ fn compute_inputs_and_output(
|
||||
DefiningTy::CoroutineClosure(def_id, args) => {
|
||||
assert_eq!(self.mir_def.to_def_id(), def_id);
|
||||
let closure_sig = args.as_coroutine_closure().coroutine_closure_sig();
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
closure_sig
|
||||
.bound_vars()
|
||||
.iter()
|
||||
.chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||
);
|
||||
let bound_vars =
|
||||
tcx.mk_bound_variable_kinds_from_iter(closure_sig.bound_vars().iter().chain(
|
||||
iter::once(ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv)),
|
||||
));
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
|
||||
let closure_kind = args.as_coroutine_closure().kind();
|
||||
|
@ -2244,7 +2244,7 @@ fn param_env_with_gat_bounds<'tcx>(
|
||||
.into()
|
||||
}
|
||||
GenericParamDefKind::Lifetime => {
|
||||
let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name);
|
||||
let kind = ty::BoundRegionKind::Named(param.def_id, param.name);
|
||||
let bound_var = ty::BoundVariableKind::Region(kind);
|
||||
bound_vars.push(bound_var);
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
|
@ -178,19 +178,19 @@ pub fn check_intrinsic_type(
|
||||
let name_str = intrinsic_name.as_str();
|
||||
|
||||
let bound_vars = tcx.mk_bound_variable_kinds(&[
|
||||
ty::BoundVariableKind::Region(ty::BrAnon),
|
||||
ty::BoundVariableKind::Region(ty::BrAnon),
|
||||
ty::BoundVariableKind::Region(ty::BrEnv),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
]);
|
||||
let mk_va_list_ty = |mutbl| {
|
||||
tcx.lang_items().va_list().map(|did| {
|
||||
let region = ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::ZERO,
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
});
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(2),
|
||||
kind: ty::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
});
|
||||
let va_list_ty = tcx.type_of(did).instantiate(tcx, &[region.into()]);
|
||||
(Ty::new_ref(tcx, env_region, va_list_ty, mutbl), va_list_ty)
|
||||
@ -509,7 +509,8 @@ pub fn check_intrinsic_type(
|
||||
);
|
||||
let discriminant_def_id = assoc_items[0];
|
||||
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
|
||||
let br =
|
||||
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
|
||||
(
|
||||
1,
|
||||
0,
|
||||
@ -573,10 +574,14 @@ pub fn check_intrinsic_type(
|
||||
}
|
||||
|
||||
sym::raw_eq => {
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BrAnon };
|
||||
let br =
|
||||
ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
|
||||
let param_ty_lhs =
|
||||
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon };
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(1),
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
};
|
||||
let param_ty_rhs =
|
||||
Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
|
||||
(1, 0, vec![param_ty_lhs, param_ty_rhs], tcx.types.bool)
|
||||
|
@ -634,7 +634,7 @@ fn get_new_lifetime_name<'tcx>(
|
||||
.collect_referenced_late_bound_regions(poly_trait_ref)
|
||||
.into_iter()
|
||||
.filter_map(|lt| {
|
||||
if let ty::BoundRegionKind::BrNamed(_, name) = lt {
|
||||
if let ty::BoundRegionKind::Named(_, name) = lt {
|
||||
Some(name.as_str().to_string())
|
||||
} else {
|
||||
None
|
||||
|
@ -322,7 +322,7 @@ fn late_arg_as_bound_arg<'tcx>(
|
||||
let name = tcx.item_name(def_id);
|
||||
match param.kind {
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(def_id, name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name))
|
||||
}
|
||||
GenericParamKind::Type { .. } => {
|
||||
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, name))
|
||||
@ -337,7 +337,7 @@ fn late_arg_as_bound_arg<'tcx>(
|
||||
fn generic_param_def_as_bound_arg(param: &ty::GenericParamDef) -> ty::BoundVariableKind {
|
||||
match param.kind {
|
||||
ty::GenericParamDefKind::Lifetime => {
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(param.def_id, param.name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(param.def_id, param.name))
|
||||
}
|
||||
ty::GenericParamDefKind::Type { .. } => {
|
||||
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(param.def_id, param.name))
|
||||
|
@ -644,7 +644,7 @@ fn lower_return_type_notation_ty(
|
||||
ty::GenericParamDefKind::Lifetime => {
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(num_bound_vars),
|
||||
kind: ty::BoundRegionKind::BrNamed(param.def_id, param.name),
|
||||
kind: ty::BoundRegionKind::Named(param.def_id, param.name),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
@ -830,8 +830,8 @@ fn visit_region(&mut self, re: ty::Region<'tcx>) -> Self::Result {
|
||||
}
|
||||
ty::ReBound(db, br) if db >= self.depth => {
|
||||
self.vars.insert(match br.kind {
|
||||
ty::BrNamed(def_id, name) => (def_id, name),
|
||||
ty::BrAnon | ty::BrEnv => {
|
||||
ty::BoundRegionKind::Named(def_id, name) => (def_id, name),
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => {
|
||||
let guar = self
|
||||
.cx
|
||||
.dcx()
|
||||
|
@ -314,7 +314,7 @@ pub fn lower_resolved_lifetime(&self, resolved: rbv::ResolvedArg) -> ty::Region<
|
||||
let name = lifetime_name(def_id);
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(index),
|
||||
kind: ty::BrNamed(def_id.to_def_id(), name),
|
||||
kind: ty::BoundRegionKind::Named(def_id.to_def_id(), name),
|
||||
};
|
||||
ty::Region::new_bound(tcx, debruijn, br)
|
||||
}
|
||||
@ -332,7 +332,7 @@ pub fn lower_resolved_lifetime(&self, resolved: rbv::ResolvedArg) -> ty::Region<
|
||||
ty::Region::new_late_param(
|
||||
tcx,
|
||||
scope.to_def_id(),
|
||||
ty::BrNamed(id.to_def_id(), name),
|
||||
ty::BoundRegionKind::Named(id.to_def_id(), name),
|
||||
)
|
||||
|
||||
// (*) -- not late-bound, won't change
|
||||
@ -2449,15 +2449,17 @@ fn validate_late_bound_regions<'cx>(
|
||||
) {
|
||||
for br in referenced_regions.difference(&constrained_regions) {
|
||||
let br_name = match *br {
|
||||
ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon | ty::BrEnv => {
|
||||
"an anonymous lifetime".to_string()
|
||||
}
|
||||
ty::BrNamed(_, name) => format!("lifetime `{name}`"),
|
||||
ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime)
|
||||
| ty::BoundRegionKind::Anon
|
||||
| ty::BoundRegionKind::ClosureEnv => "an anonymous lifetime".to_string(),
|
||||
ty::BoundRegionKind::Named(_, name) => format!("lifetime `{name}`"),
|
||||
};
|
||||
|
||||
let mut err = generate_err(&br_name);
|
||||
|
||||
if let ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon = *br {
|
||||
if let ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime)
|
||||
| ty::BoundRegionKind::Anon = *br
|
||||
{
|
||||
// The only way for an anonymous lifetime to wind up
|
||||
// in the return type but **also** be unconstrained is
|
||||
// if it only appears in "associated types" in the
|
||||
|
@ -194,21 +194,21 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
|
||||
let panic_info_ty = tcx.type_of(panic_info_did).instantiate(tcx, &[ty::GenericArg::from(
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(1),
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
}),
|
||||
)]);
|
||||
let panic_info_ref_ty = Ty::new_imm_ref(
|
||||
tcx,
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::ZERO,
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
}),
|
||||
panic_info_ty,
|
||||
);
|
||||
|
||||
let bounds = tcx.mk_bound_variable_kinds(&[
|
||||
ty::BoundVariableKind::Region(ty::BrAnon),
|
||||
ty::BoundVariableKind::Region(ty::BrAnon),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
|
||||
]);
|
||||
let expected_sig = ty::Binder::bind_with_vars(
|
||||
tcx.mk_fn_sig([panic_info_ref_ty], tcx.types.never, false, fn_sig.safety, ExternAbi::Rust),
|
||||
|
@ -381,7 +381,7 @@ fn analyze_closure(
|
||||
let closure_env_region: ty::Region<'_> =
|
||||
ty::Region::new_bound(self.tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
var: ty::BoundVar::ZERO,
|
||||
kind: ty::BoundRegionKind::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
});
|
||||
|
||||
let num_args = args
|
||||
@ -441,7 +441,7 @@ fn analyze_closure(
|
||||
rustc_abi::ExternAbi::Rust,
|
||||
),
|
||||
self.tcx.mk_bound_variable_kinds(&[ty::BoundVariableKind::Region(
|
||||
ty::BoundRegionKind::BrEnv,
|
||||
ty::BoundRegionKind::ClosureEnv,
|
||||
)]),
|
||||
),
|
||||
);
|
||||
|
@ -753,7 +753,7 @@ fn canonical_var_for_region(
|
||||
r: ty::Region<'tcx>,
|
||||
) -> ty::Region<'tcx> {
|
||||
let var = self.canonical_var(info, r.into());
|
||||
let br = ty::BoundRegion { var, kind: ty::BrAnon };
|
||||
let br = ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon };
|
||||
ty::Region::new_bound(self.cx(), self.binder_index, br)
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ fn check_fn(tcx: TyCtxt<'_>, parent_def_id: LocalDefId) {
|
||||
}
|
||||
|
||||
for bound_var in sig.bound_vars() {
|
||||
let ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(def_id, name)) = bound_var
|
||||
let ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name)) = bound_var
|
||||
else {
|
||||
span_bug!(tcx.def_span(parent_def_id), "unexpected non-lifetime binder on fn sig");
|
||||
};
|
||||
@ -215,7 +215,7 @@ fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(&mut self, t: &ty::Binder<'tcx,
|
||||
for arg in t.bound_vars() {
|
||||
let arg: ty::BoundVariableKind = arg;
|
||||
match arg {
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::BrNamed(def_id, ..))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, ..))
|
||||
| ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, _)) => {
|
||||
added.push(def_id);
|
||||
let unique = self.in_scope_parameters.insert(def_id, ParamKind::Late);
|
||||
@ -318,7 +318,7 @@ fn visit_ty(&mut self, t: Ty<'tcx>) {
|
||||
ParamKind::Free(def_id, name) => ty::Region::new_late_param(
|
||||
self.tcx,
|
||||
self.parent_def_id.to_def_id(),
|
||||
ty::BoundRegionKind::BrNamed(def_id, name),
|
||||
ty::BoundRegionKind::Named(def_id, name),
|
||||
),
|
||||
// Totally ignore late bound args from binders.
|
||||
ParamKind::Late => return true,
|
||||
@ -489,11 +489,11 @@ fn extract_def_id_from_arg<'tcx>(
|
||||
ty::ReEarlyParam(ebr) => generics.region_param(ebr, tcx).def_id,
|
||||
ty::ReBound(
|
||||
_,
|
||||
ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, ..), .. },
|
||||
ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, ..), .. },
|
||||
)
|
||||
| ty::ReLateParam(ty::LateParamRegion {
|
||||
scope: _,
|
||||
bound_region: ty::BoundRegionKind::BrNamed(def_id, ..),
|
||||
bound_region: ty::BoundRegionKind::Named(def_id, ..),
|
||||
}) => def_id,
|
||||
_ => unreachable!(),
|
||||
},
|
||||
@ -558,11 +558,11 @@ fn regions(
|
||||
ty::ReEarlyParam(ebr) => self.generics.region_param(ebr, self.tcx).def_id,
|
||||
ty::ReBound(
|
||||
_,
|
||||
ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, ..), .. },
|
||||
ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, ..), .. },
|
||||
)
|
||||
| ty::ReLateParam(ty::LateParamRegion {
|
||||
scope: _,
|
||||
bound_region: ty::BoundRegionKind::BrNamed(def_id, ..),
|
||||
bound_region: ty::BoundRegionKind::Named(def_id, ..),
|
||||
}) => def_id,
|
||||
_ => {
|
||||
return Ok(a);
|
||||
|
@ -317,7 +317,10 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> {
|
||||
pub fn bind(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self {
|
||||
let inner = tcx.fold_regions(ty, |r, depth| match r.kind() {
|
||||
ty::ReVar(vid) => {
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::new(vid.index()), kind: ty::BrAnon };
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::new(vid.index()),
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
};
|
||||
ty::Region::new_bound(tcx, depth, br)
|
||||
}
|
||||
_ => bug!("unexpected region in ClosureOutlivesSubjectTy: {r:?}"),
|
||||
|
@ -1059,7 +1059,7 @@ fn new(interners: &CtxtInterners<'tcx>) -> CommonLifetimes<'tcx> {
|
||||
.map(|v| {
|
||||
mk(ty::ReBound(ty::DebruijnIndex::from(i), ty::BoundRegion {
|
||||
var: ty::BoundVar::from(v),
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
}))
|
||||
})
|
||||
.collect()
|
||||
@ -1982,7 +1982,10 @@ pub fn is_suitable_region(
|
||||
region = self.map_opaque_lifetime_to_parent_lifetime(def_id);
|
||||
continue;
|
||||
}
|
||||
break (scope, ty::BrNamed(def_id.into(), self.item_name(def_id.into())));
|
||||
break (
|
||||
scope,
|
||||
ty::BoundRegionKind::Named(def_id.into(), self.item_name(def_id.into())),
|
||||
);
|
||||
};
|
||||
|
||||
let is_impl_item = match self.hir_node_by_def_id(suitable_region_binding_scope) {
|
||||
@ -3091,7 +3094,7 @@ pub fn map_opaque_lifetime_to_parent_lifetime(
|
||||
return ty::Region::new_late_param(
|
||||
self,
|
||||
new_parent.to_def_id(),
|
||||
ty::BoundRegionKind::BrNamed(
|
||||
ty::BoundRegionKind::Named(
|
||||
lbv.to_def_id(),
|
||||
self.item_name(lbv.to_def_id()),
|
||||
),
|
||||
|
@ -399,7 +399,7 @@ fn replace_region(&mut self, br: ty::BoundRegion) -> ty::Region<'tcx> {
|
||||
let index = entry.index();
|
||||
let var = ty::BoundVar::from_usize(index);
|
||||
let kind = entry
|
||||
.or_insert_with(|| ty::BoundVariableKind::Region(ty::BrAnon))
|
||||
.or_insert_with(|| ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon))
|
||||
.expect_region();
|
||||
let br = ty::BoundRegion { var, kind };
|
||||
ty::Region::new_bound(self.tcx, ty::INNERMOST, br)
|
||||
|
@ -84,7 +84,6 @@
|
||||
RegionOutlivesPredicate, SubtypePredicate, ToPolyTraitRef, TraitPredicate, TraitRef,
|
||||
TypeOutlivesPredicate,
|
||||
};
|
||||
pub use self::region::BoundRegionKind::*;
|
||||
pub use self::region::{
|
||||
BoundRegion, BoundRegionKind, EarlyParamRegion, LateParamRegion, Region, RegionKind, RegionVid,
|
||||
};
|
||||
@ -895,7 +894,7 @@ fn with_updated_universe(self, ui: UniverseIndex) -> Self {
|
||||
}
|
||||
|
||||
fn new(ui: UniverseIndex, var: BoundVar) -> Self {
|
||||
Placeholder { universe: ui, bound: BoundRegion { var, kind: BoundRegionKind::BrAnon } }
|
||||
Placeholder { universe: ui, bound: BoundRegion { var, kind: BoundRegionKind::Anon } }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2483,7 +2483,7 @@ pub fn pretty_print_region(&mut self, region: ty::Region<'tcx>) -> Result<(), fm
|
||||
| ty::RePlaceholder(ty::Placeholder {
|
||||
bound: ty::BoundRegion { kind: br, .. }, ..
|
||||
}) => {
|
||||
if let ty::BrNamed(_, name) = br
|
||||
if let ty::BoundRegionKind::Named(_, name) = br
|
||||
&& br.is_named()
|
||||
{
|
||||
p!(write("{}", name));
|
||||
@ -2569,7 +2569,7 @@ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
|
||||
// If this is an anonymous placeholder, don't rename. Otherwise, in some
|
||||
// async fns, we get a `for<'r> Send` bound
|
||||
match kind {
|
||||
ty::BrAnon | ty::BrEnv => r,
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => r,
|
||||
_ => {
|
||||
// Index doesn't matter, since this is just for naming and these never get bound
|
||||
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind };
|
||||
@ -2688,12 +2688,13 @@ fn name_by_region_index(
|
||||
binder_level_idx: ty::DebruijnIndex,
|
||||
br: ty::BoundRegion| {
|
||||
let (name, kind) = match br.kind {
|
||||
ty::BrAnon | ty::BrEnv => {
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => {
|
||||
let name = next_name(self);
|
||||
|
||||
if let Some(lt_idx) = lifetime_idx {
|
||||
if lt_idx > binder_level_idx {
|
||||
let kind = ty::BrNamed(CRATE_DEF_ID.to_def_id(), name);
|
||||
let kind =
|
||||
ty::BoundRegionKind::Named(CRATE_DEF_ID.to_def_id(), name);
|
||||
return ty::Region::new_bound(
|
||||
tcx,
|
||||
ty::INNERMOST,
|
||||
@ -2702,14 +2703,14 @@ fn name_by_region_index(
|
||||
}
|
||||
}
|
||||
|
||||
(name, ty::BrNamed(CRATE_DEF_ID.to_def_id(), name))
|
||||
(name, ty::BoundRegionKind::Named(CRATE_DEF_ID.to_def_id(), name))
|
||||
}
|
||||
ty::BrNamed(def_id, kw::UnderscoreLifetime | kw::Empty) => {
|
||||
ty::BoundRegionKind::Named(def_id, kw::UnderscoreLifetime | kw::Empty) => {
|
||||
let name = next_name(self);
|
||||
|
||||
if let Some(lt_idx) = lifetime_idx {
|
||||
if lt_idx > binder_level_idx {
|
||||
let kind = ty::BrNamed(def_id, name);
|
||||
let kind = ty::BoundRegionKind::Named(def_id, name);
|
||||
return ty::Region::new_bound(
|
||||
tcx,
|
||||
ty::INNERMOST,
|
||||
@ -2718,9 +2719,9 @@ fn name_by_region_index(
|
||||
}
|
||||
}
|
||||
|
||||
(name, ty::BrNamed(def_id, name))
|
||||
(name, ty::BoundRegionKind::Named(def_id, name))
|
||||
}
|
||||
ty::BrNamed(_, name) => {
|
||||
ty::BoundRegionKind::Named(_, name) => {
|
||||
if let Some(lt_idx) = lifetime_idx {
|
||||
if lt_idx > binder_level_idx {
|
||||
let kind = br.kind;
|
||||
|
@ -56,7 +56,7 @@ pub fn new_bound(
|
||||
bound_region: ty::BoundRegion,
|
||||
) -> Region<'tcx> {
|
||||
// Use a pre-interned one when possible.
|
||||
if let ty::BoundRegion { var, kind: ty::BrAnon } = bound_region
|
||||
if let ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon } = bound_region
|
||||
&& let Some(inner) = tcx.lifetimes.re_late_bounds.get(debruijn.as_usize())
|
||||
&& let Some(re) = inner.get(var.as_usize()).copied()
|
||||
{
|
||||
@ -147,7 +147,7 @@ fn new_bound(
|
||||
}
|
||||
|
||||
fn new_anon_bound(tcx: TyCtxt<'tcx>, debruijn: ty::DebruijnIndex, var: ty::BoundVar) -> Self {
|
||||
Region::new_bound(tcx, debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::BrAnon })
|
||||
Region::new_bound(tcx, debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon })
|
||||
}
|
||||
|
||||
fn new_static(tcx: TyCtxt<'tcx>) -> Self {
|
||||
@ -311,7 +311,7 @@ pub fn opt_param_def_id(self, tcx: TyCtxt<'tcx>, binding_item: DefId) -> Option<
|
||||
Some(tcx.generics_of(binding_item).region_param(ebr, tcx).def_id)
|
||||
}
|
||||
ty::ReLateParam(ty::LateParamRegion {
|
||||
bound_region: ty::BoundRegionKind::BrNamed(def_id, _),
|
||||
bound_region: ty::BoundRegionKind::Named(def_id, _),
|
||||
..
|
||||
}) => Some(def_id),
|
||||
_ => None,
|
||||
@ -355,7 +355,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
/// Similar to a placeholder region as we create `LateParam` regions when entering a binder
|
||||
/// except they are always in the root universe and instead of using a boundvar to distinguish
|
||||
/// between others we use the `DefId` of the parameter. For this reason the `bound_region` field
|
||||
/// should basically always be `BoundRegionKind::BrNamed` as otherwise there is no way of telling
|
||||
/// should basically always be `BoundRegionKind::Named` as otherwise there is no way of telling
|
||||
/// different parameters apart.
|
||||
pub struct LateParamRegion {
|
||||
pub scope: DefId,
|
||||
@ -366,17 +366,17 @@ pub struct LateParamRegion {
|
||||
#[derive(HashStable)]
|
||||
pub enum BoundRegionKind {
|
||||
/// An anonymous region parameter for a given fn (&T)
|
||||
BrAnon,
|
||||
Anon,
|
||||
|
||||
/// Named region parameters for functions (a in &'a T)
|
||||
///
|
||||
/// The `DefId` is needed to distinguish free regions in
|
||||
/// the event of shadowing.
|
||||
BrNamed(DefId, Symbol),
|
||||
Named(DefId, Symbol),
|
||||
|
||||
/// Anonymous region for the implicit env pointer parameter
|
||||
/// to a closure
|
||||
BrEnv,
|
||||
ClosureEnv,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable)]
|
||||
@ -399,9 +399,9 @@ fn assert_eq(self, var: ty::BoundVariableKind) {
|
||||
impl core::fmt::Debug for BoundRegion {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self.kind {
|
||||
BoundRegionKind::BrAnon => write!(f, "{:?}", self.var),
|
||||
BoundRegionKind::BrEnv => write!(f, "{:?}.Env", self.var),
|
||||
BoundRegionKind::BrNamed(def, symbol) => {
|
||||
BoundRegionKind::Anon => write!(f, "{:?}", self.var),
|
||||
BoundRegionKind::ClosureEnv => write!(f, "{:?}.Env", self.var),
|
||||
BoundRegionKind::Named(def, symbol) => {
|
||||
write!(f, "{:?}.Named({:?}, {:?})", self.var, def, symbol)
|
||||
}
|
||||
}
|
||||
@ -411,9 +411,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl BoundRegionKind {
|
||||
pub fn is_named(&self) -> bool {
|
||||
match *self {
|
||||
BoundRegionKind::BrNamed(_, name) => {
|
||||
name != kw::UnderscoreLifetime && name != kw::Empty
|
||||
}
|
||||
BoundRegionKind::Named(_, name) => name != kw::UnderscoreLifetime && name != kw::Empty,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -421,7 +419,7 @@ pub fn is_named(&self) -> bool {
|
||||
pub fn get_name(&self) -> Option<Symbol> {
|
||||
if self.is_named() {
|
||||
match *self {
|
||||
BoundRegionKind::BrNamed(_, name) => return Some(name),
|
||||
BoundRegionKind::Named(_, name) => return Some(name),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@ -431,7 +429,7 @@ pub fn get_name(&self) -> Option<Symbol> {
|
||||
|
||||
pub fn get_id(&self) -> Option<DefId> {
|
||||
match *self {
|
||||
BoundRegionKind::BrNamed(id, _) => Some(id),
|
||||
BoundRegionKind::Named(id, _) => Some(id),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -62,15 +62,15 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
impl fmt::Debug for ty::BoundRegionKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
ty::BrAnon => write!(f, "BrAnon"),
|
||||
ty::BrNamed(did, name) => {
|
||||
ty::BoundRegionKind::Anon => write!(f, "BrAnon"),
|
||||
ty::BoundRegionKind::Named(did, name) => {
|
||||
if did.is_crate_root() {
|
||||
write!(f, "BrNamed({name})")
|
||||
} else {
|
||||
write!(f, "BrNamed({did:?}, {name})")
|
||||
}
|
||||
}
|
||||
ty::BrEnv => write!(f, "BrEnv"),
|
||||
ty::BoundRegionKind::ClosureEnv => write!(f, "BrEnv"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -735,8 +735,11 @@ pub fn bound_coroutine_hidden_types(
|
||||
let ty = self.fold_regions(decl.ty, |re, debruijn| {
|
||||
assert_eq!(re, self.lifetimes.re_erased);
|
||||
let var = ty::BoundVar::from_usize(vars.len());
|
||||
vars.push(ty::BoundVariableKind::Region(ty::BrAnon));
|
||||
ty::Region::new_bound(self, debruijn, ty::BoundRegion { var, kind: ty::BrAnon })
|
||||
vars.push(ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon));
|
||||
ty::Region::new_bound(self, debruijn, ty::BoundRegion {
|
||||
var,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
})
|
||||
});
|
||||
ty::EarlyBinder::bind(ty::Binder::bind_with_vars(
|
||||
ty,
|
||||
|
@ -335,12 +335,12 @@ fn internal<'tcx>(&self, tables: &mut Tables<'_>, tcx: TyCtxt<'tcx>) -> Self::T<
|
||||
),
|
||||
}),
|
||||
BoundVariableKind::Region(kind) => rustc_ty::BoundVariableKind::Region(match kind {
|
||||
BoundRegionKind::BrAnon => rustc_ty::BoundRegionKind::BrAnon,
|
||||
BoundRegionKind::BrNamed(def, symbol) => rustc_ty::BoundRegionKind::BrNamed(
|
||||
BoundRegionKind::BrAnon => rustc_ty::BoundRegionKind::Anon,
|
||||
BoundRegionKind::BrNamed(def, symbol) => rustc_ty::BoundRegionKind::Named(
|
||||
def.0.internal(tables, tcx),
|
||||
Symbol::intern(symbol),
|
||||
),
|
||||
BoundRegionKind::BrEnv => rustc_ty::BoundRegionKind::BrEnv,
|
||||
BoundRegionKind::BrEnv => rustc_ty::BoundRegionKind::ClosureEnv,
|
||||
}),
|
||||
BoundVariableKind::Const => rustc_ty::BoundVariableKind::Const,
|
||||
}
|
||||
|
@ -243,11 +243,11 @@ fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
|
||||
use stable_mir::ty::BoundRegionKind;
|
||||
|
||||
match self {
|
||||
ty::BoundRegionKind::BrAnon => BoundRegionKind::BrAnon,
|
||||
ty::BoundRegionKind::BrNamed(def_id, symbol) => {
|
||||
ty::BoundRegionKind::Anon => BoundRegionKind::BrAnon,
|
||||
ty::BoundRegionKind::Named(def_id, symbol) => {
|
||||
BoundRegionKind::BrNamed(tables.br_named_def(*def_id), symbol.to_string())
|
||||
}
|
||||
ty::BoundRegionKind::BrEnv => BoundRegionKind::BrEnv,
|
||||
ty::BoundRegionKind::ClosureEnv => BoundRegionKind::BrEnv,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ fn print_region(&mut self, region: ty::Region<'_>) -> Result<(), PrintError> {
|
||||
|
||||
// Bound lifetimes use indices starting at 1,
|
||||
// see `BinderLevel` for more details.
|
||||
ty::ReBound(debruijn, ty::BoundRegion { var, kind: ty::BrAnon }) => {
|
||||
ty::ReBound(debruijn, ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon }) => {
|
||||
let binder = &self.binders[self.binders.len() - 1 - debruijn.index()];
|
||||
let depth = binder.lifetime_depths.start + var.as_u32();
|
||||
|
||||
|
@ -100,7 +100,10 @@ fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) -> Self::Result {
|
||||
// Find the index of the named region that was part of the
|
||||
// error. We will then search the function parameters for a bound
|
||||
// region at the right depth with the same index
|
||||
(Some(rbv::ResolvedArg::EarlyBound(id)), ty::BrNamed(def_id, _)) => {
|
||||
(
|
||||
Some(rbv::ResolvedArg::EarlyBound(id)),
|
||||
ty::BoundRegionKind::Named(def_id, _),
|
||||
) => {
|
||||
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
|
||||
if id.to_def_id() == def_id {
|
||||
return ControlFlow::Break(arg);
|
||||
@ -112,7 +115,7 @@ fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) -> Self::Result {
|
||||
// region at the right depth with the same index
|
||||
(
|
||||
Some(rbv::ResolvedArg::LateBound(debruijn_index, _, id)),
|
||||
ty::BrNamed(def_id, _),
|
||||
ty::BoundRegionKind::Named(def_id, _),
|
||||
) => {
|
||||
debug!(
|
||||
"FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
|
||||
@ -191,14 +194,17 @@ fn nested_visit_map(&mut self) -> Map<'tcx> {
|
||||
fn visit_lifetime(&mut self, lifetime: &hir::Lifetime) -> Self::Result {
|
||||
match (self.tcx.named_bound_var(lifetime.hir_id), self.bound_region) {
|
||||
// the lifetime of the TyPath!
|
||||
(Some(rbv::ResolvedArg::EarlyBound(id)), ty::BrNamed(def_id, _)) => {
|
||||
(Some(rbv::ResolvedArg::EarlyBound(id)), ty::BoundRegionKind::Named(def_id, _)) => {
|
||||
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
|
||||
if id.to_def_id() == def_id {
|
||||
return ControlFlow::Break(());
|
||||
}
|
||||
}
|
||||
|
||||
(Some(rbv::ResolvedArg::LateBound(debruijn_index, _, id)), ty::BrNamed(def_id, _)) => {
|
||||
(
|
||||
Some(rbv::ResolvedArg::LateBound(debruijn_index, _, id)),
|
||||
ty::BoundRegionKind::Named(def_id, _),
|
||||
) => {
|
||||
debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}", debruijn_index,);
|
||||
debug!("id={:?}", id);
|
||||
debug!("def_id={:?}", def_id);
|
||||
|
@ -60,7 +60,7 @@ pub(super) fn try_report_named_anon_conflict(&self) -> Option<Diag<'tcx>> {
|
||||
let is_impl_item = region_info.is_impl_item;
|
||||
|
||||
match br {
|
||||
ty::BrNamed(_, kw::UnderscoreLifetime) | ty::BrAnon => {}
|
||||
ty::BoundRegionKind::Named(_, kw::UnderscoreLifetime) | ty::BoundRegionKind::Anon => {}
|
||||
_ => {
|
||||
/* not an anonymous region */
|
||||
debug!("try_report_named_anon_conflict: not an anonymous region");
|
||||
|
@ -29,16 +29,16 @@ pub(super) fn try_report_placeholder_relation(&self) -> Option<Diag<'tcx>> {
|
||||
)) => {
|
||||
let span = *span;
|
||||
let (sub_span, sub_symbol) = match sub_name {
|
||||
ty::BrNamed(def_id, symbol) => {
|
||||
ty::BoundRegionKind::Named(def_id, symbol) => {
|
||||
(Some(self.tcx().def_span(def_id)), Some(symbol))
|
||||
}
|
||||
ty::BrAnon | ty::BrEnv => (None, None),
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => (None, None),
|
||||
};
|
||||
let (sup_span, sup_symbol) = match sup_name {
|
||||
ty::BrNamed(def_id, symbol) => {
|
||||
ty::BoundRegionKind::Named(def_id, symbol) => {
|
||||
(Some(self.tcx().def_span(def_id)), Some(symbol))
|
||||
}
|
||||
ty::BrAnon | ty::BrEnv => (None, None),
|
||||
ty::BoundRegionKind::Anon | ty::BoundRegionKind::ClosureEnv => (None, None),
|
||||
};
|
||||
let diag = match (sub_span, sup_span, sub_symbol, sup_symbol) {
|
||||
(Some(sub_span), Some(sup_span), Some(&sub_symbol), Some(&sup_symbol)) => {
|
||||
|
@ -46,7 +46,7 @@ pub fn find_param_with_region<'tcx>(
|
||||
ty::ReLateParam(late_param) => (late_param.scope, late_param.bound_region),
|
||||
ty::ReEarlyParam(ebr) => {
|
||||
let region_def = tcx.generics_of(generic_param_scope).region_param(ebr, tcx).def_id;
|
||||
(tcx.parent(region_def), ty::BoundRegionKind::BrNamed(region_def, ebr.name))
|
||||
(tcx.parent(region_def), ty::BoundRegionKind::Named(region_def, ebr.name))
|
||||
}
|
||||
_ => return None, // not a free region
|
||||
};
|
||||
|
@ -993,7 +993,7 @@ fn report_sub_sup_conflict(
|
||||
fn report_inference_failure(&self, var_origin: RegionVariableOrigin) -> Diag<'_> {
|
||||
let br_string = |br: ty::BoundRegionKind| {
|
||||
let mut s = match br {
|
||||
ty::BrNamed(_, name) => name.to_string(),
|
||||
ty::BoundRegionKind::Named(_, name) => name.to_string(),
|
||||
_ => String::new(),
|
||||
};
|
||||
if !s.is_empty() {
|
||||
@ -1103,7 +1103,7 @@ fn msg_span_from_named_region<'tcx>(
|
||||
("the anonymous lifetime defined here".to_string(), Some(ty.span))
|
||||
} else {
|
||||
match fr.bound_region {
|
||||
ty::BoundRegionKind::BrNamed(param_def_id, name) => {
|
||||
ty::BoundRegionKind::Named(param_def_id, name) => {
|
||||
let span = tcx.def_span(param_def_id);
|
||||
let text = if name == kw::UnderscoreLifetime {
|
||||
"the anonymous lifetime as defined here".to_string()
|
||||
@ -1112,7 +1112,7 @@ fn msg_span_from_named_region<'tcx>(
|
||||
};
|
||||
(text, Some(span))
|
||||
}
|
||||
ty::BrAnon => (
|
||||
ty::BoundRegionKind::Anon => (
|
||||
"the anonymous lifetime as defined here".to_string(),
|
||||
Some(tcx.def_span(generic_param_scope)),
|
||||
),
|
||||
@ -1125,11 +1125,11 @@ fn msg_span_from_named_region<'tcx>(
|
||||
}
|
||||
ty::ReStatic => ("the static lifetime".to_owned(), alt_span),
|
||||
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, name), .. },
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id, name), .. },
|
||||
..
|
||||
}) => (format!("the lifetime `{name}` as defined here"), Some(tcx.def_span(def_id))),
|
||||
ty::RePlaceholder(ty::PlaceholderRegion {
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon, .. },
|
||||
bound: ty::BoundRegion { kind: ty::BoundRegionKind::Anon, .. },
|
||||
..
|
||||
}) => ("an anonymous lifetime".to_owned(), None),
|
||||
_ => bug!("{:?}", region),
|
||||
|
@ -48,7 +48,7 @@ fn new<'tcx>(
|
||||
} else {
|
||||
let scope = fr.scope.expect_local();
|
||||
match fr.bound_region {
|
||||
ty::BoundRegionKind::BrNamed(_, name) => {
|
||||
ty::BoundRegionKind::Named(_, name) => {
|
||||
let span = if let Some(param) = tcx
|
||||
.hir()
|
||||
.get_generics(scope)
|
||||
@ -64,7 +64,7 @@ fn new<'tcx>(
|
||||
(Some(span), "as_defined", name.to_string())
|
||||
}
|
||||
}
|
||||
ty::BrAnon => {
|
||||
ty::BoundRegionKind::Anon => {
|
||||
let span = Some(tcx.def_span(scope));
|
||||
(span, "defined_here", String::new())
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) {
|
||||
universe: self.universe,
|
||||
bound: ty::BoundRegion {
|
||||
var: self.next_var(),
|
||||
kind: ty::BoundRegionKind::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
@ -660,7 +660,7 @@ fn confirm_object_candidate(
|
||||
.into()
|
||||
}
|
||||
GenericParamDefKind::Lifetime => {
|
||||
let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name);
|
||||
let kind = ty::BoundRegionKind::Named(param.def_id, param.name);
|
||||
let bound_var = ty::BoundVariableKind::Region(kind);
|
||||
bound_vars.push(bound_var);
|
||||
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
|
||||
|
@ -3183,7 +3183,7 @@ fn bind_coroutine_hidden_types_above<'tcx>(
|
||||
ty::ReErased => {
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_u32(counter),
|
||||
kind: ty::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
};
|
||||
counter += 1;
|
||||
ty::Region::new_bound(tcx, current_depth, br)
|
||||
@ -3196,9 +3196,11 @@ fn bind_coroutine_hidden_types_above<'tcx>(
|
||||
bty.instantiate(tcx, args)
|
||||
})
|
||||
.collect();
|
||||
let bound_vars =
|
||||
tcx.mk_bound_variable_kinds_from_iter(bound_vars.iter().chain(
|
||||
(num_bound_variables..counter).map(|_| ty::BoundVariableKind::Region(ty::BrAnon)),
|
||||
));
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
bound_vars.iter().chain(
|
||||
(num_bound_variables..counter)
|
||||
.map(|_| ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon)),
|
||||
),
|
||||
);
|
||||
ty::Binder::bind_with_vars(hidden_types, bound_vars)
|
||||
}
|
||||
|
@ -76,12 +76,13 @@ fn fn_sig_for_fn_abi<'tcx>(
|
||||
ty::Closure(def_id, args) => {
|
||||
let sig = args.as_closure().sig();
|
||||
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||
);
|
||||
let bound_vars =
|
||||
tcx.mk_bound_variable_kinds_from_iter(sig.bound_vars().iter().chain(iter::once(
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
)));
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BoundRegionKind::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
|
||||
let env_ty = tcx.closure_env_ty(
|
||||
@ -105,12 +106,13 @@ fn fn_sig_for_fn_abi<'tcx>(
|
||||
ty::CoroutineClosure(def_id, args) => {
|
||||
let coroutine_ty = Ty::new_coroutine_closure(tcx, def_id, args);
|
||||
let sig = args.as_coroutine_closure().coroutine_closure_sig();
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(
|
||||
sig.bound_vars().iter().chain(iter::once(ty::BoundVariableKind::Region(ty::BrEnv))),
|
||||
);
|
||||
let bound_vars =
|
||||
tcx.mk_bound_variable_kinds_from_iter(sig.bound_vars().iter().chain(iter::once(
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
)));
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BoundRegionKind::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
|
||||
// When this `CoroutineClosure` comes from a `ConstructCoroutineInClosureShim`,
|
||||
@ -161,11 +163,11 @@ fn fn_sig_for_fn_abi<'tcx>(
|
||||
let sig = args.as_coroutine().sig();
|
||||
|
||||
let bound_vars = tcx.mk_bound_variable_kinds_from_iter(iter::once(
|
||||
ty::BoundVariableKind::Region(ty::BrEnv),
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::ClosureEnv),
|
||||
));
|
||||
let br = ty::BoundRegion {
|
||||
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
|
||||
kind: ty::BoundRegionKind::BrEnv,
|
||||
kind: ty::BoundRegionKind::ClosureEnv,
|
||||
};
|
||||
|
||||
let env_ty = Ty::new_mut_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), ty);
|
||||
|
@ -304,7 +304,9 @@ pub(crate) fn clean_middle_region(region: ty::Region<'_>) -> Option<Lifetime> {
|
||||
match *region {
|
||||
ty::ReStatic => Some(Lifetime::statik()),
|
||||
_ if !region.has_name() => None,
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) => Some(Lifetime(name)),
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. }) => {
|
||||
Some(Lifetime(name))
|
||||
}
|
||||
ty::ReEarlyParam(ref data) => Some(Lifetime(data.name)),
|
||||
ty::ReBound(..)
|
||||
| ty::ReLateParam(..)
|
||||
@ -1896,7 +1898,9 @@ fn clean_trait_object_lifetime_bound<'tcx>(
|
||||
match *region {
|
||||
ty::ReStatic => Some(Lifetime::statik()),
|
||||
ty::ReEarlyParam(region) if region.name != kw::Empty => Some(Lifetime(region.name)),
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) if name != kw::Empty => {
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. })
|
||||
if name != kw::Empty =>
|
||||
{
|
||||
Some(Lifetime(name))
|
||||
}
|
||||
ty::ReEarlyParam(_)
|
||||
@ -2141,7 +2145,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
||||
.iter()
|
||||
.flat_map(|pred| pred.bound_vars())
|
||||
.filter_map(|var| match var {
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(def_id, name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name))
|
||||
if name != kw::UnderscoreLifetime =>
|
||||
{
|
||||
Some(GenericParamDef::lifetime(def_id, name))
|
||||
@ -3118,7 +3122,7 @@ fn clean_bound_vars(bound_vars: &ty::List<ty::BoundVariableKind>) -> Vec<Generic
|
||||
bound_vars
|
||||
.into_iter()
|
||||
.filter_map(|var| match var {
|
||||
ty::BoundVariableKind::Region(ty::BrNamed(def_id, name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name))
|
||||
if name != kw::UnderscoreLifetime =>
|
||||
{
|
||||
Some(GenericParamDef::lifetime(def_id, name))
|
||||
|
Loading…
Reference in New Issue
Block a user