@@ -191,7 +191,7 @@ pub fn object_type<'a>(input: &mut TokenStream<'a>)
191191 ObjectType {
192192 position, name, directives, fields,
193193 implements_interfaces : interfaces,
194- description : None , // is filled in type_definition
194+ description : None , // is filled in described_definition
195195 }
196196 } )
197197 . parse_stream ( input)
@@ -237,7 +237,7 @@ pub fn interface_type<'a>(input: &mut TokenStream<'a>)
237237 . map ( |( position, name, directives, fields) | {
238238 InterfaceType {
239239 position, name, directives, fields,
240- description : None , // is filled in type_definition
240+ description : None , // is filled in described_definition
241241 }
242242 } )
243243 . parse_stream ( input)
@@ -288,7 +288,7 @@ pub fn union_type<'a>(input: &mut TokenStream<'a>)
288288 UnionType {
289289 position, name, directives,
290290 types : types. unwrap_or_else ( Vec :: new) ,
291- description : None , // is filled in type_definition
291+ description : None , // is filled in described_definition
292292 }
293293 } )
294294 . parse_stream ( input)
@@ -351,7 +351,7 @@ pub fn enum_type<'a>(input: &mut TokenStream<'a>)
351351 EnumType {
352352 position, name, directives,
353353 values : values. unwrap_or_else ( Vec :: new) ,
354- description : None , // is filled in type_definition
354+ description : None , // is filled in described_definition
355355 }
356356 } )
357357 . parse_stream ( input)
@@ -402,7 +402,7 @@ pub fn input_object_type<'a>(input: &mut TokenStream<'a>)
402402 . map ( |( position, name, directives, fields) | {
403403 InputObjectType {
404404 position, name, directives, fields,
405- description : None , // is filled in type_definition
405+ description : None , // is filled in described_definition
406406 }
407407 } )
408408 . parse_stream ( input)
@@ -459,39 +459,47 @@ pub fn directive_definition<'a>(input: &mut TokenStream<'a>)
459459 . map ( |( position, name, arguments, locations) | {
460460 DirectiveDefinition {
461461 position, name, arguments, locations,
462- description : None , // is filled in type_definition
462+ description : None , // is filled in described_definition
463463 }
464464 } )
465465 . parse_stream ( input)
466466}
467467
468- pub fn type_definition < ' a > ( input : & mut TokenStream < ' a > )
469- -> ParseResult < TypeDefinition , TokenStream < ' a > >
468+ pub fn described_definition < ' a > ( input : & mut TokenStream < ' a > )
469+ -> ParseResult < Definition , TokenStream < ' a > >
470470{
471471 use self :: TypeDefinition :: * ;
472472 (
473473 optional ( parser ( string) ) ,
474474 choice ( (
475- parser ( scalar_type) . map ( Scalar ) ,
476- parser ( object_type) . map ( Object ) ,
477- parser ( interface_type) . map ( Interface ) ,
478- parser ( union_type) . map ( Union ) ,
479- parser ( enum_type) . map ( Enum ) ,
480- parser ( input_object_type) . map ( InputObject ) ,
481- ) ) ,
475+ choice ( (
476+ parser ( scalar_type) . map ( Scalar ) ,
477+ parser ( object_type) . map ( Object ) ,
478+ parser ( interface_type) . map ( Interface ) ,
479+ parser ( union_type) . map ( Union ) ,
480+ parser ( enum_type) . map ( Enum ) ,
481+ parser ( input_object_type) . map ( InputObject ) ,
482+ ) ) . map ( Definition :: TypeDefinition ) ,
483+ parser ( directive_definition) . map ( Definition :: DirectiveDefinition ) ,
484+ ) )
482485 )
483486 // We can't set description inside type definition parser, because
484487 // that means parser will need to backtrace, and that in turn
485488 // means that error reporting is bad (along with performance)
486489 . map ( |( descr, mut def) | {
487490 use schema:: ast:: TypeDefinition :: * ;
491+ use schema:: ast:: Definition :: * ;
492+ use schema:: ast:: Definition :: { TypeDefinition as T } ;
488493 match def {
489- Scalar ( ref mut s) => s. description = descr,
490- Object ( ref mut o) => o. description = descr,
491- Interface ( ref mut i) => i. description = descr,
492- Union ( ref mut u) => u. description = descr,
493- Enum ( ref mut e) => e. description = descr,
494- InputObject ( ref mut o) => o. description = descr,
494+ T ( Scalar ( ref mut s) ) => s. description = descr,
495+ T ( Object ( ref mut o) ) => o. description = descr,
496+ T ( Interface ( ref mut i) ) => i. description = descr,
497+ T ( Union ( ref mut u) ) => u. description = descr,
498+ T ( Enum ( ref mut e) ) => e. description = descr,
499+ T ( InputObject ( ref mut o) ) => o. description = descr,
500+ DirectiveDefinition ( ref mut d) => d. description = descr,
501+ SchemaDefinition ( _) => unreachable ! ( ) ,
502+ TypeExtension ( _) => unreachable ! ( ) ,
495503 }
496504 def
497505 } )
@@ -519,9 +527,8 @@ pub fn definition<'a>(input: &mut TokenStream<'a>)
519527{
520528 choice ( (
521529 parser ( schema) . map ( Definition :: SchemaDefinition ) ,
522- parser ( type_definition) . map ( Definition :: TypeDefinition ) ,
523530 parser ( type_extension) . map ( Definition :: TypeExtension ) ,
524- parser ( directive_definition ) . map ( Definition :: DirectiveDefinition ) ,
531+ parser ( described_definition ) ,
525532 ) ) . parse_stream ( input)
526533}
527534
0 commit comments