Skip to content

Commit ff66507

Browse files
Rollup merge of #155866 - oli-obk:push-xunxtyqlvwpk, r=RalfJung
Render `ConstContext` for diagnostics once Probably just a left-over from the `ftl` file removal
2 parents f13610a + 44617ef commit ff66507

2 files changed

Lines changed: 20 additions & 122 deletions

File tree

compiler/rustc_const_eval/src/errors.rs

Lines changed: 18 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,7 @@ pub(crate) struct PanicNonStrErr {
139139
}
140140

141141
#[derive(Diagnostic)]
142-
#[diag(
143-
r#"function pointer calls are not allowed in {$kind ->
144-
[const] constant
145-
[static] static
146-
[const_fn] constant function
147-
*[other] {""}
148-
}s"#
149-
)]
142+
#[diag(r#"function pointer calls are not allowed in {$kind}s"#)]
150143
pub(crate) struct UnallowedFnPointerCall {
151144
#[primary_span]
152145
pub span: Span,
@@ -224,12 +217,7 @@ pub(crate) struct MutableBorrowEscaping {
224217

225218
#[derive(Diagnostic)]
226219
#[diag(
227-
r#"cannot call {$non_or_conditionally}-const formatting macro in {$kind ->
228-
[const] constant
229-
[static] static
230-
[const_fn] constant function
231-
*[other] {""}
232-
}s"#,
220+
r#"cannot call {$non_or_conditionally}-const formatting macro in {$kind}s"#,
233221
code = E0015,
234222
)]
235223
pub(crate) struct NonConstFmtMacroCall {
@@ -240,12 +228,7 @@ pub(crate) struct NonConstFmtMacroCall {
240228
}
241229

242230
#[derive(Diagnostic)]
243-
#[diag(r#"cannot call {$non_or_conditionally}-const {$def_descr} `{$def_path_str}` in {$kind ->
244-
[const] constant
245-
[static] static
246-
[const_fn] constant function
247-
*[other] {""}
248-
}s"#, code = E0015)]
231+
#[diag(r#"cannot call {$non_or_conditionally}-const {$def_descr} `{$def_path_str}` in {$kind}s"#, code = E0015)]
249232
pub(crate) struct NonConstFnCall {
250233
#[primary_span]
251234
pub span: Span,
@@ -256,14 +239,7 @@ pub(crate) struct NonConstFnCall {
256239
}
257240

258241
#[derive(Diagnostic)]
259-
#[diag(
260-
r#"cannot call non-const intrinsic `{$name}` in {$kind ->
261-
[const] constant
262-
[static] static
263-
[const_fn] constant function
264-
*[other] {""}
265-
}s"#
266-
)]
242+
#[diag(r#"cannot call non-const intrinsic `{$name}` in {$kind}s"#)]
267243
pub(crate) struct NonConstIntrinsic {
268244
#[primary_span]
269245
pub span: Span,
@@ -280,12 +256,7 @@ pub(crate) struct UnallowedOpInConstContext {
280256
}
281257

282258
#[derive(Diagnostic)]
283-
#[diag(r#"inline assembly is not allowed in {$kind ->
284-
[const] constant
285-
[static] static
286-
[const_fn] constant function
287-
*[other] {""}
288-
}s"#, code = E0015)]
259+
#[diag(r#"inline assembly is not allowed in {$kind}s"#, code = E0015)]
289260
pub(crate) struct UnallowedInlineAsm {
290261
#[primary_span]
291262
pub span: Span,
@@ -384,14 +355,7 @@ pub(crate) struct RawBytesNote {
384355
}
385356

386357
#[derive(Diagnostic)]
387-
#[diag(
388-
r#"cannot match on `{$ty}` in {$kind ->
389-
[const] constant
390-
[static] static
391-
[const_fn] constant function
392-
*[other] {""}
393-
}s"#
394-
)]
358+
#[diag(r#"cannot match on `{$ty}` in {$kind}s"#)]
395359
#[note("`{$ty}` cannot be compared in compile-time, and therefore cannot be used in `match`es")]
396360
pub(crate) struct NonConstMatchEq<'tcx> {
397361
#[primary_span]
@@ -402,12 +366,7 @@ pub(crate) struct NonConstMatchEq<'tcx> {
402366
}
403367

