diff options
| author | Tshepang Mbambo <tshepang@gmail.com> | 2023-02-21 22:27:16 +0200 |
|---|---|---|
| committer | Tshepang Mbambo <tshepang@gmail.com> | 2023-02-21 22:27:16 +0200 |
| commit | b483816d88ebea5890f4810617ef5f2fabb25494 (patch) | |
| tree | 13cea97d0276d8902083ba43af44fa65c2dacf83 /compiler/rustc_hir_analysis | |
| parent | 3200982b7689ff496e63584c5c8f9bf707b98ae3 (diff) | |
| download | rust-b483816d88ebea5890f4810617ef5f2fabb25494.tar.gz rust-b483816d88ebea5890f4810617ef5f2fabb25494.zip | |
hir-analysis: make one diagnostic translatable
Diffstat (limited to 'compiler/rustc_hir_analysis')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/errors.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/lib.rs | 5 |
2 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 04f5f3f6276..f3c3c02a05f 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -312,3 +312,12 @@ pub struct AutoDerefReachedRecursionLimit<'a> { pub suggested_limit: rustc_session::Limit, pub crate_name: Symbol, } + +#[derive(Diagnostic)] +#[diag(hir_analysis_track_caller_on_main)] +pub(crate) struct TrackCallerOnMain { + #[primary_span] + pub span: Span, + #[label] + pub annotated: Span, +} diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 11240cf22e4..73a71376662 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -297,10 +297,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { } for attr in tcx.get_attrs(main_def_id, sym::track_caller) { - tcx.sess - .struct_span_err(attr.span, "`main` function is not allowed to be `#[track_caller]`") - .span_label(main_span, "`main` function is not allowed to be `#[track_caller]`") - .emit(); + tcx.sess.emit_err(errors::TrackCallerOnMain { span: attr.span, annotated: main_span }); error = true; } |
