@@ -161,10 +161,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
161
161
match item_segment. parameters {
162
162
hir:: AngleBracketedParameters ( _) => { }
163
163
hir:: ParenthesizedParameters ( ..) => {
164
- struct_span_err ! ( tcx. sess, span, E0214 ,
165
- "parenthesized parameters may only be used with a trait" )
166
- . span_label ( span, "only traits may use parentheses" )
167
- . emit ( ) ;
164
+ self . prohibit_parenthesized_params ( item_segment) ;
168
165
169
166
return Substs :: for_item ( tcx, def_id, |_, _| {
170
167
tcx. types . re_static
@@ -948,6 +945,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
948
945
949
946
pub fn prohibit_type_params ( & self , segments : & [ hir:: PathSegment ] ) {
950
947
for segment in segments {
948
+ if let hir:: ParenthesizedParameters ( _) = segment. parameters {
949
+ self . prohibit_parenthesized_params ( segment) ;
950
+ break ;
951
+ }
951
952
for typ in segment. parameters . types ( ) {
952
953
struct_span_err ! ( self . tcx( ) . sess, typ. span, E0109 ,
953
954
"type parameters are not allowed on this type" )
@@ -970,6 +971,15 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
970
971
}
971
972
}
972
973
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
+
973
983
pub fn prohibit_projection ( & self , span : Span ) {
974
984
let mut err = struct_span_err ! ( self . tcx( ) . sess, span, E0229 ,
975
985
"associated type bindings are not allowed here" ) ;
0 commit comments