@@ -720,7 +720,7 @@ impl<'tcx> TyCtxt<'tcx> {
720
720
/// Constructs a `TyKind::Error` type with current `ErrorGuaranteed`
721
721
#[ track_caller]
722
722
pub fn ty_error_with_guaranteed ( self , reported : ErrorGuaranteed ) -> Ty < ' tcx > {
723
- self . mk_ty ( Error ( reported) )
723
+ self . mk_ty_from_kind ( Error ( reported) )
724
724
}
725
725
726
726
/// Constructs a `TyKind::Error` type and registers a `delay_span_bug` to ensure it gets used.
@@ -734,7 +734,7 @@ impl<'tcx> TyCtxt<'tcx> {
734
734
#[ track_caller]
735
735
pub fn ty_error_with_message < S : Into < MultiSpan > > ( self , span : S , msg : & str ) -> Ty < ' tcx > {
736
736
let reported = self . sess . delay_span_bug ( span, msg) ;
737
- self . mk_ty ( Error ( reported) )
737
+ self . mk_ty_from_kind ( Error ( reported) )
738
738
}
739
739
740
740
/// Constructs a `RegionKind::ReError` lifetime.
@@ -1686,7 +1686,7 @@ impl<'tcx> TyCtxt<'tcx> {
1686
1686
// Avoid this in favour of more specific `mk_*` methods, where possible.
1687
1687
#[ allow( rustc:: usage_of_ty_tykind) ]
1688
1688
#[ inline]
1689
- pub fn mk_ty ( self , st : TyKind < ' tcx > ) -> Ty < ' tcx > {
1689
+ pub fn mk_ty_from_kind ( self , st : TyKind < ' tcx > ) -> Ty < ' tcx > {
1690
1690
self . interners . intern_ty (
1691
1691
st,
1692
1692
self . sess ,
@@ -1751,12 +1751,12 @@ impl<'tcx> TyCtxt<'tcx> {
1751
1751
#[ inline]
1752
1752
pub fn mk_adt ( self , def : AdtDef < ' tcx > , substs : SubstsRef < ' tcx > ) -> Ty < ' tcx > {
1753
1753
// Take a copy of substs so that we own the vectors inside.
1754
- self . mk_ty ( Adt ( def, substs) )
1754
+ self . mk_ty_from_kind ( Adt ( def, substs) )
1755
1755
}
1756
1756
1757
1757
#[ inline]
1758
1758
pub fn mk_foreign ( self , def_id : DefId ) -> Ty < ' tcx > {
1759
- self . mk_ty ( Foreign ( def_id) )
1759
+ self . mk_ty_from_kind ( Foreign ( def_id) )
1760
1760
}
1761
1761
1762
1762
fn mk_generic_adt ( self , wrapper_def_id : DefId , ty_param : Ty < ' tcx > ) -> Ty < ' tcx > {
@@ -1773,7 +1773,7 @@ impl<'tcx> TyCtxt<'tcx> {
1773
1773
}
1774
1774
}
1775
1775
} ) ;
1776
- self . mk_ty ( Adt ( adt_def, substs) )
1776
+ self . mk_ty_from_kind ( Adt ( adt_def, substs) )
1777
1777
}
1778
1778
1779
1779
#[ inline]
@@ -1802,12 +1802,12 @@ impl<'tcx> TyCtxt<'tcx> {
1802
1802
1803
1803
#[ inline]
1804
1804
pub fn mk_ptr ( self , tm : TypeAndMut < ' tcx > ) -> Ty < ' tcx > {
1805
- self . mk_ty ( RawPtr ( tm) )
1805
+ self . mk_ty_from_kind ( RawPtr ( tm) )
1806
1806
}
1807
1807
1808
1808
#[ inline]
1809
1809
pub fn mk_ref ( self , r : Region < ' tcx > , tm : TypeAndMut < ' tcx > ) -> Ty < ' tcx > {
1810
- self . mk_ty ( Ref ( r, tm. ty , tm. mutbl ) )
1810
+ self . mk_ty_from_kind ( Ref ( r, tm. ty , tm. mutbl ) )
1811
1811
}
1812
1812
1813
1813
#[ inline]
@@ -1832,22 +1832,26 @@ impl<'tcx> TyCtxt<'tcx> {
1832
1832
1833
1833
#[ inline]
1834
1834
pub fn mk_array ( self , ty : Ty < ' tcx > , n : u64 ) -> Ty < ' tcx > {
1835
- self . mk_ty ( Array ( ty, ty:: Const :: from_target_usize ( self , n) ) )
1835
+ self . mk_ty_from_kind ( Array ( ty, ty:: Const :: from_target_usize ( self , n) ) )
1836
1836
}
1837
1837
1838
1838
#[ inline]
1839
1839
pub fn mk_array_with_const_len ( self , ty : Ty < ' tcx > , ct : Const < ' tcx > ) -> Ty < ' tcx > {
1840
- self . mk_ty ( Array ( ty, ct) )
1840
+ self . mk_ty_from_kind ( Array ( ty, ct) )
1841
1841
}
1842
1842
1843
1843
#[ inline]
1844
1844
pub fn mk_slice ( self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
1845
- self . mk_ty ( Slice ( ty) )
1845
+ self . mk_ty_from_kind ( Slice ( ty) )
1846
1846
}
1847
1847
1848
1848
#[ inline]
1849
1849
pub fn mk_tup ( self , ts : & [ Ty < ' tcx > ] ) -> Ty < ' tcx > {
1850
- if ts. is_empty ( ) { self . types . unit } else { self . mk_ty ( Tuple ( self . mk_type_list ( & ts) ) ) }
1850
+ if ts. is_empty ( ) {
1851
+ self . types . unit
1852
+ } else {
1853
+ self . mk_ty_from_kind ( Tuple ( self . mk_type_list ( & ts) ) )
1854
+ }
1851
1855
}
1852
1856
1853
1857
pub fn mk_tup_from_iter < I , T > ( self , iter : I ) -> T :: Output
@@ -1875,7 +1879,7 @@ impl<'tcx> TyCtxt<'tcx> {
1875
1879
substs : impl IntoIterator < Item = impl Into < GenericArg < ' tcx > > > ,
1876
1880
) -> Ty < ' tcx > {
1877
1881
let substs = self . check_and_mk_substs ( def_id, substs) ;
1878
- self . mk_ty ( FnDef ( def_id, substs) )
1882
+ self . mk_ty_from_kind ( FnDef ( def_id, substs) )
1879
1883
}
1880
1884
1881
1885
#[ inline( always) ]
@@ -1900,7 +1904,7 @@ impl<'tcx> TyCtxt<'tcx> {
1900
1904
1901
1905
#[ inline]
1902
1906
pub fn mk_fn_ptr ( self , fty : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
1903
- self . mk_ty ( FnPtr ( fty) )
1907
+ self . mk_ty_from_kind ( FnPtr ( fty) )
1904
1908
}
1905
1909
1906
1910
#[ inline]
@@ -1910,7 +1914,7 @@ impl<'tcx> TyCtxt<'tcx> {
1910
1914
reg : ty:: Region < ' tcx > ,
1911
1915
repr : DynKind ,
1912
1916
) -> Ty < ' tcx > {
1913
- self . mk_ty ( Dynamic ( obj, reg, repr) )
1917
+ self . mk_ty_from_kind ( Dynamic ( obj, reg, repr) )
1914
1918
}
1915
1919
1916
1920
#[ inline]
@@ -1924,7 +1928,7 @@ impl<'tcx> TyCtxt<'tcx> {
1924
1928
1925
1929
#[ inline]
1926
1930
pub fn mk_closure ( self , closure_id : DefId , closure_substs : SubstsRef < ' tcx > ) -> Ty < ' tcx > {
1927
- self . mk_ty ( Closure ( closure_id, closure_substs) )
1931
+ self . mk_ty_from_kind ( Closure ( closure_id, closure_substs) )
1928
1932
}
1929
1933
1930
1934
#[ inline]
@@ -1934,12 +1938,12 @@ impl<'tcx> TyCtxt<'tcx> {
1934
1938
generator_substs : SubstsRef < ' tcx > ,
1935
1939
movability : hir:: Movability ,
1936
1940
) -> Ty < ' tcx > {
1937
- self . mk_ty ( Generator ( id, generator_substs, movability) )
1941
+ self . mk_ty_from_kind ( Generator ( id, generator_substs, movability) )
1938
1942
}
1939
1943
1940
1944
#[ inline]
1941
1945
pub fn mk_generator_witness ( self , types : ty:: Binder < ' tcx , & ' tcx List < Ty < ' tcx > > > ) -> Ty < ' tcx > {
1942
- self . mk_ty ( GeneratorWitness ( types) )
1946
+ self . mk_ty_from_kind ( GeneratorWitness ( types) )
1943
1947
}
1944
1948
1945
1949
/// Creates a `&mut Context<'_>` [`Ty`] with erased lifetimes.
@@ -1953,7 +1957,7 @@ impl<'tcx> TyCtxt<'tcx> {
1953
1957
1954
1958
#[ inline]
1955
1959
pub fn mk_generator_witness_mir ( self , id : DefId , substs : SubstsRef < ' tcx > ) -> Ty < ' tcx > {
1956
- self . mk_ty ( GeneratorWitnessMIR ( id, substs) )
1960
+ self . mk_ty_from_kind ( GeneratorWitnessMIR ( id, substs) )
1957
1961
}
1958
1962
1959
1963
#[ inline]
@@ -1964,17 +1968,21 @@ impl<'tcx> TyCtxt<'tcx> {
1964
1968
#[ inline]
1965
1969
pub fn mk_ty_var ( self , v : TyVid ) -> Ty < ' tcx > {
1966
1970
// Use a pre-interned one when possible.
1967
- self . types . ty_vars . get ( v. as_usize ( ) ) . copied ( ) . unwrap_or_else ( || self . mk_ty ( Infer ( TyVar ( v) ) ) )
1971
+ self . types
1972
+ . ty_vars
1973
+ . get ( v. as_usize ( ) )
1974
+ . copied ( )
1975
+ . unwrap_or_else ( || self . mk_ty_from_kind ( Infer ( TyVar ( v) ) ) )
1968
1976
}
1969
1977
1970
1978
#[ inline]
1971
1979
pub fn mk_int_var ( self , v : IntVid ) -> Ty < ' tcx > {
1972
- self . mk_ty ( Infer ( IntVar ( v) ) )
1980
+ self . mk_ty_from_kind ( Infer ( IntVar ( v) ) )
1973
1981
}
1974
1982
1975
1983
#[ inline]
1976
1984
pub fn mk_float_var ( self , v : FloatVid ) -> Ty < ' tcx > {
1977
- self . mk_ty ( Infer ( FloatVar ( v) ) )
1985
+ self . mk_ty_from_kind ( Infer ( FloatVar ( v) ) )
1978
1986
}
1979
1987
1980
1988
#[ inline]
@@ -1984,7 +1992,7 @@ impl<'tcx> TyCtxt<'tcx> {
1984
1992
. fresh_tys
1985
1993
. get ( n as usize )
1986
1994
. copied ( )
1987
- . unwrap_or_else ( || self . mk_ty ( Infer ( ty:: FreshTy ( n) ) ) )
1995
+ . unwrap_or_else ( || self . mk_ty_from_kind ( Infer ( ty:: FreshTy ( n) ) ) )
1988
1996
}
1989
1997
1990
1998
#[ inline]
@@ -1994,7 +2002,7 @@ impl<'tcx> TyCtxt<'tcx> {
1994
2002
. fresh_int_tys
1995
2003
. get ( n as usize )
1996
2004
. copied ( )
1997
- . unwrap_or_else ( || self . mk_ty ( Infer ( ty:: FreshIntTy ( n) ) ) )
2005
+ . unwrap_or_else ( || self . mk_ty_from_kind ( Infer ( ty:: FreshIntTy ( n) ) ) )
1998
2006
}
1999
2007
2000
2008
#[ inline]
@@ -2004,12 +2012,12 @@ impl<'tcx> TyCtxt<'tcx> {
2004
2012
. fresh_float_tys
2005
2013
. get ( n as usize )
2006
2014
. copied ( )
2007
- . unwrap_or_else ( || self . mk_ty ( Infer ( ty:: FreshFloatTy ( n) ) ) )
2015
+ . unwrap_or_else ( || self . mk_ty_from_kind ( Infer ( ty:: FreshFloatTy ( n) ) ) )
2008
2016
}
2009
2017
2010
2018
#[ inline]
2011
2019
pub fn mk_ty_param ( self , index : u32 , name : Symbol ) -> Ty < ' tcx > {
2012
- self . mk_ty ( Param ( ParamTy { index, name } ) )
2020
+ self . mk_ty_from_kind ( Param ( ParamTy { index, name } ) )
2013
2021
}
2014
2022
2015
2023
pub fn mk_param_from_def ( self , param : & ty:: GenericParamDef ) -> GenericArg < ' tcx > {
@@ -2031,17 +2039,17 @@ impl<'tcx> TyCtxt<'tcx> {
2031
2039
2032
2040
#[ inline]
2033
2041
pub fn mk_bound ( self , index : ty:: DebruijnIndex , bound_ty : ty:: BoundTy ) -> Ty < ' tcx > {
2034
- self . mk_ty ( Bound ( index, bound_ty) )
2042
+ self . mk_ty_from_kind ( Bound ( index, bound_ty) )
2035
2043
}
2036
2044
2037
2045
#[ inline]
2038
2046
pub fn mk_placeholder ( self , placeholder : ty:: PlaceholderType ) -> Ty < ' tcx > {
2039
- self . mk_ty ( Placeholder ( placeholder) )
2047
+ self . mk_ty_from_kind ( Placeholder ( placeholder) )
2040
2048
}
2041
2049
2042
2050
#[ inline]
2043
2051
pub fn mk_alias ( self , kind : ty:: AliasKind , alias_ty : ty:: AliasTy < ' tcx > ) -> Ty < ' tcx > {
2044
- self . mk_ty ( Alias ( kind, alias_ty) )
2052
+ self . mk_ty_from_kind ( Alias ( kind, alias_ty) )
2045
2053
}
2046
2054
2047
2055
#[ inline]
@@ -2094,7 +2102,7 @@ impl<'tcx> TyCtxt<'tcx> {
2094
2102
2095
2103
// Avoid this in favour of more specific `mk_re_*` methods, where possible,
2096
2104
// to avoid the cost of the `match`.
2097
- pub fn mk_region ( self , kind : ty:: RegionKind < ' tcx > ) -> Region < ' tcx > {
2105
+ pub fn mk_region_from_kind ( self , kind : ty:: RegionKind < ' tcx > ) -> Region < ' tcx > {
2098
2106
match kind {
2099
2107
ty:: ReEarlyBound ( region) => self . mk_re_early_bound ( region) ,
2100
2108
ty:: ReLateBound ( debruijn, region) => self . mk_re_late_bound ( debruijn, region) ,
0 commit comments