about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/decoder
AgeCommit message (Collapse)AuthorLines
2023-01-19Encode whether foreign opaques are TAITs or notMichael Goulet-0/+1
2023-01-19Use UnordMap instead of FxHashMap in define_id_collections!().Michael Woerister-3/+4
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-1/+1
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-12-28better names and a commentMichael Goulet-1/+1
2022-12-09Move the untracked cstore and source_span into a structOli Scherer-0/+3
2022-11-22rustc_metadata: Switch module children decoding to an iteratorVadim Petrochenkov-12/+7
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-2/+2
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-0/+6
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-23Rollup merge of #103192 - petrochenkov:noalltraits, r=jyn514Dylan DPC-5/+0
rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits` Another step to https://github.com/rust-lang/rust/pull/94857.
2022-10-22Auto merge of #103196 - Nilstrieb:no-meta-query, r=cjgillotbors-11/+0
Get rid of native_library projection queries They don't seem particularly useful as I don't expect native libraries to change frequently. Maybe they do provide significant value of keeping incremental compilation green though, I'm not sure.
2022-10-21Introduce deduced parameter attributes, and use them for deducing `readonly` onPatrick Walton-0/+1
indirect immutable freeze by-value function parameters. Right now, `rustc` only examines function signatures and the platform ABI when determining the LLVM attributes to apply to parameters. This results in missed optimizations, because there are some attributes that can be determined via analysis of the MIR making up the function body. In particular, `readonly` could be applied to most indirectly-passed by-value function arguments (specifically, those that are freeze and are observed not to be mutated), but it currently is not. This patch introduces the machinery that allows `rustc` to determine those attributes. It consists of a query, `deduced_param_attrs`, that, when evaluated, analyzes the MIR of the function to determine supplementary attributes. The results of this query for each function are written into the crate metadata so that the deduced parameter attributes can be applied to cross-crate functions. In this patch, we simply check the parameter for mutations to determine whether the `readonly` attribute should be applied to parameters that are indirect immutable freeze by-value. More attributes could conceivably be deduced in the future: `nocapture` and `noalias` come to mind. Adding `readonly` to indirect function parameters where applicable enables some potential optimizations in LLVM that are discussed in [issue 103103] and [PR 103070] around avoiding stack-to-stack memory copies that appear in functions like `core::fmt::Write::write_fmt` and `core::panicking::assert_failed`. These functions pass a large structure unchanged by value to a subfunction that also doesn't mutate it. Since the structure in this case is passed as an indirect parameter, it's a pointer from LLVM's perspective. As a result, the intermediate copy of the structure that our codegen emits could be optimized away by LLVM's MemCpyOptimizer if it knew that the pointer is `readonly nocapture noalias` in both the caller and callee. We already pass `nocapture noalias`, but we're missing `readonly`, as we can't determine whether a by-value parameter is mutated by examining the signature in Rust. I didn't have much success with having LLVM infer the `readonly` attribute, even with fat LTO; it seems that deducing it at the MIR level is necessary. No large benefits should be expected from this optimization *now*; LLVM needs some changes (discussed in [PR 103070]) to more aggressively use the `noalias nocapture readonly` combination in its alias analysis. I have some LLVM patches for these optimizations and have had them looked over. With all the patches applied locally, I enabled LLVM to remove all the `memcpy`s from the following code: ```rust fn main() { println!("Hello {}", 3); } ``` which is a significant codegen improvement over the status quo. I expect that if this optimization kicks in in multiple places even for such a simple program, then it will apply to Rust code all over the place. [issue 103103]: https://github.com/rust-lang/rust/issues/103103 [PR 103070]: https://github.com/rust-lang/rust/pull/103070
2022-10-19Get rid of native_library projection queriesnils-11/+0
They don't seem particularly useful as I don't expect native libraries to change frequently.
2022-10-19rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`Vadim Petrochenkov-5/+0
2022-10-07Rewrite representabilityCameron Steffen-0/+1
2022-09-23Serialize RPITIT values in libsMichael Goulet-0/+9
2022-09-07rustc: Parameterize `ty::Visibility` over used IDVadim Petrochenkov-3/+3
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-08-30Remove fn_has_self_parameter table.Camille GILLOT-3/+3
2022-08-29Rollup merge of #99821 - cjgillot:ast-lifetimes-2, r=compiler-errorsDylan DPC-0/+1
Remove separate indexing of early-bound regions ~Based on https://github.com/rust-lang/rust/pull/99728.~ This PR copies some modifications from https://github.com/rust-lang/rust/pull/97839 around object lifetime defaults. These modifications allow to stop counting generic parameters during lifetime resolution, and rely on the indexing given by `rustc_typeck::collect`.
2022-08-26Implementation of import_name_typeDaniel Paoliello-2/+2
2022-08-23get rid of another unnecessary lifetime macro argumentJoshua Nelson-12/+12
2022-08-19Auto merge of #100209 - cjgillot:source-file-index, r=estebankbors-1/+4
Lazily decode SourceFile from metadata Currently, source files from foreign crates are decoded up-front from metadata. Spans from those crates were matched with the corresponding source using binary search among those files. This PR changes the strategy by matching spans to files during encoding. This allows to decode source files on-demand, instead of up-front. The on-disk format for spans becomes: `<tag> <position from start of file> <length> <file index> <crate (if foreign file)>`.
2022-08-09Rollup merge of #96478 - WaffleLapkin:rustc_default_body_unstable, r=Aaron1011Dylan DPC-0/+1
Implement `#[rustc_default_body_unstable]` This PR implements a new stability attribute — `#[rustc_default_body_unstable]`. `#[rustc_default_body_unstable]` controls the stability of default bodies in traits. For example: ```rust pub trait Trait { #[rustc_default_body_unstable(feature = "feat", isssue = "none")] fn item() {} } ``` In order to implement `Trait` user needs to either - implement `item` (even though it has a default implementation) - enable `#![feature(feat)]` This is useful in conjunction with [`#[rustc_must_implement_one_of]`](https://github.com/rust-lang/rust/pull/92164), we may want to relax requirements for a trait, for example allowing implementing either of `PartialEq::{eq, ne}`, but do so in a safe way — making implementation of only `PartialEq::ne` unstable. r? `@Aaron1011` cc `@nrc` (iirc you were interested in this wrt `read_buf`), `@danielhenrymantilla` (you were interested in the related `#[rustc_must_implement_one_of]`) P.S. This is my first time working with stability attributes, so I'm not sure if I did everything right 😅
2022-08-06Decode SourceFile out of order.Camille GILLOT-1/+4
2022-08-03Compute `object_lifetime_default` per parameter.Camille GILLOT-0/+1
2022-08-01Remove trait_of_item query.Camille GILLOT-1/+0
2022-07-26Implement `#[rustc_default_body_unstable]`Maybe Waffle-0/+1
This attribute allows to mark default body of a trait function as unstable. This means that implementing the trait without implementing the function will require enabling unstable feature. This is useful in conjunction with `#[rustc_must_implement_one_of]`, we may want to relax requirements for a trait, for example allowing implementing either of `PartialEq::{eq, ne}`, but do so in a safe way -- making implementation of only `PartialEq::ne` unstable.
2022-07-24Do not prefer module parents which are `doc(hidden)` in visibility mapMichael Goulet-5/+15
2022-07-20passes: improved partial stabilization diagnosticDavid Wood-0/+3
Improves the diagnostic when a feature attribute is specified unnecessarily but the feature implies another (i.e. it was partially stabilized) to refer to the implied feature. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-02Auto merge of #97235 - nbdd0121:unwind, r=Amanieubors-1/+1
Fix FFI-unwind unsoundness with mixed panic mode UB maybe introduced when an FFI exception happens in a `C-unwind` foreign function and it propagates through a crate compiled with `-C panic=unwind` into a crate compiled with `-C panic=abort` (#96926). To prevent this unsoundness from happening, we will disallow a crate compiled with `-C panic=unwind` to be linked into `panic-abort` *if* it contains a call to `C-unwind` foreign function or function pointer. If no such call exists, then we continue to allow such mixed panic mode linking because it's sound (and stable). In fact we still need the ability to do mixed panic mode linking for std, because we only compile std once with `-C panic=unwind` and link it regardless panic strategy. For libraries that wish to remain compile-once-and-linkable-to-both-panic-runtimes, a `ffi_unwind_calls` lint is added (gated under `c_unwind` feature gate) to flag any FFI unwind calls that will cause the linkable panic runtime be restricted. In summary: ```rust #![warn(ffi_unwind_calls)] mod foo { #[no_mangle] pub extern "C-unwind" fn foo() {} } extern "C-unwind" { fn foo(); } fn main() { // Call to Rust function is fine regardless ABI. foo::foo(); // Call to foreign function, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. unsafe { foo(); } //~^ WARNING call to foreign function with FFI-unwind ABI let ptr: extern "C-unwind" fn() = foo::foo; // Call to function pointer, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. ptr(); //~^ WARNING call to function pointer with FFI-unwind ABI } ``` Fix #96926 `@rustbot` label: T-compiler F-c_unwind
2022-06-15Rename `impl_constness` to `constness`Deadbeef-1/+1
The current code is a basis for `is_const_fn_raw`, and `impl_constness` is no longer a valid name, which is previously used for determining the constness of impls, and not items in general.
2022-06-08Rename `panic_strategy` query to `required_panic_strategy`Gary Guo-1/+1
2022-05-23Fix iterator implementation, add some inlinesMichael Goulet-0/+6
2022-05-23split out the various responsibilities of LazyMichael Goulet-11/+72
2022-05-16Add a query for checking whether a function is an intrinsic.Oli Scherer-0/+1
2022-05-09store `codegen_fn_attrs` in crate metadatalcnr-0/+1
2022-05-03Add support for a new attribute `#[debugger_visualizer]` to support ↵ridwanabdillahi-0/+1
embedding debugger visualizers into a generated PDB. Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries. Merge the queries for debugger visualizers into a single query. Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`. Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate. Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature. Respond to PR comments and minor cleanups.
2022-04-25Auto merge of #95604 - nbdd0121:used2, r=petrochenkovbors-2/+2
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix #50007 and #47384 This is the synthetic object file approach that I described in https://github.com/rust-lang/rust/pull/95363#issuecomment-1079932354, allowing all exported and used symbols to be linked while still allowing them to be GCed. Related #93791, #95363 r? `@petrochenkov` cc `@carbotaniuman`
2022-04-21[WIP] rustdoc: Resolve some more doc links earlyVadim Petrochenkov-0/+8
2022-04-19rustc_metadata: Store a flag telling whether an item may have doc links in ↵Vadim Petrochenkov-0/+4
its attributes This should be cheap on rustc side, but it's significant optimization for rustdoc that won't need to decode and process attributes unnecessarily
2022-04-19Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkovDylan DPC-2/+2
Stop using CRATE_DEF_INDEX outside of metadata encoding. `CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want. We should not manipulate raw `DefIndex` outside of metadata encoding.
2022-04-18Add `SymbolExportInfo`Gary Guo-2/+2
This is currently a wrapper to `SymbolExportLevel` but it allows later addition of extra information.
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-2/+2
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-16Provide a better diagnostic on failure to meet send bound on futures in a ↵oribenshir-0/+1
foreign crate Adding diagnostic data on generators to the crate metadata and using it to provide a better diagnostic on failure to meet send bound on futures originated from a foreign crate
2022-04-07rustdoc: Early doc link resolution fixes and refactoringsVadim Petrochenkov-1/+3
2022-03-31Merge impl_constness and is_const_fn_raw.Camille GILLOT-1/+0
2022-03-31Create trait_def table.Camille GILLOT-1/+1
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-1/+0
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30fix rustdoc wrt builtin impls switchlcnr-4/+7
2022-03-30rework implementation for inherent impls for builtin typeslcnr-8/+20
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-1/+0
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.