2,424 matches across 25 files for func main lang:Markdown
snippet_mode: grep · sorted by relevance
RELEASES.md MARKDOWN 240 matches · showing 5 view file →
121- `mut ref` and `mut ref mut` patterns, part of the unstable [Match Ergonomics 2024 RFC](https://github.com/rust-lang/rust/issues/123076), were accidentally allowed on stable within struct pattern field shorthand. These patterns are now correctly feature-gated as unstable in this position.
122- [Add future-compatibility warning for derive helper attributes which conflict with built-in attributes](https://github.com/rust-lang/rust/pull/151152)
123- [JSON target specs](https://doc.rust-lang.org/rustc/targets/custom.html) have been destabilized and now require `-Z unstable-options` to use. Previously, they could not be used without the standard library, which has no stable build mechanism. In preparation for the `build-std` project adding that support, JSON target specs are being proactively gated to ensure they remain unstable even if `build-std` is stabilized. Cargo now includes the `-Z json-target-spec` CLI flag to automatically pass `-Z unstable-options` to the compiler when needed. See [#150151](https://github.com/rust-lang/rust/pull/150151), [#151534](https://github.com/rust-lang/rust/pull/150151), and [rust-lang/cargo#16557](https://github.com/rust-lang/cargo/pull/16557).
124- [The arguments of `#[feature]` attributes on invalid targets are now checked](https://github.com/rust-lang/rust/issues/153764)
125
· · ·
221- Stabilize the config include key. The top-level include config key allows loading additional config files, enabling better organization, sharing, and management of Cargo configurations across projects and environments. [docs](https://doc.rust-lang.org/nightly/cargo/reference/config.html#including-extra-configuration-files) [#16284](https://github.com/rust-lang/cargo/pull/16284)
222- Stabilize the pubtime field in registry index. This records when a crate version was published and enables time-based dependency resolution in the future. Note that crates.io will gradually backfill existing packages when a new version is published. Not all crates have pubtime yet. [#16369](https://github.com/rust-lang/cargo/pull/16369) [#16372](https://github.com/rust-lang/cargo/pull/16372)
223- Cargo now parses [TOML v1.1](https://toml.io/en/v1.1.0) for manifests and configuration files. Note that using these features in Cargo.toml will raise your development MSRV, but the published manifest remains compatible with older parsers. [#16415](https://github.com/rust-lang/cargo/pull/16415)
224- [Make `CARGO_BIN_EXE_<crate>` available at runtime ](https://github.com/rust-lang/cargo/pull/16421/)
225
· · ·
282--------
283- [Stabilize several s390x `vector`-related target features and the `is_s390x_feature_detected!` macro](https://github.com/rust-lang/rust/pull/145656)
284- [Stabilize declaration of C-style variadic functions for the `system` ABI](https://github.com/rust-lang/rust/pull/145954)
285- [Emit error when using some keyword as a `cfg` predicate](https://github.com/rust-lang/rust/pull/146978)
286- [Stabilize `asm_cfg`](https://github.com/rust-lang/rust/pull/147736)
· · ·
287- [During const-evaluation, support copying pointers byte-by-byte](https://github.com/rust-lang/rust/pull/148259)
288- [LUB coercions now correctly handle function item types, and functions with differing safeties](https://github.com/rust-lang/rust/pull/148602)
289- [Allow `const` items that contain mutable references to `static` (which is *very* unsafe, but not *always* UB)](https://github.com/rust-lang/rust/pull/148746)
290- [Add warn-by-default `const_item_interior_mutations` lint to warn against calls which mutate interior mutable `const` items](https://github.com/rust-lang/rust/pull/148407)
· · ·
291- [Add warn-by-default `function_casts_as_integer` lint](https://github.com/rust-lang/rust/pull/141470)
292
293
+ 235 more matches in this file
compiler/rustc_codegen_cranelift/docs/dwarf.md MARKDOWN 7 matches · showing 5 view file →
21for more information.
22
23# Function debuginfo
24
25## Tips
· · ·
43(13:56:12) bjorn3: for more context: https://github.com/bjorn3/rustc_codegen_cranelift/pull/978
44(13:58:16) osa1 verliet de ruimte (quit: Quit: osa1).
45(13:58:28) bjorn3: luispm: wait, for b m<TAB> it shows nothing, but when stepping into a new function it does
46(13:58:45) bjorn3: it still doesn't show anything for `info args` though
47(13:58:50) bjorn3: No symbol table info available.
· · ·
48(14:00:50) luispm: bjorn3, Is that expected given the nature of the binary?
49(14:01:17) bjorn3: b main<TAB> may show nothing as I only set DW_AT_linkage_name and not DW_AT_name
50(14:01:24) bjorn3: info args should work though
51(14:03:26) luispm: Sorry, I'm not sure what's up. There may be a genuine bug there.
· · ·
85(15:46:18) tromey: (which is really pretty good, most compilers manage to generate a bunch)
86(15:46:29) tromey: and then the gdb DWARF reader says
87(15:46:34) tromey: /* Ignore functions with missing or empty names. These are actually
88(15:46:34) tromey: illegal according to the DWARF standard. */
89(15:46:34) tromey: if (name == NULL)
· · ·
101(15:49:02) tromey: sort of anyway
102(15:49:43) tromey: this seems kind of pedantic of gdb, like if there's a linkage name but no DW_AT_name, then why bail?
103(15:50:01) tromey: also what about anonymous functions
104(15:50:17) tromey: but anyway this explains the current situation and if you don't mind adding DW_AT_name, then that's probably simplest
105(15:51:47) bjorn3: i added DW_AT_name.
+ 2 more matches in this file
compiler/rustc_codegen_cranelift/docs/usage.md MARKDOWN 5 matches view file →
44## Shell
45
46These are a few functions that allow you to easily run rust code from the shell using cg_clif as jit.
47
48```bash
· · ·
49function jit_naked() {
50 echo "$@" | $cg_clif_dir/dist/rustc-clif - -Zunstable-options -Cllvm-args=jit-mode -Cprefer-dynamic
51}
· · ·
52
53function jit() {
54 jit_naked "fn main() { $@ }"
55}
· · ·
54 jit_naked "fn main() { $@ }"
55}
56
· · ·
57function jit_calc() {
58 jit 'println!("0x{:x}", ' $@ ');';
59}
compiler/rustc_codegen_gcc/doc/gimple.md MARKDOWN 2 matches view file →
28```
29
30Then we'll add a `main` function which will call the `create_code` function but
31also add the calls we need to generate the GIMPLE:
32
· · ·
33```C
34int main() {
35 gcc_jit_context *ctxt = gcc_jit_context_acquire();
36 // To set `-O3`, update it depending on your needs.
compiler/rustc_driver_impl/README.md MARKDOWN 2 matches view file →
1The `driver` crate is effectively the "main" function for the rust
2compiler. It orchestrates the compilation process and "knits together"
3the code from the other crates within rustc. This crate itself does
· · ·
4not contain any of the "main logic" of the compiler (though it does
5have some code related to pretty printing or other minor compiler
6options).
compiler/rustc_error_codes/src/error_codes/E0038.md MARKDOWN 6 matches · showing 5 view file →
109If only some methods aren't dyn-compatible, you can add a `where Self: Sized`
110bound on them to mark them as explicitly unavailable to trait objects. The
111functionality will still be available to all other implementers, including
112`Box<dyn Trait>` which is itself sized (assuming you `impl Trait for Box<dyn
113Trait>`).
· · ·
116trait Trait {
117 fn foo(&self) -> Self where Self: Sized;
118 // more functions
119}
120```
· · ·
171type parameters, the number of monomorphized implementations the compiler
172generates does not grow drastically, since the compiler will only generate an
173implementation if the function is called with fully concrete arguments
174(i.e., arguments which do not contain any generic parameters).
175
· · ·
264### Trait contains associated constants
265
266Just like static functions, associated constants aren't stored on the method
267table. If the trait or any subtrait contain an associated constant, they are not
268dyn compatible.
· · ·
301impl Trait for Foo {}
302
303fn main() {
304 let x: Box<dyn Trait>;
305}
+ 1 more matches in this file
compiler/rustc_error_codes/src/error_codes/E0040.md MARKDOWN 3 matches view file →
14}
15
16fn main() {
17 let mut x = Foo { x: -7 };
18 x.drop(); // error: explicit use of destructor method
· · ·
22It is unnecessary to do this since `drop` is called automatically whenever a
23value goes out of scope. However, if you really need to drop a value by hand,
24you can use the `std::mem::drop` function:
25
26```
· · ·
33 }
34}
35fn main() {
36 let mut x = Foo { x: -7 };
37 drop(x); // ok!
compiler/rustc_error_codes/src/error_codes/E0060.md MARKDOWN 3 matches view file →
1External C functions are allowed to be variadic. However, a variadic function
2takes a minimum number of arguments. For example, consider C's variadic `printf`
3function:
· · ·
3function:
4
5```compile_fail,E0060
· · ·
22# kind = "static", modifiers = "-bundle"))]
23# extern "C" { fn printf(_: *const c_char, ...) -> c_int; }
24# fn main() {
25unsafe {
26 printf(c"test\n".as_ptr());
compiler/rustc_error_codes/src/error_codes/E0087.md MARKDOWN 2 matches view file →
1#### Note: this error code is no longer emitted by the compiler.
2
3Too many type arguments were supplied for a function. For example:
4
5```compile_fail,E0107
· · ·
6fn foo<T>() {}
7
8fn main() {
9 foo::<f64, bool>(); // error: wrong number of type arguments:
10 // expected 1, found 2
compiler/rustc_error_codes/src/error_codes/E0089.md MARKDOWN 4 matches view file →
1#### Note: this error code is no longer emitted by the compiler.
2
3Too few type arguments were supplied for a function. For example:
4
5```compile_fail,E0107
· · ·
6fn foo<T, U>() {}
7
8fn main() {
9 foo::<f64>(); // error: wrong number of type arguments: expected 2, found 1
10}
· · ·
11```
12
13Note that if a function takes multiple type arguments but you want the compiler
14to infer some of them, you can use type placeholders:
15
· · ·
17fn foo<T, U>(x: T) {}
18
19fn main() {
20 let x: bool = true;
21 foo::<f64>(x); // error: wrong number of type arguments:
compiler/rustc_error_codes/src/error_codes/E0093.md MARKDOWN 5 matches view file →
1An unknown intrinsic function was declared.
2
3Erroneous code example:
· · ·
8
9#[rustc_intrinsic]
10unsafe fn foo(); // error: unrecognized intrinsic function: `foo`
11
12fn main() {
· · ·
12fn main() {
13 unsafe {
14 foo();
· · ·
17```
18
19Please check you didn't make a mistake in the function's name. All intrinsic
20functions are defined in `library/core/src/intrinsics` in the Rust source code.
21
· · ·
20functions are defined in `library/core/src/intrinsics` in the Rust source code.
21
compiler/rustc_error_codes/src/error_codes/E0131.md MARKDOWN 3 matches view file →
1The `main` function was defined with generic parameters.
2
3Erroneous code example:
· · ·
4
5```compile_fail,E0131
6fn main<T>() { // error: main function is not allowed to have generic parameters
7}
8```
· · ·
9
10It is not possible to define the `main` function with generic parameters.
11It must not take any arguments.
12
compiler/rustc_error_codes/src/error_codes/E0133.md MARKDOWN 8 matches · showing 5 view file →
6unsafe fn f() { return; } // This is the unsafe code
7
8fn main() {
9 f(); // error: call to unsafe function requires unsafe function or block
10}
· · ·
9 f(); // error: call to unsafe function requires unsafe function or block
10}
11```
· · ·
12
13Using unsafe functionality is potentially dangerous and disallowed by safety
14checks. Examples:
15
· · ·
16* Dereferencing raw pointers
17* Calling functions via FFI
18* Calling functions marked unsafe
19
· · ·
18* Calling functions marked unsafe
19
20These safety checks can be relaxed for a section of the code by wrapping the
+ 3 more matches in this file
compiler/rustc_error_codes/src/error_codes/E0136.md MARKDOWN 4 matches view file →
1#### Note: this error code is no longer emitted by the compiler.
2
3More than one `main` function was found.
4
5Erroneous code example:
· · ·
6
7```compile_fail
8fn main() {
9 // ...
10}
· · ·
12// ...
13
14fn main() { // error!
15 // ...
16}
· · ·
18
19A binary can only have one entry point, and by default that entry point is the
20`main()` function. If there are multiple instances of this function, please
21rename one of them.
22
compiler/rustc_error_codes/src/error_codes/E0137.md MARKDOWN 9 matches · showing 5 view file →
1#### Note: this error code is no longer emitted by the compiler.
2
3More than one function was declared with the `#[main]` attribute.
4
5Erroneous code example:
· · ·
6
7```compile_fail
8#![feature(main)]
9
10#[main]
· · ·
10#[main]
11fn foo() {}
12
· · ·
13#[main]
14fn f() {} // error: multiple functions with a `#[main]` attribute
15```
· · ·
14fn f() {} // error: multiple functions with a `#[main]` attribute
15```
16
+ 4 more matches in this file
compiler/rustc_error_codes/src/error_codes/E0211.md MARKDOWN 6 matches · showing 5 view file →
1#### Note: this error code is no longer emitted by the compiler.
2
3You used a function or type which doesn't fit the requirements for where it was
4used. Erroneous code examples:
5
· · ·
13// or:
14
15fn main() -> i32 { 0 }
16// error: main function expects type: `fn() {main}`: expected (), found i32
17
· · ·
16// error: main function expects type: `fn() {main}`: expected (), found i32
17
18// or:
· · ·
37```
38
39For the first code example, please check the function definition. Example:
40
41```
· · ·
47```
48
49The second case example is a bit particular: the main function must always
50have this definition:
51
+ 1 more matches in this file
compiler/rustc_error_codes/src/error_codes/E0253.md MARKDOWN 2 matches view file →
7
8```
9#![feature(import_trait_associated_functions)]
10
11mod foo {
· · ·
18// error: `SomeType` is not directly importable
19
20fn main() {}
21```
22
compiler/rustc_error_codes/src/error_codes/E0277.md MARKDOWN 17 matches · showing 5 view file →
10}
11
12// we now declare a function which takes an object implementing the Foo trait
13fn some_func<T: Foo>(foo: T) {
14 foo.bar();
· · ·
13fn some_func<T: Foo>(foo: T) {
14 foo.bar();
15}
· · ·
16
17fn main() {
18 // we now call the method with the i32 type, which doesn't implement
19 // the Foo trait
· · ·
20 some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied
21}
22```
· · ·
35}
36
37fn some_func<T: Foo>(foo: T) {
38 foo.bar(); // we can now use this method since i32 implements the
39 // Foo trait
+ 12 more matches in this file
compiler/rustc_error_codes/src/error_codes/E0284.md MARKDOWN 3 matches view file →
1This error occurs when the compiler is unable to unambiguously infer the
2return type of a function or method which is generic on return type, such
3as the `collect` method for `Iterator`s.
4
· · ·
6
7```compile_fail,E0284
8fn main() {
9 let n: u32 = 1;
10 let mut d: u64 = 2;
· · ·
24
25```
26fn main() {
27 let n: u32 = 1;
28 let mut d: u64 = 2;
compiler/rustc_error_codes/src/error_codes/E0382.md MARKDOWN 6 matches · showing 5 view file →
6struct MyStruct { s: u32 }
7
8fn main() {
9 let mut x = MyStruct{ s: 5u32 };
10 let y = x;
· · ·
19
20Sometimes we don't need to move the value. Using a reference, we can let another
21function borrow the value without changing its ownership. In the example below,
22we don't actually have to move our string to `calculate_length`, we can give it
23a reference to it with `&` instead.
· · ·
24
25```
26fn main() {
27 let s1 = String::from("hello");
28
· · ·
49
50```
51fn main() {
52 let mut s1 = String::from("many");
53 let s2 = s1.clone();
· · ·
74struct Point { x: i32, y: i32 }
75
76fn main() {
77 let mut p1 = Point{ x: -1, y: 2 };
78 let p2 = p1;
+ 1 more matches in this file
compiler/rustc_error_codes/src/error_codes/E0412.md MARKDOWN 2 matches view file →
47
48mod foo {
49 fn some_function(f: File) {}
50}
51```
· · ·
61 fn foo(f: File) {}
62}
63# fn main() {} // don't insert it for us; that'll break imports
64```
65
compiler/rustc_error_codes/src/error_codes/E0423.md MARKDOWN 5 matches view file →
1An identifier was used like a function name or a value was expected and the
2identifier exists but it belongs to a different namespace.
3
· · ·
8
9let f = Foo();
10// error: expected function, tuple struct or tuple variant, found `Foo`
11// `Foo` is a struct name, but this expression uses it like a function name
12```
· · ·
11// `Foo` is a struct name, but this expression uses it like a function name
12```
13
· · ·
26```compile_fail,E0423
27println("");
28// error: expected function, tuple struct or tuple variant,
29// found macro `println`
30// did you mean `println!(...)`? (notice the trailing `!`)
· · ·
51
52```compile_fail,E0423
53fn main(){
54 let x = Option::<i32>;
55 //~^ ERROR expected value,found enum `Option`
compiler/rustc_error_codes/src/error_codes/E0504.md MARKDOWN 11 matches · showing 5 view file →
11}
12
13fn main() {
14 let fancy_num = FancyNum { num: 5 };
15 let fancy_ref = &fancy_num;
· · ·
16
17 let x = move || {
18 println!("child function: {}", fancy_num.num);
19 // error: cannot move `fancy_num` into closure because it is borrowed
20 };
· · ·
21
22 x();
23 println!("main function: {}", fancy_ref.num);
24}
25```
· · ·
37}
38
39fn main() {
40 let fancy_num = FancyNum { num: 5 };
41 let fancy_ref = &fancy_num;
· · ·
43 let x = move || {
44 // fancy_ref is usable here because it doesn't move `fancy_num`
45 println!("child function: {}", fancy_ref.num);
46 };
47
+ 6 more matches in this file
compiler/rustc_error_codes/src/error_codes/E0505.md MARKDOWN 6 matches · showing 5 view file →
10fn eat(val: Value) {}
11
12fn main() {
13 let x = Value{};
14 let _ref_to_val: &Value = &x;
· · ·
18```
19
20Here, the function `eat` takes ownership of `x`. However,
21`x` cannot be moved because the borrow to `_ref_to_val`
22needs to last till the function `borrow`.
· · ·
22needs to last till the function `borrow`.
23To fix that you can do a few different things:
24
· · ·
36fn eat(val: &Value) {}
37
38fn main() {
39 let x = Value{};
40
· · ·
54fn eat(val: Value) {}
55
56fn main() {
57 let x = Value{};
58
+ 1 more matches in this file
compiler/rustc_error_codes/src/error_codes/E0511.md MARKDOWN 2 matches view file →
1Invalid monomorphization of an intrinsic function was used.
2
3Erroneous code example:
· · ·
9unsafe fn simd_add<T>(a: T, b: T) -> T;
10
11fn main() {
12 unsafe { simd_add(0, 1); }
13 // error: invalid monomorphization of `simd_add` intrinsic
Search syntax
auth loginboth terms (AND is implicit)
auth OR logineither term
NOT path:vendorexclude matches
"exact phrase"quoted exact match
/func\s+Test/regex
handler~1fuzzy (Levenshtein 1)
file:*_test.gofilename glob
path:pkg/auth/**full path glob
lang:golanguage filter

Search any public repo from your terminal

This page calls POST /api/v1/code_search. Same tool, available over MCP for Claude/Cursor/Copilot.