Skip to content

Commit b0eb394

Browse files
committed
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.
1 parent b22c349 commit b0eb394

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub trait TypeInformationCtxt<'tcx> {
160160

161161
fn try_structurally_resolve_type(&self, span: Span, ty: Ty<'tcx>) -> Ty<'tcx>;
162162

163-
fn report_error(&self, span: Span, msg: impl ToString) -> Self::Error;
163+
fn report_bug(&self, span: Span, msg: impl ToString) -> Self::Error;
164164

165165
fn error_reported_in_ty(&self, ty: Ty<'tcx>) -> Result<(), Self::Error>;
166166

@@ -195,7 +195,7 @@ impl<'tcx> TypeInformationCtxt<'tcx> for &FnCtxt<'_, 'tcx> {
195195
(**self).try_structurally_resolve_type(sp, ty)
196196
}
197197

198-
fn report_error(&self, span: Span, msg: impl ToString) -> Self::Error {
198+
fn report_bug(&self, span: Span, msg: impl ToString) -> Self::Error {
199199
self.dcx().span_delayed_bug(span, msg.to_string())
200200
}
201201

@@ -245,7 +245,7 @@ impl<'tcx> TypeInformationCtxt<'tcx> for (&LateContext<'tcx>, LocalDefId) {
245245
t
246246
}
247247

248-
fn report_error(&self, span: Span, msg: impl ToString) -> ! {
248+
fn report_bug(&self, span: Span, msg: impl ToString) -> ! {
249249
span_bug!(span, "{}", msg.to_string())
250250
}
251251

@@ -1218,7 +1218,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
12181218
/// result of `*x'`, effectively, where `x'` is a `Categorization::Upvar` reference
12191219
/// tied to `x`. The type of `x'` will be a borrowed pointer.
12201220
impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx, Cx, D> {
1221-
fn resolve_type_vars_or_error(
1221+
fn resolve_type_vars_or_bug(
12221222
&self,
12231223
id: HirId,
12241224
ty: Option<Ty<'tcx>>,
@@ -1228,10 +1228,10 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
12281228
let ty = self.cx.resolve_vars_if_possible(ty);
12291229
self.cx.error_reported_in_ty(ty)?;
12301230
if ty.is_ty_var() {
1231-
debug!("resolve_type_vars_or_error: infer var from {:?}", ty);
1231+
debug!("resolve_type_vars_or_bug: infer var from {:?}", ty);
12321232
Err(self
12331233
.cx
1234-
.report_error(self.cx.tcx().hir().span(id), "encountered type variable"))
1234+
.report_bug(self.cx.tcx().hir().span(id), "encountered type variable"))
12351235
} else {
12361236
Ok(ty)
12371237
}
@@ -1248,15 +1248,15 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
12481248
}
12491249

12501250
fn node_ty(&self, hir_id: HirId) -> Result<Ty<'tcx>, Cx::Error> {
1251-
self.resolve_type_vars_or_error(hir_id, self.cx.typeck_results().node_type_opt(hir_id))
1251+
self.resolve_type_vars_or_bug(hir_id, self.cx.typeck_results().node_type_opt(hir_id))
12521252
}
12531253

12541254
fn expr_ty(&self, expr: &hir::Expr<'_>) -> Result<Ty<'tcx>, Cx::Error> {
1255-
self.resolve_type_vars_or_error(expr.hir_id, self.cx.typeck_results().expr_ty_opt(expr))
1255+
self.resolve_type_vars_or_bug(expr.hir_id, self.cx.typeck_results().expr_ty_opt(expr))
12561256
}
12571257

12581258
fn expr_ty_adjusted(&self, expr: &hir::Expr<'_>) -> Result<Ty<'tcx>, Cx::Error> {
1259-
self.resolve_type_vars_or_error(
1259+
self.resolve_type_vars_or_bug(
12601260
expr.hir_id,
12611261
self.cx.typeck_results().expr_ty_adjusted_opt(expr),
12621262
)
@@ -1321,7 +1321,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
13211321
debug!("By-ref binding of non-derefable type");
13221322
Err(self
13231323
.cx
1324-
.report_error(pat.span, "by-ref binding of non-derefable type"))
1324+
.report_bug(pat.span, "by-ref binding of non-derefable type"))
13251325
}
13261326
}
13271327
} else {
@@ -1610,7 +1610,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
16101610
Some(ty) => ty,
16111611
None => {
16121612
debug!("explicit deref of non-derefable type: {:?}", base_curr_ty);
1613-
return Err(self.cx.report_error(
1613+
return Err(self.cx.report_bug(
16141614
self.cx.tcx().hir().span(node),
16151615
"explicit deref of non-derefable type",
16161616
));
@@ -1635,7 +1635,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
16351635
let ty::Adt(adt_def, _) = self.cx.try_structurally_resolve_type(span, ty).kind() else {
16361636
return Err(self
16371637
.cx
1638-
.report_error(span, "struct or tuple struct pattern not applied to an ADT"));
1638+
.report_bug(span, "struct or tuple struct pattern not applied to an ADT"));
16391639
};
16401640

16411641
match res {
@@ -1681,7 +1681,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
16811681
let ty = self.cx.typeck_results().node_type(pat_hir_id);
16821682
match self.cx.try_structurally_resolve_type(span, ty).kind() {
16831683
ty::Tuple(args) => Ok(args.len()),
1684-
_ => Err(self.cx.report_error(span, "tuple pattern not applied to a tuple")),
1684+
_ => Err(self.cx.report_bug(span, "tuple pattern not applied to a tuple")),
16851685
}
16861686
}
16871687

@@ -1860,7 +1860,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
18601860
debug!("explicit index of non-indexable type {:?}", place_with_id);
18611861
return Err(self
18621862
.cx
1863-
.report_error(pat.span, "explicit index of non-indexable type"));
1863+
.report_bug(pat.span, "explicit index of non-indexable type"));
18641864
};
18651865
let elt_place = self.cat_projection(
18661866
pat.hir_id,

0 commit comments

Comments
 (0)