@@ -1364,8 +1364,7 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
1364
1364
self_param_ty,
1365
1365
bounds. as_slice ( ) ,
1366
1366
unbound,
1367
- it. span ,
1368
- & generics. where_clause ) ;
1367
+ it. span ) ;
1369
1368
1370
1369
let substs = mk_item_substs ( ccx, & ty_generics) ;
1371
1370
let trait_def = Rc :: new ( ty:: TraitDef {
@@ -1619,7 +1618,6 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
1619
1618
subst:: AssocSpace ,
1620
1619
& associated_type. ty_param ,
1621
1620
generics. types . len ( subst:: AssocSpace ) ,
1622
- & ast_generics. where_clause ,
1623
1621
Some ( local_def ( trait_id) ) ) ;
1624
1622
ccx. tcx . ty_param_defs . borrow_mut ( ) . insert ( associated_type. ty_param . id ,
1625
1623
def. clone ( ) ) ;
@@ -1774,7 +1772,6 @@ fn ty_generics<'tcx,AC>(this: &AC,
1774
1772
space,
1775
1773
param,
1776
1774
i,
1777
- where_clause,
1778
1775
None ) ;
1779
1776
debug ! ( "ty_generics: def for type param: {}, {}" ,
1780
1777
def. repr( this. tcx( ) ) ,
@@ -1798,6 +1795,52 @@ fn ty_generics<'tcx,AC>(this: &AC,
1798
1795
// into the predicates list. This is currently kind of non-DRY.
1799
1796
create_predicates ( this. tcx ( ) , & mut result, space) ;
1800
1797
1798
+ // Add the bounds not associated with a type parameter
1799
+ for predicate in where_clause. predicates . iter ( ) {
1800
+ match predicate {
1801
+ & ast:: WherePredicate :: BoundPredicate ( ref bound_pred) => {
1802
+ let ty = ast_ty_to_ty ( this, & ExplicitRscope , & * bound_pred. bounded_ty ) ;
1803
+
1804
+ for bound in bound_pred. bounds . iter ( ) {
1805
+ match bound {
1806
+ & ast:: TyParamBound :: TraitTyParamBound ( ref poly_trait_ref) => {
1807
+ let trait_ref = astconv:: instantiate_poly_trait_ref (
1808
+ this,
1809
+ & ExplicitRscope ,
1810
+ //@jroesch: for now trait_ref, poly_trait_ref?
1811
+ poly_trait_ref,
1812
+ Some ( ty) ,
1813
+ AllowEqConstraints :: Allow
1814
+ ) ;
1815
+
1816
+ result. predicates . push ( space, ty:: Predicate :: Trait ( trait_ref) ) ;
1817
+ }
1818
+
1819
+ & ast:: TyParamBound :: RegionTyParamBound ( ref lifetime) => {
1820
+ let region = ast_region_to_region ( this. tcx ( ) , lifetime) ;
1821
+ let pred = ty:: Binder ( ty:: OutlivesPredicate ( ty, region) ) ;
1822
+ result. predicates . push ( space, ty:: Predicate :: TypeOutlives ( pred) )
1823
+ }
1824
+ }
1825
+ }
1826
+ }
1827
+
1828
+ & ast:: WherePredicate :: RegionPredicate ( ref region_pred) => {
1829
+ let r1 = ast_region_to_region ( this. tcx ( ) , & region_pred. lifetime ) ;
1830
+ let r2 = ast_region_to_region ( this. tcx ( ) , & region_pred. bound ) ;
1831
+ let pred = ty:: Binder ( ty:: OutlivesPredicate ( r1, r2) ) ;
1832
+ result. predicates . push ( space, ty:: Predicate :: RegionOutlives ( pred) )
1833
+ }
1834
+
1835
+ & ast:: WherePredicate :: EqPredicate ( ref eq_pred) => {
1836
+ // FIXME(#20041)
1837
+ this. tcx ( ) . sess . span_bug ( eq_pred. span ,
1838
+ "Equality constraints are not yet \
1839
+ implemented (#20041)")
1840
+ }
1841
+ }
1842
+ }
1843
+
1801
1844
return result;
1802
1845
1803
1846
fn create_type_parameters_for_associated_types < ' tcx , AC > (
@@ -1915,7 +1958,6 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
1915
1958
space : subst:: ParamSpace ,
1916
1959
param : & ast:: TyParam ,
1917
1960
index : uint ,
1918
- where_clause : & ast:: WhereClause ,
1919
1961
associated_with : Option < ast:: DefId > )
1920
1962
-> ty:: TypeParameterDef < ' tcx >
1921
1963
where AC : AstConv < ' tcx >
@@ -1931,8 +1973,7 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
1931
1973
param_ty,
1932
1974
param. bounds . as_slice ( ) ,
1933
1975
& param. unbound ,
1934
- param. span ,
1935
- where_clause) ;
1976
+ param. span ) ;
1936
1977
let default = match param. default {
1937
1978
None => None ,
1938
1979
Some ( ref path) => {
@@ -1977,15 +2018,13 @@ fn compute_bounds<'tcx,AC>(this: &AC,
1977
2018
param_ty : ty:: ParamTy ,
1978
2019
ast_bounds : & [ ast:: TyParamBound ] ,
1979
2020
unbound : & Option < ast:: TraitRef > ,
1980
- span : Span ,
1981
- where_clause : & ast:: WhereClause )
2021
+ span : Span )
1982
2022
-> ty:: ParamBounds < ' tcx >
1983
2023
where AC : AstConv < ' tcx > {
1984
2024
let mut param_bounds = conv_param_bounds ( this,
1985
2025
span,
1986
2026
param_ty,
1987
- ast_bounds,
1988
- where_clause) ;
2027
+ ast_bounds) ;
1989
2028
1990
2029
1991
2030
add_unsized_bound ( this,
@@ -2031,16 +2070,14 @@ fn check_bounds_compatible<'tcx>(tcx: &ty::ctxt<'tcx>,
2031
2070
fn conv_param_bounds < ' tcx , AC > ( this : & AC ,
2032
2071
span : Span ,
2033
2072
param_ty : ty:: ParamTy ,
2034
- ast_bounds : & [ ast:: TyParamBound ] ,
2035
- where_clause : & ast:: WhereClause )
2073
+ ast_bounds : & [ ast:: TyParamBound ] )
2036
2074
-> ty:: ParamBounds < ' tcx >
2037
- where AC : AstConv < ' tcx > {
2038
- let all_bounds =
2039
- merge_param_bounds ( this. tcx ( ) , param_ty, ast_bounds, where_clause) ;
2075
+ where AC : AstConv < ' tcx >
2076
+ {
2040
2077
let astconv:: PartitionedBounds { builtin_bounds,
2041
2078
trait_bounds,
2042
2079
region_bounds } =
2043
- astconv:: partition_bounds ( this. tcx ( ) , span, all_bounds . as_slice ( ) ) ;
2080
+ astconv:: partition_bounds ( this. tcx ( ) , span, ast_bounds . as_slice ( ) ) ;
2044
2081
let trait_bounds: Vec < Rc < ty:: PolyTraitRef > > =
2045
2082
trait_bounds. into_iter ( )
2046
2083
. map ( |bound| {
@@ -2062,43 +2099,6 @@ fn conv_param_bounds<'tcx,AC>(this: &AC,
2062
2099
}
2063
2100
}
2064
2101
2065
- /// Merges the bounds declared on a type parameter with those found from where clauses into a
2066
- /// single list.
2067
- fn merge_param_bounds < ' a > ( tcx : & ty:: ctxt ,
2068
- param_ty : ty:: ParamTy ,
2069
- ast_bounds : & ' a [ ast:: TyParamBound ] ,
2070
- where_clause : & ' a ast:: WhereClause )
2071
- -> Vec < & ' a ast:: TyParamBound > {
2072
- let mut result = Vec :: new ( ) ;
2073
-
2074
- for ast_bound in ast_bounds. iter ( ) {
2075
- result. push ( ast_bound) ;
2076
- }
2077
-
2078
- for predicate in where_clause. predicates . iter ( ) {
2079
- match predicate {
2080
- & ast:: WherePredicate :: BoundPredicate ( ref bound_pred) => {
2081
- let predicate_param_id =
2082
- tcx. def_map
2083
- . borrow ( )
2084
- . get ( & bound_pred. id )
2085
- . expect ( "merge_param_bounds(): resolve didn't resolve the \
2086
- type parameter identifier in a `where` clause")
2087
- . def_id ( ) ;
2088
- if param_ty. def_id != predicate_param_id {
2089
- continue
2090
- }
2091
- for bound in bound_pred. bounds . iter ( ) {
2092
- result. push ( bound) ;
2093
- }
2094
- }
2095
- & ast:: WherePredicate :: EqPredicate ( _) => panic ! ( "not implemented" )
2096
- }
2097
- }
2098
-
2099
- result
2100
- }
2101
-
2102
2102
pub fn ty_of_foreign_fn_decl < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
2103
2103
decl : & ast:: FnDecl ,
2104
2104
def_id : ast:: DefId ,
0 commit comments