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

Prevent masking value variables with imports #4

Merged
merged 1 commit into from
Sep 23, 2021

Conversation

Disasm
Copy link
Contributor

@Disasm Disasm commented Sep 22, 2021

Fixes #2

@mciantyre
Copy link
Contributor

mciantyre commented Sep 22, 2021

I'm having trouble cherry-picking this commit onto #3. I needed extra {} throughout, changing patterns like

{ use $periph::$reg::$field::offset; offset }

into

{ use $periph::{$reg::$field::offset}; offset }

Why is that? Macros are weak in my Rust understanding.

@Disasm
Copy link
Contributor Author

Disasm commented Sep 23, 2021

Hmm, interesting. I removed braces because they looked useless to me, but apparently they are required for something.

@Disasm
Copy link
Contributor Author

Disasm commented Sep 23, 2021

Updated. Now it works with your tests.

@adamgreig
Copy link
Owner

It's a shame this update reduces the readability of the generated code, but it does nicely solve the shadowing of values, thanks! If it wasn't for rust-lang/rust#48067 we could just write $periph::$reg::$field::offset directly without using it, but alas.

@adamgreig adamgreig merged commit 587e8bd into adamgreig:main Sep 23, 2021
@Disasm Disasm deleted the prevent-masking branch September 24, 2021 04:19
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.

Local variables 'mask', 'offset' shadowed in macros
3 participants