Skip to content

Commit 339887b

Browse files
LikeLakers2mrchantey
authored andcommitted
Change bevy_reflect::RegisterForReflection::__register() to expect unused variables, rather than putting underscores on the parameter names (bevyengine#17171)
# Objective While checking over bevyengine#17160, it occurred to me that rust-analyzer will copy the method signature exactly, when using tab completion trait methods. This includes provided trait methods that use underscores to silence the `unused_variables` lint. This probably isn't good for users, seeing as how they'll have to remove the underscore if they want to use the parameters. (I mean, they technically don't have to remove the underscore... but usually you don't keep a leading underscore on parameters you're using.) ## Solution Changes `bevy_reflect::RegisterForReflection::__register()` to `#[expect(unused_variables)]`, and removes the underscores from its parameter names. ## Testing N/A
1 parent 8720164 commit 339887b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/bevy_reflect/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,11 @@ pub mod __macro_exports {
691691
note = "consider annotating `{Self}` with `#[derive(Reflect)]`"
692692
)]
693693
pub trait RegisterForReflection {
694-
fn __register(_registry: &mut TypeRegistry) {}
694+
#[expect(
695+
unused_variables,
696+
reason = "The parameters here are intentionally unused by the default implementation; however, putting underscores here will result in the underscores being copied by rust-analyzer's tab completion."
697+
)]
698+
fn __register(registry: &mut TypeRegistry) {}
695699
}
696700

697701
impl<T: GetTypeRegistration> RegisterForReflection for T {

0 commit comments

Comments
 (0)