change ct_infer
to a delay_span_bug
This commit is contained in:
parent
7531d2fdd4
commit
a8b71164af
2 changed files with 19 additions and 7 deletions
|
@ -1210,11 +1210,25 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self.mk_ty(Error(DelaySpanBugEmitted(())))
|
||||
}
|
||||
|
||||
/// Like `err` but for constants.
|
||||
/// Like [`ty_error`] but for constants.
|
||||
#[track_caller]
|
||||
pub fn const_error(self, ty: Ty<'tcx>) -> &'tcx Const<'tcx> {
|
||||
self.sess
|
||||
.delay_span_bug(DUMMY_SP, "ty::ConstKind::Error constructed but no error reported.");
|
||||
self.const_error_with_message(
|
||||
ty,
|
||||
DUMMY_SP,
|
||||
"ty::ConstKind::Error constructed but no error reported",
|
||||
)
|
||||
}
|
||||
|
||||
/// Like [`ty_error_with_message`] but for constants.
|
||||
#[track_caller]
|
||||
pub fn const_error_with_message<S: Into<MultiSpan>>(
|
||||
self,
|
||||
ty: Ty<'tcx>,
|
||||
span: S,
|
||||
msg: &str,
|
||||
) -> &'tcx Const<'tcx> {
|
||||
self.sess.delay_span_bug(span, msg);
|
||||
self.mk_const(ty::Const { val: ty::ConstKind::Error(DelaySpanBugEmitted(())), ty })
|
||||
}
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
|
|||
}
|
||||
|
||||
fn ty_infer(&self, _: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx> {
|
||||
self.tcx().ty_error_with_message(span, "bad_placeholder_type")
|
||||
self.tcx().ty_error_with_message(span, "bad placeholder type")
|
||||
}
|
||||
|
||||
fn ct_infer(
|
||||
|
@ -390,13 +390,11 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
|
|||
_: Option<&ty::GenericParamDef>,
|
||||
span: Span,
|
||||
) -> &'tcx Const<'tcx> {
|
||||
bad_placeholder(self.tcx(), "const", vec![span], "generic").emit();
|
||||
// Typeck doesn't expect erased regions to be returned from `type_of`.
|
||||
let ty = self.tcx.fold_regions(ty, &mut false, |r, _| match r {
|
||||
ty::ReErased => self.tcx.lifetimes.re_static,
|
||||
_ => r,
|
||||
});
|
||||
self.tcx().const_error(ty)
|
||||
self.tcx().const_error_with_message(ty, span, "bad placeholder constant")
|
||||
}
|
||||
|
||||
fn projected_ty_from_poly_trait_ref(
|
||||
|
|
Loading…
Reference in a new issue