ExprUseVisitor: error -> bug in helper names
A name like "report_error" suggests that the error in question might be user facing. Use "bug" to make it clear that the error in question will be an ICE.
This commit is contained in:
parent
376c88ee6f
commit
aab12930f5
1 changed files with 14 additions and 14 deletions
|
@ -160,7 +160,7 @@ pub trait TypeInformationCtxt<'tcx> {
|
||||||
|
|
||||||
fn try_structurally_resolve_type(&self, span: Span, ty: Ty<'tcx>) -> Ty<'tcx>;
|
fn try_structurally_resolve_type(&self, span: Span, ty: Ty<'tcx>) -> Ty<'tcx>;
|
||||||
|
|
||||||
fn report_error(&self, span: Span, msg: impl ToString) -> Self::Error;
|
fn report_bug(&self, span: Span, msg: impl ToString) -> Self::Error;
|
||||||
|
|
||||||
fn error_reported_in_ty(&self, ty: Ty<'tcx>) -> Result<(), Self::Error>;
|
fn error_reported_in_ty(&self, ty: Ty<'tcx>) -> Result<(), Self::Error>;
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ impl<'tcx> TypeInformationCtxt<'tcx> for &FnCtxt<'_, 'tcx> {
|
||||||
(**self).try_structurally_resolve_type(sp, ty)
|
(**self).try_structurally_resolve_type(sp, ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_error(&self, span: Span, msg: impl ToString) -> Self::Error {
|
fn report_bug(&self, span: Span, msg: impl ToString) -> Self::Error {
|
||||||
self.dcx().span_delayed_bug(span, msg.to_string())
|
self.dcx().span_delayed_bug(span, msg.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ impl<'tcx> TypeInformationCtxt<'tcx> for (&LateContext<'tcx>, LocalDefId) {
|
||||||
t
|
t
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_error(&self, span: Span, msg: impl ToString) -> ! {
|
fn report_bug(&self, span: Span, msg: impl ToString) -> ! {
|
||||||
span_bug!(span, "{}", msg.to_string())
|
span_bug!(span, "{}", msg.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,7 +1218,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||||
/// result of `*x'`, effectively, where `x'` is a `Categorization::Upvar` reference
|
/// result of `*x'`, effectively, where `x'` is a `Categorization::Upvar` reference
|
||||||
/// tied to `x`. The type of `x'` will be a borrowed pointer.
|
/// tied to `x`. The type of `x'` will be a borrowed pointer.
|
||||||
impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx, Cx, D> {
|
impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx, Cx, D> {
|
||||||
fn resolve_type_vars_or_error(
|
fn resolve_type_vars_or_bug(
|
||||||
&self,
|
&self,
|
||||||
id: HirId,
|
id: HirId,
|
||||||
ty: Option<Ty<'tcx>>,
|
ty: Option<Ty<'tcx>>,
|
||||||
|
@ -1228,10 +1228,10 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||||
let ty = self.cx.resolve_vars_if_possible(ty);
|
let ty = self.cx.resolve_vars_if_possible(ty);
|
||||||
self.cx.error_reported_in_ty(ty)?;
|
self.cx.error_reported_in_ty(ty)?;
|
||||||
if ty.is_ty_var() {
|
if ty.is_ty_var() {
|
||||||
debug!("resolve_type_vars_or_error: infer var from {:?}", ty);
|
debug!("resolve_type_vars_or_bug: infer var from {:?}", ty);
|
||||||
Err(self
|
Err(self
|
||||||
.cx
|
.cx
|
||||||
.report_error(self.cx.tcx().hir().span(id), "encountered type variable"))
|
.report_bug(self.cx.tcx().hir().span(id), "encountered type variable"))
|
||||||
} else {
|
} else {
|
||||||
Ok(ty)
|
Ok(ty)
|
||||||
}
|
}
|
||||||
|
@ -1248,15 +1248,15 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn node_ty(&self, hir_id: HirId) -> Result<Ty<'tcx>, Cx::Error> {
|
fn node_ty(&self, hir_id: HirId) -> Result<Ty<'tcx>, Cx::Error> {
|
||||||
self.resolve_type_vars_or_error(hir_id, self.cx.typeck_results().node_type_opt(hir_id))
|
self.resolve_type_vars_or_bug(hir_id, self.cx.typeck_results().node_type_opt(hir_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_ty(&self, expr: &hir::Expr<'_>) -> Result<Ty<'tcx>, Cx::Error> {
|
fn expr_ty(&self, expr: &hir::Expr<'_>) -> Result<Ty<'tcx>, Cx::Error> {
|
||||||
self.resolve_type_vars_or_error(expr.hir_id, self.cx.typeck_results().expr_ty_opt(expr))
|
self.resolve_type_vars_or_bug(expr.hir_id, self.cx.typeck_results().expr_ty_opt(expr))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> Result<Ty<'tcx>, Cx::Error> {
|
fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> Result<Ty<'tcx>, Cx::Error> {
|
||||||
self.resolve_type_vars_or_error(
|
self.resolve_type_vars_or_bug(
|
||||||
expr.hir_id,
|
expr.hir_id,
|
||||||
self.cx.typeck_results().expr_ty_adjusted_opt(expr),
|
self.cx.typeck_results().expr_ty_adjusted_opt(expr),
|
||||||
)
|
)
|
||||||
|
@ -1321,7 +1321,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||||
debug!("By-ref binding of non-derefable type");
|
debug!("By-ref binding of non-derefable type");
|
||||||
Err(self
|
Err(self
|
||||||
.cx
|
.cx
|
||||||
.report_error(pat.span, "by-ref binding of non-derefable type"))
|
.report_bug(pat.span, "by-ref binding of non-derefable type"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1610,7 +1610,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||||
Some(ty) => ty,
|
Some(ty) => ty,
|
||||||
None => {
|
None => {
|
||||||
debug!("explicit deref of non-derefable type: {:?}", base_curr_ty);
|
debug!("explicit deref of non-derefable type: {:?}", base_curr_ty);
|
||||||
return Err(self.cx.report_error(
|
return Err(self.cx.report_bug(
|
||||||
self.cx.tcx().hir().span(node),
|
self.cx.tcx().hir().span(node),
|
||||||
"explicit deref of non-derefable type",
|
"explicit deref of non-derefable type",
|
||||||
));
|
));
|
||||||
|
@ -1635,7 +1635,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||||
let ty::Adt(adt_def, _) = self.cx.try_structurally_resolve_type(span, ty).kind() else {
|
let ty::Adt(adt_def, _) = self.cx.try_structurally_resolve_type(span, ty).kind() else {
|
||||||
return Err(self
|
return Err(self
|
||||||
.cx
|
.cx
|
||||||
.report_error(span, "struct or tuple struct pattern not applied to an ADT"));
|
.report_bug(span, "struct or tuple struct pattern not applied to an ADT"));
|
||||||
};
|
};
|
||||||
|
|
||||||
match res {
|
match res {
|
||||||
|
@ -1681,7 +1681,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||||
let ty = self.cx.typeck_results().node_type(pat_hir_id);
|
let ty = self.cx.typeck_results().node_type(pat_hir_id);
|
||||||
match self.cx.try_structurally_resolve_type(span, ty).kind() {
|
match self.cx.try_structurally_resolve_type(span, ty).kind() {
|
||||||
ty::Tuple(args) => Ok(args.len()),
|
ty::Tuple(args) => Ok(args.len()),
|
||||||
_ => Err(self.cx.report_error(span, "tuple pattern not applied to a tuple")),
|
_ => Err(self.cx.report_bug(span, "tuple pattern not applied to a tuple")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1860,7 +1860,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
|
||||||
debug!("explicit index of non-indexable type {:?}", place_with_id);
|
debug!("explicit index of non-indexable type {:?}", place_with_id);
|
||||||
return Err(self
|
return Err(self
|
||||||
.cx
|
.cx
|
||||||
.report_error(pat.span, "explicit index of non-indexable type"));
|
.report_bug(pat.span, "explicit index of non-indexable type"));
|
||||||
};
|
};
|
||||||
let elt_place = self.cat_projection(
|
let elt_place = self.cat_projection(
|
||||||
pat.hir_id,
|
pat.hir_id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue