Skip to content

Commit d0625a3

Browse files
committed
Allow usage_of_ty_tykind only in sty
and in some special cases
1 parent 8e087cd commit d0625a3

File tree

5 files changed

+27
-19
lines changed

5 files changed

+27
-19
lines changed

src/librustc/ty/codec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub trait EncodableWithShorthand: Clone + Eq + Hash {
2727
fn variant(&self) -> &Self::Variant;
2828
}
2929

30+
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
3031
impl<'tcx> EncodableWithShorthand for Ty<'tcx> {
3132
type Variant = ty::TyKind<'tcx>;
3233
fn variant(&self) -> &Self::Variant {
@@ -159,6 +160,7 @@ where
159160
Ok(decoder.map_encoded_cnum_to_current(cnum))
160161
}
161162

163+
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
162164
#[inline]
163165
pub fn decode_ty<D>(decoder: &mut D) -> Result<Ty<'tcx>, D::Error>
164166
where

src/librustc/ty/context.rs

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ impl<'tcx> CtxtInterners<'tcx> {
135135
}
136136

137137
/// Intern a type
138+
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
138139
#[inline(never)]
139140
fn intern_ty(
140141
local: &CtxtInterners<'tcx>,
@@ -2195,6 +2196,7 @@ impl<'tcx> Hash for Interned<'tcx, TyS<'tcx>> {
21952196
}
21962197
}
21972198

2199+
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
21982200
impl<'tcx> Borrow<TyKind<'tcx>> for Interned<'tcx, TyS<'tcx>> {
21992201
fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> {
22002202
&self.0.sty
@@ -2429,6 +2431,7 @@ impl<'tcx> TyCtxt<'tcx> {
24292431
self.mk_fn_ptr(converted_sig)
24302432
}
24312433

2434+
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
24322435
#[inline]
24332436
pub fn mk_ty(&self, st: TyKind<'tcx>) -> Ty<'tcx> {
24342437
CtxtInterners::intern_ty(&self.interners, &self.global_interners, st)

src/librustc/ty/flags.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ impl FlagComputation {
1818
}
1919
}
2020

21+
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
2122
pub fn for_sty(st: &ty::TyKind<'_>) -> FlagComputation {
2223
let mut result = FlagComputation::new();
2324
result.add_sty(st);
@@ -61,6 +62,7 @@ impl FlagComputation {
6162
} // otherwise, this binder captures nothing
6263
}
6364

65+
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
6466
fn add_sty(&mut self, st: &ty::TyKind<'_>) {
6567
match st {
6668
&ty::Bool |

src/librustc/ty/mod.rs

+18-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// ignore-tidy-filelength
22

3-
#![cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
4-
53
pub use self::Variance::*;
64
pub use self::AssocItemContainer::*;
75
pub use self::BorrowKind::*;
@@ -484,6 +482,7 @@ bitflags! {
484482
}
485483
}
486484

485+
#[cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
487486
pub struct TyS<'tcx> {
488487
pub sty: TyKind<'tcx>,
489488
pub flags: TypeFlags,
@@ -541,29 +540,29 @@ impl<'tcx> Hash for TyS<'tcx> {
541540
impl<'tcx> TyS<'tcx> {
542541
pub fn is_primitive_ty(&self) -> bool {
543542
match self.sty {
544-
TyKind::Bool |
545-
TyKind::Char |
546-
TyKind::Int(_) |
547-
TyKind::Uint(_) |
548-
TyKind::Float(_) |
549-
TyKind::Infer(InferTy::IntVar(_)) |
550-
TyKind::Infer(InferTy::FloatVar(_)) |
551-
TyKind::Infer(InferTy::FreshIntTy(_)) |
552-
TyKind::Infer(InferTy::FreshFloatTy(_)) => true,
553-
TyKind::Ref(_, x, _) => x.is_primitive_ty(),
543+
Bool |
544+
Char |
545+
Int(_) |
546+
Uint(_) |
547+
Float(_) |
548+
Infer(InferTy::IntVar(_)) |
549+
Infer(InferTy::FloatVar(_)) |
550+
Infer(InferTy::FreshIntTy(_)) |
551+
Infer(InferTy::FreshFloatTy(_)) => true,
552+
Ref(_, x, _) => x.is_primitive_ty(),
554553
_ => false,
555554
}
556555
}
557556

558557
pub fn is_suggestable(&self) -> bool {
559558
match self.sty {
560-
TyKind::Opaque(..) |
561-
TyKind::FnDef(..) |
562-
TyKind::FnPtr(..) |
563-
TyKind::Dynamic(..) |
564-
TyKind::Closure(..) |
565-
TyKind::Infer(..) |
566-
TyKind::Projection(..) => false,
559+
Opaque(..) |
560+
FnDef(..) |
561+
FnPtr(..) |
562+
Dynamic(..) |
563+
Closure(..) |
564+
Infer(..) |
565+
Projection(..) => false,
567566
_ => true,
568567
}
569568
}

src/librustc/ty/sty.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! This module contains `TyKind` and its major components.
22
3+
#![cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
4+
35
use crate::hir;
46
use crate::hir::def_id::DefId;
57
use crate::infer::canonical::Canonical;

0 commit comments

Comments
 (0)