about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/decoder.rs
AgeCommit message (Collapse)AuthorLines
2025-07-28Clarify update_extern_crateKornel-2/+6
2025-07-01Auto merge of #143013 - bjorn3:split_exported_symbols, r=oli-obkbors-2/+9
Split exported_symbols for generic and non-generic symbols This reduces metadata decoder overhead during the monomorphization collector.
2025-06-30Introduce `ByteSymbol`.Nicholas Nethercote-23/+37
It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings. This change does slow down compilation of programs that use `include_bytes!` on large files, because the contents of those files are now interned (hashed). This makes `include_bytes!` more similar to `include_str!`, though `include_bytes!` contents still aren't escaped, and hashing is still much cheaper than escaping.
2025-06-27Split exported_symbols for generic and non-generic symbolsbjorn3-2/+9
This reduces metadata decoder overhead during the monomorphization collector.
2025-06-24Remove dependency injection for the panic runtimebjorn3-4/+0
This used to be necessary for a correct linker order, but ever since the introduction of symbols.o adding the symbols in question to symbols.o would work just as well. We do still add dependencies on the panic runtime to the local crate, but not for #![needs_panic_runtime] crates. This also removes the runtime-depends-on-needs-runtime test. inject_dependency_if used to emit this error, but with symbols.o it is no longer important that there is no dependency and in fact it may be nice to have panic_abort and panic_unwind directly depend on libstd in the future for calling std::process::abort().
2025-06-20Use gen blocks in the compiler instead of from_coroutineMichael Goulet-24/+20
2025-06-15Un-remap `rustc-dev` component pathsUrgau-0/+22
2025-06-14Prepare `rustc-dev` component un-remapping in the compilerUrgau-75/+101
2025-06-11Remove useless and wrong std crates special casing when un-remap sysrootUrgau-28/+1
2025-05-27Do not get proc_macro from the sysroot in rustcbjorn3-1/+1
With the stage0 refactor the proc_macro version found in the sysroot will no longer always match the proc_macro version that proc-macros get compiled with by the rustc executable that uses this proc_macro. This will cause problems as soon as the ABI of the bridge gets changed to implement new features or change the way existing features work. To fix this, this commit changes rustc crates to depend directly on the local version of proc_macro which will also be used in the sysroot that rustc will build.
2025-05-19Warning added when dependency crate has async drop types, and the feature is ↵Andrew Zhogin-0/+4
disabled
2025-05-04Initial support for dynamically linked cratesBryanskiy-0/+11
2025-04-15Move `name` field from `AssocItem` to `AssocKind` variants.Nicholas Nethercote-17/+13
To accurately reflect that RPITIT assoc items don't have a name. This avoids the use of `kw::Empty` to mean "no name", which is error prone. Helps with #137978.
2025-04-15Move `opt_rpitit_info` field to `hir::AssocKind::Type`.Nicholas Nethercote-4/+8
From `hir::AssocItem`.
2025-04-14Move `has_self` field to `hir::AssocKind::Fn`.Nicholas Nethercote-5/+6
`hir::AssocItem` currently has a boolean `fn_has_self_parameter` field, which is misplaced, because it's only relevant for associated fns, not for associated consts or types. This commit moves it (and renames it) to the `AssocKind::Fn` variant, where it belongs. This requires introducing a new C-style enum, `AssocTag`, which is like `AssocKind` but without the fields. This is because `AssocKind` values are passed to various functions like `find_by_ident_and_kind` to indicate what kind of associated item should be searched for, and having to specify `has_self` isn't relevant there. New methods: - Predicates `AssocItem::is_fn` and `AssocItem::is_method`. - `AssocItem::as_tag` which converts `AssocItem::kind` to `AssocTag`. Removed `find_by_name_and_kinds`, which is unused. `AssocItem::descr` can now distinguish between methods and associated functions, which slightly improves some error messages.
2025-04-11Rollup merge of #138682 - Alexendoo:extra-symbols, r=fee1-deadStuart Cook-2/+2
Allow drivers to supply a list of extra symbols to intern Allows adding new symbols as `const`s in external drivers, desirable in Clippy so we can use them in patterns to replace code like https://github.com/rust-lang/rust/blob/75530e9f72a1990ed2305e16fd51d02f47048f12/src/tools/clippy/clippy_lints/src/casts/cast_ptr_alignment.rs#L66 The Clippy change adds a couple symbols as a demo, the exact `clippy_utils` API and replacing other usages can be done on the Clippy side to minimise sync conflicts --- try-job: aarch64-gnu
2025-04-10Allow drivers to supply a list of extra symbols to internAlex Macleod-2/+2
2025-04-10Rename some `name` variables as `ident`.Nicholas Nethercote-1/+1
It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`. This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk.
2025-03-20Rollup merge of #138685 - ↵Matthias Krüger-1/+1
nnethercote:use-Option-Ident-for-lowered-param-names, r=compiler-errors Use `Option<Ident>` for lowered param names. Parameter patterns are lowered to an `Ident` by `lower_fn_params_to_names`, which is used when lowering bare function types, trait methods, and foreign functions. Currently, there are two exceptional cases where the lowered param can become an empty `Ident`. - If the incoming pattern is an empty `Ident`. This occurs if the parameter is anonymous, e.g. in a bare function type. - If the incoming pattern is neither an ident nor an underscore. Any such parameter will have triggered a compile error (hence the `span_delayed_bug`), but lowering still occurs. This commit replaces these empty `Ident` results with `None`, which eliminates a number of `kw::Empty` uses, and makes it impossible to fail to check for these exceptional cases. Note: the `FIXME` comment in `is_unwrap_or_empty_symbol` is removed. It actually should have been removed in #138482, the precursor to this PR. That PR changed the lowering of wild patterns to `_` symbols instead of empty symbols, which made the mentioned underscore check load-bearing. r? ``@compiler-errors``
2025-03-19Allow builtin macros to be used more than once.Mara Bos-3/+3
This removes E0773 "A builtin-macro was defined more than once."
2025-03-19Use `Option<Ident>` for lowered param names.Nicholas Nethercote-1/+1
Parameter patterns are lowered to an `Ident` by `lower_fn_params_to_names`, which is used when lowering bare function types, trait methods, and foreign functions. Currently, there are two exceptional cases where the lowered param can become an empty `Ident`. - If the incoming pattern is an empty `Ident`. This occurs if the parameter is anonymous, e.g. in a bare function type. - If the incoming pattern is neither an ident nor an underscore. Any such parameter will have triggered a compile error (hence the `span_delayed_bug`), but lowering still occurs. This commit replaces these empty `Ident` results with `None`, which eliminates a number of `kw::Empty` uses, and makes it impossible to fail to check for these exceptional cases. Note: the `FIXME` comment in `is_unwrap_or_empty_symbol` is removed. It actually should have been removed in #138482, the precursor to this PR. That PR changed the lowering of wild patterns to `_` symbols instead of empty symbols, which made the mentioned underscore check load-bearing.
2025-03-15Move codec module back into middleMichael Goulet-4/+2
2025-03-03Remove some unnecessary aliases from `rustc_data_structures::sync`Zalathar-2/+2
With the removal of `cfg(parallel_compiler)`, these are always shared references and `std::sync::OnceLock`.
2025-02-26Rollup merge of #137529 - klensy:unused3, r=lcnrLeón Orell Valerian Liehr-1/+0
remove few unused args
2025-02-25remove unused field from VariantDef::new and convert debug to instrumentklensy-1/+0
2025-02-24Introduce new-style attribute parsers for several attributesJana Dönszelmann-1/+0
note: compiler compiles but librustdoc and clippy don't
2025-02-23Rollup merge of #137334 - compiler-errors:edition-2024-fresh-2, ↵Jacob Pratt-15/+11
r=saethlin,traviscross Greatly simplify lifetime captures in edition 2024 Remove most of the `+ Captures` and `+ '_` from the compiler, since they are now unnecessary with the new edition 2021 lifetime capture rules. Use some `+ 'tcx` and `+ 'static` rather than being overly verbose with precise capturing syntax.
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-15/+11
2025-02-21Inject `compiler_builtins` during postprocessing rather than via ASTTrevor Gross-0/+4
`compiler_builtins` is currently injected as `extern crate compiler_builtins as _`. This has made gating via diagnostics difficult because it appears in the crate graph as a non-private dependency, and there isn't an easy way to differentiate between the injected AST and user-specified `extern crate compiler_builtins`. Resolve this by injecting `compiler_builtins` during postprocessing rather than early in the AST. Most of the time this isn't even needed because it shows up in `std` or `core`'s crate graph, but injection is still needed to ensure `#![no_core]` works correctly. A similar change was attempted at [1] but this encountered errors building `proc_macro` and `rustc-std-workspace-std`. Similar failures showed up while working on this patch, which were traced back to `compiler_builtins` showing up in the graph twice (once via dependency and once via injection). This is resolved by not injecting if a `#![compiler_builtins]` crate already exists. [1]: https://github.com/rust-lang/rust/pull/113634
2025-02-20Improve debugging for metadata structuresTrevor Gross-0/+4
I had to do a lot of debug by printing; having these `Debug` traits in place made it easier. Additionally, add some more information to existing `info!` statements.
2025-02-06Auto merge of #136471 - safinaskar:parallel, r=SparrowLiibors-4/+5
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` This is continuation of https://github.com/rust-lang/rust/pull/132282 . I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement. There are other possibilities, through. We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase. So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge. cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 ) r? SparrowLii `@rustbot` label WG-compiler-parallel
2025-02-03tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc`Askar Safin-4/+5
2025-02-02Target modifiers (special marked options) are recorded in metainfo and ↵Andrew Zhogin-0/+15
compared to be equal in different crates
2025-01-08update cfg(bootstrap)Pietro Albini-1/+1
2024-12-19Make DependencyList an IndexVecbjorn3-1/+1
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-3/+2
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-15Add hir::AttributeJonathan Dönszelmann-1/+1
2024-12-09Support x-crate default fieldsEsteban Küber-1/+5
2024-12-09Introduce `default_field_values` featureEsteban Küber-0/+1
Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681. Support default fields in enum struct variant Allow default values in an enum struct variant definition: ```rust pub enum Bar { Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Allow using `..` without a base on an enum struct variant ```rust Bar::Foo { .. } ``` `#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants. Support `#[derive(Default)]` on enum struct variants with all defaulted fields ```rust pub enum Bar { #[default] Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Check for missing fields in typeck instead of mir_build. Expand test with `const` param case (needs `generic_const_exprs` enabled). Properly instantiate MIR const The following works: ```rust struct S<A> { a: Vec<A> = Vec::new(), } S::<i32> { .. } ``` Add lint for default fields that will always fail const-eval We *allow* this to happen for API writers that might want to rely on users' getting a compile error when using the default field, different to the error that they would get when the field isn't default. We could change this to *always* error instead of being a lint, if we wanted. This will *not* catch errors for partially evaluated consts, like when the expression relies on a const parameter. Suggestions when encountering `Foo { .. }` without `#[feature(default_field_values)]`: - Suggest adding a base expression if there are missing fields. - Suggest enabling the feature if all the missing fields have optional values. - Suggest removing `..` if there are no missing fields.
2024-11-28Replace `Symbol::intern` calls with preinterned symbolsclubby789-0/+1
2024-11-21Implement the unsafe-fields RFC.Luca Versari-0/+6
Co-Authored-By: Jacob Pratt <jacob@jhpratt.dev>
2024-11-02Rename target triple to target tuple in many places in the compilerNoratrieb-1/+1
This changes the naming to the new naming, used by `--print target-tuple`. It does not change all locations, but many.
2024-10-30Remove dead code stemming from the old effects desugaringLeón Orell Valerian Liehr-4/+1
2024-10-11Auto merge of #131045 - compiler-errors:remove-unnamed_fields, r=wesleywiserbors-3/+0
Retire the `unnamed_fields` feature for now `#![feature(unnamed_fields)]` was implemented in part in #115131 and #115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature. However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly. Fixes #117942 Fixes #121161 Fixes #121263 Fixes #121299 Fixes #121722 Fixes #121799 Fixes #126969 Fixes #131041 Tracking: * https://github.com/rust-lang/rust/issues/49804 [^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields [^2]: https://github.com/rust-lang/rust/issues/49804#issuecomment-1972619108
2024-10-01add unstable support for outputting file checksums for use in cargoJacob Kiesel-0/+2
2024-10-01Remove unnamed field featureMichael Goulet-3/+0
2024-09-27Implement RFC3137 trim-paths sysroot changesUrgau-49/+56
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-3/+3
2024-08-31Rollup merge of #129723 - compiler-errors:extern-providers, r=lcnrMatthias Krüger-32/+0
Simplify some extern providers Simplifies some extern crate providers: 1. Generalize the `ProcessQueryValue` identity impl to work on non-`Option` types. 2. Allow `ProcessQueryValue` to wrap its output in an `EarlyBinder`, to simplify `explicit_item_bounds`/`explicit_item_super_predicates`. 3. Use `{ table }` and friends more when possible.
2024-08-29Simplify some extern providersMichael Goulet-32/+0