@@ -15,7 +15,7 @@ use rustc_hir::def_id::DefId;
1515use rustc_macros:: { HashStable , TyDecodable , TyEncodable , TypeFoldable , extension} ;
1616use rustc_span:: { DUMMY_SP , Span , Symbol , kw, sym} ;
1717use rustc_type_ir:: TyKind :: * ;
18- use rustc_type_ir:: inherent:: { AdtDef , IntoKind } ;
18+ use rustc_type_ir:: inherent:: IntoKind ;
1919use rustc_type_ir:: solve:: SizedTraitKind ;
2020use rustc_type_ir:: walk:: TypeWalker ;
2121use rustc_type_ir:: { self as ir, BoundVar , CollectAndApply , TypeVisitableExt , elaborate} ;
@@ -363,123 +363,123 @@ impl ParamConst {
363363
364364/// Constructors for `Ty`
365365impl < ' tcx > Ty < ' tcx > {
366- #[ inline]
367- pub fn new_infer ( tcx : TyCtxt < ' tcx > , infer : ty:: InferTy ) -> Ty < ' tcx > {
368- Ty :: new ( tcx, TyKind :: Infer ( infer) )
369- }
370-
371- #[ inline]
372- pub fn new_var ( tcx : TyCtxt < ' tcx > , v : ty:: TyVid ) -> Ty < ' tcx > {
373- // Use a pre-interned one when possible.
374- tcx. types
375- . ty_vars
376- . get ( v. as_usize ( ) )
377- . copied ( )
378- . unwrap_or_else ( || Ty :: new ( tcx, Infer ( TyVar ( v) ) ) )
379- }
380-
381- #[ inline]
382- pub fn new_int_var ( tcx : TyCtxt < ' tcx > , v : ty:: IntVid ) -> Ty < ' tcx > {
383- Ty :: new_infer ( tcx, IntVar ( v) )
384- }
366+ // #[inline]
367+ // pub fn new_infer(tcx: TyCtxt<'tcx>, infer: ty::InferTy) -> Ty<'tcx> {
368+ // Ty::new(tcx, TyKind::Infer(infer))
369+ // }
385370
386- #[ inline]
387- pub fn new_float_var ( tcx : TyCtxt < ' tcx > , v : ty:: FloatVid ) -> Ty < ' tcx > {
388- Ty :: new_infer ( tcx, FloatVar ( v) )
389- }
371+ // #[inline]
372+ // pub fn new_var(tcx: TyCtxt<'tcx>, v: ty::TyVid) -> Ty<'tcx> {
373+ // // Use a pre-interned one when possible.
374+ // tcx.types
375+ // .ty_vars
376+ // .get(v.as_usize())
377+ // .copied()
378+ // .unwrap_or_else(|| Ty::new(tcx, Infer(TyVar(v))))
379+ // }
380+
381+ // #[inline]
382+ // pub fn new_int_var(tcx: TyCtxt<'tcx>, v: ty::IntVid) -> Ty<'tcx> {
383+ // Ty::new_infer(tcx, IntVar(v))
384+ // }
385+
386+ // #[inline]
387+ // pub fn new_float_var(tcx: TyCtxt<'tcx>, v: ty::FloatVid) -> Ty<'tcx> {
388+ // Ty::new_infer(tcx, FloatVar(v))
389+ // }
390390
391- #[ inline]
392- pub fn new_fresh ( tcx : TyCtxt < ' tcx > , n : u32 ) -> Ty < ' tcx > {
393- // Use a pre-interned one when possible.
394- tcx. types
395- . fresh_tys
396- . get ( n as usize )
397- . copied ( )
398- . unwrap_or_else ( || Ty :: new_infer ( tcx, ty:: FreshTy ( n) ) )
399- }
391+ // #[inline]
392+ // pub fn new_fresh(tcx: TyCtxt<'tcx>, n: u32) -> Ty<'tcx> {
393+ // // Use a pre-interned one when possible.
394+ // tcx.types
395+ // .fresh_tys
396+ // .get(n as usize)
397+ // .copied()
398+ // .unwrap_or_else(|| Ty::new_infer(tcx, ty::FreshTy(n)))
399+ // }
400400
401- #[ inline]
402- pub fn new_fresh_int ( tcx : TyCtxt < ' tcx > , n : u32 ) -> Ty < ' tcx > {
403- // Use a pre-interned one when possible.
404- tcx. types
405- . fresh_int_tys
406- . get ( n as usize )
407- . copied ( )
408- . unwrap_or_else ( || Ty :: new_infer ( tcx, ty:: FreshIntTy ( n) ) )
409- }
401+ // #[inline]
402+ // pub fn new_fresh_int(tcx: TyCtxt<'tcx>, n: u32) -> Ty<'tcx> {
403+ // // Use a pre-interned one when possible.
404+ // tcx.types
405+ // .fresh_int_tys
406+ // .get(n as usize)
407+ // .copied()
408+ // .unwrap_or_else(|| Ty::new_infer(tcx, ty::FreshIntTy(n)))
409+ // }
410410
411- #[ inline]
412- pub fn new_fresh_float ( tcx : TyCtxt < ' tcx > , n : u32 ) -> Ty < ' tcx > {
413- // Use a pre-interned one when possible.
414- tcx. types
415- . fresh_float_tys
416- . get ( n as usize )
417- . copied ( )
418- . unwrap_or_else ( || Ty :: new_infer ( tcx, ty:: FreshFloatTy ( n) ) )
419- }
411+ // #[inline]
412+ // pub fn new_fresh_float(tcx: TyCtxt<'tcx>, n: u32) -> Ty<'tcx> {
413+ // // Use a pre-interned one when possible.
414+ // tcx.types
415+ // .fresh_float_tys
416+ // .get(n as usize)
417+ // .copied()
418+ // .unwrap_or_else(|| Ty::new_infer(tcx, ty::FreshFloatTy(n)))
419+ // }
420420
421- #[ inline]
422- pub fn new_param ( tcx : TyCtxt < ' tcx > , index : u32 , name : Symbol ) -> Ty < ' tcx > {
423- Ty :: new ( tcx, Param ( ParamTy { index, name } ) )
424- }
421+ // #[inline]
422+ // pub fn new_param(tcx: TyCtxt<'tcx>, index: u32, name: Symbol) -> Ty<'tcx> {
423+ // Ty::new(tcx, Param(ParamTy { index, name }))
424+ // }
425425
426- #[ inline]
427- pub fn new_bound (
428- tcx : TyCtxt < ' tcx > ,
429- index : ty:: DebruijnIndex ,
430- bound_ty : ty:: BoundTy < ' tcx > ,
431- ) -> Ty < ' tcx > {
432- // Use a pre-interned one when possible.
433- if let ty:: BoundTy { var, kind : ty:: BoundTyKind :: Anon } = bound_ty
434- && let Some ( inner) = tcx. types . anon_bound_tys . get ( index. as_usize ( ) )
435- && let Some ( ty) = inner. get ( var. as_usize ( ) ) . copied ( )
436- {
437- ty
438- } else {
439- Ty :: new ( tcx, Bound ( ty:: BoundVarIndexKind :: Bound ( index) , bound_ty) )
440- }
441- }
426+ // #[inline]
427+ // pub fn new_bound(
428+ // tcx: TyCtxt<'tcx>,
429+ // index: ty::DebruijnIndex,
430+ // bound_ty: ty::BoundTy<'tcx>,
431+ // ) -> Ty<'tcx> {
432+ // // Use a pre-interned one when possible.
433+ // if let ty::BoundTy { var, kind: ty::BoundTyKind::Anon } = bound_ty
434+ // && let Some(inner) = tcx.types.anon_bound_tys.get(index.as_usize())
435+ // && let Some(ty) = inner.get(var.as_usize()).copied()
436+ // {
437+ // ty
438+ // } else {
439+ // Ty::new(tcx, Bound(ty::BoundVarIndexKind::Bound(index), bound_ty))
440+ // }
441+ // }
442442
443- #[ inline]
444- pub fn new_canonical_bound ( tcx : TyCtxt < ' tcx > , var : BoundVar ) -> Ty < ' tcx > {
445- // Use a pre-interned one when possible.
446- if let Some ( ty) = tcx. types . anon_canonical_bound_tys . get ( var. as_usize ( ) ) . copied ( ) {
447- ty
448- } else {
449- Ty :: new (
450- tcx,
451- Bound (
452- ty:: BoundVarIndexKind :: Canonical ,
453- ty:: BoundTy { var, kind : ty:: BoundTyKind :: Anon } ,
454- ) ,
455- )
456- }
457- }
443+ // #[inline]
444+ // pub fn new_canonical_bound(tcx: TyCtxt<'tcx>, var: BoundVar) -> Ty<'tcx> {
445+ // // Use a pre-interned one when possible.
446+ // if let Some(ty) = tcx.types.anon_canonical_bound_tys.get(var.as_usize()).copied() {
447+ // ty
448+ // } else {
449+ // Ty::new(
450+ // tcx,
451+ // Bound(
452+ // ty::BoundVarIndexKind::Canonical,
453+ // ty::BoundTy { var, kind: ty::BoundTyKind::Anon },
454+ // ),
455+ // )
456+ // }
457+ // }
458458
459- #[ inline]
460- pub fn new_placeholder ( tcx : TyCtxt < ' tcx > , placeholder : ty:: PlaceholderType < ' tcx > ) -> Ty < ' tcx > {
461- Ty :: new ( tcx, Placeholder ( placeholder) )
462- }
459+ // #[inline]
460+ // pub fn new_placeholder(tcx: TyCtxt<'tcx>, placeholder: ty::PlaceholderType<'tcx>) -> Ty<'tcx> {
461+ // Ty::new(tcx, Placeholder(placeholder))
462+ // }
463463
464- #[ inline]
465- pub fn new_alias (
466- tcx : TyCtxt < ' tcx > ,
467- kind : ty:: AliasTyKind ,
468- alias_ty : ty:: AliasTy < ' tcx > ,
469- ) -> Ty < ' tcx > {
470- debug_assert_matches ! (
471- ( kind, tcx. def_kind( alias_ty. def_id) ) ,
472- ( ty:: Opaque , DefKind :: OpaqueTy )
473- | ( ty:: Projection | ty:: Inherent , DefKind :: AssocTy )
474- | ( ty:: Free , DefKind :: TyAlias )
475- ) ;
476- Ty :: new ( tcx, Alias ( kind, alias_ty) )
477- }
464+ // #[inline]
465+ // pub fn new_alias(
466+ // tcx: TyCtxt<'tcx>,
467+ // kind: ty::AliasTyKind,
468+ // alias_ty: ty::AliasTy<'tcx>,
469+ // ) -> Ty<'tcx> {
470+ // debug_assert_matches!(
471+ // (kind, tcx.def_kind(alias_ty.def_id)),
472+ // (ty::Opaque, DefKind::OpaqueTy)
473+ // | (ty::Projection | ty::Inherent, DefKind::AssocTy)
474+ // | (ty::Free, DefKind::TyAlias)
475+ // );
476+ // Ty::new(tcx, Alias(kind, alias_ty))
477+ // }
478478
479- #[ inline]
480- pub fn new_pat ( tcx : TyCtxt < ' tcx > , base : Ty < ' tcx > , pat : ty:: Pattern < ' tcx > ) -> Ty < ' tcx > {
481- Ty :: new ( tcx, Pat ( base, pat) )
482- }
479+ // #[inline]
480+ // pub fn new_pat(tcx: TyCtxt<'tcx>, base: Ty<'tcx>, pat: ty::Pattern<'tcx>) -> Ty<'tcx> {
481+ // Ty::new(tcx, Pat(base, pat))
482+ // }
483483
484484 #[ inline]
485485 pub fn new_field_representing_type (
@@ -516,6 +516,12 @@ impl<'tcx> Ty<'tcx> {
516516 Ty :: new_alias ( tcx, ty:: Opaque , AliasTy :: new_from_args ( tcx, def_id, args) )
517517 }
518518
519+ // #[inline]
520+ // #[instrument(level = "debug", skip(tcx))]
521+ // pub fn new_opaque(tcx: TyCtxt<'tcx>, def_id: DefId, args: GenericArgsRef<'tcx>) -> Ty<'tcx> {
522+ // Ty::new_alias(tcx, ty::Opaque, AliasTy::new_from_args(tcx, def_id, args))
523+ // }
524+
519525 /// Constructs a `TyKind::Error` type with current `ErrorGuaranteed`
520526 // pub fn new_error(tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> Ty<'tcx> {
521527 // Ty::new(tcx, Error(guar))
0 commit comments