@@ -73,7 +73,7 @@ use std::iter;
7373use syntax:: { abi, ast} ;
7474use syntax:: feature_gate:: { GateIssue , emit_feature_err} ;
7575use syntax:: symbol:: { Symbol , keywords} ;
76- use syntax_pos:: { Span , Pos } ;
76+ use syntax_pos:: Span ;
7777use errors:: DiagnosticBuilder ;
7878
7979pub trait AstConv < ' gcx , ' tcx > {
@@ -930,87 +930,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
930930 decl_ty. subst ( self . tcx ( ) , substs)
931931 }
932932
933- fn ast_ty_to_object_trait_ref ( & self ,
934- rscope : & RegionScope ,
935- span : Span ,
936- ty : & hir:: Ty ,
937- bounds : & [ hir:: TyParamBound ] )
938- -> Ty < ' tcx >
939- {
940- /*!
941- * In a type like `Foo + Send`, we want to wait to collect the
942- * full set of bounds before we make the object type, because we
943- * need them to infer a region bound. (For example, if we tried
944- * made a type from just `Foo`, then it wouldn't be enough to
945- * infer a 'static bound, and hence the user would get an error.)
946- * So this function is used when we're dealing with a sum type to
947- * convert the LHS. It only accepts a type that refers to a trait
948- * name, and reports an error otherwise.
949- */
950-
951- let tcx = self . tcx ( ) ;
952- match ty. node {
953- hir:: TyPath ( hir:: QPath :: Resolved ( None , ref path) ) => {
954- if let Def :: Trait ( trait_def_id) = path. def {
955- self . trait_path_to_object_type ( rscope,
956- path. span ,
957- trait_def_id,
958- ty. id ,
959- path. segments . last ( ) . unwrap ( ) ,
960- span,
961- partition_bounds ( bounds) )
962- } else {
963- struct_span_err ! ( tcx. sess, ty. span, E0172 ,
964- "expected a reference to a trait" )
965- . span_label ( ty. span , & format ! ( "expected a trait" ) )
966- . emit ( ) ;
967- tcx. types . err
968- }
969- }
970- _ => {
971- let mut err = struct_span_err ! ( tcx. sess, ty. span, E0178 ,
972- "expected a path on the left-hand side \
973- of `+`, not `{}`",
974- tcx. map. node_to_pretty_string( ty. id) ) ;
975- err. span_label ( ty. span , & format ! ( "expected a path" ) ) ;
976- let hi = bounds. iter ( ) . map ( |x| match * x {
977- hir:: TraitTyParamBound ( ref tr, _) => tr. span . hi ,
978- hir:: RegionTyParamBound ( ref r) => r. span . hi ,
979- } ) . max_by_key ( |x| x. to_usize ( ) ) ;
980- let full_span = hi. map ( |hi| Span {
981- lo : ty. span . lo ,
982- hi : hi,
983- expn_id : ty. span . expn_id ,
984- } ) ;
985- match ( & ty. node , full_span) {
986- ( & hir:: TyRptr ( ref lifetime, ref mut_ty) , Some ( full_span) ) => {
987- let ty_str = hir:: print:: to_string ( & tcx. map , |s| {
988- use syntax:: print:: pp:: word;
989- use syntax:: print:: pprust:: PrintState ;
990-
991- word ( & mut s. s , "&" ) ?;
992- s. print_opt_lifetime ( lifetime) ?;
993- s. print_mutability ( mut_ty. mutbl ) ?;
994- s. popen ( ) ?;
995- s. print_type ( & mut_ty. ty ) ?;
996- s. print_bounds ( " +" , bounds) ?;
997- s. pclose ( )
998- } ) ;
999- err. span_suggestion ( full_span, "try adding parentheses (per RFC 438):" ,
1000- ty_str) ;
1001- }
1002-
1003- _ => {
1004- help ! ( & mut err,
1005- "perhaps you forgot parentheses? (per RFC 438)" ) ;
1006- }
1007- }
1008- err. emit ( ) ;
1009- tcx. types . err
1010- }
1011- }
1012- }
1013-
1014933 /// Transform a PolyTraitRef into a PolyExistentialTraitRef by
1015934 /// removing the dummy Self type (TRAIT_OBJECT_DUMMY_SELF).
1016935 fn trait_ref_to_existential ( & self , trait_ref : ty:: TraitRef < ' tcx > )
@@ -1534,9 +1453,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
15341453 hir:: TySlice ( ref ty) => {
15351454 tcx. mk_slice ( self . ast_ty_to_ty ( rscope, & ty) )
15361455 }
1537- hir:: TyObjectSum ( ref ty, ref bounds) => {
1538- self . ast_ty_to_object_trait_ref ( rscope, ast_ty. span , ty, bounds)
1539- }
15401456 hir:: TyPtr ( ref mt) => {
15411457 tcx. mk_ptr ( ty:: TypeAndMut {
15421458 ty : self . ast_ty_to_ty ( rscope, & mt. ty ) ,
@@ -1609,7 +1525,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
16091525 }
16101526 tcx. mk_fn_ptr ( bare_fn_ty)
16111527 }
1612- hir:: TyPolyTraitRef ( ref bounds) => {
1528+ hir:: TyObjectSum ( ref bounds) => {
16131529 self . conv_object_ty_poly_trait_ref ( rscope, ast_ty. span , bounds)
16141530 }
16151531 hir:: TyImplTrait ( ref bounds) => {
0 commit comments