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

fix static_mut_refs lint; keep Cargo.lock; move clippy new_without_default lint to Cargo.toml #4

Merged
merged 5 commits into from
Jan 5, 2025

Conversation

zjp-CN
Copy link
Contributor

@zjp-CN zjp-CN commented Jan 3, 2025

See commit messages for details.

Wait... *&raw mut just works. I'll update the code tomorrow. Not really, it's rust-lang/rust-clippy#13783 . Braces are required, or we have to split it into assignment and deref in another line.

This PR is done.

zjp-CN added 3 commits January 3, 2025 20:47
Braces are needed to hinder clippy lint and compact in single line.

Fefer to what I posted on URLO for an example: https://users.rust-lang.org/t/static-mut-refs-lint-is-amusing/123439

---------------------------------------------------------------------------

Raw static_mut_refs lint outputs:

warning: creating a mutable reference to mutable static is discouraged
   --> src/lib.rs:208:17
    |
208 |                 COMMAND_PORT.write(CMOS_DISABLE_NMI | register);
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
    = note: `#[warn(static_mut_refs)]` on by default

warning: creating a mutable reference to mutable static is discouraged
   --> src/lib.rs:209:17
    |
209 |                 DATA_PORT.read()
    |                 ^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a mutable reference to mutable static is discouraged
   --> src/lib.rs:215:17
    |
215 |                 COMMAND_PORT.write(CMOS_DISABLE_NMI | register);
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives

warning: creating a mutable reference to mutable static is discouraged
   --> src/lib.rs:216:17
    |
216 |                 DATA_PORT.write(value)
    |                 ^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
    = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
Copy link
Contributor

@hky1999 hky1999 left a comment

Choose a reason for hiding this comment

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

LGTM

@hky1999 hky1999 merged commit 1990537 into arceos-org:main Jan 5, 2025
3 checks passed
@zjp-CN zjp-CN deleted the fix/lints branch January 5, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants