Skip to content

Commit 5748b59

Browse files
violations_coverage; unsafe_method impl
1 parent 1fa4977 commit 5748b59

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/linted.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ macro_rules! internal_prudent_unsafe_method {
214214
// We **cannot** just move/take/assign $self by value, in case it's a non-Copy
215215
// **static** variable. See also comments in
216216
// unsafe_method_internal_build_accessors_check_args_call.
217-
let rref = {
217+
let mref = {
218218
#[rustfmt::skip]
219219
#[deny(unused_unsafe)]
220220
// @TODO simplify once https://github.com/rust-lang/rust/issues/15701
@@ -230,10 +230,8 @@ macro_rules! internal_prudent_unsafe_method {
230230
#[expect(unsafe_code)]
231231
)?
232232
let rref = &( $self );
233-
rref
233+
::prudent::unlinted::shared_to_mut( rref )
234234
};
235-
//
236-
let mref = ::prudent::unlinted::shared_to_mut(rref);
237235
#[allow(unused_mut)]
238236
#[allow(invalid_value)]
239237
let mut owned_receiver = ::core::mem::replace(mref, unsafe{ ::core::mem::zeroed() });

src/linted_with_tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub use crate::linted_untested::PRUDENT_INTERNAL_LINTED_VERSION;
5656
/// ```
5757
/// test cfg test:
5858
/// ```test_harness
59+
/// // test_harness -as per https://github.com/rust-lang/rust/issues/148942#issuecomment-3565011334
5960
/// #[cfg(not(test))]
6061
/// compile_error!("NOT DOCTEST!");
6162
/// ```
@@ -195,13 +196,13 @@ pub use crate::linted_untested::internal_prudent_unsafe_method;
195196
pub const _: () = {};
196197

197198
/// ```compile_fail,E0133
198-
#[doc = include_str!("../violations_coverage/unsafe_method/sneaked_unsafe/self_some_args.rs")]
199+
#[doc = include_str!("../violations_coverage/unsafe_method/sneaked_unsafe/self_zero_args.rs")]
199200
/// ```
200201
#[cfg(doctest)]
201202
pub const _: () = {};
202203

203204
/// ```compile_fail,E0133
204-
#[doc = include_str!("../violations_coverage/unsafe_method/sneaked_unsafe/self_zero_args.rs")]
205+
#[doc = include_str!("../violations_coverage/unsafe_method/sneaked_unsafe/self_some_args.rs")]
205206
/// ```
206207
#[cfg(doctest)]
207208
pub const _: () = {};

src/unlinted.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ macro_rules! allow_unsafe_expect_unsafe_is_correct {
316316
/// NOT a part of public API. Pretend to get a mutable reference from a shared reference. For
317317
/// internal/generated **compile-time** checks only.
318318
#[doc(hidden)]
319-
pub const fn shared_to_mut<T>(_: &T) -> &mut T {
319+
pub const fn shared_to_mut<T>(_: &T) -> &'static mut T {
320320
unreachable!()
321321
}
322322

violations_coverage/unsafe_method/sneaked_unsafe/self_zero_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ impl S {
88
}
99

1010
unsafe fn new_receiver() -> S {
11-
unreachable!();
11+
unreachable!()
1212
}
1313

1414
fn main() {

0 commit comments

Comments
 (0)