Skip to content

Commit 7dca6da

Browse files
committed
used rustc::disallowed_pass_by_ref to silence the kind() error
1 parent 541dd2e commit 7dca6da

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

  • compiler/rustc_type_ir/src/sty

compiler/rustc_type_ir/src/sty/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -661,14 +661,17 @@ where
661661
I::Region: TypeVisitable<I>,
662662
I::Tys: TypeVisitable<I>,
663663
{
664-
// // It would be nicer if this returned the value instead of a reference,
665-
// // like how `Predicate::kind` and `Region::kind` do. (It would result in
666-
// // many fewer subsequent dereferences.) But that gives a small but
667-
// // noticeable performance hit. See #126069 for details.
668-
// #[inline(always)]
669-
// pub fn kind(&self) -> &TyKind<I> {
670-
// &self.0
671-
// }
664+
// It would be nicer if this returned the value instead of a reference,
665+
// like how `Predicate::kind` and `Region::kind` do. (It would result in
666+
// many fewer subsequent dereferences.) But that gives a small but
667+
// noticeable performance hit. See #126069 for details.
668+
// Using `rustc::disallowed_pass_by_ref` otherwise we need to import the
669+
// `IntoKind` trait everywhere and deference which is a lot of noise
670+
#[expect(rustc::disallowed_pass_by_ref)]
671+
#[inline(always)]
672+
pub fn kind(&self) -> &TyKind<I> {
673+
&self.0
674+
}
672675

673676
// FIXME(compiler-errors): Think about removing this.
674677
#[inline(always)]

0 commit comments

Comments
 (0)