Fix clippy for Rust 1.69 (#3246)

* Fix clippy for Rust 1.69.

* use std::marker::PhantonData.

* Change callee to caller.
This commit is contained in:
Kaede Hoshikawa 2023-04-29 03:32:11 +09:00 committed by GitHub
parent d0205a8ea3
commit dbe671e8c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,11 +69,20 @@ mod feat_ssr_hydration {
}
impl Collectable {
#[cfg(not(debug_assertions))]
#[inline(always)]
pub fn for_component<T: 'static>() -> Self {
use std::marker::PhantomData;
// This suppresses the clippy lint about unused generic.
// We inline this function
// so the function body is copied to its caller and generics get optimised away.
let _comp_type: PhantomData<T> = PhantomData;
Self::Component(PhantomData)
}
#[cfg(debug_assertions)]
pub fn for_component<T: 'static>() -> Self {
#[cfg(debug_assertions)]
let comp_name = std::any::type_name::<T>();
#[cfg(not(debug_assertions))]
let comp_name = std::marker::PhantomData;
Self::Component(comp_name)
}