ty::BrK -> ty::BoundRegionKind::K
This commit is contained in:
parent
883f8705d4
commit
d458f850aa
37 changed files with 164 additions and 139 deletions
|
@ -100,7 +100,10 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
|||
// 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 @@ impl<'tcx> Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
|
|||
// 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 @@ impl<'tcx> Visitor<'tcx> for TyPathVisitor<'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 @@ impl<'a, 'tcx> NiceRegionError<'a, '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 @@ impl<'tcx> NiceRegionError<'_, '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 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
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 @@ impl<'a> DescriptionCtx<'a> {
|
|||
} 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 @@ impl<'a> DescriptionCtx<'a> {
|
|||
(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 plug_infer_with_placeholders<'tcx>(
|
|||
universe: self.universe,
|
||||
bound: ty::BoundRegion {
|
||||
var: self.next_var(),
|
||||
kind: ty::BoundRegionKind::BrAnon,
|
||||
kind: ty::BoundRegionKind::Anon,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
|
|
@ -660,7 +660,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, '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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue