]> git.lizzy.rs Git - rust.git/commitdiff
Inline some `const`s
authorNiki4tap <rombiklol2@gmail.com>
Mon, 19 Dec 2022 12:32:49 +0000 (15:32 +0300)
committerNiki4tap <rombiklol2@gmail.com>
Mon, 19 Dec 2022 12:34:55 +0000 (15:34 +0300)
clippy_lints/src/transmute/transmute_null_to_fn.rs

index 410c9eaaba0f508f53beae821972fcf69c57dfba..e75d7f6bf1d5295eb4134622bcc38b85a2de98ed 100644 (file)
@@ -8,16 +8,19 @@
 
 use super::TRANSMUTE_NULL_TO_FN;
 
-const LINT_MSG: &str = "transmuting a known null pointer into a function pointer";
-const NOTE_MSG: &str = "this transmute results in undefined behavior";
-const HELP_MSG: &str =
-    "try wrapping your function pointer type in `Option<T>` instead, and using `None` as a null pointer value";
-
 fn lint_expr(cx: &LateContext<'_>, expr: &Expr<'_>) {
-    span_lint_and_then(cx, TRANSMUTE_NULL_TO_FN, expr.span, LINT_MSG, |diag| {
-        diag.span_label(expr.span, NOTE_MSG);
-        diag.help(HELP_MSG);
-    });
+    span_lint_and_then(
+        cx,
+        TRANSMUTE_NULL_TO_FN,
+        expr.span,
+        "transmuting a known null pointer into a function pointer",
+        |diag| {
+            diag.span_label(expr.span, "this transmute results in undefined behavior");
+            diag.help(
+               "try wrapping your function pointer type in `Option<T>` instead, and using `None` as a null pointer value"
+            );
+        },
+    );
 }
 
 pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, arg: &'tcx Expr<'_>, to_ty: Ty<'tcx>) -> bool {