1
Fork 0

Restrict diagnostic context lifetime of FnCtxt to InferCtxt instead of TyCtxt

This commit is contained in:
Oli Scherer 2024-06-25 08:10:04 +00:00
parent ef559199ef
commit f3d9523a2e
3 changed files with 6 additions and 6 deletions

View file

@ -144,7 +144,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
} }
pub(crate) fn dcx(&self) -> DiagCtxtHandle<'tcx> { pub(crate) fn dcx(&self) -> DiagCtxtHandle<'a> {
self.infcx.dcx() self.infcx.dcx()
} }

View file

@ -1881,7 +1881,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
pat: &Pat<'_>, pat: &Pat<'_>,
fields: &'tcx [hir::PatField<'tcx>], fields: &'tcx [hir::PatField<'tcx>],
) -> Diag<'tcx> { ) -> Diag<'a> {
let mut err = self let mut err = self
.dcx() .dcx()
.struct_span_err(pat.span, "pattern requires `..` due to inaccessible fields"); .struct_span_err(pat.span, "pattern requires `..` due to inaccessible fields");
@ -1973,7 +1973,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
unmentioned_fields: &[(&ty::FieldDef, Ident)], unmentioned_fields: &[(&ty::FieldDef, Ident)],
have_inaccessible_fields: bool, have_inaccessible_fields: bool,
fields: &'tcx [hir::PatField<'tcx>], fields: &'tcx [hir::PatField<'tcx>],
) -> Diag<'tcx> { ) -> Diag<'a> {
let inaccessible = if have_inaccessible_fields { " and inaccessible fields" } else { "" }; let inaccessible = if have_inaccessible_fields { " and inaccessible fields" } else { "" };
let field_names = if let [(_, field)] = unmentioned_fields { let field_names = if let [(_, field)] = unmentioned_fields {
format!("field `{field}`{inaccessible}") format!("field `{field}`{inaccessible}")

View file

@ -1607,7 +1607,7 @@ impl<'tcx> InferCtxt<'tcx> {
} }
} }
impl<'tcx> TypeErrCtxt<'_, 'tcx> { impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
// [Note-Type-error-reporting] // [Note-Type-error-reporting]
// An invariant is that anytime the expected or actual type is Error (the special // An invariant is that anytime the expected or actual type is Error (the special
// error type, meaning that an error occurred when typechecking this expression), // error type, meaning that an error occurred when typechecking this expression),
@ -1623,9 +1623,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
sp: Span, sp: Span,
mk_diag: M, mk_diag: M,
actual_ty: Ty<'tcx>, actual_ty: Ty<'tcx>,
) -> Diag<'tcx> ) -> Diag<'a>
where where
M: FnOnce(String) -> Diag<'tcx>, M: FnOnce(String) -> Diag<'a>,
{ {
let actual_ty = self.resolve_vars_if_possible(actual_ty); let actual_ty = self.resolve_vars_if_possible(actual_ty);
debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty); debug!("type_error_struct_with_diag({:?}, {:?})", sp, actual_ty);