Skip to content

Lint unnecessary transmutes from ref to ptr #930

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

Closed
crumblingstatue opened this issue May 15, 2016 · 2 comments
Closed

Lint unnecessary transmutes from ref to ptr #930

crumblingstatue opened this issue May 15, 2016 · 2 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@crumblingstatue
Copy link

crumblingstatue commented May 15, 2016

We already have transmute_ptr_to_ref, but we could also lint the opposite case.

 fn type_(evt: &mut sfEvent) -> *mut sfEventType {
 -    unsafe { ::std::mem::transmute(evt) }
 +    evt as *mut _ as _
  }
 fn size(evt: &mut sfEvent) -> event::Event {
 -    let e: *mut sfSizeEvent = unsafe { ::std::mem::transmute(evt) };
 +    let e: *mut sfSizeEvent = evt as *mut _ as _;
      unsafe { event::Resized { width: (*e).width, height: (*e).height } }
  }

Ref jeremyletang/rust-sfml@d84ce75?diff=unified

Edit: The as _ trick for the second as only works on 1.10 nightly (rust-lang/rust#33657)

@mcarton mcarton added good-first-issue These issues are a good way to get started with Clippy C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels May 15, 2016
@oli-obk
Copy link
Contributor

oli-obk commented Jun 27, 2016

fixed by #1045

@oli-obk oli-obk closed this as completed Jun 27, 2016
@llogiq
Copy link
Contributor

llogiq commented Jun 27, 2016

Another one bites the dust... 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

No branches or pull requests

4 participants