Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe ref_cast_custom function emits unused_unsafe lint on toolchains older than 1.65 #37

Closed
dtolnay opened this issue Nov 1, 2022 · 0 comments · Fixed by #38
Closed

Comments

@dtolnay
Copy link
Owner

dtolnay commented Nov 1, 2022

use ref_cast::{ref_cast_custom, RefCastCustom};

#[derive(RefCastCustom)]
#[repr(transparent)]
pub struct Repro(u8);

impl Repro {
    #[ref_cast_custom]
    pub unsafe fn unchecked_ref_cast_mut(x: &mut u8) -> &mut Self;
}
warning: unnecessary `unsafe` block
 --> src/main.rs:9:66
  |
9 |     pub unsafe fn unchecked_ref_cast_mut(x: &mut u8) -> &mut Self;
  |     -------------------------------------------------------------^ unnecessary `unsafe` block
  |     |
  |     because it's nested under this `unsafe` fn
  |
  = note: `#[warn(unused_unsafe)]` on by default
  = note: this `unsafe` block does contain unsafe operations, but those are already allowed in an `unsafe fn`
  = note: `#[allow(unsafe_op_in_unsafe_fn)]` on by default

The warning does not appear anymore on 1.65 (current beta) and up, but we might as well stick an allow(unused_unsafe) into the generated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant