Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hir-analysis: make a helpful note #108337

Merged
merged 1 commit into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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]`
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be turned back into just [label].

Then you can just add ".label = main function is not allowed to be #[track_caller]" back to the ftl file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it so because it's the exact same text, so did not want to repeat it.

pub annotated: Span,
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/rfc-2091-track-caller/error-with-main.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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]`
compiler-errors marked this conversation as resolved.
Show resolved Hide resolved

Expand Down