about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2021-06-05Auto merge of #84234 - jyn514:blanket-hash, r=Aaron1011bors-20/+22
Implement DepTrackingHash for `Option` through blanket impls instead of macros This avoids having to add a new macro call for both the `Option` and the type itself. Noticed this while working on https://github.com/rust-lang/rust/pull/84233. r? `@Aaron1011`
2021-06-04Auto merge of #85788 - rylev:force-warns, r=nikomatsakisbors-4/+27
Support for force-warns Implements https://github.com/rust-lang/rust/issues/85512. This PR adds a new command line option `force-warns` which will force the provided lints to warn even if they are allowed by some other mechanism such as `#![allow(warnings)]`. Some remaining issues: * https://github.com/rust-lang/rust/issues/85512 mentions that `force-warns` should also be capable of taking lint groups instead of individual lints. This is not implemented. * If a lint has a higher warning level than `warn`, this will cause that lint to warn instead. We probably want to allow the lint to error if it is set to a higher lint and is not allowed somewhere else. * One test is currently ignored because it's not working - when a deny-by-default lint is allowed, it does not currently warn under `force-warns`. I'm not sure why, but I wanted to get this in before the weekend. r? `@nikomatsakis`
2021-06-04Implement DepTrackingHash for `Option` through blanket impls instead of macrosJoshua Nelson-20/+22
This avoids having to add a new macro call for both the `Option` and the type itself.
2021-06-02Force warn on lint groups as wellRyan Levick-2/+11
2021-06-02Miscellaneous inlining improvementsTomasz Miąsko-0/+2
2021-06-01Rollup merge of #85473 - infinity0:master, r=jackh726Guillaume Gomez-1/+1
fix split-debuginfo error message
2021-05-31Auto merge of #85702 - Aaron1011:no-vec-sort, r=michaelwoeristerbors-26/+10
Don't sort a `Vec` before computing its `DepTrackingHash` Previously, we sorted the vec prior to hashing, making the hash independent of the original (command-line argument) order. However, the original vec was still always kept in the original order, so we were relying on the rest of the compiler always working with it in an 'order-independent' way. This assumption was not being upheld by the `native_libraries` query - the order of the entires in its result depends on the order of entries in `Options.libs`. This lead to an 'unstable fingerprint' ICE when the `-l` arguments were re-ordered. This PR removes the sorting logic entirely. Re-ordering command-line arguments (without adding/removing/changing any arguments) seems like a really niche use case, and correctly optimizing for it would require additional work. By always hashing arguments in their original order, we can entirely avoid a cause of 'unstable fingerprint' errors.
2021-05-30Auto merge of #85559 - 12101111:sanitizer-crt-static, r=nagisabors-0/+8
Diagnose use sanitizers with crt-static Fix: https://github.com/rust-lang/rust/issues/85459
2021-05-30Auto merge of #85362 - jsgf:fix-emit-metadata, r=estebankbors-0/+5
Use command line metadata path if provided If the command-line has `--emit metadata=some/path/libfoo.rmeta` then use that. Closes #85356 I couldn't find any existing tests for the `--emit TYPE=PATH` command line syntax, so I wasn't sure how to test this aside from ad-hoc manual testing. Is there a ui test type for "generated output file with expected name"?
2021-05-30Merge CrateDisambiguator into StableCrateIdbjorn3-13/+13
2021-05-28Use command line metadata path if providedJeremy Fitzhardinge-0/+5
If the command-line has `--emit metadata=some/path/libfoo.rmeta` then use that. Closes #85356
2021-05-28Initial support for force-warnsRyan Levick-3/+17
2021-05-29Diagnose use sanitizers with crt-static12101111-0/+8
2021-05-25Don't sort a `Vec` before computing its `DepTrackingHash`Aaron Hill-26/+10
Previously, we sorted the vec prior to hashing, making the hash independent of the original (command-line argument) order. However, the original vec was still always kept in the original order, so we were relying on the rest of the compiler always working with it in an 'order-independent' way. This assumption was not being upheld by the `native_libraries` query - the order of the entires in its result depends on the order of entries in `Options.libs`. This lead to an 'unstable fingerprint' ICE when the `-l` arguments were re-ordered. This PR removes the sorting logic entirely. Re-ordering command-line arguments (without adding/removing/changing any arguments) seems like a really niche use case, and correctly optimizing for it would require additional work. By always hashing arguments in their original order, we can entirely avoid a cause of 'unstable fingerprint' errors.
2021-05-25Rollup merge of #85361 - bjorn3:rustdoc_target_json_path_canonicalize, r=jyn514Guillaume Gomez-1/+4
Use TargetTriple::from_path in rustdoc This fixes the problem reported in https://github.com/Rust-for-Linux/linux/pull/272 where rustdoc requires the absolute path of a target spec json instead of accepting a relative path like rustc.
2021-05-24Use parse_target_triple in rustdocbjorn3-1/+4
2021-05-24remove cfg(bootstrap)Pietro Albini-1/+0
2021-05-19fix split-debuginfo error messageXimin Luo-1/+1
2021-05-17Provide option for specifying the profiler runtimeAlan Egerton-2/+2
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-05-13Auto merge of #83129 - LeSeulArtichaut:thir-unsafeck, r=nikomatsakisbors-0/+2
Introduce the beginning of a THIR unsafety checker This poses the foundations for the THIR unsafety checker, so that it can be implemented incrementally: - implements a rudimentary `Visitor` for the THIR (which will definitely need some tweaking in the future) - introduces a new `-Zthir-unsafeck` flag which tells the compiler to use THIR unsafeck instead of MIR unsafeck - implements detection of unsafe functions - adds revisions to the UI tests to test THIR unsafeck alongside MIR unsafeck This uses a very simple query design, where bodies are unsafety-checked on a body per body basis. This however has some big flaws: - the unsafety-checker builds the THIR itself, which means a lot of work is duplicated with MIR building constructing its own copy of the THIR - unsafety-checking closures is currently completely wrong: closures should take into account the "safety context" in which they are created, here we are considering that closures are always a safe context I had intended to fix these problems in follow-up PRs since they are always gated under the `-Zthir-unsafeck` flag (which is explicitely noted to be unsound). r? `@nikomatsakis` cc https://github.com/rust-lang/project-thir-unsafeck/issues/3 https://github.com/rust-lang/project-thir-unsafeck/issues/7
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-5/+12
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-12Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillotbors-1/+5
rustc_driver cleanup Best reviewed one commit at a time.
2021-05-12Implement span quoting for proc-macrosAaron Hill-0/+14
This PR implements span quoting, allowing proc-macros to produce spans pointing *into their own crate*. This is used by the unstable `proc_macro::quote!` macro, allowing us to get error messages like this: ``` error[E0412]: cannot find type `MissingType` in this scope --> $DIR/auxiliary/span-from-proc-macro.rs:37:20 | LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream { | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]` ... LL | field: MissingType | ^^^^^^^^^^^ not found in this scope | ::: $DIR/span-from-proc-macro.rs:8:1 | LL | #[error_from_attribute] | ----------------------- in this macro invocation ``` Here, `MissingType` occurs inside the implementation of the proc-macro `#[error_from_attribute]`. Previosuly, this would always result in a span pointing at `#[error_from_attribute]` This will make many proc-macro-related error message much more useful - when a proc-macro generates code containing an error, users will get an error message pointing directly at that code (within the macro definition), instead of always getting a span pointing at the macro invocation site. This is implemented as follows: * When a proc-macro crate is being *compiled*, it causes the `quote!` macro to get run. This saves all of the sapns in the input to `quote!` into the metadata of *the proc-macro-crate* (which we are currently compiling). The `quote!` macro then expands to a call to `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an opaque identifier for the span in the crate metadata. * When the same proc-macro crate is *run* (e.g. it is loaded from disk and invoked by some consumer crate), the call to `proc_macro::Span::recover_proc_macro_span` causes us to load the span from the proc-macro crate's metadata. The proc-macro then produces a `TokenStream` containing a `Span` pointing into the proc-macro crate itself. The recursive nature of 'quote!' can be difficult to understand at first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows the output of the `quote!` macro, which should make this eaier to understand. This PR also supports custom quoting spans in custom quote macros (e.g. the `quote` crate). All span quoting goes through the `proc_macro::quote_span` method, which can be called by a custom quote macro to perform span quoting. An example of this usage is provided in `src/test/ui/proc-macro/auxiliary/custom-quote.rs` Custom quoting currently has a few limitations: In order to quote a span, we need to generate a call to `proc_macro::Span::recover_proc_macro_span`. However, proc-macros support renaming the `proc_macro` crate, so we can't simply hardcode this path. Previously, the `quote_span` method used the path `crate::Span` - however, this only works when it is called by the builtin `quote!` macro in the same crate. To support being called from arbitrary crates, we need access to the name of the `proc_macro` crate to generate a path. This PR adds an additional argument to `quote_span` to specify the name of the `proc_macro` crate. Howver, this feels kind of hacky, and we may want to change this before stabilizing anything quote-related. Additionally, using `quote_span` currently requires enabling the `proc_macro_internals` feature. The builtin `quote!` macro has an `#[allow_internal_unstable]` attribute, but this won't work for custom quote implementations. This will likely require some additional tricks to apply `allow_internal_unstable` to the span of `proc_macro::Span::recover_proc_macro_span`.
2021-05-11Introduce the (WIP) THIR unsafety checkerLeSeulArtichaut-0/+2
2021-05-11Fix typo in variable nameLingMan-2/+2
All other sibling functions call this variable "slot", so "slote" was most likely a typo.
2021-05-10Rollup merge of #85152 - nagisa:target-search-rustlib, r=Mark-SimulacrumGuillaume Gomez-53/+15
Adjust target search algorithm for rustlib path With this the concerns expressed in #83800 should be addressed. r? `@Mark-Simulacrum`
2021-05-10Adjust target search algorithm for rustlib pathSimonas Kazlauskas-53/+15
With this the concerns expressed in #83800 should be addressed.
2021-05-10rustc_session: Use `Iterator::find` instead of manual searchVadim Petrochenkov-24/+19
2021-05-10rustc_session: Move more option building code from the `options!` macroVadim Petrochenkov-66/+87
2021-05-09Auto merge of #83800 - xobs:impl-16351-nightly, r=nagisabors-8/+14
Add default search path to `Target::search()` The function `Target::search()` accepts a target triple and returns a `Target` struct defining the requested target. There is a `// FIXME 16351: add a sane default search path?` comment that indicates it is desirable to include some sort of default. This was raised in https://github.com/rust-lang/rust/issues/16351 which was closed without any resolution. https://github.com/rust-lang/rust/pull/31117 was proposed, however that has platform-specific logic that is unsuitable for systems without `/etc/`. This patch implements the suggestion raised in https://github.com/rust-lang/rust/issues/16351#issuecomment-180878193 where a `target.json` file may be placed in `$(rustc --print sysroot)/lib/rustlib/<target-triple>/target.json`. This allows shipping a toolchain distribution as a single file that gets extracted to the sysroot.
2021-05-09Auto merge of #83894 - nikic:newpm, r=nagisabors-1/+1
Improve support for NewPM This adds various missing bits of support for NewPM and allows us to successfully run stage 2 tests with NewPM enabled. This does not yet enable NewPM by default, as there are still known issue on LLVM 12 (such as a weak fat LTO pipeline). The plan is to make the switch after we update to LLVM 13.
2021-05-08Remove unused `opt_span_warn` functionJoshua Nelson-6/+0
2021-05-08Make `Diagnostic::span_fatal` unconditionally raise an errorJoshua Nelson-3/+3
It had no callers which didn't immediately call `raise()`, and this unifies the behavior with `Session`.
2021-05-08Make -Z new-llvm-pass-manager an Option<bool>Nikita Popov-1/+1
To allow it to have an LLVM version dependent default.
2021-05-07Rollup merge of #84815 - richkadel:coverage-docs-update-2021-05, r=tmandryYuki Okushi-6/+6
Update coverage docs and command line help r? `@tmandry` cc: `@wesleywiser`
2021-05-06Update coverage docs and command line helpRich Kadel-6/+6
2021-05-05Implement RFC 2951: Native link modifiersLuqman Aden-47/+143
This commit implements both the native linking modifiers infrastructure as well as an initial attempt at the individual modifiers from the RFC. It also introduces a feature flag for the general syntax along with individual feature flags for each modifier.
2021-05-05Rollup merge of #84803 - jyn514:duplicate-macros, r=petrochenkovRalf Jung-57/+61
Reduce duplication in `impl_dep_tracking_hash` macros Cherry-picked from https://github.com/rust-lang/rust/pull/84234 since it will be a while until it lands.
2021-05-05Add -Z simulate-remapped-rust-src-base option to simulate path ↵Andy Wang-0/+3
virutalisation during bootstrapping
2021-05-05Use RealFileName for Session::working_dir as it may also be remappedAndy Wang-5/+9
2021-05-03Rollup merge of #84072 - nagisa:target-family-two-the-movie, r=petrochenkovDylan DPC-1/+1
Allow setting `target_family` to multiple values, and implement `target_family="wasm"` As per the conclusion in [this thread](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Are.20we.20comfortable.20with.20adding.20an.20insta-stable.20cfg.28wasm.29.3F/near/233158441), this implements an ability to specify any number of `target_family` values, allowing for more flexible generic groups, or "families", to be created than just the OS-based unix/windows dichotomy. cc https://github.com/rust-lang/reference/pull/1006
2021-05-02Remove dummy_configbjorn3-1/+5
2021-05-02Fix nit in rustc_session::optionsJoshua Nelson-1/+1
2021-05-01Reduce duplication in `impl_dep_tracking_hash` macrosJoshua Nelson-57/+61
2021-05-01Remove unused macro parametersJoshua Nelson-3/+3
2021-05-01Remove unused `parse_pathbuf_push` functionJoshua Nelson-12/+0
This also remove the `allow(dead_code)`.
2021-05-01Don't recompile the same functions for each debugging optionJoshua Nelson-412/+461
This reduces the amount of items in the crate by quite a lot.
2021-05-01Remove unused parse_opt_list functionJoshua Nelson-13/+0
2021-04-29Use doc-comment instad of comments consistentlyJoshua Nelson-58/+59
This makes the comments show up in the generated docs. - Fix markdown formatting
2021-04-27Make `real_rust_path_dir` a TRACKED_NO_CRATE_HASH optionJoshua Nelson-33/+45
This also adds support for doc-comments to Options.