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

Fix clippy warnings #189

Merged
merged 1 commit into from May 9, 2018

Conversation

Projects
None yet
3 participants
@EPashkin
Copy link
Member

EPashkin commented May 9, 2018

@EPashkin

This comment has been minimized.

Copy link
Member Author

EPashkin commented May 9, 2018

Last only 3 warnings, I don't fixed now as it breaking change, but IMHO this better changed in future.
pub struct FontFace(Shared<ffi::cairo_font_face_t>);
pub struct ScaledFont(Shared<ffi::cairo_scaled_font_t>);

warning: this argument is passed by value, but not consumed in the function body
  --> src\font\scaled_font.rs:42:27
   |
42 |     pub fn new(font_face: FontFace, font_matrix: &Matrix, ctm: &Matrix, options: &FontOptions) -> ScaledFont {
   |                           ^^^^^^^^ help: consider taking a reference instead: `&FontFace`
   |
   = note: #[warn(needless_pass_by_value)] on by default
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.197/index.html#needless_pass_by_value

warning: this argument is passed by value, but not consumed in the function body
   --> src\context.rs:665:44
    |
665 |     pub fn set_font_face(&self, font_face: FontFace) {
    |                                            ^^^^^^^^ help: consider taking a reference instead: `&FontFace`
    |
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.197/index.html#needless_pass_by_value

warning: this argument is passed by value, but not consumed in the function body
   --> src\context.rs:677:48
    |
677 |     pub fn set_scaled_font(&self, scaled_font: ScaledFont) {
    |                                                ^^^^^^^^^^ help: consider taking a reference instead: `&ScaledFont`
    |
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.197/index.html#needless_pass_by_value
@@ -622,7 +622,8 @@ impl Context {

pub fn select_font_face(&self, family: &str, slant: FontSlant, weight: FontWeight) {
unsafe {
ffi::cairo_select_font_face(self.0, CString::new(family).unwrap().as_ptr(), slant, weight)
let family = CString::new(family).unwrap();
ffi::cairo_select_font_face(self.0, family.as_ptr(), slant, weight)

This comment has been minimized.

@sdroege

sdroege May 9, 2018

Member

Nice catch, these are actually causing memory unsafety in practice

This comment has been minimized.

@EPashkin

EPashkin May 9, 2018

Author Member

All thanks for clippy

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented May 9, 2018

Looks good to me

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented May 9, 2018

Looks good to me as well. Thanks!

@GuillaumeGomez GuillaumeGomez merged commit c3286c0 into gtk-rs:master May 9, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@EPashkin EPashkin deleted the EPashkin:clippy branch May 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.