404368
#[derive(Diagnostic)]
405-
#[diag(r#"cannot use `for` loop on `{$ty}` in {$kind ->
406-
[const] constant
407-
[static] static
408-
[const_fn] constant function
409-
*[other] {""}
410-
}s"#, code = E0015)]
369+
#[diag(r#"cannot use `for` loop on `{$ty}` in {$kind}s"#, code = E0015)]
411370
pub(crate) struct NonConstForLoopIntoIter<'tcx> {
412371
#[primary_span]
413372
pub span: Span,
@@ -417,12 +376,7 @@ pub(crate) struct NonConstForLoopIntoIter<'tcx> {
417376
}
418377

419378
#[derive(Diagnostic)]
420-
#[diag(r#"`?` is not allowed on `{$ty}` in {$kind ->
421-
[const] constant
422-
[static] static
423-
[const_fn] constant function
424-
*[other] {""}
425-
}s"#, code = E0015)]
379+
#[diag(r#"`?` is not allowed on `{$ty}` in {$kind}s"#, code = E0015)]
426380
pub(crate) struct NonConstQuestionBranch<'tcx> {
427381
#[primary_span]
428382
pub span: Span,
@@ -432,12 +386,7 @@ pub(crate) struct NonConstQuestionBranch<'tcx> {
432386
}
433387

434388
#[derive(Diagnostic)]
435-
#[diag(r#"`?` is not allowed on `{$ty}` in {$kind ->
436-
[const] constant
437-
[static] static
438-
[const_fn] constant function
439-
*[other] {""}
440-
}s"#, code = E0015)]
389+
#[diag(r#"`?` is not allowed on `{$ty}` in {$kind}s"#, code = E0015)]
441390
pub(crate) struct NonConstQuestionFromResidual<'tcx> {
442391
#[primary_span]
443392
pub span: Span,
@@ -447,12 +396,7 @@ pub(crate) struct NonConstQuestionFromResidual<'tcx> {
447396
}
448397

449398
#[derive(Diagnostic)]
450-
#[diag(r#"`try` block cannot convert `{$ty}` to the result in {$kind ->
451-
[const] constant
452-
[static] static
453-
[const_fn] constant function
454-
*[other] {""}
455-
}s"#, code = E0015)]
399+
#[diag(r#"`try` block cannot convert `{$ty}` to the result in {$kind}s"#, code = E0015)]
456400
pub(crate) struct NonConstTryBlockFromOutput<'tcx> {
457401
#[primary_span]
458402
pub span: Span,
@@ -462,12 +406,7 @@ pub(crate) struct NonConstTryBlockFromOutput<'tcx> {
462406
}
463407

464408
#[derive(Diagnostic)]
465-
#[diag(r#"cannot convert `{$ty}` into a future in {$kind ->
466-
[const] constant
467-
[static] static
468-
[const_fn] constant function
469-
*[other] {""}
470-
}s"#, code = E0015)]
409+
#[diag(r#"cannot convert `{$ty}` into a future in {$kind}s"#, code = E0015)]
471410
pub(crate) struct NonConstAwait<'tcx> {
472411
#[primary_span]
473412
pub span: Span,
@@ -477,12 +416,7 @@ pub(crate) struct NonConstAwait<'tcx> {
477416
}
478417

