Skip to content

Workspace-level Clippy lints#1153

Open
rslawson wants to merge 2 commits intomainfrom
rs/clippy-lints
Open

Workspace-level Clippy lints#1153
rslawson wants to merge 2 commits intomainfrom
rs/clippy-lints

Conversation

@rslawson
Copy link
Collaborator

@rslawson rslawson commented Jan 26, 2026

Okay, so. You can set up clippy lints in Cargo.toml to catch some extra
things that might not be included by default in the lint group you're using.
We've discussed wanting to allow a couple things/disallow a couple others that
aren't in the default lint group, so I've done these things:

  1. Added those lints into the workspace Cargo.tomls
  2. Inherited those lints in the individual crates' Cargo.tomls
  3. Adjusted code to respect these new lints and remove now-unnecessary #[allow(clippy::<something>)]s
  4. Adjusted the rest of the code where it was simple to remove any other #[allow(clippy::<something>)]s. If it was a simple rewrite of something I immediately understood, then I made the change. Otherwise, I left it alone.

Closes #1035

@rslawson rslawson force-pushed the rs/clippy-lints branch 2 times, most recently from bbf6a5b to 2977b52 Compare January 27, 2026 15:12
Okay, so. You can set up clippy lints in `Cargo.toml` to catch some extra
things that might not be included by default in the lint group you're using.
We've discussed wanting to allow a couple things/disallow a couple others that
aren't in the default lint group, so I've done these things:
  1. Added those lints into the workspace `Cargo.toml`s
  2. Inherited those lints in the individual crates' `Cargo.toml`s
  3. Adjusted code to respect these new lints and remove now-unnecessary
     `#[allow(clippy::<something>)]`s
  4. Adjusted the rest of the code where it was simple to remove any other
     `#[allow(clippy::<something>)]`s. If it was a simple rewrite of something
     I immediately understood, then I made the change. Otherwise, I left it
     alone.
Comment on lines -196 to +193
instruction_memory: u32::MAX..0,
data_memory: u32::MAX..0,
instruction_memory: 0..0,
data_memory: 0..0,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this change. Is this a result of linting rules?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's because I deleted the #[allow(clippy::reversed_empty_ranges)] just above.

Copy link
Contributor

Choose a reason for hiding this comment

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

Owww! Good guy clippy.

Copy link
Contributor

@hydrolarus hydrolarus Jan 29, 2026

Choose a reason for hiding this comment

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

Below the code uses start = start.min(seg.addr) to calculate the bounds, this doesn't work if the start is 0!

So this edit isn't quite right.

Copy link
Contributor

Choose a reason for hiding this comment

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

As I wrote, this changes the behaviours slightly. It will always increase the size of the memories. Nothing should access this memory, and the memory-mapped regions will still be in the right spots, but it means the reporting of the sizes of memories will not be right. Not sure why that's not caught by the test actually, but I think this should be reverted.

Copy link
Contributor

@hydrolarus hydrolarus left a comment

Choose a reason for hiding this comment

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

Overall looking good, just the elf-loading test should be reverted

Comment on lines +38 to +41
dut ::
(HasCallStack) =>
Circuit (ToConstBwd Mm) (Df System (BitVector 8), CSignal System (ClockControlData LinkCount))
dut =
Copy link
Contributor

Choose a reason for hiding this comment

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

If you made this

Suggested change
dut ::
(HasCallStack) =>
Circuit (ToConstBwd Mm) (Df System (BitVector 8), CSignal System (ClockControlData LinkCount))
dut =
dut ::
(HasCallStack) =>
Circuit (ToConstBwd Mm, ()) (Df System (BitVector 8), CSignal System (ClockControlData LinkCount))
dut =

then below you could use getMMAny to get the memory map and unMemmap to get a circuit without the memory map, meaning less juggling of functions and Circuit wrappers

Comment on lines -196 to +193
instruction_memory: u32::MAX..0,
data_memory: u32::MAX..0,
instruction_memory: 0..0,
data_memory: 0..0,
Copy link
Contributor

Choose a reason for hiding this comment

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

As I wrote, this changes the behaviours slightly. It will always increase the size of the memories. Nothing should access this memory, and the memory-mapped regions will still be in the right spots, but it means the reporting of the sizes of memories will not be right. Not sure why that's not caught by the test actually, but I think this should be reverted.

Comment on lines +349 to +361
impl<T> IntoIterator for Storage<T> {
type Item = (Handle<T>, T);
type IntoIter =
std::iter::Map<std::iter::Enumerate<std::vec::IntoIter<T>>, fn((usize, T)) -> Self::Item>;

fn into_iter(self) -> Self::IntoIter {
self.0
.into_iter()
.enumerate()
.map(|(idx, val)| (Handle(idx, PhantomData), val))
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

cool! Yeah I meant to do this but thought I'd have to use a custom type, using the std types and fn is cool!

I've been wondering if this module should be turned into a crate at some point, I've wanted this for compiler development multiple times before 🙈

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.

Clippy should reject unnamed formatting arguments (when they could have been named)

3 participants