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

Document additional constructs caught by the unsafe_code lint #111967

Closed
scottmcm opened this issue May 25, 2023 · 2 comments · Fixed by #112260
Closed

Document additional constructs caught by the unsafe_code lint #111967

scottmcm opened this issue May 25, 2023 · 2 comments · Fixed by #112260
Assignees
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@scottmcm
Copy link
Member

scottmcm commented May 25, 2023

Today, the unsafe_code lint documentation https://doc.rust-lang.org/nightly/rustc/lints/listing/allowed-by-default.html#unsafe-code only mentions that it catches unsafe blocks.

But it actually catches more than that, for example

error: declaration of a `no_mangle` function
 --> src/lib.rs:3:1
  |
3 | #[no_mangle]
  | ^^^^^^^^^^^^
  |
  = note: the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them
note: the lint level is defined here
 --> src/lib.rs:1:11
  |
1 | #![forbid(unsafe_code)]
  |           ^^^^^^^^^^^

It would be nice for the documentation to include examples of those other things that the lint catches because they might result in unsoundness despite the unsafe token not appearing in them.

@scottmcm scottmcm added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label May 25, 2023
@clubby789 clubby789 added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label May 25, 2023
@eval-exec
Copy link
Contributor

@rustbot claim

@eval-exec
Copy link
Contributor

Do we need to indicate unsafe_code will emit no_mangle, export_name and link_section in the unsafe_code lint document?
https://github.com/rust-lang/rust/blob/5783e699b3a8a2fbef7294f200c16a2614c3e7ed/compiler/rustc_lint/src/builtin.rs#L375-L410

@bors bors closed this as completed in a7f46af Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants