rust-embedded / svd2rust

Generate Rust register maps (`struct`s) from SVD files
Apache License 2.0
698 stars 150 forks source link

Casting in fields' reader may be unnecessary #671

Closed duskmoon314 closed 1 year ago

duskmoon314 commented 1 year ago

I noticed this warning in the generated code:

warning: casting to the same type is unnecessary (`u32` -> `u32`)
   --> d1-pac/src/ccu/pll_ddr_pat0_ctrl.rs:265:25
    |
265 |         WAVE_BOT_R::new((self.bits & 0x0001_ffff) as u32)
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(self.bits & 0x0001_ffff)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `#[warn(clippy::unnecessary_cast)]` on by default

There are many similar warnings. I haven't checked whether it is simple to tell that RegisterSpec::Ux and #fty are the same types. Maybe add #[allow(...)] if not.