mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: add UseTree::is_star
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
from misc.codegen.lib.schemadefs import *
|
||||
from .ast import *
|
||||
|
||||
|
||||
class LabelableExpr(Expr):
|
||||
"""
|
||||
The base class for expressions that can be labeled (`LoopExpr`, `ForExpr`, `WhileExpr` or `BlockExpr`).
|
||||
"""
|
||||
label: optional[Label] | child
|
||||
|
||||
|
||||
class LoopingExpr(LabelableExpr):
|
||||
"""
|
||||
The base class for expressions that loop (`LoopExpr`, `ForExpr` or `WhileExpr`).
|
||||
@@ -14,7 +16,6 @@ class LoopingExpr(LabelableExpr):
|
||||
loop_body: optional["BlockExpr"] | child
|
||||
|
||||
|
||||
|
||||
@annotate(Module)
|
||||
@rust.doc_test_signature(None)
|
||||
class _:
|
||||
@@ -31,14 +32,14 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(Expr, cfg = True)
|
||||
@annotate(Expr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
The base class for expressions.
|
||||
"""
|
||||
|
||||
|
||||
@annotate(Pat, cfg = True)
|
||||
@annotate(Pat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
The base class for patterns.
|
||||
@@ -76,6 +77,7 @@ class _:
|
||||
```
|
||||
"""
|
||||
|
||||
|
||||
@annotate(Path)
|
||||
class _:
|
||||
"""
|
||||
@@ -120,7 +122,7 @@ class PathExprBase(Expr):
|
||||
"""
|
||||
|
||||
|
||||
@annotate(PathExpr, replace_bases={Expr: PathExprBase}, add_bases=(PathAstNode,), cfg = True)
|
||||
@annotate(PathExpr, replace_bases={Expr: PathExprBase}, add_bases=(PathAstNode,), cfg=True)
|
||||
@qltest.test_with(Path)
|
||||
class _:
|
||||
"""
|
||||
@@ -135,7 +137,7 @@ class _:
|
||||
path: drop
|
||||
|
||||
|
||||
@annotate(IfExpr, cfg = True)
|
||||
@annotate(IfExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
An `if` expression. For example:
|
||||
@@ -154,7 +156,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(LetExpr, cfg = True)
|
||||
@annotate(LetExpr, cfg=True)
|
||||
@rust.doc_test_signature("(maybe_some: Option<String>) -> ()")
|
||||
class _:
|
||||
"""
|
||||
@@ -167,7 +169,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(BlockExpr, replace_bases={Expr: LabelableExpr}, cfg = True)
|
||||
@annotate(BlockExpr, replace_bases={Expr: LabelableExpr}, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A block expression. For example:
|
||||
@@ -186,7 +188,7 @@ class _:
|
||||
label: drop
|
||||
|
||||
|
||||
@annotate(LoopExpr, replace_bases={Expr: LoopingExpr}, cfg = True)
|
||||
@annotate(LoopExpr, replace_bases={Expr: LoopingExpr}, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A loop expression. For example:
|
||||
@@ -224,7 +226,7 @@ class CallExprBase(Expr):
|
||||
attrs: list["Attr"] | child
|
||||
|
||||
|
||||
@annotate(CallExpr, replace_bases={Expr: CallExprBase}, cfg = True)
|
||||
@annotate(CallExpr, replace_bases={Expr: CallExprBase}, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A function call expression. For example:
|
||||
@@ -239,7 +241,7 @@ class _:
|
||||
attrs: drop
|
||||
|
||||
|
||||
@annotate(MethodCallExpr, replace_bases={Expr: CallExprBase}, add_bases=(Resolvable,), cfg = True)
|
||||
@annotate(MethodCallExpr, replace_bases={Expr: CallExprBase}, add_bases=(Resolvable,), cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A method call expression. For example:
|
||||
@@ -272,7 +274,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(MatchExpr, cfg = True)
|
||||
@annotate(MatchExpr, cfg=True)
|
||||
@rust.doc_test_signature("(x: i32) -> i32")
|
||||
class _:
|
||||
"""
|
||||
@@ -290,10 +292,11 @@ class _:
|
||||
}
|
||||
```
|
||||
"""
|
||||
scrutinee: _ | doc("scrutinee (the expression being matched) of this match expression")
|
||||
scrutinee: _ | doc(
|
||||
"scrutinee (the expression being matched) of this match expression")
|
||||
|
||||
|
||||
@annotate(ContinueExpr, cfg = True)
|
||||
@annotate(ContinueExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A continue expression. For example:
|
||||
@@ -314,7 +317,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(BreakExpr, cfg = True)
|
||||
@annotate(BreakExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A break expression. For example:
|
||||
@@ -343,7 +346,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(ReturnExpr, cfg = True)
|
||||
@annotate(ReturnExpr, cfg=True)
|
||||
@rust.doc_test_signature(None)
|
||||
class _:
|
||||
"""
|
||||
@@ -361,7 +364,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(BecomeExpr, cfg = True)
|
||||
@annotate(BecomeExpr, cfg=True)
|
||||
@rust.doc_test_signature(None)
|
||||
class _:
|
||||
"""
|
||||
@@ -378,7 +381,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(YieldExpr, cfg = True)
|
||||
@annotate(YieldExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A `yield` expression. For example:
|
||||
@@ -391,7 +394,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(YeetExpr, cfg = True)
|
||||
@annotate(YeetExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A `yeet` expression. For example:
|
||||
@@ -413,7 +416,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(RecordExpr, add_bases=(PathAstNode,), cfg = True)
|
||||
@annotate(RecordExpr, add_bases=(PathAstNode,), cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A record expression. For example:
|
||||
@@ -427,7 +430,7 @@ class _:
|
||||
path: drop
|
||||
|
||||
|
||||
@annotate(FieldExpr, cfg = True)
|
||||
@annotate(FieldExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A field access expression. For example:
|
||||
@@ -437,7 +440,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(AwaitExpr, cfg = True)
|
||||
@annotate(AwaitExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
An `await` expression. For example:
|
||||
@@ -450,7 +453,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(CastExpr, cfg = True)
|
||||
@annotate(CastExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A type cast expression. For example:
|
||||
@@ -460,7 +463,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(RefExpr, cfg = True)
|
||||
@annotate(RefExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A reference expression. For example:
|
||||
@@ -473,7 +476,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(PrefixExpr, cfg = True)
|
||||
@annotate(PrefixExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A unary operation expression. For example:
|
||||
@@ -485,7 +488,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(BinaryExpr, cfg = True)
|
||||
@annotate(BinaryExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A binary operation expression. For example:
|
||||
@@ -499,7 +502,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(RangeExpr, cfg = True)
|
||||
@annotate(RangeExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A range expression. For example:
|
||||
@@ -514,7 +517,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(IndexExpr, cfg = True)
|
||||
@annotate(IndexExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
An index expression. For example:
|
||||
@@ -541,7 +544,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(TupleExpr, cfg = True)
|
||||
@annotate(TupleExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A tuple expression. For example:
|
||||
@@ -558,6 +561,7 @@ class _:
|
||||
class _:
|
||||
pass
|
||||
|
||||
|
||||
class ArrayExpr(Expr):
|
||||
"""
|
||||
The base class for array expressions. For example:
|
||||
@@ -569,6 +573,7 @@ class ArrayExpr(Expr):
|
||||
exprs: list[Expr] | child
|
||||
attrs: list[Attr] | child
|
||||
|
||||
|
||||
@synth.from_class(ArrayExprInternal)
|
||||
class ArrayListExpr(ArrayExpr):
|
||||
"""
|
||||
@@ -579,6 +584,7 @@ class ArrayListExpr(ArrayExpr):
|
||||
"""
|
||||
__cfg__ = True
|
||||
|
||||
|
||||
@synth.from_class(ArrayExprInternal)
|
||||
class ArrayRepeatExpr(ArrayExpr):
|
||||
"""
|
||||
@@ -593,7 +599,7 @@ class ArrayRepeatExpr(ArrayExpr):
|
||||
repeat_length: Expr | child
|
||||
|
||||
|
||||
@annotate(LiteralExpr, cfg = True)
|
||||
@annotate(LiteralExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A literal expression. For example:
|
||||
@@ -610,7 +616,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(UnderscoreExpr, cfg = True)
|
||||
@annotate(UnderscoreExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
An underscore expression. For example:
|
||||
@@ -620,7 +626,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(OffsetOfExpr, cfg = True)
|
||||
@annotate(OffsetOfExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
An `offset_of` expression. For example:
|
||||
@@ -630,7 +636,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(AsmExpr, cfg = True)
|
||||
@annotate(AsmExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
An inline assembly expression. For example:
|
||||
@@ -642,7 +648,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(LetStmt, cfg = True)
|
||||
@annotate(LetStmt, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A let statement. For example:
|
||||
@@ -671,7 +677,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(WildcardPat, cfg = True)
|
||||
@annotate(WildcardPat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A wildcard pattern. For example:
|
||||
@@ -681,7 +687,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(TuplePat, cfg = True)
|
||||
@annotate(TuplePat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A tuple pattern. For example:
|
||||
@@ -692,7 +698,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(OrPat, cfg = True)
|
||||
@annotate(OrPat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
An or pattern. For example:
|
||||
@@ -714,7 +720,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(RecordPat, add_bases=(PathAstNode,), cfg = True)
|
||||
@annotate(RecordPat, add_bases=(PathAstNode,), cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A record pattern. For example:
|
||||
@@ -728,7 +734,7 @@ class _:
|
||||
path: drop
|
||||
|
||||
|
||||
@annotate(RangePat, cfg = True)
|
||||
@annotate(RangePat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A range pattern. For example:
|
||||
@@ -742,7 +748,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(SlicePat, cfg = True)
|
||||
@annotate(SlicePat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A slice pattern. For example:
|
||||
@@ -756,7 +762,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(PathPat, add_bases=(PathAstNode,), cfg = True)
|
||||
@annotate(PathPat, add_bases=(PathAstNode,), cfg=True)
|
||||
@qltest.test_with(Path)
|
||||
class _:
|
||||
"""
|
||||
@@ -771,7 +777,7 @@ class _:
|
||||
path: drop
|
||||
|
||||
|
||||
@annotate(LiteralPat, cfg = True)
|
||||
@annotate(LiteralPat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A literal pattern. For example:
|
||||
@@ -784,7 +790,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(IdentPat, cfg = True)
|
||||
@annotate(IdentPat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A binding pattern. For example:
|
||||
@@ -803,7 +809,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(TupleStructPat, add_bases=(PathAstNode,), cfg = True)
|
||||
@annotate(TupleStructPat, add_bases=(PathAstNode,), cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A tuple struct pattern. For example:
|
||||
@@ -818,7 +824,7 @@ class _:
|
||||
path: drop
|
||||
|
||||
|
||||
@annotate(RefPat, cfg = True)
|
||||
@annotate(RefPat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A reference pattern. For example:
|
||||
@@ -831,7 +837,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(BoxPat, cfg = True)
|
||||
@annotate(BoxPat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A box pattern. For example:
|
||||
@@ -844,7 +850,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(ConstBlockPat, cfg = True)
|
||||
@annotate(ConstBlockPat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A const block pattern. For example:
|
||||
@@ -1045,7 +1051,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(ForExpr, replace_bases={Expr: LoopingExpr}, cfg = True)
|
||||
@annotate(ForExpr, replace_bases={Expr: LoopingExpr}, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A ForExpr. For example:
|
||||
@@ -1067,7 +1073,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(FormatArgsArg, cfg = True)
|
||||
@annotate(FormatArgsArg, cfg=True)
|
||||
@qltest.test_with(FormatArgsExpr)
|
||||
class _:
|
||||
"""
|
||||
@@ -1078,7 +1084,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(FormatArgsExpr, cfg = True)
|
||||
@annotate(FormatArgsExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A FormatArgsExpr. For example:
|
||||
@@ -1213,7 +1219,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(MacroCall, cfg = True)
|
||||
@annotate(MacroCall, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A MacroCall. For example:
|
||||
@@ -1234,7 +1240,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(MacroExpr, cfg = True)
|
||||
@annotate(MacroExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A MacroExpr. For example:
|
||||
@@ -1257,7 +1263,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(MacroPat, cfg = True)
|
||||
@annotate(MacroPat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A MacroPat. For example:
|
||||
@@ -1367,11 +1373,13 @@ class ParamBase(AstNode):
|
||||
attrs: list["Attr"] | child
|
||||
type_repr: optional["TypeRepr"] | child
|
||||
|
||||
@annotate(ParamBase, cfg = True)
|
||||
|
||||
@annotate(ParamBase, cfg=True)
|
||||
class _:
|
||||
pass
|
||||
|
||||
@annotate(Param, replace_bases={AstNode: ParamBase}, cfg = True)
|
||||
|
||||
@annotate(Param, replace_bases={AstNode: ParamBase}, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A parameter in a function or method. For example `x` in:
|
||||
@@ -1515,7 +1523,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(RestPat, cfg = True)
|
||||
@annotate(RestPat, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A RestPat. For example:
|
||||
@@ -1545,7 +1553,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(SelfParam, replace_bases={AstNode: ParamBase}, cfg = True)
|
||||
@annotate(SelfParam, replace_bases={AstNode: ParamBase}, cfg=True)
|
||||
@rust.doc_test_signature(None)
|
||||
class _:
|
||||
"""
|
||||
@@ -1652,7 +1660,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(TryExpr, cfg = True)
|
||||
@annotate(TryExpr, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A TryExpr. For example:
|
||||
@@ -1767,7 +1775,10 @@ class _:
|
||||
"""
|
||||
A UseTree. For example:
|
||||
```rust
|
||||
todo!()
|
||||
use std::collections::HashMap;
|
||||
use std::collections::*;
|
||||
use std::collections::HashMap as MyHashMap;
|
||||
use std::collections::{self, HashMap, HashSet};
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -1832,7 +1843,7 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(WhileExpr, replace_bases={Expr: LoopingExpr}, cfg = True)
|
||||
@annotate(WhileExpr, replace_bases={Expr: LoopingExpr}, cfg=True)
|
||||
class _:
|
||||
"""
|
||||
A WhileExpr. For example:
|
||||
@@ -1864,7 +1875,6 @@ class FormatTemplateVariableAccess(PathExprBase):
|
||||
|
||||
@synth.on_arguments(parent=FormatArgsExpr, index=int, text=string, offset=int)
|
||||
@qltest.test_with(FormatArgsExpr)
|
||||
|
||||
class Format(Locatable):
|
||||
"""
|
||||
A format element in a formatting template. For example the `{}` in:
|
||||
@@ -1920,6 +1930,7 @@ class FormatArgument(Locatable):
|
||||
parent: Format
|
||||
variable: optional[FormatTemplateVariableAccess] | child
|
||||
|
||||
|
||||
@annotate(Item, add_bases=(Addressable,))
|
||||
class _:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user