Replace const_error methods with Const::new_error

This commit is contained in:
Boxy 2023-07-04 14:46:32 +01:00
parent ddbc774e74
commit d30f56dbf2
15 changed files with 66 additions and 59 deletions

View file

@ -528,13 +528,13 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
let reported = err.emit();
term = match def_kind {
hir::def::DefKind::AssocTy => tcx.ty_error(reported).into(),
hir::def::DefKind::AssocConst => tcx
.const_error(
tcx.type_of(assoc_item_def_id)
.subst(tcx, projection_ty.skip_binder().substs),
reported,
)
.into(),
hir::def::DefKind::AssocConst => ty::Const::new_error(
tcx,
reported,
tcx.type_of(assoc_item_def_id)
.subst(tcx, projection_ty.skip_binder().substs),
)
.into(),
_ => unreachable!(),
};
}

View file

@ -482,7 +482,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
self.astconv.ct_infer(ty, Some(param), inf.span).into()
} else {
self.inferred_params.push(inf.span);
tcx.const_error_misc(ty).into()
ty::Const::new_misc_error(tcx, ty).into()
}
}
_ => unreachable!(),
@ -537,7 +537,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.no_bound_vars()
.expect("const parameter types cannot be generic");
if let Err(guar) = ty.error_reported() {
return tcx.const_error(ty, guar).into();
return ty::Const::new_error(tcx, guar, ty).into();
}
if !infer_args && has_default {
tcx.const_param_default(param.def_id).subst(tcx, substs.unwrap()).into()
@ -546,7 +546,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
self.astconv.ct_infer(ty, Some(param), self.span).into()
} else {
// We've already errored above about the mismatch.
tcx.const_error_misc(ty).into()
ty::Const::new_misc_error(tcx, ty).into()
}
}
}

View file

@ -390,7 +390,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
// left alone.
r => bug!("unexpected region: {r:?}"),
});
self.tcx().const_error_with_message(ty, span, "bad placeholder constant")
ty::Const::new_error_with_message(self.tcx(), ty, span, "bad placeholder constant")
}
fn projected_ty_from_poly_trait_ref(