Skip to content

Fix a wrong error message in 2024 edition #140056

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

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

yuk1ty
Copy link
Contributor

@yuk1ty yuk1ty commented Apr 20, 2025

Fixes #139952

@rustbot
Copy link
Collaborator

rustbot commented Apr 20, 2025

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 20, 2025
@@ -1,4 +1,4 @@
warning: creating a shared reference to mutable static is discouraged
warning: creating a shared reference to mutable static is not allowed
Copy link
Contributor Author

@yuk1ty yuk1ty Apr 20, 2025

Choose a reason for hiding this comment

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

I would like to ask if we should keep the error message as "discouraged" here (or other tests related to 2021 Edition) since my update will change the existing message in 2021 Edition 🤔 This is the first time to contribute the diagnostic issue, it would be nice if someone could tell me about the compatibility thing.

Copy link
Member

Choose a reason for hiding this comment

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

The easy way is to reword this message to...

warning: creating a shared reference to mutable static

that way, it doesn't really matter if it's Edition 2021 / 2024.

The more complex way is to introduce different diagnostics between edition < 2024 and edition >= 2024, with edition 2021 wording being

warning: creating a shared reference to mutable static is discouraged

and edition 2024 wording being

error: creating a shared reference to mutable static is not allowed

Copy link

Choose a reason for hiding this comment

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

I agree that creating a shared reference to mutable static is better.

The warning: and error: will be enough information to let people know whether it's discouraged or not allowed.

("error" implies not being allowed and "warning" implies being discouraged)

Copy link
Contributor Author

@yuk1ty yuk1ty Apr 23, 2025

Choose a reason for hiding this comment

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

@jieyouxu @junderw Thank you for the comment. I will follow "creating a shared reference to mutable static" because from my quick investigation, the implementation is going to be really complexed (I think it's possible but) if we employ switching messages between 2021 and 2024.

@yuk1ty yuk1ty force-pushed the fix-static-mut-error-message branch from a8ec2f7 to 01eb091 Compare April 20, 2025 01:54
@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 21, 2025
@yuk1ty yuk1ty force-pushed the fix-static-mut-error-message branch from 01eb091 to 6daa8e9 Compare April 25, 2025 04:18
@rust-log-analyzer

This comment has been minimized.

@yuk1ty yuk1ty force-pushed the fix-static-mut-error-message branch from 6daa8e9 to bffb760 Compare April 26, 2025 05:50
@yuk1ty yuk1ty marked this pull request as ready for review April 26, 2025 11:41
@rustbot
Copy link
Collaborator

rustbot commented Apr 26, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@yuk1ty yuk1ty requested a review from jieyouxu April 26, 2025 11:41
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 26, 2025
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks

@jieyouxu
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 28, 2025

📌 Commit bffb760 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2025
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#140056 (Fix a wrong error message in 2024 edition)
 - rust-lang#140220 (Fix detection of main function if there are expressions around it)
 - rust-lang#140249 (Remove `weak` alias terminology)
 - rust-lang#140316 (Introduce `BoxMarker` to improve pretty-printing correctness)
 - rust-lang#140347 (ci: clean more disk space in codebuild)
 - rust-lang#140349 (ci: use aws codebuild for the `dist-x86_64-linux` job)
 - rust-lang#140379 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2025
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#140056 (Fix a wrong error message in 2024 edition)
 - rust-lang#140220 (Fix detection of main function if there are expressions around it)
 - rust-lang#140249 (Remove `weak` alias terminology)
 - rust-lang#140316 (Introduce `BoxMarker` to improve pretty-printing correctness)
 - rust-lang#140347 (ci: clean more disk space in codebuild)
 - rust-lang#140349 (ci: use aws codebuild for the `dist-x86_64-linux` job)
 - rust-lang#140379 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1a766a8 into rust-lang:master Apr 28, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 28, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 28, 2025
Rollup merge of rust-lang#140056 - yuk1ty:fix-static-mut-error-message, r=jieyouxu

Fix a wrong error message in 2024 edition

Fixes rust-lang#139952
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In edition 2024 error message "error: creating a shared reference to mutable static is discouraged" is wrong
6 participants