From f05a92d15896604faf30d33e73c7d40b98b2ec9c Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 27 May 2022 07:52:56 -0700 Subject: [PATCH] Remove some comments, inline interner fn --- compiler/rustc_metadata/src/rmeta/decoder.rs | 1 + compiler/rustc_middle/src/ty/context.rs | 38 +------------------ compiler/rustc_middle/src/ty/mod.rs | 2 +- .../rustc_typeck/src/check/intrinsicck.rs | 2 +- 4 files changed, 4 insertions(+), 39 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 806db61471a..d9f21fa9bb9 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -382,6 +382,7 @@ impl<'a, 'tcx> TyDecoder for DecodeContext<'a, 'tcx> { type I = TyInterner<'tcx>; + #[inline] fn interner(&self) -> Self::I { TyInterner { tcx: self.tcx() } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 6f548658ef3..c1c7e1389cb 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -94,43 +94,6 @@ pub struct TyInterner<'tcx> { pub tcx: TyCtxt<'tcx>, } -/* -/// We don't ever actually need this. It's only required for derives. -impl<'tcx> Hash for TyInterner<'tcx> { - fn hash(&self, _state: &mut H) {} -} - -/// We don't ever actually need this. It's only required for derives. -impl<'tcx> Ord for TyInterner<'tcx> { - fn cmp(&self, _other: &Self) -> Ordering { - Ordering::Equal - } -} - -/// We don't ever actually need this. It's only required for derives. -impl<'tcx> PartialOrd for TyInterner<'tcx> { - fn partial_cmp(&self, _other: &Self) -> Option { - None - } -} - -/// We don't ever actually need this. It's only required for derives. -impl<'tcx> PartialEq for TyInterner<'tcx> { - fn eq(&self, _other: &Self) -> bool { - false - } -} - -/// We don't ever actually need this. It's only required for derives. -impl<'tcx> Eq for TyInterner<'tcx> {} - -impl fmt::Debug for TyInterner<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "TyInterner") - } -} -*/ - #[allow(rustc::usage_of_ty_tykind)] impl<'tcx> Interner for TyInterner<'tcx> { type AdtDef = ty::AdtDef<'tcx>; @@ -1140,6 +1103,7 @@ pub struct GlobalCtxt<'tcx> { } impl<'tcx> TyCtxt<'tcx> { + #[inline] pub fn interner(self) -> TyInterner<'tcx> { TyInterner { tcx: self } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 25305804d3a..03e8a9cb96c 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -463,7 +463,7 @@ pub(crate) struct TyS<'tcx> { #[rustc_pass_by_value] pub struct Ty<'tcx>(Interned<'tcx, WithStableHash>>); -const LEAKED_BOOL_TY_ALREADY: std::sync::atomic::AtomicBool = +static LEAKED_BOOL_TY_ALREADY: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); /// "Static" bool only used for internal testing. diff --git a/compiler/rustc_typeck/src/check/intrinsicck.rs b/compiler/rustc_typeck/src/check/intrinsicck.rs index 75508009ad8..9cb57759b86 100644 --- a/compiler/rustc_typeck/src/check/intrinsicck.rs +++ b/compiler/rustc_typeck/src/check/intrinsicck.rs @@ -4,7 +4,7 @@ use rustc_hir as hir; use rustc_index::vec::Idx; use rustc_middle::ty::layout::{LayoutError, SizeSkeleton}; -use rustc_middle::ty::{self, FloatTy, InferTy, IntTy, Ty, TyCtxt, TypeFoldable, UintTy, Article}; +use rustc_middle::ty::{self, Article, FloatTy, InferTy, IntTy, Ty, TyCtxt, TypeFoldable, UintTy}; use rustc_session::lint; use rustc_span::{Span, Symbol, DUMMY_SP}; use rustc_target::abi::{Pointer, VariantIdx}; -- GitLab