Skip to content

Clean up imports, fix doc lints, get doctests to pass #59

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

Conversation

trappitsch
Copy link

As discussed in #58, this cleans up the following:

  • Remove the unused imports that are behind feature gates that don't exist anymore
  • Clean up lints for documentation

This cleanup also made the example in measurements.rs discoverable as a doc test, and it didn't pass due to the ![no_std] configuration. Removed the ![no_std] configuration in the example, reordered the description such that the example now also shows up in the docs, and added a note that in no_std environments, use core as std is required when using the macros.

Copy link
Member

@thejpster thejpster left a comment

Choose a reason for hiding this comment

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

Looks good - one suggestion to discuss

@trappitsch
Copy link
Author

Sounds good. I did make that change except for

  • feature gated uses of std.
  • modules where use core as std is already in the header with a #[cfg(not(feature = "std"))].

This also needs a extern crate core now in the example, but no note anymore.

@thejpster
Copy link
Member

Is this still on 2015 edition?

Copy link
Member

@thejpster thejpster left a comment

Choose a reason for hiding this comment

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

I think we should move to 2018 edition, where using core gets much easier.

@trappitsch trappitsch requested a review from thejpster July 21, 2025 14:21
@trappitsch
Copy link
Author

Updated to 2018 edition. I think I got everything obvious at least, it builds, clippy seems happy, and the tests pass... Give this a look and let me know :)

Copy link
Member

@thejpster thejpster left a comment

Choose a reason for hiding this comment

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

Looks much better than what we had before :)

Thanks!

@thejpster
Copy link
Member

Hmm, CI didn't pass.

@trappitsch
Copy link
Author

Oops, looks like I missed some feature combination. Let me get this fixed.

@trappitsch
Copy link
Author

Ah, looks like an unused import lint that was only there in when using the "from_str" feature. Should be fixed... hopefully now

@trappitsch
Copy link
Author

So, there was still a FromString trait missing in the tests for the from_string feature. Should be fixed now. There was also a lint in the from_string feature that was not good, fixed too.

However, I noticed that the serde feature was completely untested and... there were some issues there too. I fixed them and added the serde feature to the CI workflow (into the feature matrix).

As this is already getting the codebase modernized, what do you think of pinning clippy to a newer version? currently CI pins it at 1.52.1, current would be 1.88.1? and we might want to update the actions versions...
checkout to more modern version, actions-rs was archived a few years ago..., the more I look at it, the CI overhaul might be a separate PR? Let me know, happy to help!

Sorry for the mess with failed CI on this PR, I think I tested it all now locally and it should pass.

@thejpster
Copy link
Member

No worries. CI is tricky and this crate is old.

I wouldn't want to go newer than 1.76, which is the oldest supported Ferrocene (https://ferrous-systems.com/blog/ferrocene-24-05-0/).

@thejpster
Copy link
Member

But let's do those updates in another PR.

@trappitsch
Copy link
Author

Clippy is currently pinned to 1.51.1. However, libm is pinned in Cargo.toml to 0.2. libm-2.9 see here changed the edition in all crates to 2021, which makes clippy fail as it doesn't really know what to do with that. Error message is as following:

error: failed to download `libm v0.2.15`

Caused by:
  unable to get packages from source

Caused by:
  failed to parse manifest at `/home/reto/.cargo/registry/src/github.com-1ecc6299db9ec823/libm-0.2.15/Cargo.toml`

Caused by:
  feature `edition2021` is required

  this Cargo does not support nightly features, but if you
  switch to nightly channel you can add
  `cargo-features = ["edition2021"]` to enable this feature

Should we pin clippy to 1.76 and give this a try? At least locally, there's no issue when I run clippy with 1.76, so that's great.

@thejpster
Copy link
Member

Sounds like a good idea.

@thejpster thejpster merged commit 0a1eb8c into rust-embedded-community:master Jul 24, 2025
12 checks passed
@thejpster
Copy link
Member

Appreciate your help on this!

@trappitsch
Copy link
Author

Great, it passed :) Thanks for your patience, much appreciated!

@trappitsch trappitsch deleted the imports_and_doctest_cleanup branch July 24, 2025 12:37
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.

2 participants