-
Notifications
You must be signed in to change notification settings - Fork 92
Mute clippy transmute warnings #320
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -686,7 +686,7 @@ pub fn generate(input: TokenStream, is_qobject: bool, qt_version: QtVersion) -> | |
} else { | ||
quote! { | ||
#[allow(unused_variables)] | ||
let mut obj = ::std::mem::transmute::<*mut ::std::os::raw::c_void, &mut #name #ty_generics>(o); | ||
let mut obj = &*o; | ||
} | ||
}; | ||
|
||
|
@@ -875,7 +875,12 @@ pub fn generate(input: TokenStream, is_qobject: bool, qt_version: QtVersion) -> | |
.map(|arg| { | ||
let n = &arg.name; | ||
let ty = &arg.typ; | ||
quote! { unsafe { ::std::mem::transmute::<& #ty, *mut ::std::os::raw::c_void>(& #n) } } | ||
quote! { | ||
{ | ||
let mut n = #n; | ||
(&mut n as *mut #ty as *mut ::std::os::raw::c_void) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that doesn't look right. It seems it's taking the address of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure either. This could be catched by the compiler? The code I've tested did not generate any errors. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case it might not be catched by the compiler since the user of the pointer uses unsafe code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I now use marked the function argument as |
||
} | ||
} | ||
}) | ||
.collect(); | ||
let array_size = signal.args.len() + 1; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would think you still need to cast to the right type explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's why the CI is failling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this solution looks wrong. I kept the transmute to cast to the right type as
*mut
, but dereferenced it now to&mut
outside of the transmute.