Grammar summary
│ │ │The following is a summary of the grammar production rules. For details on the syntax of this grammar, see notation.grammar.syntax.
│ │ │ -Statements summary
│ │ │ -Syntax
│ │ │ -
│ │ │ -Statement →
;
| Item
| LetStatement
| ExpressionStatement
| OuterAttribute* MacroInvocationSemi
LetStatement →
OuterAttribute* let PatternNoTopAlt ( : Type )?
(
= Expression
| = Expressionexcept LazyBooleanExpression or end with a }
else BlockExpressionNoInnerAttributes
)? ;
ExpressionStatement →
ExpressionWithoutBlock ;
| ExpressionWithBlock ;?
Items summary
│ │ │Syntax
│ │ │
│ │ │ Item →
OuterAttribute* ( VisItem | MacroItem )
VisItem →
Visibility?
(
Module
| ExternCrate
| UseDeclaration
| Function
| TypeAlias
| Struct
| Enumeration
| Union
| ConstantItem
| StaticItem
| Trait
| Implementation
| ExternBlock
)
MacroItem →
MacroInvocationSemi
| MacroRulesDefinition
Union →
union IDENTIFIER GenericParams? WhereClause? { StructFields? }
Crate →
InnerAttribute*
Item*
Visibility →
pub
| pub ( crate )
| pub ( self )
| pub ( super )
| pub ( in SimplePath )
Trait →
unsafe? trait IDENTIFIER GenericParams? ( : Bounds? )? WhereClause?
{
InnerAttribute*
AssociatedItem*
}
TypeAlias →
type IDENTIFIER GenericParams? ( : Bounds? )?
WhereClause?
( = Type WhereClause? )? ;
ConstantItem →
const ( IDENTIFIER | _ ) : Type ( = Expression )? ;
Struct →
StructStruct
| TupleStruct
StructStruct →
struct IDENTIFIER GenericParams? WhereClause? ( { StructFields? } | ; )
TupleStruct →
struct IDENTIFIER GenericParams? ( TupleFields? ) WhereClause? ;
StructFields → StructField ( , StructField )* ,?
│ │ │ +StructField → OuterAttribute* Visibility? IDENTIFIER : Type
│ │ │ +TupleFields → TupleField ( , TupleField )* ,?
│ │ │ +TupleField → OuterAttribute* Visibility? Type
│ │ │ +Implementation → InherentImpl | TraitImpl
│ │ │ +InherentImpl →
impl GenericParams? Type WhereClause? {
InnerAttribute*
AssociatedItem*
}
TraitImpl →
unsafe? impl GenericParams? !? TypePath for Type
WhereClause?
{
InnerAttribute*
AssociatedItem*
}
Function →
FunctionQualifiers fn IDENTIFIER GenericParams?
( FunctionParameters? )
FunctionReturnType? WhereClause?
( BlockExpression | ; )
FunctionQualifiers → const? async? ItemSafety? ( extern Abi? )?
│ │ │ItemSafety → safe | unsafe
│ │ │Abi → STRING_LITERAL | RAW_STRING_LITERAL
│ │ │FunctionParameters →
SelfParam ,?
| ( SelfParam , )? FunctionParam ( , FunctionParam )* ,?
SelfParam → OuterAttribute* ( ShorthandSelf | TypedSelf )
│ │ │ShorthandSelf → ( & | & Lifetime )? mut? self
│ │ │ │ │ │FunctionParam → OuterAttribute* ( FunctionParamPattern | ... | Type )
│ │ │FunctionParamPattern → PatternNoTopAlt : ( Type | ... )
│ │ │FunctionReturnType → -> Type
│ │ │ -ExternCrate → extern crate CrateRef AsClause? ;
│ │ │ -CrateRef → IDENTIFIER | self
│ │ │ -AsClause → as ( IDENTIFIER | _ )
│ │ │ -Module →
unsafe? mod IDENTIFIER ;
| unsafe? mod IDENTIFIER {
InnerAttribute*
Item*
}
AssociatedItem →
OuterAttribute* (
MacroInvocationSemi
| ( Visibility? ( TypeAlias | ConstantItem | Function ) )
)
Enumeration →
enum IDENTIFIER GenericParams? WhereClause? { EnumVariants? }
EnumVariants → EnumVariant ( , EnumVariant )* ,?
│ │ │ -EnumVariant →
OuterAttribute* Visibility?
IDENTIFIER ( EnumVariantTuple | EnumVariantStruct )? EnumVariantDiscriminant?
EnumVariantTuple → ( TupleFields? )
│ │ │ -EnumVariantStruct → { StructFields? }
│ │ │ -EnumVariantDiscriminant → = Expression
│ │ │ -Implementation → InherentImpl | TraitImpl
│ │ │ -InherentImpl →
impl GenericParams? Type WhereClause? {
InnerAttribute*
AssociatedItem*
}
TraitImpl →
unsafe? impl GenericParams? !? TypePath for Type
WhereClause?
{
InnerAttribute*
AssociatedItem*
}
Trait →
unsafe? trait IDENTIFIER GenericParams? ( : Bounds? )? WhereClause?
{
InnerAttribute*
AssociatedItem*
}
Struct →
StructStruct
| TupleStruct
StructStruct →
struct IDENTIFIER GenericParams? WhereClause? ( { StructFields? } | ; )
TupleStruct →
struct IDENTIFIER GenericParams? ( TupleFields? ) WhereClause? ;
StructFields → StructField ( , StructField )* ,?
│ │ │ -StructField → OuterAttribute* Visibility? IDENTIFIER : Type
│ │ │ -TupleFields → TupleField ( , TupleField )* ,?
│ │ │ -TupleField → OuterAttribute* Visibility? Type
│ │ │ -ExternBlock →
unsafe? extern Abi? {
InnerAttribute*
ExternalItem*
}
ExternalItem →
OuterAttribute* (
MacroInvocationSemi
| Visibility? StaticItem
| Visibility? Function
)
StaticItem →
ItemSafety? static mut? IDENTIFIER : Type ( = Expression )? ;
ConstantItem →
const ( IDENTIFIER | _ ) : Type ( = Expression )? ;
GenericParams → < ( GenericParam ( , GenericParam )* ,? )? >
│ │ │GenericParam → OuterAttribute* ( LifetimeParam | TypeParam | ConstParam )
│ │ │LifetimeParam → Lifetime ( : LifetimeBounds? )?
│ │ │TypeParam → IDENTIFIER ( : Bounds? )? ( = Type )?
│ │ │ConstParam →
const IDENTIFIER : Type
( = ( BlockExpression | IDENTIFIER | -? LiteralExpression ) )?
WhereClause → where ( WhereClauseItem , )* WhereClauseItem?
│ │ │WhereClauseItem →
LifetimeWhereClauseItem
| TypeBoundWhereClauseItem
LifetimeWhereClauseItem → Lifetime : LifetimeBounds?
│ │ │TypeBoundWhereClauseItem → ForLifetimes? Type : Bounds?
│ │ │ +StaticItem →
ItemSafety? static mut? IDENTIFIER : Type ( = Expression )? ;
ExternCrate → extern crate CrateRef AsClause? ;
│ │ │ +CrateRef → IDENTIFIER | self
│ │ │ +AsClause → as ( IDENTIFIER | _ )
│ │ │ +AssociatedItem →
OuterAttribute* (
MacroInvocationSemi
| ( Visibility? ( TypeAlias | ConstantItem | Function ) )
)
ExternBlock →
unsafe? extern Abi? {
InnerAttribute*
ExternalItem*
}
ExternalItem →
OuterAttribute* (
MacroInvocationSemi
| Visibility? StaticItem
| Visibility? Function
)
Union →
union IDENTIFIER GenericParams? WhereClause? { StructFields? }
UseDeclaration → use UseTree ;
│ │ │UseTree →
( SimplePath? :: )? *
| ( SimplePath? :: )? { ( UseTree ( , UseTree )* ,? )? }
| SimplePath ( as ( IDENTIFIER | _ ) )?
TypeAlias →
type IDENTIFIER GenericParams? ( : Bounds? )?
WhereClause?
( = Type WhereClause? )? ;
Visibility →
pub
| pub ( crate )
| pub ( self )
| pub ( super )
| pub ( in SimplePath )
Crate →
InnerAttribute*
Item*
Module →
unsafe? mod IDENTIFIER ;
| unsafe? mod IDENTIFIER {
InnerAttribute*
Item*
}
Enumeration →
enum IDENTIFIER GenericParams? WhereClause? { EnumVariants? }
EnumVariants → EnumVariant ( , EnumVariant )* ,?
│ │ │ +EnumVariant →
OuterAttribute* Visibility?
IDENTIFIER ( EnumVariantTuple | EnumVariantStruct )? EnumVariantDiscriminant?
EnumVariantTuple → ( TupleFields? )
│ │ │ +EnumVariantStruct → { StructFields? }
│ │ │ + │ │ │ │ │ │