25,897 matches across 25 files for func main lang:Rust lang:Rust
snippet_mode: grep · sorted by relevance
compiler/rustc_abi/src/lib.rs RUST 10 matches · showing 5 view file →
95 ///
96 /// `repr(Rust)` structs with only zero-sized fields, single-variant `repr(Rust)` enums with only
97 /// zero-sized fields, and zero-variant `repr(Rust)` enums must remain zero-sized as per
98 /// T-lang decisions in https://github.com/rust-lang/reference/pull/2262 and https://github.com/rust-lang/reference/pull/2293
99 const RANDOMIZE_LAYOUT = 1 << 4;
· · ·
430 /// [llvm data layout string](https://llvm.org/docs/LangRef.html#data-layout)
431 ///
432 /// This function doesn't fill `c_enum_min_size` and it will always be `I32` since it can not be
433 /// determined from llvm string.
434 pub fn parse_from_llvm_datalayout_string<'a>(
· · ·
641 ///
642 /// The theoretical maximum object size is defined as the maximum positive `isize` value.
643 /// This ensures that the `offset` semantics remain well-defined by allowing it to correctly
644 /// index every address within an object along with one byte past the end, along with allowing
645 /// `isize` to store the difference between any two pointers into an object.
· · ·
660 ///
661 /// The theoretical maximum object size is defined as the maximum positive `isize` value.
662 /// This ensures that the `offset` semantics remain well-defined by allowing it to correctly
663 /// index every address within an object along with one byte past the end, along with allowing
664 /// `isize` to store the difference between any two pointers into an object.
· · ·
1827 // FIXME(rustc_scalable_vector): Scalable vectors are `Sized` while the
1828 // `sized_hierarchy` feature is not yet fully implemented. After `sized_hierarchy` is
1829 // fully implemented, scalable vectors will remain `Sized`, they just won't be
1830 // `const Sized` - whether `is_unsized` continues to return `false` at that point will
1831 // need to be revisited and will depend on what `is_unsized` is used for.
+ 5 more matches in this file
compiler/rustc_arena/src/lib.rs RUST 4 matches view file →
30use smallvec::SmallVec;
31
32/// This calls the passed function while ensuring it won't be inlined into the caller.
33#[inline(never)]
34#[cold]
· · ·
226 //
227 // So we collect all the elements beforehand, which takes care of reentrancy and panic
228 // safety. This function is much less hot than `DroplessArena::alloc_from_iter`, so it
229 // doesn't need to be hyper-optimized.
230 assert!(size_of::<T>() != 0);
· · ·
546 assert!(size_of::<T>() != 0);
547
548 // Warning: this function is reentrant: `iter` could hold a reference to `&self` and
549 // allocate additional elements while we're iterating.
550 let iter = iter.into_iter();
· · ·
613///
614/// As an optimization, types that are `!Copy + !needs_drop` will actually be stored in the
615/// [`DroplessArena`], and the corresponding [`TypedArena`] will remain empty. This makes
616/// better use of the dropless arena's storage blocks, while the overhead of having a few
617/// unused typed-arenas is negligible.
compiler/rustc_ast/src/ast.rs RUST 35 matches · showing 5 view file →
2//!
3//! This module contains common structures forming the language AST.
4//! Two main entities in the module are [`Item`] (which represents an AST element with
5//! additional metadata), and [`ItemKind`] (which represents a concrete type and contains
6//! information specific to the type of the item).
· · ·
11//! - [`Pat`] and [`PatKind`]: A parsed Rust pattern. Patterns are often dual to expressions.
12//! - [`Stmt`] and [`StmtKind`]: An executable action that does not return a value.
13//! - [`FnDecl`], [`FnHeader`] and [`Param`]: Metadata associated with a function declaration.
14//! - [`Generics`], [`GenericParam`], [`WhereClause`]: Metadata associated with generic parameters.
15//! - [`EnumDef`] and [`Variant`]: Enum declaration.
· · ·
186}
187
188/// Like `join_path_syms`, but for `Ident`s. This function is necessary because
189/// `Ident::to_string` does more than just print the symbol in the `name` field.
190pub fn join_path_idents(path: impl IntoIterator<Item = impl Borrow<Ident>>) -> String {
· · ·
468
469/// Represents lifetime, type and const parameters attached to a declaration of
470/// a function, enum, trait, etc.
471#[derive(Clone, Encodable, Decodable, Debug, Default, Walkable)]
472pub struct Generics {
· · ·
1410 /// is a path, it mostly dispatches to [`Path::is_single_argless_ident`].
1411 ///
1412 /// This function will only allow paths with no qself, before dispatching to the `Path`
1413 /// function of the same name.
1414 ///
+ 30 more matches in this file
compiler/rustc_ast/src/entry.rs RUST 18 matches · showing 5 view file →
3#[derive(Debug)]
4pub enum EntryPointType {
5 /// This function is not an entrypoint.
6 None,
7 /// This is a function called `main` at the root level.
· · ·
7 /// This is a function called `main` at the root level.
8 /// ```
9 /// fn main() {}
· · ·
9 /// fn main() {}
10 /// ```
11 MainNamed,
· · ·
11 MainNamed,
12 /// This is a function with the `#[rustc_main]` attribute.
13 /// Used by the testing harness to create the test entrypoint.
· · ·
12 /// This is a function with the `#[rustc_main]` attribute.
13 /// Used by the testing harness to create the test entrypoint.
14 /// ```ignore (clashes with test entrypoint)
+ 13 more matches in this file
compiler/rustc_ast/src/visit.rs RUST 10 matches · showing 5 view file →
5//!
6//! Note: it is an important invariant that the default visitor walks the body
7//! of a function in "execution order" (more concretely, reverse post-order
8//! with respect to the CFG implied by the AST), meaning that if AST node A may
9//! execute before AST node B, then A is visited first. The borrow checker in
· · ·
769
770 // This is only used by the MutVisitor. We include this symmetry here to make writing other
771 // functions easier.
772 $(${ignore($lt)}
773 #[expect(unused, rustc::disallowed_pass_by_ref)]
· · ·
828 ) -> V::Result {
829 match self {
830 ItemKind::Fn(func) => {
831 let kind = FnKind::Fn(FnCtxt::Free, visibility, &$($mut)? *func);
832 try_visit!(vis.visit_fn(kind, attrs, span, id));
· · ·
831 let kind = FnKind::Fn(FnCtxt::Free, visibility, &$($mut)? *func);
832 try_visit!(vis.visit_fn(kind, attrs, span, id));
833 }
· · ·
890 AssocItemKind::Const(item) =>
891 visit_visitable!($($mut)? vis, item),
892 AssocItemKind::Fn(func) => {
893 let kind = FnKind::Fn(FnCtxt::Assoc(ctxt), visibility, &$($mut)? *func);
894 try_visit!(vis.visit_fn(kind, attrs, span, id))
+ 5 more matches in this file
compiler/rustc_ast_lowering/src/diagnostics.rs RUST 9 matches · showing 5 view file →
84#[derive(Diagnostic)]
85#[diag("`impl Trait` is not allowed in {$position}", code = E0562)]
86#[note("`impl Trait` is only allowed in arguments and return types of functions and methods")]
87pub(crate) struct MisplacedImplTrait<'a> {
88 #[primary_span]
· · ·
114
115#[derive(Diagnostic)]
116#[diag("`await` is only allowed inside `async` functions and blocks", code = E0728)]
117pub(crate) struct AwaitOnlyInAsyncFnAndBlocks {
118 #[primary_span]
· · ·
119 #[label("only allowed inside `async` functions and blocks")]
120 pub await_kw_span: Span,
121 #[label("this is not `async`")]
· · ·
124
125#[derive(Diagnostic)]
126#[diag("a function cannot be both `comptime` and `const`")]
127pub(crate) struct ConstComptimeFn {
128 #[primary_span]
· · ·
129 #[suggestion("remove the `const`", applicability = "machine-applicable", code = "")]
130 #[note("`const` implies the function can be called at runtime, too")]
131 pub span: Span,
132 #[label("`comptime` because of this")]
+ 4 more matches in this file
compiler/rustc_ast_lowering/src/expr.rs RUST 7 matches · showing 5 view file →
21use crate::diagnostics::{
22 AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks,
23 FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd,
24 InvalidLegacyConstGenericArg, MatchArmWithNoBody, MoveExprOnlyInPlainClosures,
25 NeverPatternWithBody, NeverPatternWithGuard, UnderscoreExprLhsAssign, UseConstGenericArg,
· · ·
806 let coroutine_kind = hir::CoroutineKind::Desugared(desugaring_kind, coroutine_source);
807
808 // The `async` desugaring takes a resume argument and maintains a `task_context`,
809 // whereas a generator does not.
810 let (inputs, params, task_context): (&[_], &[_], _) = match desugaring_kind {
· · ·
990 // Note that the name of this binding must not be changed to something else because
991 // debuggers and debugger extensions expect it to be called `__awaitee`. They use
992 // this name to identify what is being awaited by a suspended async functions.
993 let awaitee_ident = Ident::with_dummy_span(sym::__awaitee);
994 let (awaitee_pat, awaitee_pat_hid) =
· · ·
1349 let fields_omitted = match &se.rest {
1350 StructRest::Base(e) => {
1351 self.dcx().emit_err(FunctionalRecordUpdateDestructuringAssignment {
1352 span: e.span,
1353 });
· · ·
1927
1928 let (constructor_item, target_id) = match self.try_block_scope {
1929 TryBlockScope::Function => {
1930 (LangItem::TryTraitFromResidual, Err(hir::LoopIdError::OutsideLoopScope))
1931 }
+ 2 more matches in this file
compiler/rustc_ast_lowering/src/lib.rs RUST 20 matches · showing 5 view file →
260
261 // Lowering state.
262 try_block_scope: TryBlockScope::Function,
263 loop_scope: None,
264 is_in_loop_condition: false,
· · ·
335
336 // We do not need to look at `partial_res_overrides`. That map only contains overrides for
337 // `self_param` locals. And here we are looking for the function definition that `expr`
338 // resolves to.
339 let def_id = self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?;
· · ·
487enum TryBlockScope {
488 /// There isn't a `try` block, so a `?` will use `return`.
489 Function,
490 /// We're inside a `try { … }` block, so a `?` will block-break
491 /// from that block using a type depending only on the argument.
· · ·
816 /// The lowered item is registered into `self.children`.
817 ///
818 /// This function sets up `HirId` lowering infrastructure,
819 /// and stashes the shared mutable state to avoid pollution by the closure.
820 #[instrument(level = "debug", skip(self, f))]
· · ·
994 // This can happen when trying to lower the return type `x` in erroneous code like
995 // async fn foo(x: u8) -> x {}
996 // In that case, `x` is lowered as a function parameter, and the return type is lowered as
997 // an opaque type as a synthesized HIR owner.
998 res.unwrap_or(Res::Err)
+ 15 more matches in this file
compiler/rustc_attr_ir/src/data_structures.rs RUST 17 matches · showing 5 view file →
114 Never,
115 /// `#[rustc_force_inline]` forces inlining to happen in the MIR inliner - it reports an error
116 /// if the inlining cannot happen. It is limited to only free functions so that the calls
117 /// can always be resolved.
118 Force {
· · ·
649 /// Conceptually either forward or reverse mode AD, as described in various autodiff papers and
650 /// e.g. in the [JAX
651 /// Documentation](https://jax.readthedocs.io/en/latest/_tutorials/advanced-autodiff.html#how-it-s-made-two-foundational-autodiff-functions).
652 pub mode: DiffMode,
653 /// A user-provided, batching width. If not given, we will default to 1 (no batching).
· · ·
654 /// Calling a differentiated, non-batched function through a loop 100 times is equivalent to:
655 /// - Calling the function 50 times with a batch size of 2
656 /// - Calling the function 25 times with a batch size of 4,
· · ·
655 /// - Calling the function 50 times with a batch size of 2
656 /// - Calling the function 25 times with a batch size of 4,
657 /// etc. A batched function takes more (or longer) arguments, and might be able to benefit from
· · ·
656 /// - Calling the function 25 times with a batch size of 4,
657 /// etc. A batched function takes more (or longer) arguments, and might be able to benefit from
658 /// cache locality, better re-usal of primal values, and other optimizations.
+ 12 more matches in this file
compiler/rustc_attr_ir/src/encode_cross_crate.rs RUST 4 matches view file →
74 NoImplicitPrelude => No,
75 NoLink => No,
76 NoMain => No,
77 NoMangle(..) => Yes, // Needed for rustdoc
78 NoStd => No,
· · ·
87 Optimize(..) => No,
88 PanicRuntime => No,
89 PatchableFunctionEntry { .. } => Yes,
90 Path(..) => No,
91 PatternComplexityLimit { .. } => No,
· · ·
97 ProfilerRuntime => No,
98 RecursionLimit { .. } => No,
99 ReexportTestHarnessMain(..) => No,
100 RegisterTool { .. } => No,
101 Repr { .. } => No,
· · ·
161 RustcLintUntrackedQueryInformation => Yes,
162 RustcMacroTransparency(..) => Yes,
163 RustcMain => No,
164 RustcMir(..) => Yes,
165 RustcMustImplementOneOf { .. } => No,
compiler/rustc_attr_ir/src/lang_items.rs RUST 5 matches view file →
6//! * Traits that specify "kinds"; e.g., `Sync`, `Send`.
7//! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`.
8//! * Functions called by the compiler itself.
9
10use rustc_data_structures::fx::FxIndexMap;
· · ·
339 FormatArguments, sym::format_arguments, format_arguments, Target::Struct, GenericRequirement::None;
340
341 // Compiler-generated drop glue function, aka `core::ptr::drop_glue`
342 DropGlue, sym::drop_glue, drop_glue_fn, Target::Fn, GenericRequirement::Exact(1);
343 AllocLayout, sym::alloc_layout, alloc_layout, Target::Struct, GenericRequirement::None;
· · ·
344
345 /// For all binary crates without `#![no_main]`, Rust will generate a "main" function.
346 /// The exact name and signature are target-dependent. The "main" function will invoke
347 /// this lang item, passing it the `argc` and `argv` (or null, if those don't exist
· · ·
346 /// The exact name and signature are target-dependent. The "main" function will invoke
347 /// this lang item, passing it the `argc` and `argv` (or null, if those don't exist
348 /// on the current target) as well as the user-defined `fn main` from the binary crate.
· · ·
348 /// on the current target) as well as the user-defined `fn main` from the binary crate.
349 Start, sym::start, start_fn, Target::Fn, GenericRequirement::Exact(1);
350
compiler/rustc_attr_ir/src/stability.rs RUST 3 matches view file →
49 pub level: StabilityLevel,
50 pub feature: Symbol,
51 /// whether the function has a `#[rustc_promotable]` attribute
52 pub promotable: bool,
53 /// This is true iff the `const_stable_indirect` attribute is present.
· · ·
89 pub level: StabilityLevel,
90 pub feature: Symbol,
91 /// whether the function has a `#[rustc_promotable]` attribute
92 pub promotable: bool,
93}
· · ·
113 /// Relevant `rust-lang/rust` issue.
114 issue: Option<NonZero<u32>>,
115 /// If part of a feature is stabilized and a new feature is added for the remaining parts,
116 /// then the `implied_by` attribute is used to indicate which now-stable feature previously
117 /// contained an item.
compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs RUST 15 matches · showing 5 view file →
10use crate::attributes::AttributeSafety;
11use crate::diagnostics::{
12 EmptyExportName, EmptySection, NakedFunctionIncompatibleAttribute, NullOnExport,
13 NullOnObjcClass, NullOnObjcSelector, NullOnSection, ObjcClassExpectedStringLiteral,
14 ObjcSelectorExpectedStringLiteral, SanitizeInvalidStatic, TargetFeatureOnLangItem,
· · ·
226 })];
227 const SAFETY: AttributeSafety = AttributeSafety::Unsafe {
228 note: "the `#[naked]` attribute adds the safety obligation that the function's body must respect the function’s calling convention, uphold its signature, and either return or diverge (i.e., not fall through past the end of the assembly code).",
229 unsafe_since: None,
230 };
· · ·
248 // * `#[test]`, `#[ignore]`, `#[should_panic]`
249 //
250 // NOTE: when making changes to this list, check that `error_codes/E0736.md` remains
251 // accurate.
252 const ALLOW_LIST: &[rustc_span::Symbol] = &[
· · ·
306
307 if other_attr.word_is(sym::target_feature) {
308 if !cx.features().naked_functions_target_feature() {
309 feature_err(
310 cx.sess(),
· · ·
311 sym::naked_functions_target_feature,
312 other_attr.span(),
313 "`#[target_feature(/* ... */)]` is currently unstable on `#[naked]` functions",
+ 10 more matches in this file
compiler/rustc_attr_parsing/src/attributes/doc.rs RUST 6 matches · showing 5 view file →
269
270 fn parse_cfg(&mut self, cx: &mut AcceptContext<'_, '_>, args: &ArgParser) {
271 // This function replaces cases like `cfg(all())` with `true`.
272 fn simplify_cfg(cfg_entry: &mut CfgEntry) {
273 match cfg_entry {
· · ·
375 }
376 ArgParser::List(list) => {
377 'main: for meta in list.mixed() {
378 let MetaItemOrLitParser::MetaItemParser(item) = meta else {
379 cx.emit_lint(
· · ·
418 item.span(),
419 );
420 continue 'main;
421 };
422 match sub_item.args() {
· · ·
424 let Some(name) = sub_item.path().word_sym() else {
425 cx.adcx().expected_identifier(sub_item.path().span());
426 continue 'main;
427 };
428 cfg_names.insert(name);
· · ·
432 let Some(sym::values) = sub_item.path().word_sym() else {
433 cx.adcx().expected_identifier(sub_item.path().span());
434 continue 'main;
435 };
436 if cfg_names.is_empty() {
+ 1 more matches in this file
compiler/rustc_attr_parsing/src/attributes/mod.rs RUST 5 matches view file →
2//!
3//! This module defines traits for attribute parsers, little state machines that recognize and parse
4//! attributes out of a longer list of attributes. The main trait is called [`AttributeParser`].
5//! You can find more docs about [`AttributeParser`]s on the trait itself.
6//! However, for many types of attributes, implementing [`AttributeParser`] is not necessary.
· · ·
89///
90/// Then, it defines what paths this group will accept in [`AttributeParser::ATTRIBUTES`].
91/// These are listed as pairs, of symbols and function pointers. The function pointer will
92/// be called when that attribute is found on an item, which can influence the state of the little
93/// state machine.
· · ·
94///
95/// Finally, after all attributes on an item have been seen, and possibly been accepted,
96/// the [`finalize`](AttributeParser::finalize) functions for all attribute parsers are called. Each can then report
97/// whether it has seen the attribute it has been looking for.
98///
· · ·
104 /// The symbols for the attributes that this parser is interested in.
105 ///
106 /// If an attribute has this symbol, the `accept` function will be called on it.
107 const ATTRIBUTES: AcceptMapping<Self>;
108 const ALLOWED_TARGETS: AllowedTargets<'_>;
· · ·
330
331 type Item;
332 /// A function that converts individual items (of type [`Item`](Self::Item)) into the final attribute.
333 ///
334 /// For example, individual representations from `#[repr(...)]` attributes into an `AttributeKind::Repr(x)`,
compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs RUST 10 matches · showing 5 view file →
20};
21
22pub(crate) struct RustcMainParser;
23
24impl NoArgsAttributeParser for RustcMainParser {
· · ·
24impl NoArgsAttributeParser for RustcMainParser {
25 const PATH: &[Symbol] = &[sym::rustc_main];
26 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
· · ·
25 const PATH: &[Symbol] = &[sym::rustc_main];
26 const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
27 const STABILITY: AttributeStability = unstable!(
· · ·
28 rustc_attrs,
29 "the `rustc_main` attribute is used internally to specify test entry point function"
30 );
31 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcMain;
· · ·
31 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcMain;
32}
33
+ 5 more matches in this file
compiler/rustc_attr_parsing/src/context.rs RUST 5 matches view file →
225 Single<MustUseParser>,
226 Single<OptimizeParser>,
227 Single<PatchableFunctionEntryParser>,
228 Single<PathAttributeParser>,
229 Single<PatternComplexityLimitParser>,
· · ·
230 Single<ProcMacroDeriveParser>,
231 Single<RecursionLimitParser>,
232 Single<ReexportTestHarnessMainParser>,
233 Single<RustcAbiParser>,
234 Single<RustcAllocatorZeroedVariantParser>,
· · ·
283 Single<WithoutArgs<NoImplicitPreludeParser>>,
284 Single<WithoutArgs<NoLinkParser>>,
285 Single<WithoutArgs<NoMainParser>>,
286 Single<WithoutArgs<NoMangleParser>>,
287 Single<WithoutArgs<NoStdParser>>,
· · ·
333 Single<WithoutArgs<RustcLintQueryInstabilityParser>>,
334 Single<WithoutArgs<RustcLintUntrackedQueryInformationParser>>,
335 Single<WithoutArgs<RustcMainParser>>,
336 Single<WithoutArgs<RustcNeverReturnsNullPtrParser>>,
337 Single<WithoutArgs<RustcNoImplicitAutorefsParser>>,
· · ·
527 ///
528 /// This is a higher-level (and harder to misuse) wrapper over [`ArgParser::as_list`] that
529 /// allows using `?` when the attribute parsing function allows it. You may still want to use
530 /// [`ArgParser::as_list`] for the following reasons:
531 ///
compiler/rustc_attr_parsing/src/lib.rs RUST 5 matches view file →
11//! This crate (`rustc_attr_parsing`) handles how to convert raw tokens into those structures.
12//! This split allows other parts of the compiler to use the data structures without needing
13//! the parsing logic, making the codebase more modular and maintainable.
14//!
15//! ## Background
· · ·
16//! Previously, the compiler had a single attribute definition ([`ast::Attribute`]) with parsing and
17//! validation scattered throughout the codebase. This was reorganized for better maintainability
18//! (see [#131229](https://github.com/rust-lang/rust/issues/131229)).
19//!
· · ·
20//! ## Types of Attributes
21//! In Rust, attributes are markers that can be attached to items. They come in two main categories.
22//!
23//! ### 1. Active Attributes
· · ·
32//! They can be user-defined (in proc-macro helpers) or built-in. Examples of built-in inert attributes:
33//! - `#[stable()]`: Marks stable API items
34//! - `#[inline()]`: Suggests function inlining
35//! - `#[repr()]`: Controls type representation
36//!
· · ·
82//! However, sometimes an attributes' parsed form is needed before the HIR is constructed.
83//! This is referred to as "early" attribute parsing,
84//! and is performed using the `parse_limited_*` family of functions on `AttributeParser`.
85//!
86//! [`ast::Attribute`]: rustc_ast::ast::Attribute
compiler/rustc_borrowck/src/dataflow.rs RUST 31 matches · showing 5 view file →
5use rustc_mir_dataflow::fmt::DebugWithContext;
6use rustc_mir_dataflow::impls::{
7 EverInitializedPlaces, EverInitializedPlacesDomain, MaybeUninitializedPlaces,
8 MaybeUninitializedPlacesDomain,
9};
· · ·
8 MaybeUninitializedPlacesDomain,
9};
10use rustc_mir_dataflow::{Analysis, GenKill, JoinSemiLattice};
· · ·
16// `iterate_to_fixpoint`, but are instead composed from the results of three sub-analyses that are
17// computed individually with `iterate_to_fixpoint`. Because it's faster that way than having a
18// single analysis where the domain has three components.
19pub(crate) struct Borrowck<'a, 'tcx> {
20 pub(crate) borrows: Borrows<'a, 'tcx>,
· · ·
24
25impl<'a, 'tcx> Analysis<'tcx> for Borrowck<'a, 'tcx> {
26 type Domain = BorrowckDomain;
27
28 const NAME: &'static str = "borrowck";
· · ·
29
30 fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain {
31 BorrowckDomain {
32 borrows: self.borrows.bottom_value(body),
+ 26 more matches in this file
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs RUST 45 matches · showing 5 view file →
465 && let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
466 {
467 // The move occurred as one of the arguments to a function call. Is that
468 // argument generic? `def_id` can't be a closure here, so using `fn_sig` is fine
469 let arg_param = if self.infcx.tcx.def_kind(def_id).is_fn_like()
· · ·
479
480 // If the moved value is a mut reference, it is used in a
481 // generic function and it's type is a generic param, it can be
482 // reborrowed to avoid moving.
483 // for example:
· · ·
515 && let Some(arg) = fn_decl.inputs.get(pos + offset)
516 {
517 // If we can't suggest borrowing in the call, but the function definition
518 // is local, instead offer changing the function to borrow that argument.
519 let mut span: MultiSpan = arg.span.into();
· · ·
518 // is local, instead offer changing the function to borrow that argument.
519 let mut span: MultiSpan = arg.span.into();
520 span.push_span_label(
· · ·
523 );
524 let descr = match node.fn_kind() {
525 Some(hir::intravisit::FnKind::ItemFn(..)) | None => "function",
526 Some(hir::intravisit::FnKind::Method(..)) => "method",
527 Some(hir::intravisit::FnKind::Closure) => "closure",
+ 40 more matches in this file
compiler/rustc_borrowck/src/diagnostics/move_errors.rs RUST 3 matches view file →
30
31 /// Illegal move due to attempt to move from field of an ADT that
32 /// implements `Drop`. Rust maintains invariant that all `Drop`
33 /// ADT's remain fully-initialized so that user-defined destructor
34 /// can safely read from all of the ADT's fields.
· · ·
33 /// ADT's remain fully-initialized so that user-defined destructor
34 /// can safely read from all of the ADT's fields.
35 InteriorOfTypeWithDestructor { container_ty: Ty<'tcx> },
· · ·
365 // LL | let mut var = None;
366 // | ------- captured outer variable
367 // LL | func(|| {
368 // | -- captured by this `FnMut` closure
369 // LL | // Shouldn't suggest `move ||.as_ref()` here
compiler/rustc_borrowck/src/lib.rs RUST 33 matches · showing 5 view file →
56use crate::borrow_set::{BorrowData, BorrowSet};
57use crate::consumers::{BodyWithBorrowckFacts, RustcFacts};
58use crate::dataflow::{BorrowIndex, Borrowck, BorrowckDomain, Borrows};
59use crate::diagnostics::{
60 AccessKind, BorrowckDiagnosticsBuffer, IllegalMoveOriginKind, MoveError, RegionName,
· · ·
163/// appear in the closure's signature or on its field types. These
164/// requirements are then verified and proved by the closure's
165/// creating function. This struct encodes those requirements.
166///
167/// The requirements are listed as being between various `RegionVid`. The 0th
· · ·
467
468 // While promoteds should mostly be correct by construction, we need to check them for
469 // invalid moves to detect moving out of arrays:`struct S; fn main() { &([S][0]); }`.
470 for promoted_body in &promoted {
471 use rustc_middle::mir::visit::Visitor;
· · ·
567 .cloned()
568 .collect();
569 // For the remaining unused locals that are marked as mutable, we avoid linting any that
570 // were never initialized. These locals may have been removed as unreachable code; or will be
571 // linted as unused variables.
· · ·
646 let entry_states: EntryStates<_> =
647 itertools::izip!(borrows.entry_states, uninits.entry_states, ever_inits.entry_states)
648 .map(|(borrows, uninits, ever_inits)| BorrowckDomain { borrows, uninits, ever_inits })
649 .collect();
650
+ 28 more matches in this file
compiler/rustc_borrowck/src/nll.rs RUST 5 matches view file →
51
52/// Rewrites the regions in the MIR to use NLL variables, also scraping out the set of universal
53/// regions (e.g., region parameters) declared on the function. That set will need to be given to
54/// `compute_regions`.
55#[instrument(skip(infcx, body, promoted), level = "debug")]
· · ·
66 let universal_regions = UniversalRegions::new(infcx, def);
67
68 // Replace all remaining regions with fresh inference variables.
69 renumber::renumber_mir(infcx, body, promoted);
70
· · ·
80/// This is intended to be used by before [BorrowCheckRootCtxt::handle_opaque_type_uses]
81/// because applying member constraints may rely on closure requirements.
82/// This is frequently the case of async functions where pretty much everything
83/// happens inside of the inner async block but the opaque only gets constrained
84/// in the parent function.
· · ·
84/// in the parent function.
85pub(crate) fn compute_closure_requirements_modulo_opaques<'tcx>(
86 infcx: &BorrowckInferCtxt<'tcx>,
· · ·
301 }
302
303 // When the enclosing function is tagged with `#[rustc_regions]`,
304 // we dump out various bits of state as warnings. This is useful
305 // for verifying that the compiler is behaving as expected. These
compiler/rustc_borrowck/src/places_conflict.rs RUST 3 matches view file →
76}
77
78/// Helper function for checking if places conflict with a mutable borrow and deep access depth.
79/// This is used to check for places conflicting outside of the borrow checking code (such as in
80/// dataflow).
· · ·
115
116 if borrow_local != access_local {
117 // We have proven the borrow disjoint - further projections will remain disjoint.
118 return false;
119 }
· · ·
184 Overlap::Disjoint => {
185 // We have proven the borrow disjoint - further
186 // projections will remain disjoint.
187 debug!("disjoint");
188 return false;
compiler/rustc_borrowck/src/region_infer/mod.rs RUST 3 matches view file →
120
121 /// Information about how the universally quantified regions in
122 /// scope on this function relate to one another.
123 universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
124}
· · ·
373 // For each universally quantified region (lifetime parameter). The
374 // first N variables always correspond to the regions appearing in the
375 // function signature (both named and anonymous) and in where-clauses.
376 match definition.origin {
377 // For each free, universally quantified region X:
· · ·
1192 assert!(self.max_nameable_universe(longer_fr_scc).is_root());
1193
1194 // Only check all of the relations for the main representative of each
1195 // SCC, otherwise just check that we outlive said representative. This
1196 // reduces the number of redundant relations propagated out of
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.