Refactor away the need for some descr methods.

Instead we use `Display` impls and their `alternate` render scheme to
decide whether we want backticks or not.
This commit is contained in:
Oli Scherer 2023-10-25 16:37:21 +00:00
parent 92b41eeee6
commit c601ade3ad
5 changed files with 32 additions and 38 deletions

View file

@ -372,7 +372,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine {
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let msg = format!("{}s are not allowed in {}s", self.0.descr(), ccx.const_kind());
let msg = format!("{:#}s are not allowed in {}s", self.0, ccx.const_kind());
if let hir::CoroutineKind::Async(hir::CoroutineSource::Block) = self.0 {
ccx.tcx.sess.create_feature_err(
errors::UnallowedOpInConstContext { span, msg },