1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 pub use self::BindingMode
::*;
14 pub use self::BinOp_
::*;
15 pub use self::BlockCheckMode
::*;
16 pub use self::CaptureClause
::*;
17 pub use self::Decl_
::*;
18 pub use self::Expr_
::*;
19 pub use self::FunctionRetTy
::*;
20 pub use self::ForeignItem_
::*;
21 pub use self::Item_
::*;
22 pub use self::Mutability
::*;
23 pub use self::PrimTy
::*;
24 pub use self::Stmt_
::*;
25 pub use self::TraitItem_
::*;
27 pub use self::TyParamBound
::*;
28 pub use self::UnOp
::*;
29 pub use self::UnsafeSource
::*;
30 pub use self::ViewPath_
::*;
31 pub use self::Visibility
::{Public, Inherited}
;
32 pub use self::PathParameters
::*;
35 use hir
::def_id
::DefId
;
36 use util
::nodemap
::{NodeMap, FnvHashSet}
;
38 use syntax_pos
::{mk_sp, Span, ExpnId, DUMMY_SP}
;
39 use syntax
::codemap
::{self, respan, Spanned}
;
41 use syntax
::ast
::{Name, NodeId, DUMMY_NODE_ID, AsmDialect}
;
42 use syntax
::ast
::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem}
;
43 use syntax
::parse
::token
::{keywords, InternedString}
;
45 use syntax
::tokenstream
::TokenTree
;
46 use syntax
::util
::ThinVec
;
48 use std
::collections
::BTreeMap
;
51 /// HIR doesn't commit to a concrete storage type and have its own alias for a vector.
52 /// It can be `Vec`, `P<[T]>` or potentially `Box<[T]>`, or some other container with similar
53 /// behavior. Unlike AST, HIR is mostly a static structure, so we can use an owned slice instead
54 /// of `Vec` to avoid keeping extra capacity.
55 pub type HirVec
<T
> = P
<[T
]>;
57 macro_rules
! hir_vec
{
58 ($elem
:expr
; $n
:expr
) => (
59 $
crate::hir
::HirVec
::from(vec
![$elem
; $n
])
62 $
crate::hir
::HirVec
::from(vec
![$
($x
),*])
64 ($
($x
:expr
,)*) => (hir_vec
![$
($x
),*])
77 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
84 impl fmt
::Debug
for Lifetime
{
85 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
89 print
::lifetime_to_string(self))
93 /// A lifetime definition, eg `'a: 'b+'c+'d`
94 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
95 pub struct LifetimeDef
{
96 pub lifetime
: Lifetime
,
97 pub bounds
: HirVec
<Lifetime
>,
100 /// A "Path" is essentially Rust's notion of a name; for instance:
101 /// std::cmp::PartialEq . It's represented as a sequence of identifiers,
102 /// along with a bunch of supporting information.
103 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
106 /// A `::foo` path, is relative to the crate root rather than current
107 /// module (like paths in an import).
109 /// The segments in the path: the things separated by `::`.
110 pub segments
: HirVec
<PathSegment
>,
113 impl fmt
::Debug
for Path
{
114 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
115 write
!(f
, "path({})", print
::path_to_string(self))
119 impl fmt
::Display
for Path
{
120 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
121 write
!(f
, "{}", print
::path_to_string(self))
126 /// Convert a span and an identifier to the corresponding
128 pub fn from_name(s
: Span
, name
: Name
) -> Path
{
132 segments
: hir_vec
![PathSegment
{
134 parameters
: PathParameters
::none()
140 /// A segment of a path: an identifier, an optional lifetime, and a set of
142 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
143 pub struct PathSegment
{
144 /// The identifier portion of this path segment.
147 /// Type/lifetime parameters attached to this path. They come in
148 /// two flavors: `Path<A,B,C>` and `Path(A,B) -> C`. Note that
149 /// this is more than just simple syntactic sugar; the use of
150 /// parens affects the region binding rules, so we preserve the
152 pub parameters
: PathParameters
,
155 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
156 pub enum PathParameters
{
157 /// The `<'a, A,B,C>` in `foo::bar::baz::<'a, A,B,C>`
158 AngleBracketedParameters(AngleBracketedParameterData
),
159 /// The `(A,B)` and `C` in `Foo(A,B) -> C`
160 ParenthesizedParameters(ParenthesizedParameterData
),
163 impl PathParameters
{
164 pub fn none() -> PathParameters
{
165 AngleBracketedParameters(AngleBracketedParameterData
{
166 lifetimes
: HirVec
::new(),
167 types
: HirVec
::new(),
168 bindings
: HirVec
::new(),
172 pub fn is_empty(&self) -> bool
{
174 AngleBracketedParameters(ref data
) => data
.is_empty(),
176 // Even if the user supplied no types, something like
177 // `X()` is equivalent to `X<(),()>`.
178 ParenthesizedParameters(..) => false,
182 pub fn has_lifetimes(&self) -> bool
{
184 AngleBracketedParameters(ref data
) => !data
.lifetimes
.is_empty(),
185 ParenthesizedParameters(_
) => false,
189 pub fn has_types(&self) -> bool
{
191 AngleBracketedParameters(ref data
) => !data
.types
.is_empty(),
192 ParenthesizedParameters(..) => true,
196 /// Returns the types that the user wrote. Note that these do not necessarily map to the type
197 /// parameters in the parenthesized case.
198 pub fn types(&self) -> HirVec
<&P
<Ty
>> {
200 AngleBracketedParameters(ref data
) => {
201 data
.types
.iter().collect()
203 ParenthesizedParameters(ref data
) => {
206 .chain(data
.output
.iter())
212 pub fn lifetimes(&self) -> HirVec
<&Lifetime
> {
214 AngleBracketedParameters(ref data
) => {
215 data
.lifetimes
.iter().collect()
217 ParenthesizedParameters(_
) => {
223 pub fn bindings(&self) -> HirVec
<&TypeBinding
> {
225 AngleBracketedParameters(ref data
) => {
226 data
.bindings
.iter().collect()
228 ParenthesizedParameters(_
) => {
235 /// A path like `Foo<'a, T>`
236 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
237 pub struct AngleBracketedParameterData
{
238 /// The lifetime parameters for this path segment.
239 pub lifetimes
: HirVec
<Lifetime
>,
240 /// The type parameters for this path segment, if present.
241 pub types
: HirVec
<P
<Ty
>>,
242 /// Bindings (equality constraints) on associated types, if present.
243 /// E.g., `Foo<A=Bar>`.
244 pub bindings
: HirVec
<TypeBinding
>,
247 impl AngleBracketedParameterData
{
248 fn is_empty(&self) -> bool
{
249 self.lifetimes
.is_empty() && self.types
.is_empty() && self.bindings
.is_empty()
253 /// A path like `Foo(A,B) -> C`
254 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
255 pub struct ParenthesizedParameterData
{
260 pub inputs
: HirVec
<P
<Ty
>>,
263 pub output
: Option
<P
<Ty
>>,
266 /// The AST represents all type param bounds as types.
267 /// typeck::collect::compute_bounds matches these against
268 /// the "special" built-in traits (see middle::lang_items) and
269 /// detects Copy, Send and Sync.
270 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
271 pub enum TyParamBound
{
272 TraitTyParamBound(PolyTraitRef
, TraitBoundModifier
),
273 RegionTyParamBound(Lifetime
),
276 /// A modifier on a bound, currently this is only used for `?Sized`, where the
277 /// modifier is `Maybe`. Negative bounds should also be handled here.
278 #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
279 pub enum TraitBoundModifier
{
284 pub type TyParamBounds
= HirVec
<TyParamBound
>;
286 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
290 pub bounds
: TyParamBounds
,
291 pub default: Option
<P
<Ty
>>,
295 /// Represents lifetimes and type parameters attached to a declaration
296 /// of a function, enum, trait, etc.
297 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
298 pub struct Generics
{
299 pub lifetimes
: HirVec
<LifetimeDef
>,
300 pub ty_params
: HirVec
<TyParam
>,
301 pub where_clause
: WhereClause
,
306 pub fn empty() -> Generics
{
308 lifetimes
: HirVec
::new(),
309 ty_params
: HirVec
::new(),
310 where_clause
: WhereClause
{
312 predicates
: HirVec
::new(),
318 pub fn is_lt_parameterized(&self) -> bool
{
319 !self.lifetimes
.is_empty()
322 pub fn is_type_parameterized(&self) -> bool
{
323 !self.ty_params
.is_empty()
326 pub fn is_parameterized(&self) -> bool
{
327 self.is_lt_parameterized() || self.is_type_parameterized()
331 /// A `where` clause in a definition
332 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
333 pub struct WhereClause
{
335 pub predicates
: HirVec
<WherePredicate
>,
338 /// A single predicate in a `where` clause
339 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
340 pub enum WherePredicate
{
341 /// A type binding, eg `for<'c> Foo: Send+Clone+'c`
342 BoundPredicate(WhereBoundPredicate
),
343 /// A lifetime predicate, e.g. `'a: 'b+'c`
344 RegionPredicate(WhereRegionPredicate
),
345 /// An equality predicate (unsupported)
346 EqPredicate(WhereEqPredicate
),
349 /// A type bound, eg `for<'c> Foo: Send+Clone+'c`
350 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
351 pub struct WhereBoundPredicate
{
353 /// Any lifetimes from a `for` binding
354 pub bound_lifetimes
: HirVec
<LifetimeDef
>,
355 /// The type being bounded
356 pub bounded_ty
: P
<Ty
>,
357 /// Trait and lifetime bounds (`Clone+Send+'static`)
358 pub bounds
: TyParamBounds
,
361 /// A lifetime predicate, e.g. `'a: 'b+'c`
362 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
363 pub struct WhereRegionPredicate
{
365 pub lifetime
: Lifetime
,
366 pub bounds
: HirVec
<Lifetime
>,
369 /// An equality predicate (unsupported), e.g. `T=int`
370 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
371 pub struct WhereEqPredicate
{
378 pub type CrateConfig
= HirVec
<P
<MetaItem
>>;
380 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
383 pub attrs
: HirVec
<Attribute
>,
384 pub config
: CrateConfig
,
386 pub exported_macros
: HirVec
<MacroDef
>,
388 // NB: We use a BTreeMap here so that `visit_all_items` iterates
389 // over the ids in increasing order. In principle it should not
390 // matter what order we visit things in, but in *practice* it
391 // does, because it can affect the order in which errors are
392 // detected, which in turn can make compile-fail tests yield
393 // slightly different results.
394 pub items
: BTreeMap
<NodeId
, Item
>,
398 pub fn item(&self, id
: NodeId
) -> &Item
{
402 /// Visits all items in the crate in some determinstic (but
403 /// unspecified) order. If you just need to process every item,
404 /// but don't care about nesting, this method is the best choice.
406 /// If you do care about nesting -- usually because your algorithm
407 /// follows lexical scoping rules -- then you want a different
408 /// approach. You should override `visit_nested_item` in your
409 /// visitor and then call `intravisit::walk_crate` instead.
410 pub fn visit_all_items
<'hir
, V
>(&'hir
self, visitor
: &mut V
)
411 where V
: intravisit
::Visitor
<'hir
>
413 for (_
, item
) in &self.items
{
414 visitor
.visit_item(item
);
419 /// A macro definition, in this crate or imported from another.
421 /// Not parsed directly, but created on macro import or `macro_rules!` expansion.
422 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
423 pub struct MacroDef
{
425 pub attrs
: HirVec
<Attribute
>,
428 pub imported_from
: Option
<Name
>,
430 pub use_locally
: bool
,
431 pub allow_internal_unstable
: bool
,
432 pub body
: HirVec
<TokenTree
>,
435 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
437 /// Statements in a block
438 pub stmts
: HirVec
<Stmt
>,
439 /// An expression at the end of the block
440 /// without a semicolon, if any
441 pub expr
: Option
<P
<Expr
>>,
443 /// Distinguishes between `unsafe { ... }` and `{ ... }`
444 pub rules
: BlockCheckMode
,
448 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
455 impl fmt
::Debug
for Pat
{
456 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
457 write
!(f
, "pat({}: {})", self.id
, print
::pat_to_string(self))
462 // FIXME(#19596) this is a workaround, but there should be a better way
463 fn walk_
<G
>(&self, it
: &mut G
) -> bool
464 where G
: FnMut(&Pat
) -> bool
471 PatKind
::Binding(.., Some(ref p
)) => p
.walk_(it
),
472 PatKind
::Struct(_
, ref fields
, _
) => {
473 fields
.iter().all(|field
| field
.node
.pat
.walk_(it
))
475 PatKind
::TupleStruct(_
, ref s
, _
) | PatKind
::Tuple(ref s
, _
) => {
476 s
.iter().all(|p
| p
.walk_(it
))
478 PatKind
::Box(ref s
) | PatKind
::Ref(ref s
, _
) => {
481 PatKind
::Vec(ref before
, ref slice
, ref after
) => {
482 before
.iter().all(|p
| p
.walk_(it
)) &&
483 slice
.iter().all(|p
| p
.walk_(it
)) &&
484 after
.iter().all(|p
| p
.walk_(it
))
489 PatKind
::Binding(..) |
490 PatKind
::Path(..) => {
496 pub fn walk
<F
>(&self, mut it
: F
) -> bool
497 where F
: FnMut(&Pat
) -> bool
503 /// A single field in a struct pattern
505 /// Patterns like the fields of Foo `{ x, ref y, ref mut z }`
506 /// are treated the same as` x: x, y: ref y, z: ref mut z`,
507 /// except is_shorthand is true
508 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
509 pub struct FieldPat
{
510 /// The identifier for the field
512 /// The pattern the field is destructured to
514 pub is_shorthand
: bool
,
517 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
518 pub enum BindingMode
{
519 BindByRef(Mutability
),
520 BindByValue(Mutability
),
523 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
525 /// Represents a wildcard pattern (`_`)
528 /// A fresh binding `ref mut binding @ OPT_SUBPATTERN`.
529 Binding(BindingMode
, Spanned
<Name
>, Option
<P
<Pat
>>),
531 /// A struct or struct variant pattern, e.g. `Variant {x, y, ..}`.
532 /// The `bool` is `true` in the presence of a `..`.
533 Struct(Path
, HirVec
<Spanned
<FieldPat
>>, bool
),
535 /// A tuple struct/variant pattern `Variant(x, y, .., z)`.
536 /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
537 /// 0 <= position <= subpats.len()
538 TupleStruct(Path
, HirVec
<P
<Pat
>>, Option
<usize>),
540 /// A possibly qualified path pattern.
541 /// Such pattern can be resolved to a unit struct/variant or a constant.
542 Path(Option
<QSelf
>, Path
),
544 /// A tuple pattern `(a, b)`.
545 /// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
546 /// 0 <= position <= subpats.len()
547 Tuple(HirVec
<P
<Pat
>>, Option
<usize>),
550 /// A reference pattern, e.g. `&mut (a, b)`
551 Ref(P
<Pat
>, Mutability
),
554 /// A range pattern, e.g. `1...2`
555 Range(P
<Expr
>, P
<Expr
>),
556 /// `[a, b, ..i, y, z]` is represented as:
557 /// `PatKind::Vec(box [a, b], Some(i), box [y, z])`
558 Vec(HirVec
<P
<Pat
>>, Option
<P
<Pat
>>, HirVec
<P
<Pat
>>),
561 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
562 pub enum Mutability
{
567 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
569 /// The `+` operator (addition)
571 /// The `-` operator (subtraction)
573 /// The `*` operator (multiplication)
575 /// The `/` operator (division)
577 /// The `%` operator (modulus)
579 /// The `&&` operator (logical and)
581 /// The `||` operator (logical or)
583 /// The `^` operator (bitwise xor)
585 /// The `&` operator (bitwise and)
587 /// The `|` operator (bitwise or)
589 /// The `<<` operator (shift left)
591 /// The `>>` operator (shift right)
593 /// The `==` operator (equality)
595 /// The `<` operator (less than)
597 /// The `<=` operator (less than or equal to)
599 /// The `!=` operator (not equal to)
601 /// The `>=` operator (greater than or equal to)
603 /// The `>` operator (greater than)
608 pub fn as_str(self) -> &'
static str {
631 pub fn is_lazy(self) -> bool
{
633 BiAnd
| BiOr
=> true,
638 pub fn is_shift(self) -> bool
{
640 BiShl
| BiShr
=> true,
645 pub fn is_comparison(self) -> bool
{
647 BiEq
| BiLt
| BiLe
| BiNe
| BiGt
| BiGe
=> true,
663 /// Returns `true` if the binary operator takes its arguments by value
664 pub fn is_by_value(self) -> bool
{
665 !self.is_comparison()
669 pub type BinOp
= Spanned
<BinOp_
>;
671 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
673 /// The `*` operator for dereferencing
675 /// The `!` operator for logical inversion
677 /// The `-` operator for negation
682 pub fn as_str(self) -> &'
static str {
690 /// Returns `true` if the unary operator takes its argument by value
691 pub fn is_by_value(self) -> bool
{
693 UnNeg
| UnNot
=> true,
700 pub type Stmt
= Spanned
<Stmt_
>;
702 impl fmt
::Debug
for Stmt_
{
703 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
705 let spanned
= codemap
::dummy_spanned(self.clone());
709 print
::stmt_to_string(&spanned
))
713 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
715 /// Could be an item or a local (let) binding:
716 StmtDecl(P
<Decl
>, NodeId
),
718 /// Expr without trailing semi-colon (must have unit type):
719 StmtExpr(P
<Expr
>, NodeId
),
721 /// Expr with trailing semi-colon (may have any type):
722 StmtSemi(P
<Expr
>, NodeId
),
726 pub fn attrs(&self) -> &[Attribute
] {
728 StmtDecl(ref d
, _
) => d
.node
.attrs(),
730 StmtSemi(ref e
, _
) => &e
.attrs
,
734 pub fn id(&self) -> NodeId
{
736 StmtDecl(_
, id
) => id
,
737 StmtExpr(_
, id
) => id
,
738 StmtSemi(_
, id
) => id
,
743 // FIXME (pending discussion of #1697, #2178...): local should really be
744 // a refinement on pat.
745 /// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
746 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
749 pub ty
: Option
<P
<Ty
>>,
750 /// Initializer expression to set the value, if any
751 pub init
: Option
<P
<Expr
>>,
754 pub attrs
: ThinVec
<Attribute
>,
757 pub type Decl
= Spanned
<Decl_
>;
759 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
761 /// A local (let) binding:
768 pub fn attrs(&self) -> &[Attribute
] {
770 DeclLocal(ref l
) => &l
.attrs
,
776 /// represents one arm of a 'match'
777 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
779 pub attrs
: HirVec
<Attribute
>,
780 pub pats
: HirVec
<P
<Pat
>>,
781 pub guard
: Option
<P
<Expr
>>,
785 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
787 pub name
: Spanned
<Name
>,
792 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
793 pub enum BlockCheckMode
{
795 UnsafeBlock(UnsafeSource
),
796 PushUnsafeBlock(UnsafeSource
),
797 PopUnsafeBlock(UnsafeSource
),
798 // Within this block (but outside a PopUnstableBlock), we suspend checking of stability.
803 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
804 pub enum UnsafeSource
{
810 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
815 pub attrs
: ThinVec
<Attribute
>,
818 impl fmt
::Debug
for Expr
{
819 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
820 write
!(f
, "expr({}: {})", self.id
, print
::expr_to_string(self))
824 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
826 /// A `box x` expression.
828 /// An array (`[a, b, c, d]`)
829 ExprVec(HirVec
<P
<Expr
>>),
832 /// The first field resolves to the function itself (usually an `ExprPath`),
833 /// and the second field is the list of arguments
834 ExprCall(P
<Expr
>, HirVec
<P
<Expr
>>),
835 /// A method call (`x.foo::<Bar, Baz>(a, b, c, d)`)
837 /// The `Spanned<Name>` is the identifier for the method name.
838 /// The vector of `Ty`s are the ascripted type parameters for the method
839 /// (within the angle brackets).
841 /// The first element of the vector of `Expr`s is the expression that
842 /// evaluates to the object on which the method is being called on (the
843 /// receiver), and the remaining elements are the rest of the arguments.
845 /// Thus, `x.foo::<Bar, Baz>(a, b, c, d)` is represented as
846 /// `ExprMethodCall(foo, [Bar, Baz], [x, a, b, c, d])`.
847 ExprMethodCall(Spanned
<Name
>, HirVec
<P
<Ty
>>, HirVec
<P
<Expr
>>),
848 /// A tuple (`(a, b, c ,d)`)
849 ExprTup(HirVec
<P
<Expr
>>),
850 /// A binary operation (For example: `a + b`, `a * b`)
851 ExprBinary(BinOp
, P
<Expr
>, P
<Expr
>),
852 /// A unary operation (For example: `!x`, `*x`)
853 ExprUnary(UnOp
, P
<Expr
>),
854 /// A literal (For example: `1`, `"foo"`)
856 /// A cast (`foo as f64`)
857 ExprCast(P
<Expr
>, P
<Ty
>),
858 ExprType(P
<Expr
>, P
<Ty
>),
859 /// An `if` block, with an optional else block
861 /// `if expr { block } else { expr }`
862 ExprIf(P
<Expr
>, P
<Block
>, Option
<P
<Expr
>>),
863 /// A while loop, with an optional label
865 /// `'label: while expr { block }`
866 ExprWhile(P
<Expr
>, P
<Block
>, Option
<Spanned
<Name
>>),
867 /// Conditionless loop (can be exited with break, continue, or return)
869 /// `'label: loop { block }`
870 ExprLoop(P
<Block
>, Option
<Spanned
<Name
>>),
871 /// A `match` block, with a source that indicates whether or not it is
872 /// the result of a desugaring, and if so, which kind.
873 ExprMatch(P
<Expr
>, HirVec
<Arm
>, MatchSource
),
874 /// A closure (for example, `move |a, b, c| {a + b + c}`).
876 /// The final span is the span of the argument block `|...|`
877 ExprClosure(CaptureClause
, P
<FnDecl
>, P
<Block
>, Span
),
878 /// A block (`{ ... }`)
881 /// An assignment (`a = foo()`)
882 ExprAssign(P
<Expr
>, P
<Expr
>),
883 /// An assignment with an operator
885 /// For example, `a += 1`.
886 ExprAssignOp(BinOp
, P
<Expr
>, P
<Expr
>),
887 /// Access of a named struct field (`obj.foo`)
888 ExprField(P
<Expr
>, Spanned
<Name
>),
889 /// Access of an unnamed field of a struct or tuple-struct
891 /// For example, `foo.0`.
892 ExprTupField(P
<Expr
>, Spanned
<usize>),
893 /// An indexing operation (`foo[2]`)
894 ExprIndex(P
<Expr
>, P
<Expr
>),
896 /// Variable reference, possibly containing `::` and/or type
897 /// parameters, e.g. foo::bar::<baz>.
899 /// Optionally "qualified",
900 /// e.g. `<HirVec<T> as SomeTrait>::SomeType`.
901 ExprPath(Option
<QSelf
>, Path
),
903 /// A referencing operation (`&a` or `&mut a`)
904 ExprAddrOf(Mutability
, P
<Expr
>),
905 /// A `break`, with an optional label to break
906 ExprBreak(Option
<Spanned
<Name
>>),
907 /// A `continue`, with an optional label
908 ExprAgain(Option
<Spanned
<Name
>>),
909 /// A `return`, with an optional value to be returned
910 ExprRet(Option
<P
<Expr
>>),
912 /// Inline assembly (from `asm!`), with its outputs and inputs.
913 ExprInlineAsm(InlineAsm
, Vec
<P
<Expr
>>, Vec
<P
<Expr
>>),
915 /// A struct or struct-like variant literal expression.
917 /// For example, `Foo {x: 1, y: 2}`, or
918 /// `Foo {x: 1, .. base}`, where `base` is the `Option<Expr>`.
919 ExprStruct(Path
, HirVec
<Field
>, Option
<P
<Expr
>>),
921 /// An array literal constructed from one repeated element.
923 /// For example, `[1; 5]`. The first expression is the element
924 /// to be repeated; the second is the number of times to repeat it.
925 ExprRepeat(P
<Expr
>, P
<Expr
>),
928 /// The explicit Self type in a "qualified path". The actual
929 /// path, including the trait and the associated item, is stored
930 /// separately. `position` represents the index of the associated
931 /// item qualified with this Self type.
933 /// <HirVec<T> as a::b::Trait>::AssociatedItem
934 /// ^~~~~ ~~~~~~~~~~~~~~^
937 /// <HirVec<T>>::AssociatedItem
940 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
946 /// Hints at the original code for a `match _ { .. }`
947 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
948 pub enum MatchSource
{
949 /// A `match _ { .. }`
951 /// An `if let _ = _ { .. }` (optionally with `else { .. }`)
953 contains_else_clause
: bool
,
955 /// A `while let _ = _ { .. }` (which was desugared to a
956 /// `loop { match _ { .. } }`)
958 /// A desugared `for _ in _ { .. }` loop
960 /// A desugared `?` operator
964 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
965 pub enum CaptureClause
{
970 // NB: If you change this, you'll probably want to change the corresponding
971 // type structure in middle/ty.rs as well.
972 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
975 pub mutbl
: Mutability
,
978 /// Represents a method's signature in a trait declaration or implementation.
979 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
980 pub struct MethodSig
{
981 pub unsafety
: Unsafety
,
982 pub constness
: Constness
,
985 pub generics
: Generics
,
988 /// Represents an item declaration within a trait declaration,
989 /// possibly including a default implementation. A trait item is
990 /// either required (meaning it doesn't have an implementation, just a
991 /// signature) or provided (meaning it has a default implementation).
992 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
993 pub struct TraitItem
{
996 pub attrs
: HirVec
<Attribute
>,
997 pub node
: TraitItem_
,
1001 /// Represents a trait method or associated constant or type
1002 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1003 pub enum TraitItem_
{
1004 /// An associated constant with an optional value (otherwise `impl`s
1005 /// must contain a value)
1006 ConstTraitItem(P
<Ty
>, Option
<P
<Expr
>>),
1007 /// A method with an optional body
1008 MethodTraitItem(MethodSig
, Option
<P
<Block
>>),
1009 /// An associated type with (possibly empty) bounds and optional concrete
1011 TypeTraitItem(TyParamBounds
, Option
<P
<Ty
>>),
1014 /// Represents anything within an `impl` block
1015 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1016 pub struct ImplItem
{
1019 pub vis
: Visibility
,
1020 pub defaultness
: Defaultness
,
1021 pub attrs
: HirVec
<Attribute
>,
1022 pub node
: ImplItemKind
,
1026 /// Represents different contents within `impl`s
1027 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1028 pub enum ImplItemKind
{
1029 /// An associated constant of the given type, set to the constant result
1030 /// of the expression
1031 Const(P
<Ty
>, P
<Expr
>),
1032 /// A method implementation with the given signature and body
1033 Method(MethodSig
, P
<Block
>),
1034 /// An associated type
1038 // Bind a type to an associated type: `A=Foo`.
1039 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1040 pub struct TypeBinding
{
1048 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
1055 impl fmt
::Debug
for Ty
{
1056 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
1057 write
!(f
, "type({})", print
::ty_to_string(self))
1061 /// Not represented directly in the AST, referred to by name through a ty_path.
1062 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
1072 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1073 pub struct BareFnTy
{
1074 pub unsafety
: Unsafety
,
1076 pub lifetimes
: HirVec
<LifetimeDef
>,
1077 pub decl
: P
<FnDecl
>,
1080 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1081 /// The different kinds of types recognized by the compiler
1083 /// A variable length array (`[T]`)
1085 /// A fixed length array (`[T; n]`)
1086 TyFixedLengthVec(P
<Ty
>, P
<Expr
>),
1087 /// A raw pointer (`*const T` or `*mut T`)
1089 /// A reference (`&'a T` or `&'a mut T`)
1090 TyRptr(Option
<Lifetime
>, MutTy
),
1091 /// A bare function (e.g. `fn(usize) -> bool`)
1092 TyBareFn(P
<BareFnTy
>),
1093 /// The never type (`!`)
1095 /// A tuple (`(A, B, C, D,...)`)
1096 TyTup(HirVec
<P
<Ty
>>),
1097 /// A path (`module::module::...::Type`), optionally
1098 /// "qualified", e.g. `<HirVec<T> as SomeTrait>::SomeType`.
1100 /// Type parameters are stored in the Path itself
1101 TyPath(Option
<QSelf
>, Path
),
1102 /// Something like `A+B`. Note that `B` must always be a path.
1103 TyObjectSum(P
<Ty
>, TyParamBounds
),
1104 /// A type like `for<'a> Foo<&'a Bar>`
1105 TyPolyTraitRef(TyParamBounds
),
1106 /// An `impl TraitA+TraitB` type.
1107 TyImplTrait(TyParamBounds
),
1110 /// TyInfer means the type should be inferred instead of it having been
1111 /// specified. This can appear anywhere in a type.
1115 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1116 pub struct InlineAsmOutput
{
1117 pub constraint
: InternedString
,
1119 pub is_indirect
: bool
,
1122 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1123 pub struct InlineAsm
{
1124 pub asm
: InternedString
,
1125 pub asm_str_style
: StrStyle
,
1126 pub outputs
: HirVec
<InlineAsmOutput
>,
1127 pub inputs
: HirVec
<InternedString
>,
1128 pub clobbers
: HirVec
<InternedString
>,
1130 pub alignstack
: bool
,
1131 pub dialect
: AsmDialect
,
1132 pub expn_id
: ExpnId
,
1135 /// represents an argument in a function header
1136 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1143 /// Alternative representation for `Arg`s describing `self` parameter of methods.
1144 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1146 /// `self`, `mut self`
1148 /// `&'lt self`, `&'lt mut self`
1149 Region(Option
<Lifetime
>, Mutability
),
1150 /// `self: TYPE`, `mut self: TYPE`
1151 Explicit(P
<Ty
>, Mutability
),
1154 pub type ExplicitSelf
= Spanned
<SelfKind
>;
1157 pub fn to_self(&self) -> Option
<ExplicitSelf
> {
1158 if let PatKind
::Binding(BindByValue(mutbl
), name
, _
) = self.pat
.node
{
1159 if name
.node
== keywords
::SelfValue
.name() {
1160 return match self.ty
.node
{
1161 TyInfer
=> Some(respan(self.pat
.span
, SelfKind
::Value(mutbl
))),
1162 TyRptr(lt
, MutTy{ref ty, mutbl}
) if ty
.node
== TyInfer
=> {
1163 Some(respan(self.pat
.span
, SelfKind
::Region(lt
, mutbl
)))
1165 _
=> Some(respan(mk_sp(self.pat
.span
.lo
, self.ty
.span
.hi
),
1166 SelfKind
::Explicit(self.ty
.clone(), mutbl
)))
1173 pub fn is_self(&self) -> bool
{
1174 if let PatKind
::Binding(_
, name
, _
) = self.pat
.node
{
1175 name
.node
== keywords
::SelfValue
.name()
1182 /// Represents the header (not the body) of a function declaration
1183 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1185 pub inputs
: HirVec
<Arg
>,
1186 pub output
: FunctionRetTy
,
1191 pub fn get_self(&self) -> Option
<ExplicitSelf
> {
1192 self.inputs
.get(0).and_then(Arg
::to_self
)
1194 pub fn has_self(&self) -> bool
{
1195 self.inputs
.get(0).map(Arg
::is_self
).unwrap_or(false)
1199 #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1205 #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1206 pub enum Constness
{
1211 #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1212 pub enum Defaultness
{
1218 pub fn is_final(&self) -> bool
{
1219 *self == Defaultness
::Final
1222 pub fn is_default(&self) -> bool
{
1223 *self == Defaultness
::Default
1227 impl fmt
::Display
for Unsafety
{
1228 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
1229 fmt
::Display
::fmt(match *self {
1230 Unsafety
::Normal
=> "normal",
1231 Unsafety
::Unsafe
=> "unsafe",
1237 #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
1238 pub enum ImplPolarity
{
1239 /// `impl Trait for Type`
1241 /// `impl !Trait for Type`
1245 impl fmt
::Debug
for ImplPolarity
{
1246 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
1248 ImplPolarity
::Positive
=> "positive".fmt(f
),
1249 ImplPolarity
::Negative
=> "negative".fmt(f
),
1255 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1256 pub enum FunctionRetTy
{
1257 /// Return type is not specified.
1259 /// Functions default to `()` and
1260 /// closures default to inference. Span points to where return
1261 /// type would be inserted.
1262 DefaultReturn(Span
),
1267 impl FunctionRetTy
{
1268 pub fn span(&self) -> Span
{
1270 DefaultReturn(span
) => span
,
1271 Return(ref ty
) => ty
.span
,
1276 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1278 /// A span from the first token past `{` to the last token until `}`.
1279 /// For `mod foo;`, the inner span ranges from the first token
1280 /// to the last token in the external file.
1282 pub item_ids
: HirVec
<ItemId
>,
1285 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1286 pub struct ForeignMod
{
1288 pub items
: HirVec
<ForeignItem
>,
1291 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1292 pub struct EnumDef
{
1293 pub variants
: HirVec
<Variant
>,
1296 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1297 pub struct Variant_
{
1299 pub attrs
: HirVec
<Attribute
>,
1300 pub data
: VariantData
,
1301 /// Explicit discriminant, eg `Foo = 1`
1302 pub disr_expr
: Option
<P
<Expr
>>,
1305 pub type Variant
= Spanned
<Variant_
>;
1307 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
1308 pub struct PathListItem_
{
1310 /// renamed in list, eg `use foo::{bar as baz};`
1311 pub rename
: Option
<Name
>,
1315 pub type PathListItem
= Spanned
<PathListItem_
>;
1317 pub type ViewPath
= Spanned
<ViewPath_
>;
1319 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1320 pub enum ViewPath_
{
1321 /// `foo::bar::baz as quux`
1325 /// `foo::bar::baz` (with `as baz` implicitly on the right)
1326 ViewPathSimple(Name
, Path
),
1331 /// `foo::bar::{a,b,c}`
1332 ViewPathList(Path
, HirVec
<PathListItem
>),
1335 /// TraitRef's appear in impls.
1337 /// resolve maps each TraitRef's ref_id to its defining trait; that's all
1338 /// that the ref_id is for. Note that ref_id's value is not the NodeId of the
1339 /// trait being referred to but just a unique NodeId that serves as a key
1340 /// within the DefMap.
1341 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1342 pub struct TraitRef
{
1347 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1348 pub struct PolyTraitRef
{
1349 /// The `'a` in `<'a> Foo<&'a T>`
1350 pub bound_lifetimes
: HirVec
<LifetimeDef
>,
1352 /// The `Foo<&'a T>` in `<'a> Foo<&'a T>`
1353 pub trait_ref
: TraitRef
,
1358 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1359 pub enum Visibility
{
1362 Restricted { path: P<Path>, id: NodeId }
,
1366 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1367 pub struct StructField
{
1370 pub vis
: Visibility
,
1373 pub attrs
: HirVec
<Attribute
>,
1377 // Still necessary in couple of places
1378 pub fn is_positional(&self) -> bool
{
1379 let first
= self.name
.as_str().as_bytes()[0];
1380 first
>= b'
0'
&& first
<= b'
9'
1384 /// Fields and Ids of enum variants and structs
1386 /// For enum variants: `NodeId` represents both an Id of the variant itself (relevant for all
1387 /// variant kinds) and an Id of the variant's constructor (not relevant for `Struct`-variants).
1388 /// One shared Id can be successfully used for these two purposes.
1389 /// Id of the whole enum lives in `Item`.
1391 /// For structs: `NodeId` represents an Id of the structure's constructor, so it is not actually
1392 /// used for `Struct`-structs (but still presents). Structures don't have an analogue of "Id of
1393 /// the variant itself" from enum variants.
1394 /// Id of the whole struct lives in `Item`.
1395 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1396 pub enum VariantData
{
1397 Struct(HirVec
<StructField
>, NodeId
),
1398 Tuple(HirVec
<StructField
>, NodeId
),
1403 pub fn fields(&self) -> &[StructField
] {
1405 VariantData
::Struct(ref fields
, _
) | VariantData
::Tuple(ref fields
, _
) => fields
,
1409 pub fn id(&self) -> NodeId
{
1411 VariantData
::Struct(_
, id
) | VariantData
::Tuple(_
, id
) | VariantData
::Unit(id
) => id
,
1414 pub fn is_struct(&self) -> bool
{
1415 if let VariantData
::Struct(..) = *self {
1421 pub fn is_tuple(&self) -> bool
{
1422 if let VariantData
::Tuple(..) = *self {
1428 pub fn is_unit(&self) -> bool
{
1429 if let VariantData
::Unit(..) = *self {
1437 // The bodies for items are stored "out of line", in a separate
1438 // hashmap in the `Crate`. Here we just record the node-id of the item
1439 // so it can fetched later.
1440 #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1445 // FIXME (#3300): Should allow items to be anonymous. Right now
1446 // we just use dummy names for anon items.
1449 /// The name might be a dummy name in case of anonymous items
1450 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1453 pub attrs
: HirVec
<Attribute
>,
1456 pub vis
: Visibility
,
1460 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1462 /// An`extern crate` item, with optional original crate name,
1464 /// e.g. `extern crate foo` or `extern crate foo_bar as foo`
1465 ItemExternCrate(Option
<Name
>),
1466 /// A `use` or `pub use` item
1467 ItemUse(P
<ViewPath
>),
1470 ItemStatic(P
<Ty
>, Mutability
, P
<Expr
>),
1472 ItemConst(P
<Ty
>, P
<Expr
>),
1473 /// A function declaration
1474 ItemFn(P
<FnDecl
>, Unsafety
, Constness
, Abi
, Generics
, P
<Block
>),
1477 /// An external module
1478 ItemForeignMod(ForeignMod
),
1479 /// A type alias, e.g. `type Foo = Bar<u8>`
1480 ItemTy(P
<Ty
>, Generics
),
1481 /// An enum definition, e.g. `enum Foo<A, B> {C<A>, D<B>}`
1482 ItemEnum(EnumDef
, Generics
),
1483 /// A struct definition, e.g. `struct Foo<A> {x: A}`
1484 ItemStruct(VariantData
, Generics
),
1485 /// A union definition, e.g. `union Foo<A, B> {x: A, y: B}`
1486 ItemUnion(VariantData
, Generics
),
1487 /// Represents a Trait Declaration
1488 ItemTrait(Unsafety
, Generics
, TyParamBounds
, HirVec
<TraitItem
>),
1490 // Default trait implementations
1492 /// `impl Trait for .. {}`
1493 ItemDefaultImpl(Unsafety
, TraitRef
),
1494 /// An implementation, eg `impl<A> Trait for Foo { .. }`
1498 Option
<TraitRef
>, // (optional) trait this impl implements
1504 pub fn descriptive_variant(&self) -> &str {
1506 ItemExternCrate(..) => "extern crate",
1507 ItemUse(..) => "use",
1508 ItemStatic(..) => "static item",
1509 ItemConst(..) => "constant item",
1510 ItemFn(..) => "function",
1511 ItemMod(..) => "module",
1512 ItemForeignMod(..) => "foreign module",
1513 ItemTy(..) => "type alias",
1514 ItemEnum(..) => "enum",
1515 ItemStruct(..) => "struct",
1516 ItemUnion(..) => "union",
1517 ItemTrait(..) => "trait",
1519 ItemDefaultImpl(..) => "item",
1524 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1525 pub struct ForeignItem
{
1527 pub attrs
: HirVec
<Attribute
>,
1528 pub node
: ForeignItem_
,
1531 pub vis
: Visibility
,
1534 /// An item within an `extern` block
1535 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1536 pub enum ForeignItem_
{
1537 /// A foreign function
1538 ForeignItemFn(P
<FnDecl
>, Generics
),
1539 /// A foreign static item (`static ext: u8`), with optional mutability
1540 /// (the boolean is true when mutable)
1541 ForeignItemStatic(P
<Ty
>, bool
),
1545 pub fn descriptive_variant(&self) -> &str {
1547 ForeignItemFn(..) => "foreign function",
1548 ForeignItemStatic(..) => "foreign static item",
1553 /// A free variable referred to in a function.
1554 #[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
1555 pub struct Freevar
{
1556 /// The variable being accessed free.
1559 // First span where it is accessed (there can be multiple).
1563 pub type FreevarMap
= NodeMap
<Vec
<Freevar
>>;
1565 pub type CaptureModeMap
= NodeMap
<CaptureClause
>;
1567 #[derive(Clone, Debug)]
1568 pub struct TraitCandidate
{
1570 pub import_id
: Option
<NodeId
>,
1573 // Trait method resolution
1574 pub type TraitMap
= NodeMap
<Vec
<TraitCandidate
>>;
1576 // Map from the NodeId of a glob import to a list of items which are actually
1578 pub type GlobMap
= NodeMap
<FnvHashSet
<Name
>>;