This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -286,7 +286,9 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
286286}
287287
288288declare_lint ! {
289- /// The `unsafe_code` lint catches usage of `unsafe` code.
289+ /// The `unsafe_code` lint catches usage of `unsafe` code and other
290+ /// potentially unsound constructs like `no_mangle`, `export_name`,
291+ /// and `link_section`.
290292 ///
291293 /// ### Example
292294 ///
@@ -297,17 +299,29 @@ declare_lint! {
297299 ///
298300 /// }
299301 /// }
302+ ///
303+ /// #[no_mangle]
304+ /// fn func_0() { }
305+ ///
306+ /// #[export_name = "exported_symbol_name"]
307+ /// pub fn name_in_rust() { }
308+ ///
309+ /// #[no_mangle]
310+ /// #[link_section = ".example_section"]
311+ /// pub static VAR1: u32 = 1;
300312 /// ```
301313 ///
302314 /// {{produces}}
303315 ///
304316 /// ### Explanation
305317 ///
306- /// This lint is intended to restrict the usage of `unsafe`, which can be
307- /// difficult to use correctly.
318+ /// This lint is intended to restrict the usage of `unsafe` blocks and other
319+ /// constructs (including, but not limited to `no_mangle`, `link_section`
320+ /// and `export_name` attributes) wrong usage of which causes undefined
321+ /// behavior.
308322 UNSAFE_CODE ,
309323 Allow ,
310- "usage of `unsafe` code"
324+ "usage of `unsafe` code and other potentially unsound constructs "
311325}
312326
313327declare_lint_pass ! ( UnsafeCode => [ UNSAFE_CODE ] ) ;
You can’t perform that action at this time.
0 commit comments