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

Suggestion: Don't lose trailing semicolons (and other context-relevant stuff) #1076

Closed
killercup opened this issue Jul 9, 2016 · 3 comments

Comments

@killercup
Copy link
Member

Some suggestions for lines that end with ; do not currently end with a ;?

Just got this one in my rustfix demo:

Info: transmute from a pointer type (`*mut libc::c_void`) to a reference type (`&mut Box<for<'r, 'r> std::ops::FnMut(&'r menus::MenuItem, &'r windows::Window)>`)
      #[warn(transmute_ptr_to_ref)] on by default
  --> src/menus.rs:50:17-51:76
Suggestion - Replace:

    mem::transmute::<*mut c_void,
                     &mut Box<FnMut(&MenuItem, &Window)>>(data)(&menu_item, &window);

with:

    &mut *(data as *mut Box<for<'r, 'r> std::ops::FnMut(&'r menus::MenuItem, &'r windows::Window)>)

(note the missing semicolon in the suggestion).

@oli-obk
Copy link
Contributor

oli-obk commented Aug 17, 2016

it suggests to replace transmute(x) with &mut *(data as *...), the function arguments are missing entirely, since they are outside the span that should be replaced.

The bug here is, that there are no parens around the &mut *(x) part, because that's needed so (&mut *(x))(args); works

@mcarton
Copy link
Member

mcarton commented Aug 17, 2016

IIRC, rustfix always displays only the changed part after “replace […] with:”, and always ignores the context (including the rest of the line), hence the missing (&menu_item, &window);.

@camsteffen
Copy link
Contributor

Output looks quite different these days

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

No branches or pull requests

4 participants