CodeQL library for Rust
codeql/rust-all 0.2.23 (changelog, source)
Search

Module MakeCfgNodes::Nodes

Provides sub classes of CfgNode.

Import path

import codeql.rust.controlflow.internal.generated.CfgNodes

Classes

ArrayExprCfgNode

The base class for array expressions. For example: rust [1, 2, 3]; [1; 10];

ArrayListExprCfgNode

An array expression with a list of elements. For example: rust [1, 2, 3];

ArrayRepeatExprCfgNode

An array expression with a repeat operand and a repeat length. For example: rust [1; 10];

AsmExprCfgNode

An inline assembly expression. For example: rust unsafe { #[inline(always)] builtin # asm("cmp {0}, {1}", in(reg) a, in(reg) b); }

AwaitExprCfgNode

An await expression. For example: rust async { let x = foo().await; x }

BecomeExprCfgNode

A become expression. For example: rust fn fact_a(n: i32, a: i32) -> i32 { if n == 0 { a } else { become fact_a(n - 1, n * a) } }

BinaryExprCfgNode

A binary operation expression. For example: rust x + y; x && y; x <= y; x = y; x += y;

BlockExprCfgNode

A block expression. For example: rust { let x = 42; } rust 'label: { let x = 42; x }

BoxPatCfgNode

A box pattern. For example: rust match x { box Option::Some(y) => y, box Option::None => 0, };

BreakExprCfgNode

A break expression. For example: rust loop { if not_ready() { break; } } rust let x = 'label: loop { if done() { break 'label 42; } }; rust let x = 'label: { if exit() { break 'label 42; } 0; };

CallExprCfgNode

NOTE: Consider using Call instead, as that excludes call expressions that are instantiations of tuple structs and tuple variants.

CastExprCfgNode

A type cast expression. For example: rust value as u64;

ConstBlockPatCfgNode

A const block pattern. For example: rust match x { const { 1 + 2 + 3 } => "ok", _ => "fail", };

ContinueExprCfgNode

A continue expression. For example: rust loop { if not_ready() { continue; } } rust 'label: loop { if not_ready() { continue 'label; } }

DerefPatCfgNode

A deref pattern, matching the value behind a smart pointer. This is an experimental Rust feature that cannot be written directly in stable Rust; the example below uses rust-analyzer’s canonical builtin#deref syntax for such patterns: rust match x { builtin#deref(y) => y, _ => 0, };

ExprCfgNode

The base class for expressions.

FieldExprCfgNode

A field access expression. For example: rust x.foo

ForExprCfgNode

A for loop expression.

FormatArgsArgCfgNode

A FormatArgsArg. For example the "world" in: rust format_args!("Hello, {}!", "world")

FormatArgsExprCfgNode

A FormatArgsExpr. For example: rust format_args!("no args"); format_args!("{} foo {:?}", 1, 2); format_args!("{b} foo {a:?}", a=1, b=2); let (x, y) = (1, 42); format_args!("{x}, {y}");

FormatTemplateVariableAccessCfgNode
IdentPatCfgNode

A binding pattern. For example: rust match x { Option::Some(y) => y, Option::None => 0, }; rust match x { y@Option::Some(_) => y, Option::None => 0, };

IfExprCfgNode

An if expression. For example: rust if x == 42 { println!("that's the answer"); } rust let y = if x > 0 { 1 } else { 0 };

IncludeBytesExprCfgNode

An expression produced by the built-in include_bytes! macro, embedding the contents of a file as a byte array. For example: rust let data = include_bytes!("data.bin");

IndexExprCfgNode

An index expression. For example: rust list[42]; list[42] = 1;

LabelableExprCfgNode

The base class for expressions that can be labeled (LoopExpr, ForExpr, WhileExpr or BlockExpr).

LetExprCfgNode

A let expression. For example: rust if let Some(x) = maybe_some { println!("{}", x); }

LetStmtCfgNode

A let statement. For example: rust let x = 42; let x: i32 = 42; let x: i32; let x; let (x, y) = (1, 2); let Some(x) = std::env::var("FOO") else { return; };

LiteralExprCfgNode

A literal expression. For example: rust 42; 42.0; "Hello, world!"; b"Hello, world!"; 'x'; b'x'; r"Hello, world!"; true;

LiteralPatCfgNode

A literal pattern. For example: rust match x { 42 => "ok", _ => "fail", }

LoopExprCfgNode

A loop expression. For example: rust loop { println!("Hello, world (again)!"); }; rust 'label: loop { println!("Hello, world (once)!"); break 'label; }; rust let mut x = 0; loop { if x < 10 { x += 1; } else { break; } };

LoopingExprCfgNode

The base class for expressions that loop (LoopExpr, ForExpr or WhileExpr).

