Skip to content

Document additional constructs caught by the unsafe_code lint #111967

Closed
@scottmcm

Description

@scottmcm

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.

Metadata

Metadata

Assignees

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions