Copyright | (c) Alec Theriault 2017-2018 |
---|---|
License | BSD-style |
Maintainer | alec.theriault@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data SourceFile a = SourceFile (Maybe Name) [Attribute a] [Item a]
- data Mutability
- data Unsafety
- data Arg a
- = Arg (Maybe (Pat a)) (Ty a) a
- | SelfValue Mutability a
- | SelfRegion (Maybe (Lifetime a)) Mutability a
- | SelfExplicit (Ty a) Mutability a
- data FnDecl a = FnDecl [Arg a] (Maybe (Ty a)) Bool a
- data Path a = Path Bool [PathSegment a] a
- data PathParameters a
- = AngleBracketed [Lifetime a] [Ty a] [(Ident, Ty a)] a
- | Parenthesized [Ty a] (Maybe (Ty a)) a
- data PathSegment a = PathSegment Ident (Maybe (PathParameters a)) a
- data QSelf a = QSelf (Ty a) Int
- data Attribute a
- = Attribute AttrStyle (Path a) TokenStream a
- | SugaredDoc AttrStyle Bool Name a
- data AttrStyle
- data Lit a
- byteStr :: String -> StrStyle -> Suffix -> a -> Lit a
- data Suffix
- suffix :: Lit a -> Suffix
- data IntRep
- data StrStyle
- data Expr a
- = Box [Attribute a] (Expr a) a
- | InPlace [Attribute a] (Expr a) (Expr a) a
- | Vec [Attribute a] [Expr a] a
- | Call [Attribute a] (Expr a) [Expr a] a
- | MethodCall [Attribute a] (Expr a) Ident (Maybe [Ty a]) [Expr a] a
- | TupExpr [Attribute a] [Expr a] a
- | Binary [Attribute a] BinOp (Expr a) (Expr a) a
- | Unary [Attribute a] UnOp (Expr a) a
- | Lit [Attribute a] (Lit a) a
- | Cast [Attribute a] (Expr a) (Ty a) a
- | TypeAscription [Attribute a] (Expr a) (Ty a) a
- | If [Attribute a] (Expr a) (Block a) (Maybe (Expr a)) a
- | IfLet [Attribute a] (NonEmpty (Pat a)) (Expr a) (Block a) (Maybe (Expr a)) a
- | While [Attribute a] (Expr a) (Block a) (Maybe (Label a)) a
- | WhileLet [Attribute a] (NonEmpty (Pat a)) (Expr a) (Block a) (Maybe (Label a)) a
- | ForLoop [Attribute a] (Pat a) (Expr a) (Block a) (Maybe (Label a)) a
- | Loop [Attribute a] (Block a) (Maybe (Label a)) a
- | Match [Attribute a] (Expr a) [Arm a] a
- | Closure [Attribute a] Movability CaptureBy (FnDecl a) (Expr a) a
- | BlockExpr [Attribute a] (Block a) a
- | Catch [Attribute a] (Block a) a
- | Assign [Attribute a] (Expr a) (Expr a) a
- | AssignOp [Attribute a] BinOp (Expr a) (Expr a) a
- | FieldAccess [Attribute a] (Expr a) Ident a
- | TupField [Attribute a] (Expr a) Int a
- | Index [Attribute a] (Expr a) (Expr a) a
- | Range [Attribute a] (Maybe (Expr a)) (Maybe (Expr a)) RangeLimits a
- | PathExpr [Attribute a] (Maybe (QSelf a)) (Path a) a
- | AddrOf [Attribute a] Mutability (Expr a) a
- | Break [Attribute a] (Maybe (Label a)) (Maybe (Expr a)) a
- | Continue [Attribute a] (Maybe (Label a)) a
- | Ret [Attribute a] (Maybe (Expr a)) a
- | MacExpr [Attribute a] (Mac a) a
- | Struct [Attribute a] (Path a) [Field a] (Maybe (Expr a)) a
- | Repeat [Attribute a] (Expr a) (Expr a) a
- | ParenExpr [Attribute a] (Expr a) a
- | Try [Attribute a] (Expr a) a
- | Yield [Attribute a] (Maybe (Expr a)) a
- | EmbeddedExpr [Attribute a] String a
- data Abi
- data Arm a = Arm [Attribute a] (NonEmpty (Pat a)) (Maybe (Expr a)) (Expr a) a
- data UnOp
- data BinOp
- data Label a = Label Name a
- data CaptureBy
- data Movability
- data Field a = Field Ident (Maybe (Expr a)) a
- data RangeLimits
- data Ty a
- = Slice (Ty a) a
- | Array (Ty a) (Expr a) a
- | Ptr Mutability (Ty a) a
- | Rptr (Maybe (Lifetime a)) Mutability (Ty a) a
- | BareFn Unsafety Abi [LifetimeDef a] (FnDecl a) a
- | Never a
- | TupTy [Ty a] a
- | PathTy (Maybe (QSelf a)) (Path a) a
- | TraitObject (NonEmpty (TyParamBound a)) a
- | ImplTrait (NonEmpty (TyParamBound a)) a
- | ParenTy (Ty a) a
- | Typeof (Expr a) a
- | Infer a
- | MacTy (Mac a) a
- data Generics a = Generics [LifetimeDef a] [TyParam a] (WhereClause a) a
- data Lifetime a = Lifetime Name a
- data LifetimeDef a = LifetimeDef [Attribute a] (Lifetime a) [Lifetime a] a
- data TyParam a = TyParam [Attribute a] Ident [TyParamBound a] (Maybe (Ty a)) a
- data TyParamBound a
- = TraitTyParamBound (PolyTraitRef a) TraitBoundModifier a
- | RegionTyParamBound (Lifetime a) a
- partitionTyParamBounds :: [TyParamBound a] -> ([TyParamBound a], [TyParamBound a])
- data WhereClause a = WhereClause [WherePredicate a] a
- whereClause :: Generics a -> WhereClause a
- data WherePredicate a
- = BoundPredicate [LifetimeDef a] (Ty a) [TyParamBound a] a
- | RegionPredicate (Lifetime a) [Lifetime a] a
- | EqPredicate (Ty a) (Ty a) a
- data PolyTraitRef a = PolyTraitRef [LifetimeDef a] (TraitRef a) a
- newtype TraitRef a = TraitRef (Path a)
- data TraitBoundModifier
- data Pat a
- = WildP a
- | IdentP BindingMode Ident (Maybe (Pat a)) a
- | StructP (Path a) [FieldPat a] Bool a
- | TupleStructP (Path a) [Pat a] (Maybe Int) a
- | PathP (Maybe (QSelf a)) (Path a) a
- | TupleP [Pat a] (Maybe Int) a
- | BoxP (Pat a) a
- | RefP (Pat a) Mutability a
- | LitP (Expr a) a
- | RangeP (Expr a) (Expr a) a
- | SliceP [Pat a] (Maybe (Pat a)) [Pat a] a
- | MacP (Mac a) a
- data BindingMode
- data FieldPat a = FieldPat (Maybe Ident) (Pat a) a
- data Stmt a
- data Item a
- = ExternCrate [Attribute a] (Visibility a) Ident (Maybe Ident) a
- | Use [Attribute a] (Visibility a) (UseTree a) a
- | Static [Attribute a] (Visibility a) Ident (Ty a) Mutability (Expr a) a
- | ConstItem [Attribute a] (Visibility a) Ident (Ty a) (Expr a) a
- | Fn [Attribute a] (Visibility a) Ident (FnDecl a) Unsafety Constness Abi (Generics a) (Block a) a
- | Mod [Attribute a] (Visibility a) Ident (Maybe [Item a]) a
- | ForeignMod [Attribute a] (Visibility a) Abi [ForeignItem a] a
- | TyAlias [Attribute a] (Visibility a) Ident (Ty a) (Generics a) a
- | Enum [Attribute a] (Visibility a) Ident [Variant a] (Generics a) a
- | StructItem [Attribute a] (Visibility a) Ident (VariantData a) (Generics a) a
- | Union [Attribute a] (Visibility a) Ident (VariantData a) (Generics a) a
- | Trait [Attribute a] (Visibility a) Ident Bool Unsafety (Generics a) [TyParamBound a] [TraitItem a] a
- | TraitAlias [Attribute a] (Visibility a) Ident (Generics a) (NonEmpty (TyParamBound a)) a
- | Impl [Attribute a] (Visibility a) Defaultness Unsafety ImplPolarity (Generics a) (Maybe (TraitRef a)) (Ty a) [ImplItem a] a
- | MacItem [Attribute a] (Maybe Ident) (Mac a) a
- | MacroDef [Attribute a] Ident TokenStream a
- data ForeignItem a
- = ForeignFn [Attribute a] (Visibility a) Ident (FnDecl a) (Generics a) a
- | ForeignStatic [Attribute a] (Visibility a) Ident (Ty a) Mutability a
- | ForeignTy [Attribute a] (Visibility a) Ident a
- data ImplItem a
- = ConstI [Attribute a] (Visibility a) Defaultness Ident (Ty a) (Expr a) a
- | MethodI [Attribute a] (Visibility a) Defaultness Ident (Generics a) (MethodSig a) (Block a) a
- | TypeI [Attribute a] (Visibility a) Defaultness Ident (Ty a) a
- | MacroI [Attribute a] Defaultness (Mac a) a
- data TraitItem a
- data Defaultness
- data ImplPolarity
- data StructField a = StructField (Maybe Ident) (Visibility a) (Ty a) [Attribute a] a
- data Variant a = Variant Ident [Attribute a] (VariantData a) (Maybe (Expr a)) a
- data VariantData a
- = StructD [StructField a] a
- | TupleD [StructField a] a
- | UnitD a
- data UseTree a
- = UseTreeSimple (Path a) (Maybe Ident) a
- | UseTreeGlob (Path a) a
- | UseTreeNested (Path a) [UseTree a] a
- data Visibility a
- = PublicV
- | CrateV
- | RestrictedV (Path a)
- | InheritedV
- data Constness
- data MethodSig a = MethodSig Unsafety Constness Abi (FnDecl a)
- data Block a = Block [Stmt a] Unsafety a
- data TokenTree
- data TokenStream
- = Tree TokenTree
- | Stream [TokenStream]
- unconsTokenStream :: TokenStream -> Maybe (TokenTree, TokenStream)
- data Nonterminal a
- data Mac a = Mac (Path a) TokenStream a
- data MacStmtStyle
Top level
data SourceFile a Source #
This is the fundamental unit of parsing - it represents the contents of one source file. It is composed of an optional shebang line, inner attributes that follow, and then the module items.
Example:
#!/usr/bin/env rust #![allow(dead_code)] fn main() { println!("Hello world") }
SourceFile (Maybe Name) [Attribute a] [Item a] |
Instances
General
data Mutability Source #
Encodes whether something can be updated or changed (syntax::ast::Mutability
).
Instances
Qualifies whether something is using unsafe Rust or not (syntax::ast::Unsafety
). Note that we
also use this to describe whether a Block
is unsafe or not, while Rust has a seperate structure
(syntax::ast::BlockCheckMode
) for that. This is because they also need to keep track of whether
an unsafe block is compiler generated.
Instances
Bounded Unsafety Source # | |
Enum Unsafety Source # | |
Defined in Language.Rust.Syntax.AST | |
Eq Unsafety Source # | |
Data Unsafety Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Unsafety -> c Unsafety # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Unsafety # toConstr :: Unsafety -> Constr # dataTypeOf :: Unsafety -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Unsafety) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Unsafety) # gmapT :: (forall b. Data b => b -> b) -> Unsafety -> Unsafety # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Unsafety -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Unsafety -> r # gmapQ :: (forall d. Data d => d -> u) -> Unsafety -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Unsafety -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Unsafety -> m Unsafety # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Unsafety -> m Unsafety # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Unsafety -> m Unsafety # | |
Ord Unsafety Source # | |
Defined in Language.Rust.Syntax.AST | |
Show Unsafety Source # | |
Generic Unsafety Source # | |
NFData Unsafety Source # | |
Defined in Language.Rust.Syntax.AST | |
Pretty Unsafety Source # | |
Defined in Language.Rust.Pretty prettyUnresolved :: Unsafety -> Doc b Source # | |
type Rep Unsafety Source # | |
An argument in a function header (syntax::ast::Arg
, except with SelfKind
and ExplicitSelf
inlined).
Example: x: usize
, self
, mut self
, &self
, &'lt mut self
, mut self: Foo
as in
trait Foo { // Regular argument fn new(x: usize) -> Foo; // Self argument, by value fn foo(self) -> i32; fn bar(mut self); // Self argument, by reference fn baz(&self) -> Bar<'lt>; fn qux(&'lt mut self) -> Bar<'lt>; // Explicit self argument fn quux(mut self: Foo); }
Arg (Maybe (Pat a)) (Ty a) a | Regular argument |
SelfValue Mutability a | Self argument, by value |
SelfRegion (Maybe (Lifetime a)) Mutability a | Self argument, by reference |
SelfExplicit (Ty a) Mutability a | Explicit self argument |
Instances
Header (not the body) of a function declaration (syntax::ast::FnDecl
). The Lit
argument
indicates whether the header is variadic (so whether the argument list ends in ...
).
Example: (bar: i32) -> i32
as in
fn foo(bar: i32) -> i32 { bar + 2 }
Instances
Paths
Everything in Rust is namespaced using nested modules. A Path
represents a path into nested
modules, possibly instantiating type parameters along the way (syntax::ast::Path
). Much like
file paths, these paths can be relative or absolute (global) with respect to the crate root.
Paths are used to identify expressions (see PathExpr
), types (see PathTy
), and modules
(indirectly through ViewPath
and such).
The Lit
argument identifies whether the path is relative or absolute.
Example: std::cmp::PartialEq
Path Bool [PathSegment a] a |
Instances
Functor Path Source # | |
PrettyAnnotated Path Source # | |
Defined in Language.Rust.Pretty prettyAnnUnresolved :: Path a -> Doc a Source # | |
Eq a => Eq (Path a) Source # | |
Data a => Data (Path a) Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Path a -> c (Path a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Path a) # toConstr :: Path a -> Constr # dataTypeOf :: Path a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Path a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Path a)) # gmapT :: (forall b. Data b => b -> b) -> Path a -> Path a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Path a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Path a -> r # gmapQ :: (forall d. Data d => d -> u) -> Path a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Path a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Path a -> m (Path a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Path a -> m (Path a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Path a -> m (Path a) # | |
Ord a => Ord (Path a) Source # | |
Show a => Show (Path a) Source # | |
Generic (Path a) Source # | |
NFData a => NFData (Path a) Source # | |
Defined in Language.Rust.Syntax.AST | |
Located a => Located (Path a) Source # | |
(Typeable a, Monoid a) => Resolve (Path a) Source # | There are three potential instances for resolving a path (depending on what type it is). The
|
Pretty (Path a) Source # | |
Defined in Language.Rust.Pretty prettyUnresolved :: Path a -> Doc b Source # | |
Generic1 Path Source # | |
type Rep (Path a) Source # | |
Defined in Language.Rust.Syntax.AST type Rep (Path a) = D1 (MetaData "Path" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "Path" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [PathSegment a]) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))) | |
type Rep1 Path Source # | |
Defined in Language.Rust.Syntax.AST type Rep1 Path = D1 (MetaData "Path" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "Path" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) ([] :.: Rec1 PathSegment) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1))) |
data PathParameters a Source #
Parameters on a path segment (syntax::ast::PathParameters
).
AngleBracketed [Lifetime a] [Ty a] [(Ident, Ty a)] a | Parameters in a chevron comma-delimited list ( Example: |
Parenthesized [Ty a] (Maybe (Ty a)) a | Parameters in a parenthesized comma-delimited list, with an optional output type
( Example: |
Instances
data PathSegment a Source #
Segment of a path (syntax::ast::PathSegment
).
PathSegment Ident (Maybe (PathParameters a)) a |
Instances
The explicit Self
type in a "qualified path". The actual path, including the trait and the
associated item, is stored separately. The first argument is the type given to Self
and the
second is the index of the associated qualified with this Self
type
Instances
Functor QSelf Source # | |
Eq a => Eq (QSelf a) Source # | |
Data a => Data (QSelf a) Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> QSelf a -> c (QSelf a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (QSelf a) # toConstr :: QSelf a -> Constr # dataTypeOf :: QSelf a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (QSelf a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (QSelf a)) # gmapT :: (forall b. Data b => b -> b) -> QSelf a -> QSelf a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> QSelf a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> QSelf a -> r # gmapQ :: (forall d. Data d => d -> u) -> QSelf a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> QSelf a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> QSelf a -> m (QSelf a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> QSelf a -> m (QSelf a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> QSelf a -> m (QSelf a) # | |
Ord a => Ord (QSelf a) Source # | |
Show a => Show (QSelf a) Source # | |
Generic (QSelf a) Source # | |
NFData a => NFData (QSelf a) Source # | |
Defined in Language.Rust.Syntax.AST | |
(Typeable a, Monoid a) => Resolve (QSelf a) Source # | |
Generic1 QSelf Source # | |
type Rep (QSelf a) Source # | |
Defined in Language.Rust.Syntax.AST type Rep (QSelf a) = D1 (MetaData "QSelf" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "QSelf" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Ty a)) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int))) | |
type Rep1 QSelf Source # | |
Defined in Language.Rust.Syntax.AST type Rep1 QSelf = D1 (MetaData "QSelf" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "QSelf" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec1 Ty) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int))) |
Attributes
Attribute
s are annotations for other AST nodes (syntax::ast::Attribute
). Note that
doc-comments are promoted to attributes.
Example: #[derive(Copy,Clone)]
as in
#[derive(Clone, Copy)] struct Complex { re: f32, im: f32 }
Attribute AttrStyle (Path a) TokenStream a | Regular attributes of the form |
SugaredDoc AttrStyle Bool Name a | Doc comment attributes. The |
Instances
Distinguishes between attributes that are associated with the node that follows them and
attributes that are associated with the node that contains them (syntax::ast::AttrStyle
).
These two cases need to be distinguished only for pretty printing - they are otherwise
fundamentally equivalent.
Example: #[repr(C)]
is an outer attribute while #![feature(slice_patterns)]
is an inner one
Instances
Literals
Literals in Rust (syntax::ast::Lit
). As discussed in Suffix
, Rust AST is designed to parse
suffixes for all literals, even if they are currently only valid on Lit
and Lit
literals.
Str String StrStyle Suffix a | string (example: |
ByteStr [Word8] StrStyle Suffix a | byte string (example: |
Char Char Suffix a | character (example: |
Byte Word8 Suffix a | byte (example: |
Int IntRep Integer String Suffix a | integer (example: |
Float Double Suffix a | float (example: |
Bool Bool Suffix a | boolean (example: |
Instances
The suffix on a literal (unifies syntax::ast::LitIntType
, syntax::ast::IntTy
,
syntax::ast::UintTy
, and syntax::ast::FloatTy
). As of today, only numeric types can have
suffixes, but the possibility of adding more (possibly arbitrary) suffixes to literals in general
is being kept open intentionally. RFC about future-proofing literal
suffixes
Examples: i32
, isize
, and f32
Instances
Bounded Suffix Source # | |
Enum Suffix Source # | |
Defined in Language.Rust.Syntax.AST | |
Eq Suffix Source # | |
Data Suffix Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Suffix -> c Suffix # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Suffix # toConstr :: Suffix -> Constr # dataTypeOf :: Suffix -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Suffix) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Suffix) # gmapT :: (forall b. Data b => b -> b) -> Suffix -> Suffix # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Suffix -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Suffix -> r # gmapQ :: (forall d. Data d => d -> u) -> Suffix -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Suffix -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Suffix -> m Suffix # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Suffix -> m Suffix # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Suffix -> m Suffix # | |
Ord Suffix Source # | |
Show Suffix Source # | |
Generic Suffix Source # | |
NFData Suffix Source # | |
Defined in Language.Rust.Syntax.AST | |
Pretty Suffix Source # | |
Defined in Language.Rust.Pretty prettyUnresolved :: Suffix -> Doc b Source # | |
type Rep Suffix Source # | |
Defined in Language.Rust.Syntax.AST type Rep Suffix = D1 (MetaData "Suffix" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (((C1 (MetaCons "Unsuffixed" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "Is" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "I8" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "I16" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "I32" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "I64" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "I128" PrefixI False) (U1 :: Type -> Type)))) :+: (((C1 (MetaCons "Us" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "U8" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "U16" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "U32" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "U64" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "U128" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "F32" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "F64" PrefixI False) (U1 :: Type -> Type))))) |
The base of the number in an Int
literal can be binary (e.g. 0b1100
), octal (e.g. 0o14
),
decimal (e.g. 12
), or hexadecimal (e.g. 0xc
).
Instances
Bounded IntRep Source # | |
Enum IntRep Source # | |
Defined in Language.Rust.Syntax.AST | |
Eq IntRep Source # | |
Data IntRep Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IntRep -> c IntRep # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c IntRep # toConstr :: IntRep -> Constr # dataTypeOf :: IntRep -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c IntRep) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IntRep) # gmapT :: (forall b. Data b => b -> b) -> IntRep -> IntRep # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IntRep -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IntRep -> r # gmapQ :: (forall d. Data d => d -> u) -> IntRep -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> IntRep -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> IntRep -> m IntRep # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IntRep -> m IntRep # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IntRep -> m IntRep # | |
Ord IntRep Source # | |
Show IntRep Source # | |
Generic IntRep Source # | |
NFData IntRep Source # | |
Defined in Language.Rust.Syntax.AST | |
type Rep IntRep Source # | |
Defined in Language.Rust.Syntax.AST type Rep IntRep = D1 (MetaData "IntRep" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) ((C1 (MetaCons "Bin" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Oct" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "Dec" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Hex" PrefixI False) (U1 :: Type -> Type))) |
Style of a string literal (syntax::ast::StrStyle
).
Instances
Eq StrStyle Source # | |
Data StrStyle Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> StrStyle -> c StrStyle # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c StrStyle # toConstr :: StrStyle -> Constr # dataTypeOf :: StrStyle -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c StrStyle) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c StrStyle) # gmapT :: (forall b. Data b => b -> b) -> StrStyle -> StrStyle # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StrStyle -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StrStyle -> r # gmapQ :: (forall d. Data d => d -> u) -> StrStyle -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> StrStyle -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> StrStyle -> m StrStyle # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> StrStyle -> m StrStyle # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> StrStyle -> m StrStyle # | |
Ord StrStyle Source # | |
Defined in Language.Rust.Syntax.AST | |
Show StrStyle Source # | |
Generic StrStyle Source # | |
NFData StrStyle Source # | |
Defined in Language.Rust.Syntax.AST | |
type Rep StrStyle Source # | |
Defined in Language.Rust.Syntax.AST type Rep StrStyle = D1 (MetaData "StrStyle" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "Cooked" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Raw" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int))) |
Expressions
Expression (syntax::ast::Expr
). Note that Rust pushes into expressions an unusual number
of constructs including if
, while
, match
, etc.
Box [Attribute a] (Expr a) a | box expression (example: |
InPlace [Attribute a] (Expr a) (Expr a) a | in-place expression - first |
Vec [Attribute a] [Expr a] a | array literal (example: |
Call [Attribute a] (Expr a) [Expr a] a | function call where the first |
MethodCall [Attribute a] (Expr a) Ident (Maybe [Ty a]) [Expr a] a | method call where the first |
TupExpr [Attribute a] [Expr a] a | tuple (example: |
Binary [Attribute a] BinOp (Expr a) (Expr a) a | binary operation (example: |
Unary [Attribute a] UnOp (Expr a) a | unary operation (example: |
Lit [Attribute a] (Lit a) a | literal (example: |
Cast [Attribute a] (Expr a) (Ty a) a | cast (example: |
TypeAscription [Attribute a] (Expr a) (Ty a) a | type annotation (example: |
If [Attribute a] (Expr a) (Block a) (Maybe (Expr a)) a | if expression, with an optional |
IfLet [Attribute a] (NonEmpty (Pat a)) (Expr a) (Block a) (Maybe (Expr a)) a | if-let expression with an optional else block (example: |
While [Attribute a] (Expr a) (Block a) (Maybe (Label a)) a | while loop, with an optional label (example: |
WhileLet [Attribute a] (NonEmpty (Pat a)) (Expr a) (Block a) (Maybe (Label a)) a | while-let loop, with an optional label (example: |
ForLoop [Attribute a] (Pat a) (Expr a) (Block a) (Maybe (Label a)) a | for loop, with an optional label (example: |
Loop [Attribute a] (Block a) (Maybe (Label a)) a | conditionless loop (can be exited with |
Match [Attribute a] (Expr a) [Arm a] a | match block |
Closure [Attribute a] Movability CaptureBy (FnDecl a) (Expr a) a | closure (example: |
BlockExpr [Attribute a] (Block a) a | (possibly unsafe) block (example: |
Catch [Attribute a] (Block a) a | a catch block (example: |
Assign [Attribute a] (Expr a) (Expr a) a | assignment (example: |
AssignOp [Attribute a] BinOp (Expr a) (Expr a) a | assignment with an operator (example: |
FieldAccess [Attribute a] (Expr a) Ident a | access of a named struct field (example: |
TupField [Attribute a] (Expr a) Int a | access of an unnamed field of a struct or tuple-struct (example: |
Index [Attribute a] (Expr a) (Expr a) a | indexing operation (example: |
Range [Attribute a] (Maybe (Expr a)) (Maybe (Expr a)) RangeLimits a | range (examples: |
PathExpr [Attribute a] (Maybe (QSelf a)) (Path a) a | variable reference |
AddrOf [Attribute a] Mutability (Expr a) a | referencing operation (example: |
Break [Attribute a] (Maybe (Label a)) (Maybe (Expr a)) a |
|
Continue [Attribute a] (Maybe (Label a)) a |
|
Ret [Attribute a] (Maybe (Expr a)) a |
|
MacExpr [Attribute a] (Mac a) a | macro invocation before expansion |
Struct [Attribute a] (Path a) [Field a] (Maybe (Expr a)) a | struct literal expression (examples: |
Repeat [Attribute a] (Expr a) (Expr a) a | array literal constructed from one repeated element (example: |
ParenExpr [Attribute a] (Expr a) a | no-op: used solely so we can pretty print faithfully |
Try [Attribute a] (Expr a) a | sugar for error handling with |
Yield [Attribute a] (Maybe (Expr a)) a |
|
EmbeddedExpr [Attribute a] String a | embedded Haskell expressions for use by quasiquoters |
Instances
ABIs support by Rust's foreign function interface (syntax::abi::Abi
). Note that of these,
only Rust
, C
, System
, RustIntrinsic
, RustCall
, and PlatformIntrinsic
and Unadjusted
are cross-platform - all the rest are platform-specific.
Example: "C"
as in extern "C" fn foo(x: i32);
Cdecl | |
Stdcall | |
Fastcall | |
Vectorcall | |
Aapcs | |
Win64 | |
SysV64 | |
PtxKernel | |
Msp430Interrupt | |
X86Interrupt | |
Rust | |
C | |
System | |
RustIntrinsic | |
RustCall | |
PlatformIntrinsic | |
Unadjusted |
Instances
Bounded Abi Source # | |
Enum Abi Source # | |
Eq Abi Source # | |
Data Abi Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Abi -> c Abi # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Abi # dataTypeOf :: Abi -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Abi) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Abi) # gmapT :: (forall b. Data b => b -> b) -> Abi -> Abi # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Abi -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Abi -> r # gmapQ :: (forall d. Data d => d -> u) -> Abi -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Abi -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Abi -> m Abi # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Abi -> m Abi # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Abi -> m Abi # | |
Ord Abi Source # | |
Read Abi Source # | |
Show Abi Source # | |
Generic Abi Source # | |
NFData Abi Source # | |
Defined in Language.Rust.Syntax.AST | |
Pretty Abi Source # | |
Defined in Language.Rust.Pretty prettyUnresolved :: Abi -> Doc b Source # | |
type Rep Abi Source # | |
Defined in Language.Rust.Syntax.AST type Rep Abi = D1 (MetaData "Abi" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) ((((C1 (MetaCons "Cdecl" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Stdcall" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "Fastcall" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Vectorcall" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "Aapcs" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Win64" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "SysV64" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "PtxKernel" PrefixI False) (U1 :: Type -> Type)))) :+: (((C1 (MetaCons "Msp430Interrupt" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "X86Interrupt" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "Rust" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "C" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "System" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "RustIntrinsic" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "RustCall" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "PlatformIntrinsic" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Unadjusted" PrefixI False) (U1 :: Type -> Type)))))) |
An arm of a Match
expression (syntax::ast::Arm
). An arm has at least one patten, possibly a
guard expression, and a body expression.
Example: n if n % 4 == 3 => { println!("{} % 4 = 3", n) }
as in
match n { n if n % 4 == 3 => { println!("{} % 4 = 3", n) } n if n % 4 == 1 => { println!("{} % 4 = 1", n) } _ => println!("{} % 2 = 0", n) }
Instances
Instances
Bounded UnOp Source # | |
Enum UnOp Source # | |
Eq UnOp Source # | |
Data UnOp Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UnOp -> c UnOp # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UnOp # dataTypeOf :: UnOp -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UnOp) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UnOp) # gmapT :: (forall b. Data b => b -> b) -> UnOp -> UnOp # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UnOp -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UnOp -> r # gmapQ :: (forall d. Data d => d -> u) -> UnOp -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UnOp -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UnOp -> m UnOp # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UnOp -> m UnOp # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UnOp -> m UnOp # | |
Ord UnOp Source # | |
Show UnOp Source # | |
Generic UnOp Source # | |
NFData UnOp Source # | |
Defined in Language.Rust.Syntax.AST | |
Pretty UnOp Source # | |
Defined in Language.Rust.Pretty prettyUnresolved :: UnOp -> Doc b Source # | |
type Rep UnOp Source # | |
Defined in Language.Rust.Syntax.AST |
Binary operators, used in the Binary
and AssignOp
constructors of Expr
(syntax::ast::BinOp
).
Example: +
as in 1 + 1
or 1 += 1
AddOp |
|
SubOp |
|
MulOp |
|
DivOp |
|
RemOp |
|
AndOp |
|
OrOp |
|
BitXorOp |
|
BitAndOp |
|
BitOrOp |
|
ShlOp |
|
ShrOp |
|
EqOp |
|
LtOp |
|
LeOp |
|
NeOp |
|
GeOp |
|
GtOp |
|
Instances
Bounded BinOp Source # | |
Enum BinOp Source # | |
Defined in Language.Rust.Syntax.AST | |
Eq BinOp Source # | |
Data BinOp Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BinOp -> c BinOp # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BinOp # dataTypeOf :: BinOp -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BinOp) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BinOp) # gmapT :: (forall b. Data b => b -> b) -> BinOp -> BinOp # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BinOp -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BinOp -> r # gmapQ :: (forall d. Data d => d -> u) -> BinOp -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BinOp -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BinOp -> m BinOp # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BinOp -> m BinOp # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BinOp -> m BinOp # | |
Ord BinOp Source # | |
Show BinOp Source # | |
Generic BinOp Source # | |
NFData BinOp Source # | |
Defined in Language.Rust.Syntax.AST | |
Pretty BinOp Source # | |
Defined in Language.Rust.Pretty prettyUnresolved :: BinOp -> Doc b Source # | |
type Rep BinOp Source # | |
Defined in Language.Rust.Syntax.AST type Rep BinOp = D1 (MetaData "BinOp" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) ((((C1 (MetaCons "AddOp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "SubOp" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "MulOp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "DivOp" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "RemOp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "AndOp" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "OrOp" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "BitXorOp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "BitAndOp" PrefixI False) (U1 :: Type -> Type))))) :+: (((C1 (MetaCons "BitOrOp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "ShlOp" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "ShrOp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "EqOp" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "LtOp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "LeOp" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "NeOp" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "GeOp" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "GtOp" PrefixI False) (U1 :: Type -> Type)))))) |
Used to annotate loops, breaks, continues, etc.
Instances
Functor Label Source # | |
Eq a => Eq (Label a) Source # | |
Data a => Data (Label a) Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Label a -> c (Label a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Label a) # toConstr :: Label a -> Constr # dataTypeOf :: Label a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Label a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Label a)) # gmapT :: (forall b. Data b => b -> b) -> Label a -> Label a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Label a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Label a -> r # gmapQ :: (forall d. Data d => d -> u) -> Label a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Label a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Label a -> m (Label a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Label a -> m (Label a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Label a -> m (Label a) # | |
Ord a => Ord (Label a) Source # | |
Show a => Show (Label a) Source # | |
Generic (Label a) Source # | |
NFData a => NFData (Label a) Source # | |
Defined in Language.Rust.Syntax.AST | |
Located a => Located (Label a) Source # | |
Generic1 Label Source # | |
type Rep (Label a) Source # | |
Defined in Language.Rust.Syntax.AST type Rep (Label a) = D1 (MetaData "Label" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "Label" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Name) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))) | |
type Rep1 Label Source # | |
Defined in Language.Rust.Syntax.AST type Rep1 Label = D1 (MetaData "Label" "Language.Rust.Syntax.AST" "flp-0.1.0.0-DeMkA8gwwJbCOh6gqZDp9v" False) (C1 (MetaCons "Label" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Name) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) Par1)) |
Describes how a Closure
should close over its free variables (syntax::ast::CaptureBy
).
Instances
data Movability Source #
The movability of a generator / closure literal (syntax::ast::Movability
).
Instances
Field in a struct literal expression (syntax::ast::Field
).
Example: x: 1
in Point { x: 1, y: 2 }
Instances
data RangeLimits Source #
Limit types of a Range
Instances
Types and lifetimes
Types (syntax::ast::Ty
).
Slice (Ty a) a | variable length slice (example: |
Array (Ty a) (Expr a) a | fixed length array (example: |
Ptr Mutability (Ty a) a | raw pointer (example: |
Rptr (Maybe (Lifetime a)) Mutability (Ty a) a | reference (example: |
BareFn Unsafety Abi [LifetimeDef a] (FnDecl a) a | bare function (example: |
Never a | never type: |
TupTy [Ty a] a | tuple (example: |
PathTy (Maybe (QSelf a)) (Path a) a | path type (examples: |
TraitObject (NonEmpty (TyParamBound a)) a | trait object type (example: |
ImplTrait (NonEmpty (TyParamBound a)) a | impl trait type (see the
RFC)
(example: |
ParenTy (Ty a) a | no-op; kept solely so that we can pretty print faithfully |
Typeof (Expr a) a | typeof, currently unsupported in |
Infer a | inferred type: |
MacTy (Mac a) a | generated from a call to a macro (example: |
Instances
Represents lifetimes and type parameters attached to a declaration of a functions, enums,
traits, etc. (syntax::ast::Generics
). Note that lifetime definitions are always required to be
before the type parameters.
This one AST node is also a bit weird: it is the only node whose source representation is not
compact - the lifetimes and type parameters occur by themselves between <
and >
then a
bit further the where clause occurs after a where
.
Example: <'a, 'b: 'c, T: 'a>
and where Option<T>: Copy
as in
fn nonsense<'a, 'b: 'c, T: 'a>(x: i32) -> i32
where Option<T>: Copy {
1
}
.
Generics [LifetimeDef a] [TyParam a] (WhereClause a) a |
Instances
A lifetime is a name for a scope in a program (syntax::ast::Lifetime
). One of the novel
features of Rust is that code can be parametrized over lifetimes. Syntactically, they are like
regular identifiers, but start with a tick '
mark. The Name
argument is not supposed to
include that tick.
Examples: 'a
or 'static
Instances
data LifetimeDef a Source #
A lifetime definition, introducing a lifetime and the other lifetimes that bound it
(syntax::ast::LifetimeDef
).
Example: 'a: 'b + 'c + 'd
LifetimeDef [Attribute a] (Lifetime a) [Lifetime a] a |
Instances
Type parameter definition used in Generics
(syntax::ast::TyParam
). Note that each
parameter can have any number of (lifetime or trait) bounds, as well as possibly a default type.
Instances
data TyParamBound a Source #
Bounds that can be placed on types (syntax::ast::TyParamBound
). These can be either traits or
lifetimes.
TraitTyParamBound (PolyTraitRef a) TraitBoundModifier a | trait bound |
RegionTyParamBound (Lifetime a) a | lifetime bound |
Instances
partitionTyParamBounds :: [TyParamBound a] -> ([TyParamBound a], [TyParamBound a]) Source #
Partition a list of TyParamBound
into a tuple of the TraitTyParamBound
and
RegionTyParamBound
variants.
data WhereClause a Source #
A where
clause in a definition, where one can apply a series of constraints to the types
introduced and used by a Generic
clause (syntax::ast::WhereClause
). In many cases, where
is the only way to express certain bounds (since those bounds may not be immediately on a type
defined in the generic, but on a type derived from types defined in the generic).
Note that while WhereClause
is a field of Generic
, not all uses of generics are coupled with
a where clause. In those cases, we leave the list of predicates empty.
Example: where Option<T>: Debug
as in
impl<T> PrintInOption for T where Option<T>: Debug { }
WhereClause [WherePredicate a] a |
Instances
whereClause :: Generics a -> WhereClause a Source #
Extract the where clause from a Generics
.
data WherePredicate a Source #
An individual predicate in a WhereClause
(syntax::ast::WherePredicate
).
BoundPredicate [LifetimeDef a] (Ty a) [TyParamBound a] a | type bound ( |
RegionPredicate (Lifetime a) [Lifetime a] a | lifetime predicate ( |
EqPredicate (Ty a) (Ty a) a | equality predicate ( |
Instances
data PolyTraitRef a Source #
Trait ref parametrized over lifetimes introduced by a for
(syntax::ast::PolyTraitRef
).
Example: for<'a,'b> Foo<&'a Bar>
PolyTraitRef [LifetimeDef a] (TraitRef a) a |
Instances
A TraitRef
is a path which identifies a trait (syntax::ast::TraitRef
).
Instances
Functor TraitRef Source # | |
PrettyAnnotated TraitRef Source # | |
Defined in Language.Rust.Pretty prettyAnnUnresolved :: TraitRef a -> Doc a Source # | |
Eq a => Eq (TraitRef a) Source # | |
Data a => Data (TraitRef a) Source # | |
Defined in Language.Rust.Syntax.AST gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TraitRef a -> c (TraitRef a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (TraitRef a) # toConstr :: TraitRef a -> Constr # dataTypeOf :: TraitRef a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (TraitRef a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (TraitRef a)) # gmapT :: (forall b. Data b => b -> b) -> TraitRef a -> TraitRef a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TraitRef a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TraitRef a -> r # gmapQ :: (forall d. Data d => d -> u) -> TraitRef a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TraitRef a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TraitRef a -> m (TraitRef a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TraitRef a -> m (TraitRef a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TraitRef a -> m (TraitRef a) # | |
Ord a => Ord (TraitRef a) Source # | |
Show a => Show (TraitRef a) Source # | |
Generic (TraitRef a) Source # | |
NFData a => NFData (TraitRef a) Source # | |
Defined in Language.Rust.Syntax.AST | |
Located a => Located (TraitRef a) Source # | |
(Typeable a, Monoid a) => Resolve (TraitRef a) Source # | |
Pretty (TraitRef a) Source # | |
Defined in Language.Rust.Pretty prettyUnresolved :: TraitRef a -> Doc b Source # | |
Generic1 TraitRef Source # | |
type Rep (TraitRef a) Source # | |
Defined in Language.Rust.Syntax.AST | |
type Rep1 TraitRef Source # | |
Defined in Language.Rust.Syntax.AST |
data TraitBoundModifier Source #
Modifier on a bound, currently this is only used for ?Sized
, where the modifier is Maybe
.
Negative bounds should also be handled here.
Instances
Patterns
Patterns (syntax::ast::Pat
).
WildP a | wildcard pattern: |
IdentP BindingMode Ident (Maybe (Pat a)) a | identifier pattern - either a new bound variable or a unit (tuple) struct pattern, or a
const pattern. Disambiguation cannot be done with parser alone, so it happens during name
resolution. (example: |
StructP (Path a) [FieldPat a] Bool a | struct pattern. The |
TupleStructP (Path a) [Pat a] (Maybe Int) a | tuple struct pattern. If the |
PathP (Maybe (QSelf a)) (Path a) a | path pattern (example |
TupleP [Pat a] (Maybe Int) a | tuple pattern. If the |
BoxP (Pat a) a | box pattern (example: |
RefP (Pat a) Mutability a | reference pattern (example: |
LitP (Expr a) a | literal (example: |
RangeP (Expr a) (Expr a) a | range pattern (example: |
SliceP [Pat a] (Maybe (Pat a)) [Pat a] a | slice pattern where, as per this RFC,
the pattern is split into the patterns before/after the |
MacP (Mac a) a | generated from a call to a macro (example: |
Instances
data BindingMode Source #
Describes how a value bound to an identifier in a pattern is going to be borrowed
(syntax::ast::BindingMode
).
Example: &mut
in |&mut x: i32| -> { x += 1 }
Instances
Field in a struct literal pattern (syntax::ast::FieldPat
). The field name Ident
is optional
but, when it is Nothing
, the pattern the field is destructured to must be IdentP
.
Example: x
in Point { x, y }
Instances
Statements
A statement (syntax::ast::Stmt
). Rust has relatively few types of statements by turning both
expressions (sometimes with a required semicolon at the end) and items into statements.
Local (Pat a) (Maybe (Ty a)) (Maybe (Expr a)) [Attribute a] a | A local |
ItemStmt (Item a) a | Item definition (example: |
NoSemi (Expr a) a | Expression without a trailing semicolon (example: |
Semi (Expr a) a | Expression with a trailing semicolon (example: |
MacStmt (Mac a) MacStmtStyle [Attribute a] a | A macro call (example: |
Instances
Items
A top-level item, possibly in a Mod
or a ItemStmt
(syntax::ast::Item
with
syntax::ast::ItemKind
inlined).
Example: fn main() { return; }
ExternCrate [Attribute a] (Visibility a) Ident (Maybe Ident) a | extern crate item, with optional original crate name.
Examples: |
Use [Attribute a] (Visibility a) (UseTree a) a | use declaration ( |
Static [Attribute a] (Visibility a) Ident (Ty a) Mutability (Expr a) a | static item ( |
ConstItem [Attribute a] (Visibility a) Ident (Ty a) (Expr a) a | constant item ( |
Fn [Attribute a] (Visibility a) Ident (FnDecl a) Unsafety Constness Abi (Generics a) (Block a) a | function declaration ( |
Mod [Attribute a] (Visibility a) Ident (Maybe [Item a]) a | module declaration ( |
ForeignMod [Attribute a] (Visibility a) Abi [ForeignItem a] a | external module ( |
TyAlias [Attribute a] (Visibility a) Ident (Ty a) (Generics a) a | type alias ( |
Enum [Attribute a] (Visibility a) Ident [Variant a] (Generics a) a | enum definition ( |
StructItem [Attribute a] (Visibility a) Ident (VariantData a) (Generics a) a | struct definition ( |
Union [Attribute a] (Visibility a) Ident (VariantData a) (Generics a) a | union definition ( |
Trait [Attribute a] (Visibility a) Ident Bool Unsafety (Generics a) [TyParamBound a] [TraitItem a] a | trait declaration ( |
TraitAlias [Attribute a] (Visibility a) Ident (Generics a) (NonEmpty (TyParamBound a)) a | trait alias
Example: |
Impl [Attribute a] (Visibility a) Defaultness Unsafety ImplPolarity (Generics a) (Maybe (TraitRef a)) (Ty a) [ImplItem a] a | implementation
Example: |
MacItem [Attribute a] (Maybe Ident) (Mac a) a | generated from a call to a macro
Example: |
MacroDef [Attribute a] Ident TokenStream a | definition of a macro via |
Instances
data ForeignItem a Source #
An item within an extern block (syntax::ast::ForeignItem
with syntax::ast::ForeignItemKind
inlined).
Example: static ext: u8
in extern "C" { static ext: u8 }
ForeignFn [Attribute a] (Visibility a) Ident (FnDecl a) (Generics a) a | Foreign function Example: |
ForeignStatic [Attribute a] (Visibility a) Ident (Ty a) Mutability a | Foreign static variable, optionally mutable Example: |
ForeignTy [Attribute a] (Visibility a) Ident a | Foreign type Example: |
Instances
An item within an impl (syntax::ast::ImplItem
with syntax::ast::ImplItemKind
inlined).
Examples:
impl MyTrait { // Associated constant const ID: i32 = 1; // Method fn area(&self) -> f64 { 1f64 } // Associated type type N = i32; // Call to a macro foo!{} }
ConstI [Attribute a] (Visibility a) Defaultness Ident (Ty a) (Expr a) a | Associated constant |
MethodI [Attribute a] (Visibility a) Defaultness Ident (Generics a) (MethodSig a) (Block a) a | Method |
TypeI [Attribute a] (Visibility a) Defaultness Ident (Ty a) a | Associated type |
MacroI [Attribute a] Defaultness (Mac a) a | Macro call |
Instances
Item declaration within a trait declaration (syntax::ast::TraitItem
with
syntax::ast::TraitItemKind
inlined), possibly including a default implementation. A trait item
is either required (meaning it doesn't have an implementation, just a signature) or provided
(meaning it has a default implementation).
Examples:
trait MyTrait { // Associated constant const ID: i32 = 1; // Method fn area(&self) -> f64; // Associated type type N: fmt::Display; // Call to a macro foo!{} }
ConstT [Attribute a] Ident (Ty a) (Maybe (Expr a)) a | Associated constants |
MethodT [Attribute a] Ident (Generics a) (MethodSig a) (Maybe (Block a)) a | Method with optional body |
TypeT [Attribute a] Ident [TyParamBound a] (Maybe (Ty a)) a | Possibly abstract associated types |
MacroT [Attribute a] (Mac a) a | Call to a macro |
Instances
data Defaultness Source #
An ImplItem
can be marked default
(syntax::ast::Defaultness
).
Instances
data ImplPolarity Source #
For traits with a default impl, one can "opt out" of that impl with a negative impl, by adding
!
mark before the trait name. RFC on builtin
traits
Example: !
as in impl !Trait for Foo { }
Instances
data StructField a Source #
Field of a struct (syntax::ast::StructField
) used in declarations
Example: bar: usize
as in struct Foo { bar: usize }
StructField (Maybe Ident) (Visibility a) (Ty a) [Attribute a] a |
Instances
A variant in Rust is a constructor (either in a StructItem
, Union
, or Item
) which groups
together fields (syntax::ast::Variant
). In the case of a unit variant, there can also be an
explicit discriminant expression.
Instances
data VariantData a Source #
Main payload in a Variant
(syntax::ast::VariantData
).
Examples:
enum Foo { // Struct variant Bar { x: f64 }, // Tuple variant Baz(i32, i32), // Unit variant Qux, }
StructD [StructField a] a | Struct variant |
TupleD [StructField a] a | Tuple variant |
UnitD a | Unit variant |
Instances
Paths used in Use
items (ast::syntax::UseTree
).
Examples:
// Simple use paths use foo::bar::baz as quux; use foo::bar::baz; // Glob use paths use foo::bar::*; // Nested use paths use foo::bar::{a, b, c::quux as d}
UseTreeSimple (Path a) (Maybe Ident) a | Simple path, optionally ending in an |
UseTreeGlob (Path a) a | Path ending in a glob pattern |
UseTreeNested (Path a) [UseTree a] a | Path ending in a list of more paths |
Instances
data Visibility a Source #
The visibility modifier dictates from where one can access something
(ast::syntax::Visibility
). RFC about adding restricted
visibility
PublicV |
|
CrateV |
|
RestrictedV (Path a) | for some path |
InheritedV | if no visbility is specified, this is the default |
Instances
Const annotation to specify if a function or method is allowed to be called in constants
context with constant arguments (syntax::ast::Constness
). Relevant
RFC
Example: const
in const fn inc(x: i32) -> i32 { x + 1 }
Instances
Represents a method's signature in a trait declaration, or in an implementation.
Instances
Blocks
A curly brace delimited sequence of statements (syntax::ast::Block
). The last statement in
the block can always be a NoSemi
expression.
Example: { let x = 1; return x + y }
as in fn foo() { let x = 1; return x + y }
Instances
Token trees
When the parser encounters a macro call, it parses what follows as a Delimited
token tree.
Basically, token trees let you store raw tokens or Sequence
forms inside of balanced
parens, braces, or brackets. This is a very loose structure, such that all sorts of different
AST-fragments can be passed to syntax extensions using a uniform type.
Token Span Token | A single token |
Delimited | A delimited sequence of tokens ( |
Instances
data TokenStream Source #
An abstract sequence of tokens, organized into a sequence (e.g. stream) of TokenTree
, each of
which is a single TokenTree
or a Delimited
subsequence of tokens.
Tree TokenTree | a single token or a single set of delimited tokens |
Stream [TokenStream] | stream of streams of tokens |
Instances
unconsTokenStream :: TokenStream -> Maybe (TokenTree, TokenStream) Source #
A TokenStream
is at its core just a stream of TokenTree
. This function lets you get at that
directly. For example, you can use 'Data.List.unfoldr unconsTokenStream' to convert between a
TokenStream
and '[TokenTree]'.
data Nonterminal a Source #
For interpolation during macro expansion (syntax::ast::NonTerminal
).
NtItem (Item a) | |
NtBlock (Block a) | |
NtStmt (Stmt a) | |
NtPat (Pat a) | |
NtExpr (Expr a) | |
NtTy (Ty a) | |
NtIdent Ident | |
NtPath (Path a) | |
NtTT TokenTree | |
NtArm (Arm a) | |
NtImplItem (ImplItem a) | |
NtTraitItem (TraitItem a) | |
NtGenerics (Generics a) | |
NtWhereClause (WhereClause a) | |
NtArg (Arg a) | |
NtLit (Lit a) |
Instances
Represents a macro invocation (syntax::ast::Mac
). The Path
indicates which macro is being
invoked, and the TokenStream
contains the source of the macro invocation.
Mac (Path a) TokenStream a |
Instances
data MacStmtStyle Source #
Style of the macro statement (syntax::ast::MacStmtStyle
).
SemicolonMac | trailing semicolon (example: |
BracesMac | braces (example: |