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

Ignore clippy warnings in generated code #279

Merged

Conversation

7sDream
Copy link
Contributor

@7sDream 7sDream commented Jul 11, 2022

Just meet clippy::unused_unit warning with a tiny test wit file:

because of generated code has redundant unit type/value in function signature/body, example:

    pub fn send(evt: EventParam<'_>) -> () {
        unsafe {
            // ... omit ...
            wit_import(result3_0, result3_1, result3_2, result3_3, result3_4);
            ()
        }
    }

This PR attempts to remove them, which in turn eliminates thoose warnings.

PS:Didn't find a good way to determine the return type during instruction translation, currently using string matching, if there is a better way please let me know.

@alexcrichton
Copy link
Member

Personally I would prefer to keep the code generator clean so I would rather not be appeasing clippy in the generated code. Is there a way to get clippy to ignore all generated code?

@Liamolucko
Copy link
Contributor

Liamolucko commented Jul 11, 2022

From rust-lang/rust-clippy#702, it looks like you can blanket #[allow(clippy)] #[allow(clippy::all)] (looks like it was changed since the question was first answered).

@7sDream
Copy link
Contributor Author

7sDream commented Jul 12, 2022

I would prefer to keep the code generator clean

it makes sense.

Add a allow attr on the top of each generated module seems a better idea, will try to change to use this method today.

@7sDream
Copy link
Contributor Author

7sDream commented Jul 12, 2022

#[allow(clippy::all)] attribute at module level just finished.

But I notice that there is a standalone option (in gen-rust-wasm), when user enable it, generated items will not be wrapped in a module, so they will continue face lint warnings.

Since I never use this option, It's pretty OK for me, but I'm not sure if this inconsistency is acceptable...

@7sDream 7sDream changed the title fix(gen-rust-wasm): get rid of unused unit warning Ignore clippy warnings in generated code Jul 12, 2022
@alexcrichton alexcrichton merged commit 128fd67 into bytecodealliance:main Jul 12, 2022
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

Successfully merging this pull request may close these issues.

3 participants