@@ -156,10 +156,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
156156 match item_segment. parameters {
157157 hir:: AngleBracketedParameters ( _) => { }
158158 hir:: ParenthesizedParameters ( ..) => {
159- struct_span_err ! ( tcx. sess, span, E0214 ,
160- "parenthesized parameters may only be used with a trait" )
161- . span_label ( span, "only traits may use parentheses" )
162- . emit ( ) ;
159+ self . prohibit_parenthesized_params ( item_segment) ;
163160
164161 return Substs :: for_item ( tcx, def_id, |_, _| {
165162 tcx. types . re_static
@@ -370,6 +367,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
370367 self_ty : Ty < ' tcx > )
371368 -> ty:: TraitRef < ' tcx >
372369 {
370+ self . prohibit_type_params ( trait_ref. path . segments . split_last ( ) . unwrap ( ) . 1 ) ;
371+
373372 let trait_def_id = self . trait_def_id ( trait_ref) ;
374373 self . ast_path_to_mono_trait_ref ( trait_ref. path . span ,
375374 trait_def_id,
@@ -402,6 +401,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
402401
403402 debug ! ( "ast_path_to_poly_trait_ref({:?}, def_id={:?})" , trait_ref, trait_def_id) ;
404403
404+ self . prohibit_type_params ( trait_ref. path . segments . split_last ( ) . unwrap ( ) . 1 ) ;
405+
405406 let ( substs, assoc_bindings) =
406407 self . create_substs_for_ast_trait_ref ( trait_ref. path . span ,
407408 trait_def_id,
@@ -623,6 +624,13 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
623624 dummy_self,
624625 & mut projection_bounds) ;
625626
627+ for trait_bound in trait_bounds[ 1 ..] . iter ( ) {
628+ // Sanity check for non-principal trait bounds
629+ self . instantiate_poly_trait_ref ( trait_bound,
630+ dummy_self,
631+ & mut vec ! [ ] ) ;
632+ }
633+
626634 let ( auto_traits, trait_bounds) = split_auto_traits ( tcx, & trait_bounds[ 1 ..] ) ;
627635
628636 if !trait_bounds. is_empty ( ) {
@@ -937,6 +945,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
937945
938946 pub fn prohibit_type_params ( & self , segments : & [ hir:: PathSegment ] ) {
939947 for segment in segments {
948+ if let hir:: ParenthesizedParameters ( _) = segment. parameters {
949+ self . prohibit_parenthesized_params ( segment) ;
950+ break ;
951+ }
940952 for typ in segment. parameters . types ( ) {
941953 struct_span_err ! ( self . tcx( ) . sess, typ. span, E0109 ,
942954 "type parameters are not allowed on this type" )
@@ -959,6 +971,15 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
959971 }
960972 }
961973
974+ pub fn prohibit_parenthesized_params ( & self , segment : & hir:: PathSegment ) {
975+ if let hir:: ParenthesizedParameters ( ref data) = segment. parameters {
976+ struct_span_err ! ( self . tcx( ) . sess, data. span, E0214 ,
977+ "parenthesized parameters may only be used with a trait" )
978+ . span_label ( data. span , "only traits may use parentheses" )
979+ . emit ( ) ;
980+ }
981+ }
982+
962983 pub fn prohibit_projection ( & self , span : Span ) {
963984 let mut err = struct_span_err ! ( self . tcx( ) . sess, span, E0229 ,
964985 "associated type bindings are not allowed here" ) ;
0 commit comments