479418
#[derive(Diagnostic)]
480-
#[diag(r#"cannot call {$non_or_conditionally}-const closure in {$kind ->
481-
[const] constant
482-
[static] static
483-
[const_fn] constant function
484-
*[other] {""}
485-
}s"#, code = E0015)]
419+
#[diag(r#"cannot call {$non_or_conditionally}-const closure in {$kind}s"#, code = E0015)]
486420
pub(crate) struct NonConstClosure {
487421
#[primary_span]
488422
pub span: Span,
@@ -493,12 +427,7 @@ pub(crate) struct NonConstClosure {
493427
}
494428

495429
#[derive(Diagnostic)]
496-
#[diag(r#"calling const c-variadic functions is unstable in {$kind ->
497-
[const] constant
498-
[static] static
499-
[const_fn] constant function
500-
*[other] {""}
501-
}s"#, code = E0015)]
430+
#[diag(r#"calling const c-variadic functions is unstable in {$kind}s"#, code = E0015)]
502431
pub(crate) struct NonConstCVariadicCall {
503432
#[primary_span]
504433
pub span: Span,
@@ -512,23 +441,9 @@ pub(crate) enum NonConstClosureNote {
512441
#[primary_span]
513442
span: Span,
514443
},
515-
#[note(
516-
r#"function pointers need an RFC before allowed to be called in {$kind ->
517-
[const] constant
518-
[static] static
519-
[const_fn] constant function
520-
*[other] {""}
521-
}s"#
522-
)]
444+
#[note(r#"function pointers need an RFC before allowed to be called in {$kind}s"#)]
523445
FnPtr { kind: ConstContext },
524-
#[note(
525-
r#"closures need an RFC before allowed to be called in {$kind ->
526-
[const] constant
527-
[static] static
528-
[const_fn] constant function
529-
*[other] {""}
530-
}s"#
531-
)]
446+
#[note(r#"closures need an RFC before allowed to be called in {$kind}s"#)]
532447
Closure { kind: ConstContext },
533448
}
534449

@@ -543,12 +458,7 @@ pub(crate) struct ConsiderDereferencing {
543458
}
544459

545460
#[derive(Diagnostic)]
546-
#[diag(r#"cannot call {$non_or_conditionally}-const operator in {$kind ->
547-
[const] constant
548-
[static] static
549-
[const_fn] constant function
550-
*[other] {""}
551-
}s"#, code = E0015)]
461+
#[diag(r#"cannot call {$non_or_conditionally}-const operator in {$kind}s"#, code = E0015)]
552462
pub(crate) struct NonConstOperator {
553463
#[primary_span]
554464
pub span: Span,
@@ -559,12 +469,7 @@ pub(crate) struct NonConstOperator {
559469
}
560470

561471
#[derive(Diagnostic)]
562-
#[diag(r#"cannot perform {$non_or_conditionally}-const deref coercion on `{$ty}` in {$kind ->
563-
[const] constant
564-
[static] static
565-
[const_fn] constant function
566-
*[other] {""}
567-
}s"#, code = E0015)]
472+
#[diag(r#"cannot perform {$non_or_conditionally}-const deref coercion on `{$ty}` in {$kind}s"#, code = E0015)]
568473
#[note("attempting to deref into `{$target_ty}`")]
569474
pub(crate) struct NonConstDerefCoercion<'tcx> {
570475
#[primary_span]
@@ -581,14 +486,7 @@ pub(crate) struct NonConstDerefCoercion<'tcx> {
581486
#[diag("destructor of `{$dropped_ty}` cannot be evaluated at compile-time", code = E0493)]
582487
pub(crate) struct LiveDrop<'tcx> {
583488
#[primary_span]
584-
#[label(
585-
r#"the destructor for this type cannot be evaluated in {$kind ->
586-
[const] constant
587-
[static] static
588-
[const_fn] constant function
589-
*[other] {""}
590-
}s"#
591-
)]
489+
#[label(r#"the destructor for this type cannot be evaluated in {$kind}s"#)]
592490
pub span: Span,
593491
pub kind: ConstContext,
594492
pub dropped_ty: Ty<'tcx>,

compiler/rustc_hir/src/hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,9 +2389,9 @@ impl fmt::Display for ConstContext {
23892389
impl IntoDiagArg for ConstContext {
23902390
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
23912391
DiagArgValue::Str(Cow::Borrowed(match self {
2392-
ConstContext::ConstFn => "const_fn",
2392+
ConstContext::ConstFn => "constant function",
23932393
ConstContext::Static(_) => "static",
2394-
ConstContext::Const { .. } => "const",
2394+
ConstContext::Const { .. } => "constant",
23952395
}))
23962396
}
23972397
}

0 commit comments

Comments
 (0)