42 editorial revisions, annotations, elaborations, or other modifications
43 represent, as a whole, an original work of authorship. For the purposes
44▶ of this License, Derivative Works shall not include works that remain
45 separable from, or merely link (or bind by name) to the interfaces of,
46 the Work and Derivative Works thereof.
· · ·
159 result of this License or out of the use or inability to use the
160 Work (including but not limited to damages for loss of goodwill,
161▶ work stoppage, computer failure or malfunction, or any and all
162 other commercial damages or losses), even if such Contributor
163 has been advised of the possibility of such damages.
21"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
23▶"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
25"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
· · ·
497. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
51▶8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
539. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
11The GNU General Public License is a free, copyleft license for software and other kinds of works.
12
13▶The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
14
15When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
· · ·
23For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
24
25▶Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
26
27Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
· · ·
63 All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
64
65▶ You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
66
67 Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
· · ·
87 b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
88 c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
89▶ d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
90 e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
91
· · ·
94 A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
95
96▶ "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
97
98 If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
+ 1 more matches in this 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
387 /// [llvm data layout string](https://llvm.org/docs/LangRef.html#data-layout)
388 ///
389▶ /// This function doesn't fill `c_enum_min_size` and it will always be `I32` since it can not be
390 /// determined from llvm string.
391 pub fn parse_from_llvm_datalayout_string<'a>(
· · ·
598 ///
599 /// The theoretical maximum object size is defined as the maximum positive `isize` value.
600▶ /// This ensures that the `offset` semantics remain well-defined by allowing it to correctly
601 /// index every address within an object along with one byte past the end, along with allowing
602 /// `isize` to store the difference between any two pointers into an object.
· · ·
617 ///
618 /// The theoretical maximum object size is defined as the maximum positive `isize` value.
619▶ /// This ensures that the `offset` semantics remain well-defined by allowing it to correctly
620 /// index every address within an object along with one byte past the end, along with allowing
621 /// `isize` to store the difference between any two pointers into an object.
· · ·
1818 // FIXME(rustc_scalable_vector): Scalable vectors are `Sized` while the
1819 // `sized_hierarchy` feature is not yet fully implemented. After `sized_hierarchy` is
1820▶ // fully implemented, scalable vectors will remain `Sized`, they just won't be
1821 // `const Sized` - whether `is_unsized` continues to return `false` at that point will
1822 // need to be revisited and will depend on what `is_unsized` is used for.
· · ·
1983 /// For example, `Option<(usize, &T)>` is represented such that the tag for
1984 /// `None` is the null pointer in the second tuple field, and
1985▶ /// `Some` is the identity function (with a non-null reference)
1986 /// and has no additional tag, i.e. the reference being non-null uniquely identifies this variant.
1987 ///
+ 4 more matches in this 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.
· · ·
185}
186
187▶/// Like `join_path_syms`, but for `Ident`s. This function is necessary because
188/// `Ident::to_string` does more than just print the symbol in the `name` field.
189pub fn join_path_idents(path: impl IntoIterator<Item = impl Borrow<Ident>>) -> String {
· · ·
467
468/// Represents lifetime, type and const parameters attached to a declaration of
469▶/// a function, enum, trait, etc.
470#[derive(Clone, Encodable, Decodable, Debug, Default, Walkable)]
471pub struct Generics {
· · ·
1417 /// is a path, it mostly dispatches to [`Path::is_potential_trivial_const_arg`].
1418 ///
1419▶ /// This function will only allow paths with no qself, before dispatching to the `Path`
1420 /// function of the same name.
1421 ///
+ 29 more matches in this 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
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
· · ·
762
763 // This is only used by the MutVisitor. We include this symmetry here to make writing other
764▶ // functions easier.
765 $(${ignore($lt)}
766 #[expect(unused, rustc::disallowed_pass_by_ref)]
· · ·
821 ) -> V::Result {
822 match self {
823▶ ItemKind::Fn(func) => {
824 let kind = FnKind::Fn(FnCtxt::Free, visibility, &$($mut)? *func);
825 try_visit!(vis.visit_fn(kind, attrs, span, id));
· · ·
824▶ let kind = FnKind::Fn(FnCtxt::Free, visibility, &$($mut)? *func);
825 try_visit!(vis.visit_fn(kind, attrs, span, id));
826 }
· · ·
883 AssocItemKind::Const(item) =>
884 visit_visitable!($($mut)? vis, item),
885▶ AssocItemKind::Fn(func) => {
886 let kind = FnKind::Fn(FnCtxt::Assoc(ctxt), visibility, &$($mut)? *func);
887 try_visit!(vis.visit_fn(kind, attrs, span, id))
+ 5 more matches in this 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`")]
· · ·
138
139#[derive(Diagnostic)]
140▶#[diag("functional record updates are not allowed in destructuring assignments")]
141pub(crate) struct FunctionalRecordUpdateDestructuringAssignment {
142 #[primary_span]
· · ·
141▶pub(crate) struct FunctionalRecordUpdateDestructuringAssignment {
142 #[primary_span]
143 #[suggestion(
+ 1 more matches in this file
19use super::errors::{
20 AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks, ClosureCannotBeStatic,
21▶ CoroutineTooManyParameters, FunctionalRecordUpdateDestructuringAssignment,
22 InclusiveRangeWithNoEnd, MatchArmWithNoBody, NeverPatternWithBody, NeverPatternWithGuard,
23 UnderscoreExprLhsAssign,
· · ·
712 let coroutine_kind = hir::CoroutineKind::Desugared(desugaring_kind, coroutine_source);
713
714▶ // The `async` desugaring takes a resume argument and maintains a `task_context`,
715 // whereas a generator does not.
716 let (inputs, params, task_context): (&[_], &[_], _) = match desugaring_kind {
· · ·
896 // Note that the name of this binding must not be changed to something else because
897 // debuggers and debugger extensions expect it to be called `__awaitee`. They use
898▶ // this name to identify what is being awaited by a suspended async functions.
899 let awaitee_ident = Ident::with_dummy_span(sym::__awaitee);
900 let (awaitee_pat, awaitee_pat_hid) =
· · ·
1428 let fields_omitted = match &se.rest {
1429 StructRest::Base(e) => {
1430▶ self.dcx().emit_err(FunctionalRecordUpdateDestructuringAssignment {
1431 span: e.span,
1432 });
· · ·
2006
2007 let (constructor_item, target_id) = match self.try_block_scope {
2008▶ TryBlockScope::Function => {
2009 (hir::LangItem::TryTraitFromResidual, Err(hir::LoopIdError::OutsideLoopScope))
2010 }
+ 2 more matches in this file
188
189 // Lowering state.
190▶ try_block_scope: TryBlockScope::Function,
191 loop_scope: None,
192 is_in_loop_condition: false,
· · ·
262
263 // We do not need to look at `partial_res_overrides`. That map only contains overrides for
264▶ // `self_param` locals. And here we are looking for the function definition that `expr`
265 // resolves to.
266 let def_id = self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?;
· · ·
452enum TryBlockScope {
453 /// There isn't a `try` block, so a `?` will use `return`.
454▶ Function,
455 /// We're inside a `try { … }` block, so a `?` will block-break
456 /// from that block using a type depending only on the argument.
· · ·
686 /// The lowered item is registered into `self.children`.
687 ///
688▶ /// This function sets up `HirId` lowering infrastructure,
689 /// and stashes the shared mutable state to avoid pollution by the closure.
690 #[instrument(level = "debug", skip(self, f))]
· · ·
844 // This can happen when trying to lower the return type `x` in erroneous code like
845 // async fn foo(x: u8) -> x {}
846▶ // In that case, `x` is lowered as a function parameter, and the return type is lowered as
847 // an opaque type as a synthesized HIR owner.
848 res.unwrap_or(Res::Err)
+ 13 more matches in this file
6use crate::attributes::AttributeSafety;
7use crate::session_diagnostics::{
8▶ NakedFunctionIncompatibleAttribute, NullOnExport, NullOnObjcClass, NullOnObjcSelector,
9 ObjcClassExpectedStringLiteral, ObjcSelectorExpectedStringLiteral,
10};
· · ·
227 // * `#[test]`, `#[ignore]`, `#[should_panic]`
228 //
229▶ // NOTE: when making changes to this list, check that `error_codes/E0736.md` remains
230 // accurate.
231 const ALLOW_LIST: &[rustc_span::Symbol] = &[
· · ·
288
289 if other_attr.word_is(sym::target_feature) {
290▶ if !cx.features().naked_functions_target_feature() {
291 feature_err(
292 &cx.sess(),
· · ·
293▶ sym::naked_functions_target_feature,
294 other_attr.span(),
295 "`#[target_feature(/* ... */)]` is currently unstable on `#[naked]` functions",
· · ·
295▶ "`#[target_feature(/* ... */)]` is currently unstable on `#[naked]` functions",
296 ).emit();
297 }
+ 5 more matches in this file
1//! This module defines traits for attribute parsers, little state machines that recognize and parse
2▶//! attributes out of a longer list of attributes. The main trait is called [`AttributeParser`].
3//! You can find more docs about [`AttributeParser`]s on the trait itself.
4//! However, for many types of attributes, implementing [`AttributeParser`] is not necessary.
· · ·
81///
82/// Then, it defines what paths this group will accept in [`AttributeParser::ATTRIBUTES`].
83▶/// These are listed as pairs, of symbols and function pointers. The function pointer will
84/// be called when that attribute is found on an item, which can influence the state of the little
85/// state machine.
· · ·
86///
87/// Finally, after all attributes on an item have been seen, and possibly been accepted,
88▶/// the [`finalize`](AttributeParser::finalize) functions for all attribute parsers are called. Each can then report
89/// whether it has seen the attribute it has been looking for.
90///
· · ·
96 /// The symbols for the attributes that this parser is interested in.
97 ///
98▶ /// If an attribute has this symbol, the `accept` function will be called on it.
99 const ATTRIBUTES: AcceptMapping<Self>;
100 const ALLOWED_TARGETS: AllowedTargets;
· · ·
183 Ignore,
184
185▶ /// Custom function called when a duplicate attribute is found.
186 ///
187 /// - `unused` is the span of the attribute that was unused or bad because of some
+ 1 more matches in this file
16};
17
18▶pub(crate) struct RustcMainParser;
19
20impl NoArgsAttributeParser for RustcMainParser {
· · ·
20▶impl NoArgsAttributeParser for RustcMainParser {
21 const PATH: &[Symbol] = &[sym::rustc_main];
22 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
· · ·
21▶ const PATH: &[Symbol] = &[sym::rustc_main];
22 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
23 const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcMain;
· · ·
23▶ const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcMain;
24}
25
· · ·
29 const PATH: &[Symbol] = &[sym::rustc_must_implement_one_of];
30 const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Trait)]);
31▶ const TEMPLATE: AttributeTemplate = template!(List: &["function1, function2, ..."]);
32 fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option<AttributeKind> {
33 let list = cx.expect_list(args, cx.attr_span)?;
+ 1 more matches in this file
191 Single<MustUseParser>,
192 Single<OptimizeParser>,
193▶ Single<PatchableFunctionEntryParser>,
194 Single<PathAttributeParser>,
195 Single<PatternComplexityLimitParser>,
· · ·
196 Single<ProcMacroDeriveParser>,
197 Single<RecursionLimitParser>,
198▶ Single<ReexportTestHarnessMainParser>,
199 Single<RustcAbiParser>,
200 Single<RustcAllocatorZeroedVariantParser>,
· · ·
247 Single<WithoutArgs<NoImplicitPreludeParser>>,
248 Single<WithoutArgs<NoLinkParser>>,
249▶ Single<WithoutArgs<NoMainParser>>,
250 Single<WithoutArgs<NoMangleParser>>,
251 Single<WithoutArgs<NoStdParser>>,
· · ·
294 Single<WithoutArgs<RustcLintQueryInstabilityParser>>,
295 Single<WithoutArgs<RustcLintUntrackedQueryInformationParser>>,
296▶ Single<WithoutArgs<RustcMainParser>>,
297 Single<WithoutArgs<RustcNeverReturnsNullPtrParser>>,
298 Single<WithoutArgs<RustcNoImplicitAutorefsParser>>,
· · ·
485 ///
486 /// This is a higher-level (and harder to misuse) wrapper over [`ArgParser::as_list`] that
487▶ /// allows using `?` when the attribute parsing function allows it. You may still want to use
488 /// [`ArgParser::as_list`] for the following reasons:
489 ///
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// tidy-alphabetical-start
9use rustc_mir_dataflow::fmt::DebugWithContext;
10use rustc_mir_dataflow::impls::{
11▶ EverInitializedPlaces, EverInitializedPlacesDomain, MaybeUninitializedPlaces,
12 MaybeUninitializedPlacesDomain,
13};
· · ·
12▶ MaybeUninitializedPlacesDomain,
13};
14use rustc_mir_dataflow::{Analysis, GenKill, JoinSemiLattice};
· · ·
27
28impl<'a, 'tcx> Analysis<'tcx> for Borrowck<'a, 'tcx> {
29▶ type Domain = BorrowckDomain;
30
31 const NAME: &'static str = "borrowck";
· · ·
32
33▶ fn bottom_value(&self, body: &mir::Body<'tcx>) -> Self::Domain {
34 BorrowckDomain {
35 borrows: self.borrows.bottom_value(body),
· · ·
34▶ BorrowckDomain {
35 borrows: self.borrows.bottom_value(body),
36 uninits: self.uninits.bottom_value(body),
+ 26 more matches in this file
462 && let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
463 {
464▶ // The move occurred as one of the arguments to a function call. Is that
465 // argument generic? `def_id` can't be a closure here, so using `fn_sig` is fine
466 let arg_param = if self.infcx.tcx.def_kind(def_id).is_fn_like()
· · ·
476
477 // If the moved value is a mut reference, it is used in a
478▶ // generic function and it's type is a generic param, it can be
479 // reborrowed to avoid moving.
480 // for example:
· · ·
512 && let Some(arg) = fn_decl.inputs.get(pos + offset)
513 {
514▶ // If we can't suggest borrowing in the call, but the function definition
515 // is local, instead offer changing the function to borrow that argument.
516 let mut span: MultiSpan = arg.span.into();
· · ·
515▶ // is local, instead offer changing the function to borrow that argument.
516 let mut span: MultiSpan = arg.span.into();
517 span.push_span_label(
· · ·
520 );
521 let descr = match node.fn_kind() {
522▶ Some(hir::intravisit::FnKind::ItemFn(..)) | None => "function",
523 Some(hir::intravisit::FnKind::Method(..)) => "method",
524 Some(hir::intravisit::FnKind::Closure) => "closure",
+ 39 more matches in this 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> },
· · ·
359 // LL | let mut var = None;
360 // | ------- captured outer variable
361▶ // LL | func(|| {
362 // | -- captured by this `FnMut` closure
363 // LL | // Shouldn't suggest `move ||.as_ref()` here
54use crate::borrow_set::{BorrowData, BorrowSet};
55use crate::consumers::{BodyWithBorrowckFacts, RustcFacts};
56▶use crate::dataflow::{BorrowIndex, Borrowck, BorrowckDomain, Borrows};
57use crate::diagnostics::{
58 AccessKind, BorrowckDiagnosticsBuffer, IllegalMoveOriginKind, MoveError, RegionName,
· · ·
153/// appear in the closure's signature or on its field types. These
154/// requirements are then verified and proved by the closure's
155▶/// creating function. This struct encodes those requirements.
156///
157/// The requirements are listed as being between various `RegionVid`. The 0th
· · ·
458 let diags_buffer = &mut BorrowckDiagnosticsBuffer::default();
459 // While promoteds should mostly be correct by construction, we need to check them for
460▶ // invalid moves to detect moving out of arrays:`struct S; fn main() { &([S][0]); }`.
461 for promoted_body in &promoted {
462 use rustc_middle::mir::visit::Visitor;
· · ·
558 .cloned()
559 .collect();
560▶ // For the remaining unused locals that are marked as mutable, we avoid linting any that
561 // were never initialized. These locals may have been removed as unreachable code; or will be
562 // linted as unused variables.
· · ·
631 let entry_states: EntryStates<_> =
632 itertools::izip!(borrows.entry_states, uninits.entry_states, ever_inits.entry_states)
633▶ .map(|(borrows, uninits, ever_inits)| BorrowckDomain { borrows, uninits, ever_inits })
634 .collect();
635
+ 29 more matches in this 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>,
· · ·
300 }
301
302▶ // When the enclosing function is tagged with `#[rustc_regions]`,
303 // we dump out various bits of state as warnings. This is useful
304 // for verifying that the compiler is behaving as expected. These
117
118 /// Information about how the universally quantified regions in
119▶ /// scope on this function relate to one another.
120 universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
121}
· · ·
348 /// Initializes the region variables for each universally
349 /// quantified region (lifetime parameter). The first N variables
350▶ /// always correspond to the regions appearing in the function
351 /// signature (both named and anonymous) and where-clauses. This
352 /// function iterates over those regions and initializes them with
· · ·
352▶ /// function iterates over those regions and initializes them with
353 /// minimum values.
354 ///
· · ·
1199 assert!(self.max_nameable_universe(longer_fr_scc).is_root());
1200
1201▶ // Only check all of the relations for the main representative of each
1202 // SCC, otherwise just check that we outlive said representative. This
1203 // reduces the number of redundant relations propagated out of
91/// See the corresponding [rustc-dev-guide chapter] for more details. This
92/// ignores changes to the region values due to member constraints. Applying
93▶/// member constraints does not impact the result of this function.
94///
95/// [rustc-dev-guide chapter]: https://rustc-dev-guide.rust-lang.org/borrow_check/opaque-types-region-inference-restrictions.html
· · ·
191
192/// This computes the actual hidden types of the opaque types and maps them to their
193▶/// definition sites. Outside of registering the computed hidden types this function
194/// does not mutate the current borrowck state.
195///
· · ·
199/// defining scope.
200///
201▶/// It also means that this whole function is not really soundness critical as we
202/// recheck all uses of the opaques regardless.
203pub(crate) fn compute_definition_site_hidden_types<'tcx>(
· · ·
215 // We don't mutate the region graph used by `fn compute_regions` but instead
216 // manually track region information via a `RegionCtxt`. We discard this
217▶ // information at the end of this function.
218 let mut rcx = RegionCtxt::new(infcx, universal_region_relations, location_map, constraints);
219
· · ·
521}
522
523▶/// This function is what actually applies member constraints to the borrowck
524/// state. It is also responsible to check all uses of the opaques in their
525/// defining scope.
+ 3 more matches in this file