@@ -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 ( 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.
@@ -1681,7 +1681,7 @@ impl<'tcx> TyCtxt<'tcx> {
1681
1681
// Avoid this in favour of more specific `mk_*` methods, where possible.
1682
1682
#[ allow( rustc:: usage_of_ty_tykind) ]
1683
1683
#[ inline]
1684
- pub fn mk_ty ( self , st : TyKind < ' tcx > ) -> Ty < ' tcx > {
1684
+ pub fn mk_ty_from_kind ( self , st : TyKind < ' tcx > ) -> Ty < ' tcx > {
1685
1685
self . interners . intern_ty (
1686
1686
st,
1687
1687
self . sess ,
@@ -1746,12 +1746,12 @@ impl<'tcx> TyCtxt<'tcx> {
1746
1746
#[ inline]
1747
1747
pub fn mk_adt ( self , def : AdtDef < ' tcx > , substs : SubstsRef < ' tcx > ) -> Ty < ' tcx > {
1748
1748
// Take a copy of substs so that we own the vectors inside.
1749
- self . mk_ty ( Adt ( def, substs) )
1749
+ self . mk_ty_from_kind ( Adt ( def, substs) )
1750
1750
}
1751
1751
1752
1752
#[ inline]
1753
1753
pub fn mk_foreign ( self , def_id : DefId ) -> Ty < ' tcx > {
1754
- self . mk_ty ( Foreign ( def_id) )
1754
+ self . mk_ty_from_kind ( Foreign ( def_id) )
1755
1755
}
1756
1756
1757
1757
fn mk_generic_adt ( self , wrapper_def_id : DefId , ty_param : Ty < ' tcx > ) -> Ty < ' tcx > {
@@ -1768,7 +1768,7 @@ impl<'tcx> TyCtxt<'tcx> {
1768
1768
}
1769
1769
}
1770
1770
} ) ;
1771
- self . mk_ty ( Adt ( adt_def, substs) )
1771
+ self . mk_ty_from_kind ( Adt ( adt_def, substs) )
1772
1772
}
1773
1773
1774
1774
#[ inline]
@@ -1797,12 +1797,12 @@ impl<'tcx> TyCtxt<'tcx> {
1797
1797
1798
1798
#[ inline]
1799
1799
pub fn mk_ptr ( self , tm : TypeAndMut < ' tcx > ) -> Ty < ' tcx > {
1800
- self . mk_ty ( RawPtr ( tm) )
1800
+ self . mk_ty_from_kind ( RawPtr ( tm) )
1801
1801
}
1802
1802
1803
1803
#[ inline]
1804
1804
pub fn mk_ref ( self , r : Region < ' tcx > , tm : TypeAndMut < ' tcx > ) -> Ty < ' tcx > {
1805
- self . mk_ty ( Ref ( r, tm. ty , tm. mutbl ) )
1805
+ self . mk_ty_from_kind ( Ref ( r, tm. ty , tm. mutbl ) )
1806
1806
}
1807
1807
1808
1808
#[ inline]
@@ -1827,22 +1827,26 @@ impl<'tcx> TyCtxt<'tcx> {
1827
1827
1828
1828
#[ inline]
1829
1829
pub fn mk_array ( self , ty : Ty < ' tcx > , n : u64 ) -> Ty < ' tcx > {
1830
- self . mk_ty ( Array ( ty, ty:: Const :: from_target_usize ( self , n) ) )
1830
+ self . mk_ty_from_kind ( Array ( ty, ty:: Const :: from_target_usize ( self , n) ) )
1831
1831
}
1832
1832
1833
1833
#[ inline]
1834
1834
pub fn mk_array_with_const_len ( self , ty : Ty < ' tcx > , ct : Const < ' tcx > ) -> Ty < ' tcx > {
1835
- self . mk_ty ( Array ( ty, ct) )
1835
+ self . mk_ty_from_kind ( Array ( ty, ct) )
1836
1836
}
1837
1837
1838
1838
#[ inline]
1839
1839
pub fn mk_slice ( self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
1840
- self . mk_ty ( Slice ( ty) )
1840
+ self . mk_ty_from_kind ( Slice ( ty) )
1841
1841
}
1842
1842
1843
1843
#[ inline]
1844
1844
pub fn mk_tup ( self , ts : & [ Ty < ' tcx > ] ) -> Ty < ' tcx > {
1845
- if ts. is_empty ( ) { self . types . unit } else { self . mk_ty ( Tuple ( self . mk_type_list ( & ts) ) ) }
1845
+ if ts. is_empty ( ) {
1846
+ self . types . unit
1847
+ } else {
1848
+ self . mk_ty_from_kind ( Tuple ( self . mk_type_list ( & ts) ) )
1849
+ }
1846
1850
}
1847
1851
1848
1852
pub fn mk_tup_from_iter < I , T > ( self , iter : I ) -> T :: Output
@@ -1870,7 +1874,7 @@ impl<'tcx> TyCtxt<'tcx> {
1870
1874
substs : impl IntoIterator < Item : Into < GenericArg < ' tcx > > > ,
1871
1875
) -> Ty < ' tcx > {
1872
1876
let substs = self . check_and_mk_substs ( def_id, substs) ;
1873
- self . mk_ty ( FnDef ( def_id, substs) )
1877
+ self . mk_ty_from_kind ( FnDef ( def_id, substs) )
1874
1878
}
1875
1879
1876
1880
#[ inline( always) ]
@@ -1895,7 +1899,7 @@ impl<'tcx> TyCtxt<'tcx> {
1895
1899
1896
1900
#[ inline]
1897
1901
pub fn mk_fn_ptr ( self , fty : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
1898
- self . mk_ty ( FnPtr ( fty) )
1902
+ self . mk_ty_from_kind ( FnPtr ( fty) )
1899
1903
}
1900
1904
1901
1905
#[ inline]
@@ -1905,7 +1909,7 @@ impl<'tcx> TyCtxt<'tcx> {
1905
1909
reg : ty:: Region < ' tcx > ,
1906
1910
repr : DynKind ,
1907
1911
) -> Ty < ' tcx > {
1908
- self . mk_ty ( Dynamic ( obj, reg, repr) )
1912
+ self . mk_ty_from_kind ( Dynamic ( obj, reg, repr) )
1909
1913
}
1910
1914
1911
1915
#[ inline]
@@ -1919,7 +1923,7 @@ impl<'tcx> TyCtxt<'tcx> {
1919
1923
1920
1924
#[ inline]
1921
1925
pub fn mk_closure ( self , closure_id : DefId , closure_substs : SubstsRef < ' tcx > ) -> Ty < ' tcx > {
1922
- self . mk_ty ( Closure ( closure_id, closure_substs) )
1926
+ self . mk_ty_from_kind ( Closure ( closure_id, closure_substs) )
1923
1927
}
1924
1928
1925
1929
#[ inline]
@@ -1929,12 +1933,12 @@ impl<'tcx> TyCtxt<'tcx> {
1929
1933
generator_substs : SubstsRef < ' tcx > ,
1930
1934
movability : hir:: Movability ,
1931
1935
) -> Ty < ' tcx > {
1932
- self . mk_ty ( Generator ( id, generator_substs, movability) )
1936
+ self . mk_ty_from_kind ( Generator ( id, generator_substs, movability) )
1933
1937
}
1934
1938
1935
1939
#[ inline]
1936
1940
pub fn mk_generator_witness ( self , types : ty:: Binder < ' tcx , & ' tcx List < Ty < ' tcx > > > ) -> Ty < ' tcx > {
1937
- self . mk_ty ( GeneratorWitness ( types) )
1941
+ self . mk_ty_from_kind ( GeneratorWitness ( types) )
1938
1942
}
1939
1943
1940
1944
/// Creates a `&mut Context<'_>` [`Ty`] with erased lifetimes.
@@ -1948,7 +1952,7 @@ impl<'tcx> TyCtxt<'tcx> {
1948
1952
1949
1953
#[ inline]
1950
1954
pub fn mk_generator_witness_mir ( self , id : DefId , substs : SubstsRef < ' tcx > ) -> Ty < ' tcx > {
1951
- self . mk_ty ( GeneratorWitnessMIR ( id, substs) )
1955
+ self . mk_ty_from_kind ( GeneratorWitnessMIR ( id, substs) )
1952
1956
}
1953
1957
1954
1958
#[ inline]
@@ -1959,17 +1963,21 @@ impl<'tcx> TyCtxt<'tcx> {
1959
1963
#[ inline]
1960
1964
pub fn mk_ty_var ( self , v : TyVid ) -> Ty < ' tcx > {
1961
1965
// Use a pre-interned one when possible.
1962
- self . types . ty_vars . get ( v. as_usize ( ) ) . copied ( ) . unwrap_or_else ( || self . mk_ty ( Infer ( TyVar ( v) ) ) )
1966
+ self . types
1967
+ . ty_vars
1968
+ . get ( v. as_usize ( ) )
1969
+ . copied ( )
1970
+ . unwrap_or_else ( || self . mk_ty_from_kind ( Infer ( TyVar ( v) ) ) )
1963
1971
}
1964
1972
1965
1973
#[ inline]
1966
1974
pub fn mk_int_var ( self , v : IntVid ) -> Ty < ' tcx > {
1967
- self . mk_ty ( Infer ( IntVar ( v) ) )
1975
+ self . mk_ty_from_kind ( Infer ( IntVar ( v) ) )
1968
1976
}
1969
1977
1970
1978
#[ inline]
1971
1979
pub fn mk_float_var ( self , v : FloatVid ) -> Ty < ' tcx > {
1972
- self . mk_ty ( Infer ( FloatVar ( v) ) )
1980
+ self . mk_ty_from_kind ( Infer ( FloatVar ( v) ) )
1973
1981
}
1974
1982
1975
1983
#[ inline]
@@ -1979,7 +1987,7 @@ impl<'tcx> TyCtxt<'tcx> {
1979
1987
. fresh_tys
1980
1988
. get ( n as usize )
1981
1989
. copied ( )
1982
- . unwrap_or_else ( || self . mk_ty ( Infer ( ty:: FreshTy ( n) ) ) )
1990
+ . unwrap_or_else ( || self . mk_ty_from_kind ( Infer ( ty:: FreshTy ( n) ) ) )
1983
1991
}
1984
1992
1985
1993
#[ inline]
@@ -1989,7 +1997,7 @@ impl<'tcx> TyCtxt<'tcx> {
1989
1997
. fresh_int_tys
1990
1998
. get ( n as usize )
1991
1999
. copied ( )
1992
- . unwrap_or_else ( || self . mk_ty ( Infer ( ty:: FreshIntTy ( n) ) ) )
2000
+ . unwrap_or_else ( || self . mk_ty_from_kind ( Infer ( ty:: FreshIntTy ( n) ) ) )
1993
2001
}
1994
2002
1995
2003
#[ inline]
@@ -1999,12 +2007,12 @@ impl<'tcx> TyCtxt<'tcx> {
1999
2007
. fresh_float_tys
2000
2008
. get ( n as usize )
2001
2009
. copied ( )
2002
- . unwrap_or_else ( || self . mk_ty ( Infer ( ty:: FreshFloatTy ( n) ) ) )
2010
+ . unwrap_or_else ( || self . mk_ty_from_kind ( Infer ( ty:: FreshFloatTy ( n) ) ) )
2003
2011
}
2004
2012
2005
2013
#[ inline]
2006
2014
pub fn mk_ty_param ( self , index : u32 , name : Symbol ) -> Ty < ' tcx > {
2007
- self . mk_ty ( Param ( ParamTy { index, name } ) )
2015
+ self . mk_ty_from_kind ( Param ( ParamTy { index, name } ) )
2008
2016
}
2009
2017
2010
2018
pub fn mk_param_from_def ( self , param : & ty:: GenericParamDef ) -> GenericArg < ' tcx > {
@@ -2026,17 +2034,17 @@ impl<'tcx> TyCtxt<'tcx> {
2026
2034
2027
2035
#[ inline]
2028
2036
pub fn mk_bound ( self , index : ty:: DebruijnIndex , bound_ty : ty:: BoundTy ) -> Ty < ' tcx > {
2029
- self . mk_ty ( Bound ( index, bound_ty) )
2037
+ self . mk_ty_from_kind ( Bound ( index, bound_ty) )
2030
2038
}
2031
2039
2032
2040
#[ inline]
2033
2041
pub fn mk_placeholder ( self , placeholder : ty:: PlaceholderType ) -> Ty < ' tcx > {
2034
- self . mk_ty ( Placeholder ( placeholder) )
2042
+ self . mk_ty_from_kind ( Placeholder ( placeholder) )
2035
2043
}
2036
2044
2037
2045
#[ inline]
2038
2046
pub fn mk_alias ( self , kind : ty:: AliasKind , alias_ty : ty:: AliasTy < ' tcx > ) -> Ty < ' tcx > {
2039
- self . mk_ty ( Alias ( kind, alias_ty) )
2047
+ self . mk_ty_from_kind ( Alias ( kind, alias_ty) )
2040
2048
}
2041
2049
2042
2050
#[ inline]
@@ -2089,7 +2097,7 @@ impl<'tcx> TyCtxt<'tcx> {
2089
2097
2090
2098
// Avoid this in favour of more specific `mk_re_*` methods, where possible,
2091
2099
// to avoid the cost of the `match`.
2092
- pub fn mk_region ( self , kind : ty:: RegionKind < ' tcx > ) -> Region < ' tcx > {
2100
+ pub fn mk_region_from_kind ( self , kind : ty:: RegionKind < ' tcx > ) -> Region < ' tcx > {
2093
2101
match kind {
2094
2102
ty:: ReEarlyBound ( region) => self . mk_re_early_bound ( region) ,
2095
2103
ty:: ReLateBound ( debruijn, region) => self . mk_re_late_bound ( debruijn, region) ,
0 commit comments