Skip to content

Conversation

@lucasly-ba
Copy link
Contributor

gcc/rust/ChangeLog:

* checks/lints/unused/rust-unused-checker.cc (is_camel_case): Add warning for struct, enum, and trait. (UnusedChecker::visit): New.
* checks/lints/unused/rust-unused-checker.h: New.

gcc/testsuite/ChangeLog:

* rust/compile/non-camel-case-types_0.rs: New test.

Thank you for making Rust GCC better!

If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.

Here is a checklist to help you with your PR.

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

*Please write a comment explaining your change. This is the message
that will be part of the merge commit.

gcc/rust/ChangeLog:

	* checks/lints/unused/rust-unused-checker.cc (is_camel_case):
	Add warning for struct, enum, and trait.
	(UnusedChecker::visit):
	New.
	* checks/lints/unused/rust-unused-checker.h:
	New.

gcc/testsuite/ChangeLog:

	* rust/compile/non-camel-case-types_0.rs: New test.

Signed-off-by: Lucas Ly Ba <[email protected]>
@lucasly-ba lucasly-ba force-pushed the non-camel-case-types branch from ea552aa to 1525d29 Compare January 14, 2026 15:55
@dkm
Copy link
Member

dkm commented Jan 14, 2026

Hello :)
This is not correct:

* checks/lints/unused/rust-unused-checker.h:
	New.

As it can be read as "new file rust-unused-checker.h". A more correct changelog would be:

	* checks/lints/unused/rust-unused-checker.h
	(UnusedChecker::visit(HIR::Trait),UnusedChecker::visit(HIR::StructStruct))
	(UnusedChecker::visit(HIR::TupleStruct),UnusedChecker::visit(HIR::Enum)):
	New.


#include "options.h"
#include "rust-keyword-values.h"
#include <cctype>
Copy link
Member

Choose a reason for hiding this comment

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

This is a system header, which should not be used. Use rust-system.h instead.

Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

The implementation is great - just one nitpick about code location but otherwise we should merge this :)

Comment on lines +137 to +139
UnusedChecker::visit (HIR::Trait &trait)
{
if (!is_camel_case (trait.get_name ()))
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if having this as part of the UnusedChecker is great. I would rather see it as its own pass, or maybe as part of smaller, less-essential lints

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.

4 participants