summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta/decoder.rs
AgeCommit message (Collapse)AuthorLines
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-4/+4
2022-11-26Auto merge of #104730 - petrochenkov:modchild5, r=cjgillotbors-61/+38
rustc_metadata: Switch module children decoding to an iterator Previously https://github.com/rust-lang/rust/pull/103578, https://github.com/rust-lang/rust/pull/103524 and previous PRs simplified it as much as possible. A couple of cleanup commits is also added. r? `@cjgillot`
2022-11-25Add empty ConstKind::Abstractkadmin-6/+0
Initial pass at expr/abstract const/s Address comments Switch to using a list instead of &[ty::Const], rm `AbstractConst` Remove try_unify_abstract_consts Update comments Add edits Recurse more More edits Prevent equating associated consts Move failing test to ui Changes this test from incremental to ui, and mark it as failing and a known bug. Does not cause the compiler to ICE, so should be ok.
2022-11-22rustc_metadata: Cleanup to `get_module_children`Vadim Petrochenkov-49/+26
to unify proc-macro and non-proc-macro cases in particular.
2022-11-22rustc_metadata: Switch module children decoding to an iteratorVadim Petrochenkov-47/+47
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-30/+6
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-0/+4
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-29Encode LangItem directlyCameron Steffen-3/+2
2022-10-25rustc_metadata: Add constructors to module children at encoding timeVadim Petrochenkov-44/+35
instead of decoding time.
2022-09-14make `mk_attr_id` part of `ParseSess`SparrowLii-0/+7
2022-09-07rustc: Parameterize `ty::Visibility` over used IDVadim Petrochenkov-3/+12
It allows using `LocalDefId` instead of `DefId` when possible, and also encode cheaper `Visibility<DefIndex>` into metadata.
2022-09-01Auto merge of #98960 - cjgillot:entry-kind, r=estebankbors-68/+50
Remove EntryKind from metadata. This PR continues the refactor of metadata emission to be more systematic, iterating on definitions and filtering based on each definition's `DefKind`. This allows to remove the large `EntryKind` enum, replaced by linear tables in metadata.
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-08-30Remove fn_has_self_parameter table.Camille GILLOT-5/+12
2022-08-30Separate macro_rules and macro_definition.Camille GILLOT-8/+5
2022-08-30Remove EntryKind.Camille GILLOT-35/+21
2022-08-30Create a module-reexports table.Camille GILLOT-11/+5
2022-08-30Create a table for fn_has_self_parameter.Camille GILLOT-8/+6
2022-08-30Use tables for macros.Camille GILLOT-7/+11
2022-08-30Move AssocContainer to a metadata table.Camille GILLOT-6/+7
2022-08-30Move VariantData to a metadata table.Camille GILLOT-14/+9
2022-08-20rmeta/query cache: don't write string values of preinterned symbolsklensy-0/+4
2022-08-19Auto merge of #100209 - cjgillot:source-file-index, r=estebankbors-126/+102
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-15cache strings while encoding/decoding to compiler artifactsklensy-0/+29
2022-08-08Remove unused parameter.Camille GILLOT-1/+0
2022-08-07Only encode position from start of file.Camille GILLOT-10/+8
2022-08-06Support parallel compiler.Camille GILLOT-4/+3
2022-08-06Remove unused cache.Camille GILLOT-10/+0
2022-08-06Decode SourceFile out of order.Camille GILLOT-93/+94
2022-08-06Encode index of SourceFile along with span.Camille GILLOT-22/+11
2022-08-01Remove trait_of_item query.Camille GILLOT-13/+0
2022-08-01Remove DefId from AssocItemContainer.Camille GILLOT-9/+4
2022-08-01Remove visibility from AssocItem.Camille GILLOT-1/+0
2022-08-01Store associated item defaultness in impl_defaultness.Camille GILLOT-1/+0
2022-07-27Update mentions to `rustc_metadata::rmeta::Lazy`Yuki Okushi-1/+1
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-24remove new allocations from imported_source_filesPietro Albini-20/+20
2022-07-20passes: improved partial stabilization diagnosticDavid Wood-0/+7
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-14Rollup merge of #99000 - JulianKnodt:allow_resolve_no_substs, r=lcnrDylan DPC-2/+1
Move abstract const to middle Moves AbstractConst (and all associated methods) to rustc middle for use in `rustc_infer`. This allows for const resolution in infer to use abstract consts to walk consts and check if they are resolvable. This attempts to resolve the issue where `Foo<{ concrete const }, generic T>` is incorrectly marked as conflicting, and is independent from the other issue where nested abstract consts must be resolved. r? `@lcnr`
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-3/+3
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-12Move abstract const to rustc_middle::tykadmin-2/+1
2022-07-02Auto merge of #97235 - nbdd0121:unwind, r=Amanieubors-2/+2
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-29Rollup merge of #97786 - ferrocene:pa-fix-simulate-remap-prefix, ↵Dylan DPC-16/+22
r=Mark-Simulacrum Account for `-Z simulate-remapped-rust-src-base` when resolving remapped paths Discovered in #97682, `-Z simulate-remapped-rust-src-base` only partially simulated the behavior of `remap-debuginfo = true`. While the flag successfully simulates the remapping when stdlib's `rmeta` file is loaded, the simulated prefix was not accounted for when the remapped path's local path was being discovered. This caused the flag to not fully simulate the behavior of `remap-debuginfo = true`, leading to inconsistent behaviors. This PR fixes https://github.com/rust-lang/rust/issues/97682 by also accounting for the simulated path.
2022-06-14Rename rustc_serialize::opaque::Encoder as MemEncoder.Nicholas Nethercote-4/+5
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports). (This was previously merged as commit 5 in #94732 and then was reverted in #97905 because of a perf regression caused by commit 4 in #94732.)
2022-06-13account for simulated remap-debuginfo when resolving remapped pathsPietro Albini-16/+22
2022-06-11Auto merge of #95880 - cjgillot:def-ident-span, r=petrochenkovbors-11/+2
Handle `def_ident_span` like `def_span`. `def_ident_span` had an ad-hoc status in the compiler. This PR refactors it to be a first-class citizen like `def_span`: - it gets encoded in the main metadata loop, instead of the visitor; - its implementation is updated to mirror the one of `def_span`. We do not remove the `Option` in the return type, since some items do not have an ident, AnonConsts for instance.
2022-06-10Assert def_ident_span presence.Camille GILLOT-1/+2
2022-06-10Encode def_ident_span using the query.Camille GILLOT-11/+1
2022-06-08Rename `panic_strategy` query to `required_panic_strategy`Gary Guo-2/+2
2022-06-08Fix FFI-unwind unsoundness with mixed panic modeGary Guo-1/+1
2022-06-08Rename `rustc_serialize::opaque::Encoder` as `MemEncoder`.Nicholas Nethercote-4/+5
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports).