Add AAST `Hole` for subtype/coercion error annotation
[hiphop-php.git] / hphp / hack / src / oxidized / gen / aast.rs
blobef03c4789db77d509feb3e832411bb403f08b9c3
1 // Copyright (c) Facebook, Inc. and its affiliates.
2 //
3 // This source code is licensed under the MIT license found in the
4 // LICENSE file in the "hack" directory of this source tree.
5 //
6 // @generated SignedSource<<59caa083c81456c6dc5b200a6865e540>>
7 //
8 // To regenerate this file, run:
9 //   hphp/hack/src/oxidized_regen.sh
11 use arena_trait::TrivialDrop;
12 use no_pos_hash::NoPosHash;
13 use ocamlrep_derive::FromOcamlRep;
14 use ocamlrep_derive::FromOcamlRepIn;
15 use ocamlrep_derive::ToOcamlRep;
16 use serde::Deserialize;
17 use serde::Serialize;
19 #[allow(unused_imports)]
20 use crate::*;
22 pub use aast_defs::*;
23 pub use doc_comment::DocComment;
25 /// Aast.program represents the top-level definitions in a Hack program.
26 /// ex: Expression annotation type (when typechecking, the inferred type)
27 /// fb: Function body tag (e.g. has naming occurred)
28 /// en: Environment (tracking state inside functions and classes)
29 /// hi: Hint annotation (when typechecking it will be the localized type hint or the
30 /// inferred missing type if the hint is missing)
31 pub type Program<Ex, Fb, En, Hi> = Vec<Def<Ex, Fb, En, Hi>>;
33 #[derive(
34     Clone,
35     Debug,
36     Deserialize,
37     Eq,
38     FromOcamlRep,
39     Hash,
40     NoPosHash,
41     Ord,
42     PartialEq,
43     PartialOrd,
44     Serialize,
45     ToOcamlRep
47 pub struct Stmt<Ex, Fb, En, Hi>(pub Pos, pub Stmt_<Ex, Fb, En, Hi>);
49 #[derive(
50     Clone,
51     Debug,
52     Deserialize,
53     Eq,
54     FromOcamlRep,
55     Hash,
56     NoPosHash,
57     Ord,
58     PartialEq,
59     PartialOrd,
60     Serialize,
61     ToOcamlRep
63 pub enum Stmt_<Ex, Fb, En, Hi> {
64     /// Marker for a switch statement that falls through.
65     ///
66     /// // FALLTHROUGH
67     Fallthrough,
68     /// Standalone expression.
69     ///
70     /// 1 + 2;
71     Expr(Box<Expr<Ex, Fb, En, Hi>>),
72     /// Break inside a loop or switch statement.
73     ///
74     /// break;
75     Break,
76     /// Continue inside a loop or switch statement.
77     ///
78     /// continue;
79     Continue,
80     /// Throw an exception.
81     ///
82     /// throw $foo;
83     Throw(Box<Expr<Ex, Fb, En, Hi>>),
84     /// Return, with an optional value.
85     ///
86     /// return;
87     /// return $foo;
88     Return(Box<Option<Expr<Ex, Fb, En, Hi>>>),
89     /// Yield break, terminating the current generator. This behaves like
90     /// return; but is more explicit, and ensures the function is treated
91     /// as a generator.
92     ///
93     /// yield break;
94     YieldBreak,
95     /// Concurrent block. All the await expressions are awaited at the
96     /// same time, similar to genva().
97     ///
98     /// We store the desugared form. In the below example, the list is:
99     /// [('__tmp$1', f()), (__tmp$2, g()), (None, h())]
100     /// and the block assigns the temporary variables back to the locals.
101     /// { $foo = __tmp$1; $bar = __tmp$2; }
102     ///
103     /// concurrent {
104     /// $foo = await f();
105     /// $bar = await g();
106     /// await h();
107     /// }
108     Awaitall(
109         Box<(
110             Vec<(Option<Lid>, Expr<Ex, Fb, En, Hi>)>,
111             Block<Ex, Fb, En, Hi>,
112         )>,
113     ),
114     /// If statement.
115     ///
116     /// if ($foo) { ... } else { ... }
117     If(
118         Box<(
119             Expr<Ex, Fb, En, Hi>,
120             Block<Ex, Fb, En, Hi>,
121             Block<Ex, Fb, En, Hi>,
122         )>,
123     ),
124     /// Do-while loop.
125     ///
126     /// do {
127     /// bar();
128     /// } while($foo)
129     Do(Box<(Block<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>),
130     /// While loop.
131     ///
132     /// while ($foo) {
133     /// bar();
134     /// }
135     While(Box<(Expr<Ex, Fb, En, Hi>, Block<Ex, Fb, En, Hi>)>),
136     /// Initialize a value that is automatically disposed of.
137     ///
138     /// using $foo = bar(); // disposed at the end of the function
139     /// using ($foo = bar(), $baz = quux()) {} // disposed after the block
140     Using(Box<UsingStmt<Ex, Fb, En, Hi>>),
141     /// For loop. The initializer and increment parts can include
142     /// multiple comma-separated statements. The termination condition is
143     /// optional.
144     ///
145     /// for ($i = 0; $i < 100; $i++) { ... }
146     /// for ($x = 0, $y = 0; ; $x++, $y++) { ... }
147     For(
148         Box<(
149             Vec<Expr<Ex, Fb, En, Hi>>,
150             Option<Expr<Ex, Fb, En, Hi>>,
151             Vec<Expr<Ex, Fb, En, Hi>>,
152             Block<Ex, Fb, En, Hi>,
153         )>,
154     ),
155     /// Switch statement.
156     ///
157     /// switch ($foo) {
158     /// case X:
159     /// bar();
160     /// break;
161     /// default:
162     /// baz();
163     /// break;
164     /// }
165     Switch(Box<(Expr<Ex, Fb, En, Hi>, Vec<Case<Ex, Fb, En, Hi>>)>),
166     /// For-each loop.
167     ///
168     /// foreach ($items as $item) { ... }
169     /// foreach ($items as $key => value) { ... }
170     /// foreach ($items await as $item) { ... } // AsyncIterator<_>
171     /// foreach ($items await as $key => value) { ... } // AsyncKeyedIterator<_>
172     Foreach(
173         Box<(
174             Expr<Ex, Fb, En, Hi>,
175             AsExpr<Ex, Fb, En, Hi>,
176             Block<Ex, Fb, En, Hi>,
177         )>,
178     ),
179     /// Try statement, with catch blocks and a finally block.
180     ///
181     /// try {
182     /// foo();
183     /// } catch (SomeException $e) {
184     /// bar();
185     /// } finally {
186     /// baz();
187     /// }
188     Try(
189         Box<(
190             Block<Ex, Fb, En, Hi>,
191             Vec<Catch<Ex, Fb, En, Hi>>,
192             Block<Ex, Fb, En, Hi>,
193         )>,
194     ),
195     /// No-op, the empty statement.
196     ///
197     /// {}
198     /// while (true) ;
199     /// if ($foo) {} // the else is Noop here
200     Noop,
201     /// Block, a list of statements in curly braces.
202     ///
203     /// { $foo = 42; }
204     Block(Block<Ex, Fb, En, Hi>),
205     /// The mode tag at the beginning of a file.
206     /// TODO: this really belongs in def.
207     ///
208     /// <?hh
209     Markup(Box<Pstring>),
210     /// Used in IFC to track type inference environments. Not user
211     /// denotable.
212     AssertEnv(Box<(EnvAnnot, LocalIdMap<Ex>)>),
215 #[derive(
216     Clone,
217     Copy,
218     Debug,
219     Deserialize,
220     Eq,
221     FromOcamlRep,
222     FromOcamlRepIn,
223     Hash,
224     NoPosHash,
225     Ord,
226     PartialEq,
227     PartialOrd,
228     Serialize,
229     ToOcamlRep
231 pub enum EnvAnnot {
232     Join,
233     Refinement,
235 impl TrivialDrop for EnvAnnot {}
237 #[derive(
238     Clone,
239     Debug,
240     Deserialize,
241     Eq,
242     FromOcamlRep,
243     Hash,
244     NoPosHash,
245     Ord,
246     PartialEq,
247     PartialOrd,
248     Serialize,
249     ToOcamlRep
251 pub struct UsingStmt<Ex, Fb, En, Hi> {
252     pub is_block_scoped: bool,
253     pub has_await: bool,
254     pub exprs: (Pos, Vec<Expr<Ex, Fb, En, Hi>>),
255     pub block: Block<Ex, Fb, En, Hi>,
258 #[derive(
259     Clone,
260     Debug,
261     Deserialize,
262     Eq,
263     FromOcamlRep,
264     Hash,
265     NoPosHash,
266     Ord,
267     PartialEq,
268     PartialOrd,
269     Serialize,
270     ToOcamlRep
272 pub enum AsExpr<Ex, Fb, En, Hi> {
273     AsV(Expr<Ex, Fb, En, Hi>),
274     AsKv(Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>),
275     AwaitAsV(Pos, Expr<Ex, Fb, En, Hi>),
276     AwaitAsKv(Pos, Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>),
279 pub type Block<Ex, Fb, En, Hi> = Vec<Stmt<Ex, Fb, En, Hi>>;
281 #[derive(
282     Clone,
283     Debug,
284     Deserialize,
285     Eq,
286     FromOcamlRep,
287     Hash,
288     NoPosHash,
289     Ord,
290     PartialEq,
291     PartialOrd,
292     Serialize,
293     ToOcamlRep
295 pub struct ClassId<Ex, Fb, En, Hi>(pub Ex, pub ClassId_<Ex, Fb, En, Hi>);
297 /// Class ID, used in things like instantiation and static property access.
298 #[derive(
299     Clone,
300     Debug,
301     Deserialize,
302     Eq,
303     FromOcamlRep,
304     Hash,
305     NoPosHash,
306     Ord,
307     PartialEq,
308     PartialOrd,
309     Serialize,
310     ToOcamlRep
312 pub enum ClassId_<Ex, Fb, En, Hi> {
313     /// The class ID of the parent of the lexically scoped class.
314     ///
315     /// In a trait, it is the parent class ID of the using class.
316     ///
317     /// parent::some_meth()
318     /// parent::$prop = 1;
319     /// new parent();
320     CIparent,
321     /// The class ID of the lexically scoped class.
322     ///
323     /// In a trait, it is the class ID of the using class.
324     ///
325     /// self::some_meth()
326     /// self::$prop = 1;
327     /// new self();
328     CIself,
329     /// The class ID of the late static bound class.
330     ///
331     /// https://www.php.net/manual/en/language.oop5.late-static-bindings.php
332     ///
333     /// In a trait, it is the late static bound class ID of the using class.
334     ///
335     /// static::some_meth()
336     /// static::$prop = 1;
337     /// new static();
338     CIstatic,
339     /// Dynamic class name.
340     ///
341     /// TODO: Syntactically this can only be an Lvar/This/Lplacehodller.
342     /// We should use lid rather than expr.
343     ///
344     /// // Assume $d has type dynamic.
345     /// $d::some_meth();
346     /// $d::$prop = 1;
347     /// new $d();
348     CIexpr(Expr<Ex, Fb, En, Hi>),
349     /// Explicit class name. This is the common case.
350     ///
351     /// Foop::some_meth()
352     /// Foo::$prop = 1;
353     /// new Foo();
354     CI(Sid),
357 #[derive(
358     Clone,
359     Debug,
360     Deserialize,
361     Eq,
362     FromOcamlRep,
363     Hash,
364     NoPosHash,
365     Ord,
366     PartialEq,
367     PartialOrd,
368     Serialize,
369     ToOcamlRep
371 pub struct Expr<Ex, Fb, En, Hi>(pub Ex, pub Expr_<Ex, Fb, En, Hi>);
373 #[derive(
374     Clone,
375     Debug,
376     Deserialize,
377     Eq,
378     FromOcamlRep,
379     Hash,
380     NoPosHash,
381     Ord,
382     PartialEq,
383     PartialOrd,
384     Serialize,
385     ToOcamlRep
387 pub enum CollectionTarg<Hi> {
388     CollectionTV(Targ<Hi>),
389     CollectionTKV(Targ<Hi>, Targ<Hi>),
392 #[derive(
393     Clone,
394     Debug,
395     Deserialize,
396     Eq,
397     FromOcamlRep,
398     Hash,
399     NoPosHash,
400     Ord,
401     PartialEq,
402     PartialOrd,
403     Serialize,
404     ToOcamlRep
406 pub enum FunctionPtrId<Ex, Fb, En, Hi> {
407     FPId(Sid),
408     FPClassConst(ClassId<Ex, Fb, En, Hi>, Pstring),
411 #[derive(
412     Clone,
413     Debug,
414     Deserialize,
415     Eq,
416     FromOcamlRep,
417     Hash,
418     NoPosHash,
419     Ord,
420     PartialEq,
421     PartialOrd,
422     Serialize,
423     ToOcamlRep
425 pub struct ExpressionTree<Ex, Fb, En, Hi> {
426     pub hint: Hint,
427     pub desugared_expr: Expr<Ex, Fb, En, Hi>,
430 #[derive(
431     Clone,
432     Debug,
433     Deserialize,
434     Eq,
435     FromOcamlRep,
436     Hash,
437     NoPosHash,
438     Ord,
439     PartialEq,
440     PartialOrd,
441     Serialize,
442     ToOcamlRep
444 pub enum Expr_<Ex, Fb, En, Hi> {
445     /// darray literal.
446     ///
447     /// darray['x' => 0, 'y' => 1]
448     /// darray<string, int>['x' => 0, 'y' => 1]
449     Darray(
450         Box<(
451             Option<(Targ<Hi>, Targ<Hi>)>,
452             Vec<(Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>,
453         )>,
454     ),
455     /// varray literal.
456     ///
457     /// varray['hello', 'world']
458     /// varray<string>['hello', 'world']
459     Varray(Box<(Option<Targ<Hi>>, Vec<Expr<Ex, Fb, En, Hi>>)>),
460     /// Shape literal.
461     ///
462     /// shape('x' => 1, 'y' => 2)
463     Shape(Vec<(ast_defs::ShapeFieldName, Expr<Ex, Fb, En, Hi>)>),
464     /// Collection literal for indexable structures.
465     ///
466     /// Vector {1, 2}
467     /// ImmVector {}
468     /// Set<string> {'foo', 'bar'}
469     /// vec[1, 2]
470     /// keyset[]
471     ValCollection(Box<(VcKind, Option<Targ<Hi>>, Vec<Expr<Ex, Fb, En, Hi>>)>),
472     /// Collection literal for key-value structures.
473     ///
474     /// dict['x' => 1, 'y' => 2]
475     /// Map<int, string> {}
476     /// ImmMap {}
477     KeyValCollection(
478         Box<(
479             KvcKind,
480             Option<(Targ<Hi>, Targ<Hi>)>,
481             Vec<Field<Ex, Fb, En, Hi>>,
482         )>,
483     ),
484     /// Null literal.
485     ///
486     /// null
487     Null,
488     /// The local variable representing the current class instance.
489     ///
490     /// $this
491     This,
492     /// Boolean literal.
493     ///
494     /// true
495     True,
496     /// Boolean literal.
497     ///
498     /// false
499     False,
500     /// The empty expression.
501     ///
502     /// list(, $y) = vec[1, 2] // Omitted is the first expression inside list()
503     Omitted,
504     /// An identifier. Used for method names and global constants.
505     ///
506     /// SOME_CONST
507     /// $x->foo() // id: "foo"
508     Id(Box<Sid>),
509     /// Local variable.
510     ///
511     /// $foo
512     Lvar(Box<Lid>),
513     /// The extra variable in a pipe expression.
514     ///
515     /// $$
516     Dollardollar(Box<Lid>),
517     /// Clone expression.
518     ///
519     /// clone $foo
520     Clone(Box<Expr<Ex, Fb, En, Hi>>),
521     /// Array indexing.
522     ///
523     /// $foo[]
524     /// $foo[$bar]
525     ArrayGet(Box<(Expr<Ex, Fb, En, Hi>, Option<Expr<Ex, Fb, En, Hi>>)>),
526     /// Instance property or method access.  is_prop_call is always
527     /// false, except when inside a call is accessing a property.
528     ///
529     /// $foo->bar // (Obj_get false) property access
530     /// $foo->bar() // (Call (Obj_get false)) method call
531     /// ($foo->bar)() // (Call (Obj_get true)) call lambda stored in property
532     /// $foo?->bar // nullsafe access
533     ObjGet(
534         Box<(
535             Expr<Ex, Fb, En, Hi>,
536             Expr<Ex, Fb, En, Hi>,
537             OgNullFlavor,
538             bool,
539         )>,
540     ),
541     /// Static property access.
542     ///
543     /// Foo::$bar
544     /// $some_classname::$bar
545     /// Foo::${$bar} // only in partial mode
546     ClassGet(Box<(ClassId<Ex, Fb, En, Hi>, ClassGetExpr<Ex, Fb, En, Hi>, bool)>),
547     /// Class constant or static method call. As a standalone expression,
548     /// this is a class constant. Inside a Call node, this is a static
549     /// method call.
550     ///
551     /// This is not ambiguous, because constants are not allowed to
552     /// contain functions.
553     ///
554     /// Foo::some_const // Class_const
555     /// Foo::someStaticMeth() // Call (Class_const)
556     ///
557     /// This syntax is used for both static and instance methods when
558     /// calling the implementation on the superclass.
559     ///
560     /// parent::someStaticMeth()
561     /// parent::someInstanceMeth()
562     ClassConst(Box<(ClassId<Ex, Fb, En, Hi>, Pstring)>),
563     /// Function or method call.
564     ///
565     /// foo()
566     /// $x()
567     /// foo<int>(1, 2, ...$rest)
568     /// $x->foo()
569     ///
570     /// async { return 1; }
571     /// // lowered to:
572     /// (async () ==> { return 1; })()
573     Call(
574         Box<(
575             Expr<Ex, Fb, En, Hi>,
576             Vec<Targ<Hi>>,
577             Vec<Expr<Ex, Fb, En, Hi>>,
578             Option<Expr<Ex, Fb, En, Hi>>,
579         )>,
580     ),
581     /// A reference to a function or method.
582     ///
583     /// foo_fun<>
584     /// FooCls::meth<int>
585     FunctionPointer(Box<(FunctionPtrId<Ex, Fb, En, Hi>, Vec<Targ<Hi>>)>),
586     /// Integer literal.
587     ///
588     /// 42
589     /// 0123 // octal
590     /// 0xBEEF // hexadecimal
591     /// 0b11111111 // binary
592     Int(String),
593     /// Float literal.
594     ///
595     /// 1.0
596     /// 1.2e3
597     /// 7E-10
598     Float(String),
599     /// String literal.
600     ///
601     /// "foo"
602     /// 'foo'
603     ///
604     /// <<<DOC
605     /// foo
606     /// DOC
607     ///
608     /// <<<'DOC'
609     /// foo
610     /// DOC
611     String(bstr::BString),
612     /// Interpolated string literal.
613     ///
614     /// "hello $foo $bar"
615     ///
616     /// <<<DOC
617     /// hello $foo $bar
618     /// DOC
619     String2(Vec<Expr<Ex, Fb, En, Hi>>),
620     /// Prefixed string literal. Only used for regular expressions.
621     ///
622     /// re"foo"
623     PrefixedString(Box<(String, Expr<Ex, Fb, En, Hi>)>),
624     /// Yield expression. The enclosing function should have an Iterator
625     /// return type.
626     ///
627     /// yield $foo // enclosing function returns an Iterator
628     /// yield $foo => $bar // enclosing function returns a KeyedIterator
629     Yield(Box<Afield<Ex, Fb, En, Hi>>),
630     /// Await expression.
631     ///
632     /// await $foo
633     Await(Box<Expr<Ex, Fb, En, Hi>>),
634     /// Readonly expression.
635     ///
636     /// readonly $foo
637     ReadonlyExpr(Box<Expr<Ex, Fb, En, Hi>>),
638     /// List expression, only used in destructuring. Allows any arbitrary
639     /// lvalue as a subexpression. May also nest.
640     ///
641     /// Note that tuple(1, 2) is lowered to a Call, but naming converts it to a List.
642     /// TODO: Define a separate AAST node for tuple.
643     ///
644     /// list($x, $y) = vec[1, 2];
645     /// list(, $y) = vec[1, 2]; // skipping items
646     /// list(list($x)) = vec[vec[1]]; // nesting
647     /// list($v[0], $x[], $y->foo) = $blah;
648     List(Vec<Expr<Ex, Fb, En, Hi>>),
649     /// Cast expression, converting a value to a different type. Only
650     /// primitive types are supported in the hint position.
651     ///
652     /// (int)$foo
653     /// (string)$foo
654     Cast(Box<(Hint, Expr<Ex, Fb, En, Hi>)>),
655     /// Unary operator.
656     ///
657     /// !$foo
658     /// -$foo
659     /// +$foo
660     Unop(Box<(ast_defs::Uop, Expr<Ex, Fb, En, Hi>)>),
661     /// Binary operator.
662     ///
663     /// $foo + $bar
664     Binop(Box<(ast_defs::Bop, Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>),
665     /// Pipe expression. The lid is the ID of the $$ that is implicitly
666     /// declared by this pipe.
667     ///
668     /// See also Dollardollar.
669     ///
670     /// $foo |> bar() // equivalent: bar($foo)
671     /// $foo |> bar(1, $$) // equivalent: bar(1, $foo)
672     Pipe(Box<(Lid, Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>),
673     /// Ternary operator, or elvis operator.
674     ///
675     /// $foo ? $bar : $baz // ternary
676     /// $foo ?: $baz // elvis
677     Eif(
678         Box<(
679             Expr<Ex, Fb, En, Hi>,
680             Option<Expr<Ex, Fb, En, Hi>>,
681             Expr<Ex, Fb, En, Hi>,
682         )>,
683     ),
684     /// Is operator.
685     ///
686     /// $foo is SomeType
687     Is(Box<(Expr<Ex, Fb, En, Hi>, Hint)>),
688     /// As operator.
689     ///
690     /// $foo as int
691     /// $foo ?as int
692     As(Box<(Expr<Ex, Fb, En, Hi>, Hint, bool)>),
693     /// Instantiation.
694     ///
695     /// new Foo(1, 2);
696     /// new Foo<int, T>();
697     /// new Foo('blah', ...$rest);
698     New(
699         Box<(
700             ClassId<Ex, Fb, En, Hi>,
701             Vec<Targ<Hi>>,
702             Vec<Expr<Ex, Fb, En, Hi>>,
703             Option<Expr<Ex, Fb, En, Hi>>,
704             Ex,
705         )>,
706     ),
707     /// Record literal.
708     ///
709     /// MyRecord['x' => $foo, 'y' => $bar]
710     Record(Box<(Sid, Vec<(Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>)>)>),
711     /// PHP-style lambda. Does not capture variables unless explicitly
712     /// specified.
713     ///
714     /// Mnemonic: 'expanded lambda', since we can desugar Lfun to Efun.
715     ///
716     /// function($x) { return $x; }
717     /// function(int $x): int { return $x; }
718     /// function($x) use ($y) { return $y; }
719     /// function($x): int use ($y, $z) { return $x + $y + $z; }
720     Efun(Box<(Fun_<Ex, Fb, En, Hi>, Vec<Lid>)>),
721     /// Hack lambda. Captures variables automatically.
722     ///
723     /// $x ==> $x
724     /// (int $x): int ==> $x + $other
725     /// ($x, $y) ==> { return $x + $y; }
726     Lfun(Box<(Fun_<Ex, Fb, En, Hi>, Vec<Lid>)>),
727     /// XHP expression. May contain interpolated expressions.
728     ///
729     /// <foo x="hello" y={$foo}>hello {$bar}</foo>
730     Xml(
731         Box<(
732             Sid,
733             Vec<XhpAttribute<Ex, Fb, En, Hi>>,
734             Vec<Expr<Ex, Fb, En, Hi>>,
735         )>,
736     ),
737     /// Explicit calling convention, used for inout. Inout supports any lvalue.
738     ///
739     /// TODO: This could be a flag on parameters in Call.
740     ///
741     /// foo(inout $x[0])
742     Callconv(Box<(ast_defs::ParamKind, Expr<Ex, Fb, En, Hi>)>),
743     /// Include or require expression.
744     ///
745     /// require('foo.php')
746     /// require_once('foo.php')
747     /// include('foo.php')
748     /// include_once('foo.php')
749     Import(Box<(ImportFlavor, Expr<Ex, Fb, En, Hi>)>),
750     /// Collection literal.
751     ///
752     /// TODO: T38184446 this is redundant with ValCollection/KeyValCollection.
753     ///
754     /// Vector {}
755     Collection(Box<(Sid, Option<CollectionTarg<Hi>>, Vec<Afield<Ex, Fb, En, Hi>>)>),
756     /// Expression tree literal. Expression trees are not evaluated at
757     /// runtime, but desugared to an expression representing the code.
758     ///
759     /// Foo`1 + bar()`
760     /// Foo`$x ==> $x * ${$value}` // splicing $value
761     ExpressionTree(Box<ExpressionTree<Ex, Fb, En, Hi>>),
762     /// Placeholder local variable.
763     ///
764     /// $_
765     Lplaceholder(Box<Pos>),
766     /// Global function reference.
767     ///
768     /// fun('foo')
769     FunId(Box<Sid>),
770     /// Instance method reference on a specific instance.
771     ///
772     /// TODO: This is only created in naming, and ought to happen in
773     /// lowering or be removed. The emitter just sees a normal Call.
774     ///
775     /// inst_meth($f, 'some_meth') // equivalent: $f->some_meth<>
776     MethodId(Box<(Expr<Ex, Fb, En, Hi>, Pstring)>),
777     /// Instance method reference that can be called with an instance.
778     ///
779     /// meth_caller(FooClass::class, 'some_meth')
780     /// meth_caller('FooClass', 'some_meth')
781     ///
782     /// These examples are equivalent to:
783     ///
784     /// (FooClass $f, ...$args) ==> $f->some_meth(...$args)
785     MethodCaller(Box<(Sid, Pstring)>),
786     /// Static method reference.
787     ///
788     /// class_meth('FooClass', 'some_static_meth')
789     /// // equivalent: FooClass::some_static_meth<>
790     SmethodId(Box<(ClassId<Ex, Fb, En, Hi>, Pstring)>),
791     /// Pair literal.
792     ///
793     /// Pair {$foo, $bar}
794     Pair(
795         Box<(
796             Option<(Targ<Hi>, Targ<Hi>)>,
797             Expr<Ex, Fb, En, Hi>,
798             Expr<Ex, Fb, En, Hi>,
799         )>,
800     ),
801     /// Expression tree splice expression. Only valid inside an
802     /// expression tree literal (backticks).
803     ///
804     /// ${$foo}
805     ETSplice(Box<Expr<Ex, Fb, En, Hi>>),
806     /// Enum atom used for enum classes.
807     ///
808     /// #field_name
809     EnumAtom(String),
810     /// Placeholder for expressions that aren't understood by parts of
811     /// the toolchain.
812     ///
813     /// TODO: Remove.
814     Any,
815     /// Annotation used to record failure in subtyping or coercion of an
816     /// expression and calls to [unsafe_cast] or [enforced_cast].
817     ///
818     /// The [hole_source] indicates whether this came from an
819     /// explicit call to [unsafe_cast] or [enforced_cast] or was
820     /// generated during typing.
821     Hole(Box<(Expr<Ex, Fb, En, Hi>, Hi, Hi, HoleSource)>),
824 #[derive(
825     Clone,
826     Debug,
827     Deserialize,
828     Eq,
829     FromOcamlRep,
830     Hash,
831     NoPosHash,
832     Ord,
833     PartialEq,
834     PartialOrd,
835     Serialize,
836     ToOcamlRep
838 pub enum ClassGetExpr<Ex, Fb, En, Hi> {
839     CGstring(Pstring),
840     CGexpr(Expr<Ex, Fb, En, Hi>),
843 #[derive(
844     Clone,
845     Debug,
846     Deserialize,
847     Eq,
848     FromOcamlRep,
849     Hash,
850     NoPosHash,
851     Ord,
852     PartialEq,
853     PartialOrd,
854     Serialize,
855     ToOcamlRep
857 pub enum Case<Ex, Fb, En, Hi> {
858     Default(Pos, Block<Ex, Fb, En, Hi>),
859     Case(Expr<Ex, Fb, En, Hi>, Block<Ex, Fb, En, Hi>),
862 #[derive(
863     Clone,
864     Debug,
865     Deserialize,
866     Eq,
867     FromOcamlRep,
868     Hash,
869     NoPosHash,
870     Ord,
871     PartialEq,
872     PartialOrd,
873     Serialize,
874     ToOcamlRep
876 pub struct Catch<Ex, Fb, En, Hi>(pub Sid, pub Lid, pub Block<Ex, Fb, En, Hi>);
878 #[derive(
879     Clone,
880     Debug,
881     Deserialize,
882     Eq,
883     FromOcamlRep,
884     Hash,
885     NoPosHash,
886     Ord,
887     PartialEq,
888     PartialOrd,
889     Serialize,
890     ToOcamlRep
892 pub struct Field<Ex, Fb, En, Hi>(pub Expr<Ex, Fb, En, Hi>, pub Expr<Ex, Fb, En, Hi>);
894 #[derive(
895     Clone,
896     Debug,
897     Deserialize,
898     Eq,
899     FromOcamlRep,
900     Hash,
901     NoPosHash,
902     Ord,
903     PartialEq,
904     PartialOrd,
905     Serialize,
906     ToOcamlRep
908 pub enum Afield<Ex, Fb, En, Hi> {
909     AFvalue(Expr<Ex, Fb, En, Hi>),
910     AFkvalue(Expr<Ex, Fb, En, Hi>, Expr<Ex, Fb, En, Hi>),
913 #[derive(
914     Clone,
915     Debug,
916     Deserialize,
917     Eq,
918     FromOcamlRep,
919     Hash,
920     NoPosHash,
921     Ord,
922     PartialEq,
923     PartialOrd,
924     Serialize,
925     ToOcamlRep
927 pub struct XhpSimple<Ex, Fb, En, Hi> {
928     pub name: Pstring,
929     pub type_: Hi,
930     pub expr: Expr<Ex, Fb, En, Hi>,
933 #[derive(
934     Clone,
935     Debug,
936     Deserialize,
937     Eq,
938     FromOcamlRep,
939     Hash,
940     NoPosHash,
941     Ord,
942     PartialEq,
943     PartialOrd,
944     Serialize,
945     ToOcamlRep
947 pub enum XhpAttribute<Ex, Fb, En, Hi> {
948     XhpSimple(XhpSimple<Ex, Fb, En, Hi>),
949     XhpSpread(Expr<Ex, Fb, En, Hi>),
952 pub type IsVariadic = bool;
954 #[derive(
955     Clone,
956     Debug,
957     Deserialize,
958     Eq,
959     FromOcamlRep,
960     Hash,
961     NoPosHash,
962     Ord,
963     PartialEq,
964     PartialOrd,
965     Serialize,
966     ToOcamlRep
968 pub struct FunParam<Ex, Fb, En, Hi> {
969     pub annotation: Ex,
970     pub type_hint: TypeHint<Hi>,
971     pub is_variadic: IsVariadic,
972     pub pos: Pos,
973     pub name: String,
974     pub expr: Option<Expr<Ex, Fb, En, Hi>>,
975     pub readonly: Option<ast_defs::ReadonlyKind>,
976     pub callconv: Option<ast_defs::ParamKind>,
977     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
978     pub visibility: Option<Visibility>,
981 /// Does this function/method take a variable number of arguments?
982 #[derive(
983     Clone,
984     Debug,
985     Deserialize,
986     Eq,
987     FromOcamlRep,
988     Hash,
989     NoPosHash,
990     Ord,
991     PartialEq,
992     PartialOrd,
993     Serialize,
994     ToOcamlRep
996 pub enum FunVariadicity<Ex, Fb, En, Hi> {
997     /// Named variadic argument.
998     ///
999     /// function foo(int ...$args): void {}
1000     FVvariadicArg(FunParam<Ex, Fb, En, Hi>),
1001     /// Unnamed variaidic argument. Partial mode only.
1002     ///
1003     /// function foo(...): void {}
1004     FVellipsis(Pos),
1005     /// Function is not variadic, takes an exact number of arguments.
1006     FVnonVariadic,
1009 #[derive(
1010     Clone,
1011     Debug,
1012     Deserialize,
1013     Eq,
1014     FromOcamlRep,
1015     Hash,
1016     NoPosHash,
1017     Ord,
1018     PartialEq,
1019     PartialOrd,
1020     Serialize,
1021     ToOcamlRep
1023 pub struct Fun_<Ex, Fb, En, Hi> {
1024     pub span: Pos,
1025     pub annotation: En,
1026     pub mode: file_info::Mode,
1027     pub readonly_ret: Option<ast_defs::ReadonlyKind>,
1028     pub ret: TypeHint<Hi>,
1029     pub name: Sid,
1030     pub tparams: Vec<Tparam<Ex, Fb, En, Hi>>,
1031     pub where_constraints: Vec<WhereConstraintHint>,
1032     pub variadic: FunVariadicity<Ex, Fb, En, Hi>,
1033     pub params: Vec<FunParam<Ex, Fb, En, Hi>>,
1034     pub ctxs: Option<Contexts>,
1035     pub unsafe_ctxs: Option<Contexts>,
1036     pub body: FuncBody<Ex, Fb, En, Hi>,
1037     pub fun_kind: ast_defs::FunKind,
1038     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1039     pub file_attributes: Vec<FileAttribute<Ex, Fb, En, Hi>>,
1040     /// true if this declaration has no body because it is an
1041     /// external function declaration (e.g. from an HHI file)
1042     pub external: bool,
1043     pub namespace: Nsenv,
1044     pub doc_comment: Option<DocComment>,
1045     pub static_: bool,
1048 /// Naming has two phases and the annotation helps to indicate the phase.
1049 /// In the first pass, it will perform naming on everything except for function
1050 /// and method bodies and collect information needed. Then, another round of
1051 /// naming is performed where function bodies are named. Thus, naming will
1052 /// have named and unnamed variants of the annotation.
1053 /// See BodyNamingAnnotation in nast.ml and the comment in naming.ml
1054 #[derive(
1055     Clone,
1056     Debug,
1057     Deserialize,
1058     Eq,
1059     FromOcamlRep,
1060     Hash,
1061     NoPosHash,
1062     Ord,
1063     PartialEq,
1064     PartialOrd,
1065     Serialize,
1066     ToOcamlRep
1068 pub struct FuncBody<Ex, Fb, En, Hi> {
1069     pub ast: Block<Ex, Fb, En, Hi>,
1070     pub annotation: Fb,
1073 /// A type annotation is two things:
1074 /// - the localized hint, or if the hint is missing, the inferred type
1075 /// - The typehint associated to this expression if it exists
1076 #[derive(
1077     Clone,
1078     Debug,
1079     Deserialize,
1080     Eq,
1081     FromOcamlRep,
1082     Hash,
1083     NoPosHash,
1084     Ord,
1085     PartialEq,
1086     PartialOrd,
1087     Serialize,
1088     ToOcamlRep
1090 pub struct TypeHint<Hi>(pub Hi, pub TypeHint_);
1092 /// Explicit type argument to function, constructor, or collection literal.
1093 /// 'hi = unit in NAST
1094 /// 'hi = Typing_defs.(locl ty) in TAST,
1095 /// and is used to record inferred type arguments, with wildcard hint.
1096 #[derive(
1097     Clone,
1098     Debug,
1099     Deserialize,
1100     Eq,
1101     FromOcamlRep,
1102     Hash,
1103     NoPosHash,
1104     Ord,
1105     PartialEq,
1106     PartialOrd,
1107     Serialize,
1108     ToOcamlRep
1110 pub struct Targ<Hi>(pub Hi, pub Hint);
1112 pub type TypeHint_ = Option<Hint>;
1114 #[derive(
1115     Clone,
1116     Debug,
1117     Deserialize,
1118     Eq,
1119     FromOcamlRep,
1120     Hash,
1121     NoPosHash,
1122     Ord,
1123     PartialEq,
1124     PartialOrd,
1125     Serialize,
1126     ToOcamlRep
1128 pub struct UserAttribute<Ex, Fb, En, Hi> {
1129     pub name: Sid,
1130     /// user attributes are restricted to scalar values
1131     pub params: Vec<Expr<Ex, Fb, En, Hi>>,
1134 #[derive(
1135     Clone,
1136     Debug,
1137     Deserialize,
1138     Eq,
1139     FromOcamlRep,
1140     Hash,
1141     NoPosHash,
1142     Ord,
1143     PartialEq,
1144     PartialOrd,
1145     Serialize,
1146     ToOcamlRep
1148 pub struct FileAttribute<Ex, Fb, En, Hi> {
1149     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1150     pub namespace: Nsenv,
1153 #[derive(
1154     Clone,
1155     Debug,
1156     Deserialize,
1157     Eq,
1158     FromOcamlRep,
1159     Hash,
1160     NoPosHash,
1161     Ord,
1162     PartialEq,
1163     PartialOrd,
1164     Serialize,
1165     ToOcamlRep
1167 pub struct Tparam<Ex, Fb, En, Hi> {
1168     pub variance: ast_defs::Variance,
1169     pub name: Sid,
1170     pub parameters: Vec<Tparam<Ex, Fb, En, Hi>>,
1171     pub constraints: Vec<(ast_defs::ConstraintKind, Hint)>,
1172     pub reified: ReifyKind,
1173     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1176 #[derive(
1177     Clone,
1178     Debug,
1179     Deserialize,
1180     Eq,
1181     FromOcamlRep,
1182     Hash,
1183     NoPosHash,
1184     Ord,
1185     PartialEq,
1186     PartialOrd,
1187     Serialize,
1188     ToOcamlRep
1190 pub struct UseAsAlias(
1191     pub Option<Sid>,
1192     pub Pstring,
1193     pub Option<Sid>,
1194     pub Vec<UseAsVisibility>,
1197 #[derive(
1198     Clone,
1199     Debug,
1200     Deserialize,
1201     Eq,
1202     FromOcamlRep,
1203     Hash,
1204     NoPosHash,
1205     Ord,
1206     PartialEq,
1207     PartialOrd,
1208     Serialize,
1209     ToOcamlRep
1211 pub struct InsteadofAlias(pub Sid, pub Pstring, pub Vec<Sid>);
1213 pub type IsExtends = bool;
1215 #[derive(
1216     Clone,
1217     Copy,
1218     Debug,
1219     Deserialize,
1220     Eq,
1221     FromOcamlRep,
1222     FromOcamlRepIn,
1223     Hash,
1224     NoPosHash,
1225     Ord,
1226     PartialEq,
1227     PartialOrd,
1228     Serialize,
1229     ToOcamlRep
1231 pub enum EmitId {
1232     EmitId(isize),
1233     Anonymous,
1236 #[derive(
1237     Clone,
1238     Debug,
1239     Deserialize,
1240     Eq,
1241     FromOcamlRep,
1242     Hash,
1243     NoPosHash,
1244     Ord,
1245     PartialEq,
1246     PartialOrd,
1247     Serialize,
1248     ToOcamlRep
1250 pub struct Class_<Ex, Fb, En, Hi> {
1251     pub span: Pos,
1252     pub annotation: En,
1253     pub mode: file_info::Mode,
1254     pub final_: bool,
1255     pub is_xhp: bool,
1256     pub has_xhp_keyword: bool,
1257     pub kind: ast_defs::ClassKind,
1258     pub name: Sid,
1259     /// The type parameters of a class A<T> (T is the parameter)
1260     pub tparams: Vec<Tparam<Ex, Fb, En, Hi>>,
1261     pub extends: Vec<ClassHint>,
1262     pub uses: Vec<TraitHint>,
1263     /// PHP feature not supported in hack but required
1264     /// because we have runtime support.
1265     pub use_as_alias: Vec<UseAsAlias>,
1266     /// PHP feature not supported in hack but required
1267     /// because we have runtime support.
1268     pub insteadof_alias: Vec<InsteadofAlias>,
1269     pub xhp_attr_uses: Vec<XhpAttrHint>,
1270     pub xhp_category: Option<(Pos, Vec<Pstring>)>,
1271     pub reqs: Vec<(ClassHint, IsExtends)>,
1272     pub implements: Vec<ClassHint>,
1273     pub implements_dynamic: bool,
1274     pub where_constraints: Vec<WhereConstraintHint>,
1275     pub consts: Vec<ClassConst<Ex, Fb, En, Hi>>,
1276     pub typeconsts: Vec<ClassTypeconst<Ex, Fb, En, Hi>>,
1277     pub vars: Vec<ClassVar<Ex, Fb, En, Hi>>,
1278     pub methods: Vec<Method_<Ex, Fb, En, Hi>>,
1279     pub attributes: Vec<ClassAttr<Ex, Fb, En, Hi>>,
1280     pub xhp_children: Vec<(Pos, XhpChild)>,
1281     pub xhp_attrs: Vec<XhpAttr<Ex, Fb, En, Hi>>,
1282     pub namespace: Nsenv,
1283     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1284     pub file_attributes: Vec<FileAttribute<Ex, Fb, En, Hi>>,
1285     pub enum_: Option<Enum_>,
1286     pub doc_comment: Option<DocComment>,
1287     pub emit_id: Option<EmitId>,
1290 pub type ClassHint = Hint;
1292 pub type TraitHint = Hint;
1294 pub type XhpAttrHint = Hint;
1296 #[derive(
1297     Clone,
1298     Copy,
1299     Debug,
1300     Deserialize,
1301     Eq,
1302     FromOcamlRep,
1303     FromOcamlRepIn,
1304     Hash,
1305     NoPosHash,
1306     Ord,
1307     PartialEq,
1308     PartialOrd,
1309     Serialize,
1310     ToOcamlRep
1312 pub enum XhpAttrTag {
1313     Required,
1314     LateInit,
1316 impl TrivialDrop for XhpAttrTag {}
1318 #[derive(
1319     Clone,
1320     Debug,
1321     Deserialize,
1322     Eq,
1323     FromOcamlRep,
1324     Hash,
1325     NoPosHash,
1326     Ord,
1327     PartialEq,
1328     PartialOrd,
1329     Serialize,
1330     ToOcamlRep
1332 pub struct XhpAttr<Ex, Fb, En, Hi>(
1333     pub TypeHint<Hi>,
1334     pub ClassVar<Ex, Fb, En, Hi>,
1335     pub Option<XhpAttrTag>,
1336     pub Option<(Pos, Vec<Expr<Ex, Fb, En, Hi>>)>,
1339 #[derive(
1340     Clone,
1341     Debug,
1342     Deserialize,
1343     Eq,
1344     FromOcamlRep,
1345     Hash,
1346     NoPosHash,
1347     Ord,
1348     PartialEq,
1349     PartialOrd,
1350     Serialize,
1351     ToOcamlRep
1353 pub enum ClassAttr<Ex, Fb, En, Hi> {
1354     CAName(Sid),
1355     CAField(CaField<Ex, Fb, En, Hi>),
1358 #[derive(
1359     Clone,
1360     Debug,
1361     Deserialize,
1362     Eq,
1363     FromOcamlRep,
1364     Hash,
1365     NoPosHash,
1366     Ord,
1367     PartialEq,
1368     PartialOrd,
1369     Serialize,
1370     ToOcamlRep
1372 pub struct CaField<Ex, Fb, En, Hi> {
1373     pub type_: CaType,
1374     pub id: Sid,
1375     pub value: Option<Expr<Ex, Fb, En, Hi>>,
1376     pub required: bool,
1379 #[derive(
1380     Clone,
1381     Debug,
1382     Deserialize,
1383     Eq,
1384     FromOcamlRep,
1385     Hash,
1386     NoPosHash,
1387     Ord,
1388     PartialEq,
1389     PartialOrd,
1390     Serialize,
1391     ToOcamlRep
1393 pub enum CaType {
1394     CAHint(Hint),
1395     CAEnum(Vec<String>),
1398 #[derive(
1399     Clone,
1400     Debug,
1401     Deserialize,
1402     Eq,
1403     FromOcamlRep,
1404     Hash,
1405     NoPosHash,
1406     Ord,
1407     PartialEq,
1408     PartialOrd,
1409     Serialize,
1410     ToOcamlRep
1412 pub struct ClassConst<Ex, Fb, En, Hi> {
1413     pub type_: Option<Hint>,
1414     pub id: Sid,
1415     /// expr = None indicates an abstract const
1416     pub expr: Option<Expr<Ex, Fb, En, Hi>>,
1417     pub doc_comment: Option<DocComment>,
1420 #[derive(
1421     Clone,
1422     Debug,
1423     Deserialize,
1424     Eq,
1425     FromOcamlRep,
1426     Hash,
1427     NoPosHash,
1428     Ord,
1429     PartialEq,
1430     PartialOrd,
1431     Serialize,
1432     ToOcamlRep
1434 pub enum TypeconstAbstractKind {
1435     TCAbstract(Option<Hint>),
1436     TCPartiallyAbstract,
1437     TCConcrete,
1440 /// This represents a type const definition. If a type const is abstract then
1441 /// then the type hint acts as a constraint. Any concrete definition of the
1442 /// type const must satisfy the constraint.
1444 /// If the type const is not abstract then a type must be specified.
1445 #[derive(
1446     Clone,
1447     Debug,
1448     Deserialize,
1449     Eq,
1450     FromOcamlRep,
1451     Hash,
1452     NoPosHash,
1453     Ord,
1454     PartialEq,
1455     PartialOrd,
1456     Serialize,
1457     ToOcamlRep
1459 pub struct ClassTypeconst<Ex, Fb, En, Hi> {
1460     pub abstract_: TypeconstAbstractKind,
1461     pub name: Sid,
1462     pub as_constraint: Option<Hint>,
1463     pub super_constraint: Option<Hint>,
1464     pub type_: Option<Hint>,
1465     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1466     pub span: Pos,
1467     pub doc_comment: Option<DocComment>,
1468     pub is_ctx: bool,
1471 #[derive(
1472     Clone,
1473     Copy,
1474     Debug,
1475     Deserialize,
1476     Eq,
1477     FromOcamlRep,
1478     FromOcamlRepIn,
1479     Hash,
1480     NoPosHash,
1481     Ord,
1482     PartialEq,
1483     PartialOrd,
1484     Serialize,
1485     ToOcamlRep
1487 pub struct XhpAttrInfo {
1488     pub xai_tag: Option<XhpAttrTag>,
1491 #[derive(
1492     Clone,
1493     Debug,
1494     Deserialize,
1495     Eq,
1496     FromOcamlRep,
1497     Hash,
1498     NoPosHash,
1499     Ord,
1500     PartialEq,
1501     PartialOrd,
1502     Serialize,
1503     ToOcamlRep
1505 pub struct ClassVar<Ex, Fb, En, Hi> {
1506     pub final_: bool,
1507     pub xhp_attr: Option<XhpAttrInfo>,
1508     pub abstract_: bool,
1509     pub readonly: bool,
1510     pub visibility: Visibility,
1511     pub type_: TypeHint<Hi>,
1512     pub id: Sid,
1513     pub expr: Option<Expr<Ex, Fb, En, Hi>>,
1514     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1515     pub doc_comment: Option<DocComment>,
1516     pub is_promoted_variadic: bool,
1517     pub is_static: bool,
1518     pub span: Pos,
1521 #[derive(
1522     Clone,
1523     Debug,
1524     Deserialize,
1525     Eq,
1526     FromOcamlRep,
1527     Hash,
1528     NoPosHash,
1529     Ord,
1530     PartialEq,
1531     PartialOrd,
1532     Serialize,
1533     ToOcamlRep
1535 pub struct Method_<Ex, Fb, En, Hi> {
1536     pub span: Pos,
1537     pub annotation: En,
1538     pub final_: bool,
1539     pub abstract_: bool,
1540     pub static_: bool,
1541     pub readonly_this: bool,
1542     pub visibility: Visibility,
1543     pub name: Sid,
1544     pub tparams: Vec<Tparam<Ex, Fb, En, Hi>>,
1545     pub where_constraints: Vec<WhereConstraintHint>,
1546     pub variadic: FunVariadicity<Ex, Fb, En, Hi>,
1547     pub params: Vec<FunParam<Ex, Fb, En, Hi>>,
1548     pub ctxs: Option<Contexts>,
1549     pub unsafe_ctxs: Option<Contexts>,
1550     pub body: FuncBody<Ex, Fb, En, Hi>,
1551     pub fun_kind: ast_defs::FunKind,
1552     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1553     pub readonly_ret: Option<ast_defs::ReadonlyKind>,
1554     pub ret: TypeHint<Hi>,
1555     /// true if this declaration has no body because it is an external method
1556     /// declaration (e.g. from an HHI file)
1557     pub external: bool,
1558     pub doc_comment: Option<DocComment>,
1561 pub type Nsenv = ocamlrep::rc::RcOc<namespace_env::Env>;
1563 #[derive(
1564     Clone,
1565     Debug,
1566     Deserialize,
1567     Eq,
1568     FromOcamlRep,
1569     Hash,
1570     NoPosHash,
1571     Ord,
1572     PartialEq,
1573     PartialOrd,
1574     Serialize,
1575     ToOcamlRep
1577 pub struct Typedef<Ex, Fb, En, Hi> {
1578     pub annotation: En,
1579     pub name: Sid,
1580     pub tparams: Vec<Tparam<Ex, Fb, En, Hi>>,
1581     pub constraint: Option<Hint>,
1582     pub kind: Hint,
1583     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1584     pub mode: file_info::Mode,
1585     pub vis: TypedefVisibility,
1586     pub namespace: Nsenv,
1587     pub span: Pos,
1588     pub emit_id: Option<EmitId>,
1591 #[derive(
1592     Clone,
1593     Debug,
1594     Deserialize,
1595     Eq,
1596     FromOcamlRep,
1597     Hash,
1598     NoPosHash,
1599     Ord,
1600     PartialEq,
1601     PartialOrd,
1602     Serialize,
1603     ToOcamlRep
1605 pub struct Gconst<Ex, Fb, En, Hi> {
1606     pub annotation: En,
1607     pub mode: file_info::Mode,
1608     pub name: Sid,
1609     pub type_: Option<Hint>,
1610     pub value: Expr<Ex, Fb, En, Hi>,
1611     pub namespace: Nsenv,
1612     pub span: Pos,
1613     pub emit_id: Option<EmitId>,
1616 #[derive(
1617     Clone,
1618     Debug,
1619     Deserialize,
1620     Eq,
1621     FromOcamlRep,
1622     Hash,
1623     NoPosHash,
1624     Ord,
1625     PartialEq,
1626     PartialOrd,
1627     Serialize,
1628     ToOcamlRep
1630 pub struct RecordDef<Ex, Fb, En, Hi> {
1631     pub annotation: En,
1632     pub name: Sid,
1633     pub extends: Option<RecordHint>,
1634     pub abstract_: bool,
1635     pub fields: Vec<(Sid, Hint, Option<Expr<Ex, Fb, En, Hi>>)>,
1636     pub user_attributes: Vec<UserAttribute<Ex, Fb, En, Hi>>,
1637     pub namespace: Nsenv,
1638     pub span: Pos,
1639     pub doc_comment: Option<DocComment>,
1640     pub emit_id: Option<EmitId>,
1643 pub type RecordHint = Hint;
1645 pub type FunDef<Ex, Fb, En, Hi> = Fun_<Ex, Fb, En, Hi>;
1647 #[derive(
1648     Clone,
1649     Debug,
1650     Deserialize,
1651     Eq,
1652     FromOcamlRep,
1653     Hash,
1654     NoPosHash,
1655     Ord,
1656     PartialEq,
1657     PartialOrd,
1658     Serialize,
1659     ToOcamlRep
1661 pub enum Def<Ex, Fb, En, Hi> {
1662     Fun(Box<FunDef<Ex, Fb, En, Hi>>),
1663     Class(Box<Class_<Ex, Fb, En, Hi>>),
1664     RecordDef(Box<RecordDef<Ex, Fb, En, Hi>>),
1665     Stmt(Box<Stmt<Ex, Fb, En, Hi>>),
1666     Typedef(Box<Typedef<Ex, Fb, En, Hi>>),
1667     Constant(Box<Gconst<Ex, Fb, En, Hi>>),
1668     Namespace(Box<(Sid, Program<Ex, Fb, En, Hi>)>),
1669     NamespaceUse(Vec<(NsKind, Sid, Sid)>),
1670     SetNamespaceEnv(Box<Nsenv>),
1671     FileAttributes(Box<FileAttribute<Ex, Fb, En, Hi>>),
1674 #[derive(
1675     Clone,
1676     Copy,
1677     Debug,
1678     Deserialize,
1679     Eq,
1680     FromOcamlRep,
1681     FromOcamlRepIn,
1682     Hash,
1683     NoPosHash,
1684     Ord,
1685     PartialEq,
1686     PartialOrd,
1687     Serialize,
1688     ToOcamlRep
1690 pub enum NsKind {
1691     NSNamespace,
1692     NSClass,
1693     NSClassAndNamespace,
1694     NSFun,
1695     NSConst,
1697 impl TrivialDrop for NsKind {}
1699 #[derive(
1700     Clone,
1701     Copy,
1702     Debug,
1703     Deserialize,
1704     Eq,
1705     FromOcamlRep,
1706     FromOcamlRepIn,
1707     Hash,
1708     NoPosHash,
1709     Ord,
1710     PartialEq,
1711     PartialOrd,
1712     Serialize,
1713     ToOcamlRep
1715 pub enum HoleSource {
1716     Typing,
1717     UnsafeCast,
1718     EnforcedCast,
1720 impl TrivialDrop for HoleSource {}
1722 #[derive(
1723     Clone,
1724     Debug,
1725     Deserialize,
1726     Eq,
1727     FromOcamlRep,
1728     Hash,
1729     NoPosHash,
1730     Ord,
1731     PartialEq,
1732     PartialOrd,
1733     Serialize,
1734     ToOcamlRep
1736 pub enum BreakContinueLevel {
1737     LevelOk(Option<isize>),
1738     LevelNonLiteral,
1739     LevelNonPositive,