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

loadfn does not need to be mutable? #502

Open
hofstee opened this issue Aug 25, 2019 · 4 comments
Open

loadfn does not need to be mutable? #502

hofstee opened this issue Aug 25, 2019 · 4 comments

Comments

@hofstee
Copy link

hofstee commented Aug 25, 2019

I'm seeing this warning on rust nightly:

warning: variable does not need to be mutable
 --> out/gl_bindings.rs:9:23
  |
9 |         fn metaloadfn(mut loadfn: &mut FnMut(&str) -> *const __gl_imports::raw::c_void,
  |                       ----^^^^^^
  |                       |
  |                       help: remove this `mut`
  |
  = note: #[warn(unused_mut)] on by default

Is this necessary or am I doing something wrong? Is there a way I can configure it to not have this warning in my build.rs?

@brendanzab
Copy link
Owner

Hmm, this might be an issue with how we are generating the bindings. What is the source code around out/gl_bindings.rs:9:23?

@brendanzab
Copy link
Owner

In the interim you'll be able to suppress this by adding the #[allow(unused_mut)] attribute to wherever you reference the bindings, but we should really fix this in the generator.

@hofstee
Copy link
Author

hofstee commented Aug 26, 2019

Here's the first few lines of the generated code:


        mod __gl_imports {
            pub use std::mem;
            pub use std::os::raw;
        }
    

        #[inline(never)]
        fn metaloadfn(mut loadfn: &mut FnMut(&str) -> *const __gl_imports::raw::c_void,
                      symbol: &str,
                      fallbacks: &[&str]) -> *const __gl_imports::raw::c_void {
            let mut ptr = loadfn(symbol);
            if ptr.is_null() {
                for &sym in fallbacks {
                    ptr = loadfn(sym);
                    if !ptr.is_null() { break; }
                }
            }
            ptr
        }
    

        pub mod types {
            #![allow(non_camel_case_types, non_snake_case, dead_code, missing_copy_implementations)]

@brendanzab
Copy link
Owner

brendanzab commented Aug 26, 2019

Yeah, it seems that the mut on mut loadfn is unnecessary, due to the &mut on the type! We should fix the generator to not generate this 🤔

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

2 participants