mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: fix QLdoc examples
This commit is contained in:
@@ -644,7 +644,8 @@ class _:
|
||||
An inline assembly expression. For example:
|
||||
```rust
|
||||
unsafe {
|
||||
builtin # asm(_);
|
||||
#[inline(always)]
|
||||
builtin # asm("cmp {0}, {1}", in(reg) a, in(reg) b);
|
||||
}
|
||||
```
|
||||
"""
|
||||
@@ -932,8 +933,13 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
<T as Iterator>::Item
|
||||
// ^^^^
|
||||
fn process_cloneable<T>(iter: T)
|
||||
where
|
||||
T: Iterator<Item: Clone>
|
||||
// ^^^^^^^^^^^
|
||||
{
|
||||
// ...
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -959,8 +965,13 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
for <'a> |x: &'a u32 | x
|
||||
// ^^^^^^
|
||||
let print_any = for<T: std::fmt::Debug> |x: T| {
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
println!("{:?}", x);
|
||||
};
|
||||
|
||||
print_any(42);
|
||||
print_any("hello");
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -1135,8 +1146,13 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
for <'a> fn(&'a str)
|
||||
// ^^^^^
|
||||
fn foo<T>(value: T)
|
||||
where
|
||||
T: for<'a> Fn(&'a str) -> &'a str
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
{
|
||||
// ...
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -1311,7 +1327,7 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
Foo<'a>
|
||||
let text: Text<'a>;
|
||||
// ^^
|
||||
```
|
||||
"""
|
||||
@@ -1399,6 +1415,9 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
macro_rules! macro_type {
|
||||
() => { i32 };
|
||||
}
|
||||
type T = macro_type!();
|
||||
// ^^^^^^^^^^^^^
|
||||
```
|
||||
@@ -1445,8 +1464,13 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
#[cfg(feature = "foo")]
|
||||
// ^^^^^^^^^^^^^^^
|
||||
#[unsafe(lint::name = "reason_for_bypass")]
|
||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
#[deprecated(since = "1.2.0", note = "Use bar instead", unsafe=true)]
|
||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
fn foo() {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -1578,8 +1602,8 @@ class _:
|
||||
"""
|
||||
A path referring to a type. For example:
|
||||
```rust
|
||||
let x: (i32);
|
||||
// ^^^
|
||||
type X = std::collections::HashMap<i32, i32>;
|
||||
type Y = X::Item;
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -2187,14 +2211,12 @@ class FormatArgument(Locatable):
|
||||
@annotate(MacroDef)
|
||||
class _:
|
||||
"""
|
||||
A macro definition using the `macro_rules!` or similar syntax.
|
||||
A Rust 2.0 style declarative macro definition.
|
||||
|
||||
For example:
|
||||
```rust
|
||||
macro_rules! my_macro {
|
||||
() => {
|
||||
println!("This is a macro!");
|
||||
};
|
||||
pub macro vec_of_two($element:expr) {
|
||||
vec![$element, $element]
|
||||
}
|
||||
```
|
||||
"""
|
||||
@@ -2219,8 +2241,14 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
macro_rules! my_macro {
|
||||
() => {
|
||||
Ok(_)
|
||||
};
|
||||
}
|
||||
match x {
|
||||
my_macro!() => "matched",
|
||||
// ^^^^^^^^^^^
|
||||
_ => "not matched",
|
||||
}
|
||||
```
|
||||
@@ -2243,11 +2271,12 @@ class _:
|
||||
@annotate(AsmDirSpec)
|
||||
class _:
|
||||
"""
|
||||
An inline assembly directive specification.
|
||||
An inline assembly direction specifier.
|
||||
|
||||
For example:
|
||||
```rust
|
||||
asm!("nop");
|
||||
use core::arch::asm;
|
||||
asm!("mov {input:x}, {input:x}", output = out(reg) x, input = in(reg) y);
|
||||
// ^^^ ^^
|
||||
```
|
||||
"""
|
||||
@@ -2260,6 +2289,7 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
use core::arch::asm;
|
||||
asm!("mov {0}, {1}", out(reg) x, in(reg) y);
|
||||
// ^ ^
|
||||
```
|
||||
@@ -2273,6 +2303,7 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
use core::arch::asm;
|
||||
asm!("", options(nostack, nomem));
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
```
|
||||
@@ -2286,7 +2317,8 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
asm!("mov {0}, {1}", out("eax") x, in("ebx") y);
|
||||
use core::arch::asm;
|
||||
asm!("mov {0}, {1}", out("eax") x, in(EBX) y);
|
||||
// ^^^ ^^^
|
||||
```
|
||||
"""
|
||||
@@ -2299,6 +2331,7 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
use core::arch::asm;
|
||||
asm!("", clobber_abi("C"));
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
```
|
||||
@@ -2312,6 +2345,7 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
use core::arch::asm;
|
||||
asm!("mov eax, {const}", const 42);
|
||||
// ^^^^^^^
|
||||
```
|
||||
@@ -2325,8 +2359,12 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
asm!("jmp {label}", label = sym my_label);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
use core::arch::asm;
|
||||
asm!(
|
||||
"jmp {}",
|
||||
label { println!("Jumped from asm!"); }
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
);
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -2338,8 +2376,9 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
asm!("mov {out}, {in}", out = out(reg) x, in = in(reg) y);
|
||||
// ^^^^^ ^^^^
|
||||
use core::arch::asm;
|
||||
asm!("mov {0:x}, {input:x}", out(reg) x, input = in(reg) y);
|
||||
// ^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
|
||||
```
|
||||
"""
|
||||
|
||||
@@ -2351,6 +2390,7 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
use core::arch::asm;
|
||||
asm!("", options(nostack, nomem));
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
```
|
||||
@@ -2364,6 +2404,7 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
use core::arch::asm;
|
||||
asm!("mov {0}, {1}", out(reg) x, in(reg) y);
|
||||
// ^ ^
|
||||
```
|
||||
@@ -2377,6 +2418,7 @@ class _:
|
||||
|
||||
For example:
|
||||
```rust
|
||||
use core::arch::asm;
|
||||
asm!("call {sym}", sym = sym my_function);
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user