Skip to content

Ignore non snake case types that can exist in SVD files #397

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

Merged
merged 1 commit into from
Nov 16, 2019

Conversation

mvertescher
Copy link
Contributor

@mvertescher mvertescher commented Nov 12, 2019

Hi! 👋 Thanks for this awesome project!

I've run into a build error generating bindings for the psoc6-pac. Here's a example of one of the many build failures:

error: structure field `data_list_sent_update__status` should have a snake case name
   --> src/ble.rs:187:9
    |
187 |     pub data_list_sent_update__status: self::blell::DATA_LIST_SENT_UPDATE__STATUS,
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `data_list_sent_update_status`

This issue is caused by #![deny(warnings)] and should be fixed by adding the #![allow(non_snake_case)] exception. There may be alternative fixes, I'm open to suggestions!

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @therealprof (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools labels Nov 12, 2019
@therealprof
Copy link
Contributor

The dreaded #![deny(warnings)] strikes again. I'd rather remove that and add explicit deny rules for the things we really do not want to allow.

@therealprof
Copy link
Contributor

@mvertescher
Copy link
Contributor Author

I'd rather remove that and add explicit deny rules for the things we really do not want to allow.

SGTM, I'll update this PR to instead deny a (hopefully safe) list of warnings.

@therealprof
Copy link
Contributor

If you would be so kind to update the CHANGELOG.md and rebase I'd give this a CI run...

@mvertescher
Copy link
Contributor Author

@therealprof I've updated to only deny a subset of warning adopted from the patterns repo (the warnings referenced there are a little out of date, I'll fix that up later).

I think the set of denied warnings should not affect users, but I could be wrong.

@mvertescher
Copy link
Contributor Author

Hrm, taking a closer look at this, there are some rustc lints denied in this change that are explicitly allowed (rustc -W help) by the Rust 1.39.0 compiler:

missing_debug_implementations,
trivial_casts,
unused_import_braces,
unused_results,

I believe that by denying these, we could potentially break future PAC builds. What do you think @therealprof ?

@therealprof
Copy link
Contributor

No idea to be honest. Can you rebase, then we can give it a spin? I'm totally expecting that we will need to tweak those...

@mvertescher
Copy link
Contributor Author

Cool, that sounds good. This branch should be up to date with master. I think we can run CI?

@burrbull
Copy link
Member

bors try

bors bot added a commit that referenced this pull request Nov 13, 2019
@therealprof
Copy link
Contributor

Cool, that sounds good. This branch should be up to date with master. I think we can run CI?

It's still separate commits. ;) Maybe I should have said rebase and squash. It looks a weird to merge a PR that does one thing in a commit and reverses course in the next.

@mvertescher
Copy link
Contributor Author

It's still separate commits. ;) Maybe I should have said rebase and squash. It looks a weird to merge a PR that does one thing in a commit and reverses course in the next.

Ah yes, that makes more sense. :) I'll rebase and squash!

@therealprof
Copy link
Contributor

bors try

@bors
Copy link
Contributor

bors bot commented Nov 13, 2019

try

Already running a review

@bors
Copy link
Contributor

bors bot commented Nov 13, 2019

try

Timed out

@therealprof
Copy link
Contributor

bors try

bors bot added a commit that referenced this pull request Nov 13, 2019
@therealprof
Copy link
Contributor

I think it got confused by the rebase in the middle of the try run. ;)

@therealprof
Copy link
Contributor

As expected tons of errors here:
https://travis-ci.org/rust-embedded/svd2rust/builds/611328824

Not sure whether this is the only one but it's certainly the most common one:
error: trivial cast: &uart0::RegisterBlockas*const uart0::RegisterBlock`

@bors
Copy link
Contributor

bors bot commented Nov 13, 2019

try

Build failed

@therealprof
Copy link
Contributor

@mvertescher Can you have a look at the logs and adjust the PR accordingly?

This change decreases the chance of Rust build failures when SVD
files have strange formatting for types. The changelog has also
been updated.
@mvertescher
Copy link
Contributor Author

mvertescher commented Nov 16, 2019

So, I've removed any deprecated (bad-style) or now allowed lints (like trivial-casts) from the denied lint list. I believe this new configuration should not break any existing crates, but we'll see!

@bors
Copy link
Contributor

bors bot commented Nov 16, 2019

🔒 Permission denied

Existing reviewers: click here to make mvertescher a reviewer

@mvertescher
Copy link
Contributor Author

@therealprof can you give CI a run?

Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@therealprof
Copy link
Contributor

bors r+

bors bot added a commit that referenced this pull request Nov 16, 2019
397: Ignore non snake case types that can exist in SVD files r=therealprof a=mvertescher

Hi! 👋 Thanks for this awesome project!

I've run into a build error generating bindings for the [psoc6-pac](https://github.com/psoc-rs/psoc6-pac). Here's a example of one of the many build failures:

```
error: structure field `data_list_sent_update__status` should have a snake case name
   --> src/ble.rs:187:9
    |
187 |     pub data_list_sent_update__status: self::blell::DATA_LIST_SENT_UPDATE__STATUS,
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `data_list_sent_update_status`
```

This issue is caused by `#![deny(warnings)]` and should be fixed by adding the `#![allow(non_snake_case)]` exception. There may be alternative fixes, I'm open to suggestions! 


Co-authored-by: Matt Vertescher <[email protected]>
@therealprof
Copy link
Contributor

bors d+

@bors
Copy link
Contributor

bors bot commented Nov 16, 2019

✌️ mvertescher can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@therealprof
Copy link
Contributor

Just in case something fails.

@bors
Copy link
Contributor

bors bot commented Nov 16, 2019

Build succeeded

@bors bors bot merged commit 73cfa74 into rust-embedded:master Nov 16, 2019
@mvertescher mvertescher deleted the non-snake-case-types branch November 16, 2019 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants