From 54f7f806c42eaaa9f5cf03bd176bd373cdf3fe1d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 21 Dec 2023 10:58:10 -0800 Subject: [PATCH 1/2] Turn on deny(unsafe_op_in_unsafe_fn) --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index d5a5b99..5d6a458 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,6 +90,7 @@ #![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))] #![cfg_attr(super_unstable, feature(proc_macro_def_site))] #![cfg_attr(doc_cfg, feature(doc_cfg))] +#![deny(unsafe_op_in_unsafe_fn)] #![allow( clippy::cast_lossless, clippy::cast_possible_truncation, From e95447cf07ae73bc7f21ac0d2b39704f38b0715b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 21 Dec 2023 10:58:30 -0800 Subject: [PATCH 2/2] Fill in unsafe blocks inside unsafe functions --- src/lib.rs | 2 +- src/wrapper.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5d6a458..36ea850 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1240,7 +1240,7 @@ impl Literal { // representation. This is not public API other than for quote. #[doc(hidden)] pub unsafe fn from_str_unchecked(repr: &str) -> Self { - Literal::_new(imp::Literal::from_str_unchecked(repr)) + Literal::_new(unsafe { imp::Literal::from_str_unchecked(repr) }) } } diff --git a/src/wrapper.rs b/src/wrapper.rs index 37fdf37..a5d49b5 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -762,7 +762,7 @@ impl Literal { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::from_str(repr).expect("invalid literal")) } else { - Literal::Fallback(fallback::Literal::from_str_unchecked(repr)) + Literal::Fallback(unsafe { fallback::Literal::from_str_unchecked(repr) }) } }