Skip to content

Commit

Permalink
Address latest clippy warnings
Browse files Browse the repository at this point in the history
Clippy warns when we're re-exporting an empty module, since it detects
our import of that empty module is "unused." I'm not a fan of leaking
the family selection into the top-level module, but I also want signal
if something is exported through the chip module and never used, like a
pub(crate) item. This is the easiest fix to read and write.

The alternates were to hide this complexity down in the `chip/none.rs`
module. I tried a doc(hidden) type that would be re-exported through all
the other modules, then marked the whole none module as allowing unused
imports. Looked strange and took more lines than what's shown here, but
it did solve the problem.

Another approach: change the module structures. We make all chips
responsible for re-exporting common. The none chip would only re-export
common, so there's no more unused imports, and no more empty modules for
the none build. This is a bigger refactor for another time.
  • Loading branch information
mciantyre committed Jan 16, 2024
1 parent 51d4521 commit d639253
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() {
enabled_chip
);

if let Some(chip) = enabled_chip.get(0) {
if let Some(chip) = enabled_chip.first() {
let feat_10xx = features_10xx();
let feat_11xx = features_11xx();

Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ pub mod ccm {
///
/// For examples of using DMA with a peripheral, see the peripheral's documentation.
pub mod dma {
#[cfg_attr(family = "none", allow(unused_imports))] // Nothing to export in this build.
pub use crate::chip::dma::*;
pub use crate::common::dma::*;
}
Expand Down Expand Up @@ -287,8 +288,10 @@ pub mod usbd {
/// [`Pads`](crate::iomuxc::pads::Pads) exposes all pads as individual, owned objects. Use [`configure`](crate::iomuxc::configure)
/// to specify any pad configurations. Then use the pad object(s) to construct your driver.
pub mod iomuxc {
#[cfg_attr(family = "none", allow(unused_imports))] // Nothing to export in this build.
pub use crate::chip::iomuxc::*;
pub use imxrt_iomuxc::prelude::*;
}

#[cfg_attr(family = "none", allow(unused_imports))] // Nothing to export in this build.
pub use crate::chip::reexports::*;

0 comments on commit d639253

Please sign in to comment.