about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTshepang Mbambo <tshepang@gmail.com>2023-02-26 00:01:44 +0200
committerTshepang Mbambo <tshepang@gmail.com>2023-02-26 00:01:44 +0200
commite5d1fcd535cf664f8157a6208797a2df3c5fd17c (patch)
tree0d7e44e39ace4fb70996e5d33e09c16546bc850e
parent31448badfd74ea72d2c8622cc60d3dca889ef7d4 (diff)
downloadrust-e5d1fcd535cf664f8157a6208797a2df3c5fd17c.tar.gz
rust-e5d1fcd535cf664f8157a6208797a2df3c5fd17c.zip
hir-analysis: make a helpful note
-rw-r--r--compiler/rustc_hir_analysis/locales/en-US.ftl2
-rw-r--r--compiler/rustc_hir_analysis/src/errors.rs3
-rw-r--r--tests/ui/rfc-2091-track-caller/error-with-main.stderr2
3 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_hir_analysis/locales/en-US.ftl b/compiler/rustc_hir_analysis/locales/en-US.ftl
index e87731160d9..50b0816889b 100644
--- a/compiler/rustc_hir_analysis/locales/en-US.ftl
+++ b/compiler/rustc_hir_analysis/locales/en-US.ftl
@@ -131,7 +131,7 @@ hir_analysis_where_clause_on_main = `main` function is not allowed to have a `wh
     .label = `main` cannot have a `where` clause
 
 hir_analysis_track_caller_on_main = `main` function is not allowed to be `#[track_caller]`
-    .label = `main` function is not allowed to be `#[track_caller]`
+    .suggestion = remove this annotation
 
 hir_analysis_start_not_track_caller = `start` is not allowed to be `#[track_caller]`
     .label = `start` is not allowed to be `#[track_caller]`
diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs
index 309d02052b7..a566e73912e 100644
--- a/compiler/rustc_hir_analysis/src/errors.rs
+++ b/compiler/rustc_hir_analysis/src/errors.rs
@@ -329,8 +329,9 @@ pub(crate) struct WhereClauseOnMain {
 #[diag(hir_analysis_track_caller_on_main)]
 pub(crate) struct TrackCallerOnMain {
     #[primary_span]
+    #[suggestion(applicability = "maybe-incorrect", code = "")]
     pub span: Span,
-    #[label]
+    #[label(hir_analysis_track_caller_on_main)]
     pub annotated: Span,
 }
 
diff --git a/tests/ui/rfc-2091-track-caller/error-with-main.stderr b/tests/ui/rfc-2091-track-caller/error-with-main.stderr
index 7e2ec352414..6d6562dae3b 100644
--- a/tests/ui/rfc-2091-track-caller/error-with-main.stderr
+++ b/tests/ui/rfc-2091-track-caller/error-with-main.stderr
@@ -2,7 +2,7 @@ error: `main` function is not allowed to be `#[track_caller]`
   --> $DIR/error-with-main.rs:1:1
    |
 LL | #[track_caller]
-   | ^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^ help: remove this annotation
 LL | fn main() {
    | --------- `main` function is not allowed to be `#[track_caller]`