summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/creader.rs
AgeCommit message (Collapse)AuthorLines
2022-09-03Rollup merge of #100928 - CleanCut:rustc_metadata_diagnostics, r=davidtwcoDylan DPC-34/+19
Migrate rustc_metadata to SessionDiagnostics Migrate rustc_metadata to SessionDiagnostics. Part of https://github.com/rust-lang/rust/issues/100717
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-2/+1
by module
2022-08-31respond to review feedback: mainly eliminate as many conversions as possible...Nathan Stocks-11/+8
- ... when creating diagnostics in rustc_metadata - use the error_code! macro - pass macro output to diag.code() - use fluent from within manual implementation of SessionDiagnostic - emit the untested errors in case they occur in the wild - stop panicking in the probably-not-dead code, add fixme to write test
2022-08-31port creader.rs to SessionDiagnosticsNathan Stocks-34/+22
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-5/+5
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
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-20Fix panic by checking if `CStore` has the crate data we want before actually ↵Guillaume Gomez-0/+4
querying it
2022-06-08Rename `panic_strategy` query to `required_panic_strategy`Gary Guo-1/+1
2022-06-08Fix FFI-unwind unsoundness with mixed panic modeGary Guo-1/+1
2022-05-24Make Lazy not care about lifetimes until decodeMichael Goulet-3/+3
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-8/+8
2022-04-27Add --json unused-externs-silent with original behaviourJeremy Fitzhardinge-3/+9
Since Cargo wants to do its own fatal error handling for unused dependencies, add the option `--json unused-externs-silent` which has the original behaviour of not indicating non-zero exit status for `deny`/`forbid`-level unused dependencies.
2022-04-27Plumb through rustc_lint_defs::Level as enum rather than string.Jeremy Fitzhardinge-4/+1
2022-04-23Add support for `nounused` --extern flagJeremy Fitzhardinge-0/+4
This adds `nounused` to the set of extern flags: `--extern nounused:core=/path/to/core/libcore.rlib`. The effect of this flag is to suppress `unused-crate-dependencies` warnings relating to the crate.
2022-04-19Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwcoDylan DPC-18/+2
Remove `--extern-location` and all associated code `--extern-location` was an experiment to investigate the best way to generate useful diagnostics for unused dependency warnings by enabling a build system to identify the corresponding build config. While I did successfully use this, I've since been convinced the alternative `--json unused-externs` mechanism is the way to go, and there's no point in having two mechanisms with basically the same functionality. This effectively reverts https://github.com/rust-lang/rust/pull/72603
2022-04-15Remove `--extern-location` and all associated codeJeremy Fitzhardinge-18/+2
`--extern-location` was an experiment to investigate the best way to generate useful diagnostics for unused dependency warnings by enabling a build system to identify the corresponding build config. While I did successfully use this, I've since been convinced the alternative `--json unused-externs` mechanism is the way to go, and there's no point in having two mechanisms with basically the same functionality. This effectively reverts https://github.com/rust-lang/rust/pull/72603
2022-04-14library: Move `CStr` to libcore, and `CString` to liballocVadim Petrochenkov-0/+1
2022-03-16rustc_error: make ErrorReported impossible to constructmark-3/+5
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-03Associate multiple with a crate too.Felix S. Klock II-1/+1
2022-02-19Adopt let else in more placesest31-6/+4
2021-12-21rustc_metadata: Switch crate data iteration from a callback to iteratorVadim Petrochenkov-94/+67
The iteration looks more conventional this way, and some allocations are avoided.
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-3/+3
2021-12-06replace dynamic library module with libloadingAndy Russell-14/+7
2021-12-01Improve suggestion for extern crate self error messageMichael-20/+10
2021-12-01Stop treating extern crate loading failures as fatal errorsMichael-12/+26
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-0/+1
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-2/+2
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-03Move rustc_middle::middle::cstore to rustc_session.Camille GILLOT-2/+2
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-1/+1
2021-09-14Store DefPathHash->DefIndex map in on-disk-hash-table format in crate metadata.Michael Woerister-1/+1
This encoding allows for random access without an expensive upfront decoding state which in turn allows simplifying the DefPathIndex lookup logic without regressing performance.
2021-09-02Remove unused argument from resolve_cratebjorn3-9/+6
2021-09-02Remove root field from CrateLocatorbjorn3-2/+1
2021-09-02Remove host_hash from CrateLocatorbjorn3-3/+3
2021-09-02Refactor CrateLocator.is_proc_macrobjorn3-4/+3
This also fixes a (theoretical) bug where a proc-macro may be loaded as plugin if it exports a symbol with the right name.
2021-08-04Add back -Zno-profiler-runtimeAmanieu d'Antras-6/+4
This was removed by #85284 in favor of -Zprofiler-runtime=<name>. However the suggested -Zprofiler-runtime=None doesn't work because "None" is treated as a crate name.
2021-07-18Move OnDiskCache to rustc_query_impl.Camille GILLOT-1/+4
2021-07-15Auto merge of #86876 - jyn514:56935-target-crate-num, r=petrochenkovbors-1/+5
Reuse CrateNum for proc-macro crates even when cross-compiling Proc-macros are always compiled for the host, so this should be the same in every way as recompiling the crate. I am not sure why the previous code special-cased the target, since the compiler properly gives an error when trying to load a crate for a different host: ``` error[E0461]: couldn't find crate `dependency` with expected target triple x86_64-unknown-linux-gnu --> /home/joshua/rustc4/src/test/ui/cfg-dependent.rs:8:2 | LL | dependency::is_64(); | ^^^^^^^^^^ | = note: the following crate versions were found: crate `dependency`, target triple i686-unknown-linux-gnu: /home/joshua/rustc4/build/x86_64-unknown-linux-gnu/test/ui/cfg-dependent/auxiliary/libdependency.so ``` I think another possible fix is to remove the check altogether. But I'm not sure, and this fix works, so I'm not making the larger change here. Fixes https://github.com/rust-lang/rust/issues/56935. r? `@petrochenkov` cc `@alexcrichton`
2021-07-14Reuse CrateNum for proc-macro crates even when cross-compilingJoshua Nelson-1/+5
Proc-macros are always compiled for the host, so this should be the same in every way as recompiling the crate. I am not sure why the previous code special-cased the target, since the compiler properly gives an error when trying to load a crate for a different host: ``` error[E0461]: couldn't find crate `dependency` with expected target triple x86_64-unknown-linux-gnu --> /home/joshua/rustc4/src/test/ui/cfg-dependent.rs:8:2 | LL | dependency::is_64(); | ^^^^^^^^^^ | = note: the following crate versions were found: crate `dependency`, target triple i686-unknown-linux-gnu: /home/joshua/rustc4/build/x86_64-unknown-linux-gnu/test/ui/cfg-dependent/auxiliary/libdependency.so ``` I think another possible fix is to remove the check altogether. But I'm not sure, and this fix works, so I'm not making the larger change here.
2021-07-14Shrink the CrateStore dynamic interface.Camille GILLOT-1/+1
2021-07-06Make resolutions a query.Camille GILLOT-0/+6
2021-07-06Revert "Revert "Merge CrateDisambiguator into StableCrateId""bjorn3-12/+7
This reverts commit 8176ab8bc18fdd7d3c2cf7f720c51166364c33a3.
2021-06-18Auto merge of #85284 - eggyal:custom-profiler-runtime, r=jackh726bors-18/+22
Provide option for specifying the profiler runtime Currently, if `-Zinstrument-coverage` is enabled, the target is linked against the `library/profiler_builtins` crate (which pulls in LLVM's compiler-rt runtime). This option enables backends to specify an alternative runtime crate for handling injected instrumentation calls.
2021-06-17Early return from `inject_profiler_runtime`Alan Egerton-23/+23
2021-06-08Store boxed metadata loader in CrateLoaderbjorn3-3/+3
2021-06-07Revert "Merge CrateDisambiguator into StableCrateId"bjorn3-7/+12
This reverts commit d0ec85d3fb6d322496cb8f4bc1c21e19f23284ad.
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-6/+0
2021-05-30Make resolutions a query.Camille GILLOT-0/+6
2021-05-30Merge CrateDisambiguator into StableCrateIdbjorn3-12/+7
2021-05-17Provide option for specifying the profiler runtimeAlan Egerton-17/+21
Currently, if `-Zinstrument-coverage` is enabled, the target is linked against the `library/profiler_builtins` crate (which pulls in LLVM's compiler-rt runtime). This option enables backends to specify an alternative runtime crate for handling injected instrumentation calls.
2021-04-25Give a better error when std or core are missingJoshua Nelson-2/+5
- Suggest using `rustup target add` if `RUSTUP_HOME` is set. I don't know if there's any precedent for doing this, but it seems harmless enough and it will be a big help. - Add a note about `#![no_std]` if `std` is missing but not core - On nightly, suggest using `cargo build -Z build-std` if `CARGO` is set - Add a note that std may be unsupported if `std` is missing but not core - Don't suggest `#![no_std]` when the load isn't injected by the compiler