MacroCallCfgNode

A macro invocation.

MacroExprCfgNode

A macro expression, representing the invocation of a macro that produces an expression.

MacroPatCfgNode

A macro pattern, representing the invocation of a macro that produces a pattern.

MatchExprCfgNode

A match expression. For example: rust match x { Option::Some(y) => y, Option::None => 0, } rust match x { Some(y) if y != 0 => 1 / y, _ => 0, }

MethodCallExprCfgNode

NOTE: Consider using MethodCall instead, as that also includes calls to methods using call syntax (such as Foo::method(x)), operation syntax (such as x + y), and indexing syntax (such as x[y]).

NameCfgNode

An identifier name.

NotNullCfgNode

The !null pattern used in a pattern type to denote a non-null value. Pattern types are an experimental, mostly compiler-internal feature (used in the standard library for types such as NonZero and NonNull) and cannot be written directly in stable Rust; the example below uses rust-analyzer’s canonical builtin#pattern_type syntax: rust type NonNull = builtin#pattern_type(*const () is !null);

OffsetOfExprCfgNode

An offset_of expression. For example: rust builtin # offset_of(Struct, field);

OrPatCfgNode

An or pattern. For example: rust match x { Option::Some(y) | Option::None => 0, }

ParamBaseCfgNode

A normal parameter, Param, or a self parameter SelfParam.

ParamCfgNode

A parameter in a function or method. For example x in: rust fn new(x: T) -> Foo<T> { // ... }

PatCfgNode

The base class for patterns.

PathExprBaseCfgNode

A path expression or a variable access in a formatting template. See PathExpr and FormatTemplateVariableAccess for further details.

PathExprCfgNode

A path expression. For example: rust let x = variable; let x = foo::bar; let y = <T>::foo; let z = <TypeRepr as Trait>::foo;

PathPatCfgNode

A path pattern. For example: rust match x { Foo::Bar => "ok", _ => "fail", }

PrefixExprCfgNode

A unary operation expression. For example: rust let x = -42; let y = !true; let z = *ptr;

RangeExprCfgNode

A range expression. For example: rust let x = 1..=10; let x = 1..10; let x = 10..; let x = ..10; let x = ..=10; let x = ..;

RangePatCfgNode

A range pattern. For example: rust match x { ..15 => "too cold", 16..=25 => "just right", 26.. => "too hot", }

RefExprCfgNode

A reference expression. For example: rust let ref_const = &foo; let ref_mut = &mut foo; let raw_const: &mut i32 = &raw const foo; let raw_mut: &mut i32 = &raw mut foo;

RefPatCfgNode

A reference pattern. For example: rust match x { &mut Option::Some(y) => y, &Option::None => 0, };

RestPatCfgNode

A rest pattern (..) in a tuple, slice, or struct pattern.

ReturnExprCfgNode

A return expression. For example: rust fn some_value() -> i32 { return 42; } rust fn no_value() -> () { return; }

SelfParamCfgNode

A self parameter. For example self in: rust struct X; impl X { fn one(&self) {} fn two(&mut self) {} fn three(self) {} fn four(mut self) {} fn five<'a>(&'a self) {} }

SlicePatCfgNode

A slice pattern. For example: rust match x { [1, 2, 3, 4, 5] => "ok", [1, 2, ..] => "fail", [x, y, .., z, 7] => "fail", }

StructExprCfgNode

A struct expression. For example: rust let first = Foo { a: 1, b: 2 }; let second = Foo { a: 2, ..first }; let n = Foo { a: 1, b: 2 }.b; Foo { a: m, .. } = second;

StructPatCfgNode

A struct pattern. For example: rust match x { Foo { a: 1, b: 2 } => "ok", Foo { .. } => "fail", }

TryExprCfgNode

A try expression using the ? operator.

TupleExprCfgNode

A tuple expression. For example: rust let tuple = (1, "one"); let n = (2, "two").0; let (a, b) = tuple;

TuplePatCfgNode

A tuple pattern. For example: rust let (x, y) = (1, 2); let (a, b, .., z) = (1, 2, 3, 4, 5);

TupleStructPatCfgNode

A tuple struct pattern. For example: rust match x { Tuple("a", 1, 2, 3) => "great", Tuple(.., 3) => "fine", Tuple(..) => "fail", };

UnderscoreExprCfgNode

An underscore expression. For example: rust _ = 42;

WhileExprCfgNode

A while loop expression.

WildcardPatCfgNode

A wildcard pattern. For example: rust let _ = 42;

YeetExprCfgNode

A yeet expression. For example: rust if x < size { do yeet "index out of bounds"; }

YieldExprCfgNode

A yield expression. For example: rust let one = #[coroutine] || { yield 1; };