Commit graph

394 commits

Author SHA1 Message Date
bjorn3
c9abc7e2bb Remove print_fuel_crate field of Session 2021-09-02 12:29:11 +02:00
bjorn3
5464b2e713 Remove optimization_fuel_crate from Session 2021-09-02 12:29:11 +02:00
Aaron Hill
672d370764
Remove Session.if_let_suggestions
We can instead if either the LHS or RHS types contain
`TyKind::Error`. In addition to covering the case where
we would have previously updated `if_let_suggestions`, this might
also prevent redundant errors in other cases as well.
2021-08-27 18:28:22 -05:00
Erik Desjardins
5e81d643d9 don't generate partially-undef consts 2021-08-25 17:49:28 -04:00
Léo Lanteri Thauvin
f2cbbb93a2
Rollup merge of #88218 - Aaron1011:missing-method-dyn, r=nagisa
Remove `Session.trait_methods_not_found`

Instead, avoid registering the problematic well-formed obligation
to begin with. This removes global untracked mutable state,
and avoids potential issues with incremental compilation.
2021-08-25 15:48:51 +02:00
inquisitivecrystal
aee2c30f69 Stabilize force-warn 2021-08-24 11:19:55 -04:00
inquisitivecrystal
d89b4a705c Tidy up lint command line flags 2021-08-24 11:19:55 -04:00
bors
f66e825f73 Auto merge of #87739 - Aaron1011:remove-used-attrs, r=wesleywiser
Remove `Session.used_attrs` and move logic to `CheckAttrVisitor`

Instead of updating global state to mark attributes as used,
we now explicitly emit a warning when an attribute is used in
an unsupported position. As a side effect, we are to emit more
detailed warning messages (instead of just a generic "unused" message).

`Session.check_name` is removed, since its only purpose was to mark
the attribute as used. All of the callers are modified to use
`Attribute.has_name`

Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed
used' attribute is implemented by simply not performing any checks
in `CheckAttrVisitor` for a particular attribute.

We no longer emit unused attribute warnings for the `#[rustc_dummy]`
attribute - it's an internal attribute used for tests, so it doesn't
mark sense to treat it as 'unused'.

With this commit, a large source of global untracked state is removed.
2021-08-24 03:58:22 +00:00
Léo Lanteri Thauvin
6a2b448f2a Do not mark -Z thir-unsafeck as unsound anymore 2021-08-23 14:52:42 +02:00
Aaron Hill
41f9f38d6e
Remove Session.trait_methods_not_found
Instead, avoid registering the problematic well-formed obligation
to begin with. This removes global untracked mutable state,
and avoids potential issues with incremental compilation.
2021-08-21 20:45:11 -05:00
Aaron Hill
af46699f81
Remove Session.used_attrs and move logic to CheckAttrVisitor
Instead of updating global state to mark attributes as used,
we now explicitly emit a warning when an attribute is used in
an unsupported position. As a side effect, we are to emit more
detailed warning messages (instead of just a generic "unused" message).

`Session.check_name` is removed, since its only purpose was to mark
the attribute as used. All of the callers are modified to use
`Attribute.has_name`

Additionally, `AttributeType::AssumedUsed` is removed - an 'assumed
used' attribute is implemented by simply not performing any checks
in `CheckAttrVisitor` for a particular attribute.

We no longer emit unused attribute warnings for the `#[rustc_dummy]`
attribute - it's an internal attribute used for tests, so it doesn't
mark sense to treat it as 'unused'.

With this commit, a large source of global untracked state is removed.
2021-08-21 13:27:27 -05:00
Aaron Hill
a895069c50
Include (potentially remapped) working dir in crate hash
Fixes #85019

A `SourceFile` created during compilation may have a relative
path (e.g. if rustc itself is invoked with a relative path).
When we write out crate metadata, we convert all relative paths
to absolute paths using the current working direction.

However, the working directory is not included in the crate hash.
This means that the crate metadata can change while the crate
hash remains the same. Among other problems, this can cause a
fingerprint mismatch ICE, since incremental compilation uses
the crate metadata hash to determine if a foreign query is green.

This commit moves the field holding the working directory from
`Session` to `Options`, including it as part of the crate hash.
2021-08-15 15:17:37 -05:00
bors
eb2226b1f1 Auto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkov
Plugin interface cleanup

The first commit performs two uncontroversial cleanups. The second commit removes `#[plugin_registrar]` and instead requires you to export a `__rustc_plugin_registrar` function, this will require a change to servo's script_plugins (cc `@jdm)`
2021-08-12 04:30:41 +00:00
bjorn3
a501308ec1 Replace #[plugin_registrar] with exporting __rustc_plugin_registrar 2021-08-10 14:20:48 +02:00
bors
7b52ad00cb Auto merge of #87619 - 12101111:fix-native_link_modifiers_bundle, r=petrochenkov
Fix feature gate checking of static-nobundle and native_link_modifiers

Feature native_link_modifiers_bundle don't need feature static-nobundle
to work.

Also check the feature gates when using native_link_modifiers from command line options. Current nighly compiler don't check those feature gate.

```
> touch lib.rs
> rustc +nightly lib.rs -L /usr/lib -l static:+bundle=dl --crate-type=rlib
> rustc +nightly lib.rs -L /usr/lib -l dylib:+as-needed=dl --crate-type=dylib -Ctarget-feature=-crt-static
> rustc +nightly lib.rs -L /usr/lib -l static:-bundle=dl --crate-type=rlib
error[E0658]: kind="static-nobundle" is unstable
  |
  = note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information
  = help: add `#![feature(static_nobundle)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

```

First found this in https://github.com/rust-lang/rust/pull/85600#discussion_r676612655
2021-08-09 03:59:30 +00:00
12101111
d935a14f4c
Fix feature gate checking of static-nobundle and native_link_modifiers 2021-08-08 21:46:40 +08:00
Yuki Okushi
3b0e797ee6
Rollup merge of #87761 - rusticstuff:rustc_error_overflow, r=Mark-Simulacrum
Fix overflow in rustc happening if the `err_count()` is reduced in a stage.

This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow checks. Fixes #84219.

Background: I came across this independently by running `RUSTFLAGS="-C overflow-checks=on" ./x.py test`. Fixing this will allow us to move on and find further overflow errors with testing or fuzzing.
2021-08-07 01:46:32 +09:00
Yuki Okushi
5a36cdb9d2
Rollup merge of #87756 - Amanieu:no_profiler_runtime, r=jackh726
Add back -Zno-profiler-runtime

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-08-06 11:21:32 +09:00
Guillaume Gomez
5cf300d695 Remove warnings/errors from compiler when using typeck_body in rustdoc span map builder 2021-08-05 23:08:29 +02:00
Hans Kratz
5ff06fb77f Fix overflow in rustc happening if the err_count() is reduced in a stage.
This can happen if stashed diagnostics are removed or replaced with fewer errors. The semantics stay the same if built without overflow. Fixes #84219.
2021-08-04 14:25:45 +00:00
Amanieu d'Antras
1247f9b829 Add back -Zno-profiler-runtime
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-08-04 10:47:59 +01:00
bors
b53a93db2d Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information for contributors, we may as well
remove it from crates in this repo.
2021-08-02 05:49:17 +00:00
Yuki Okushi
5cf6566df4
Rollup merge of #87608 - Aaron1011:remove-system-library, r=Mark-Simulacrum
Remove unused field `Session.system_library_path`
2021-08-02 11:03:27 +09:00
bors
aadd6189ad Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa
more clippy::complexity fixes

(also a couple of clippy::perf fixes)
2021-08-01 09:15:15 +00:00
Esteban Küber
0b8f192cfe Use multispan suggestions more often
* Use more accurate span for `async move` suggestion
* Use more accurate span for deref suggestion
* Use `multipart_suggestion` more often
2021-07-30 09:26:31 -07:00
Aaron Hill
377b4ce2b9
Remove unused field Session.system_library_path 2021-07-29 16:56:50 -05:00
Jade
3cf820e17d rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
Yuki Okushi
99a6474bc4
Rollup merge of #86450 - tmiasko:move-size-limit, r=pnkfelix
Add flag to configure `large_assignments` lint

The `large_assignments` lints detects moves over specified limit.  The
limit is configured through `move_size_limit = "N"` attribute placed at
the root of a crate. When attribute is absent, the lint is disabled.

Make it possible to enable the lint without making any changes to the
source code, through a new flag `-Zmove-size-limit=N`.  For example, to
detect moves exceeding 1023 bytes in a cargo crate, including all
dependencies one could use:

```
$ env RUSTFLAGS=-Zmove-size-limit=1024 cargo build -vv
```

Lint tracking issue #83518.
2021-07-27 19:52:40 +09:00
bors
7d6bf861f8 Auto merge of #83491 - jyn514:remove-pretty, r=pnkfelix
Remove unstable `--pretty` flag

It doesn't do anything `--unpretty` doesn't, and due to a bug, also
didn't show up in `--help`. I don't think there's any reason to keep it
around, I haven't seen anyone using it.

Closes https://github.com/rust-lang/rust/issues/36473.
2021-07-27 03:12:40 +00:00
Matthias Krüger
d709e6efef clippy::single_char_pattern 2021-07-25 12:25:26 +02:00
Aaron Hill
a2ae191295
Rename known_attrs to expanded_inert_attrs and move to rustc_expand
There's no need for this to be (untracked) global state.
2021-07-23 17:03:07 -05:00
bors
1158367a6d Auto merge of #87366 - GuillaumeGomez:rollup-7muueab, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #87270 (Don't display <table> in item summary)
 - #87281 (Normalize generic_ty before checking if bound is met)
 - #87288 (rustdoc: Restore --default-theme, etc, by restoring varname escaping)
 - #87307 (Allow combining -Cprofile-generate and -Cpanic=unwind when targeting MSVC.)
 - #87343 (Regression fix to avoid further beta backports: Remove unsound TrustedRandomAccess implementations)
 - #87357 (Update my name/email in .mailmap)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-07-22 12:29:30 +00:00
Guillaume Gomez
90d6d3327d
Rollup merge of #87307 - michaelwoerister:pgo-unwind-msvc, r=nagisa
Allow combining -Cprofile-generate and -Cpanic=unwind when targeting MSVC.

The LLVM limitation that previously prevented this has been fixed in LLVM 9 which is older than the oldest LLVM version we currently support.

Fixes https://github.com/rust-lang/rust/issues/61002.

r? ``@nagisa`` (or anyone else from ``@rust-lang/wg-llvm)``
2021-07-22 13:39:23 +02:00
bors
f913a4fe90 Auto merge of #86619 - rylev:incr-hashing-profiling, r=wesleywiser
Profile incremental compilation hashing fingerprints

Adds profiling instrumentation for the hashing of incremental compilation fingerprints per query.

This will eventually feed into the `measureme` and `rustc-perf` infrastructure for tracking if computing hashes changes over time.

TODOs:
* [x] Address the FIXME where we are including node interning in the hash timing.
* [ ] Update measureme/summarize to handle this new data: https://github.com/rust-lang/measureme/pull/166
* [ ] ~Update rustc-perf to handle the new data from measureme~ (will be done at a later time)

r? `@ghost`

cc `@michaelwoerister`
2021-07-22 10:04:44 +00:00
Ryan Levick
800c5f9202 Rename force-warns to force-warn 2021-07-21 15:41:10 +02:00
Michael Woerister
d56c02d7e9 Allow combining -Cprofile-generate and -Cpanic=unwind when targeting
MSVC.

The LLVM limitation that previously prevented this has been fixed in LLVM
9 which is older than the oldest LLVM version we currently support.

See https://github.com/rust-lang/rust/issues/61002.
2021-07-20 11:41:51 +02:00
inquisitivecrystal
2f2db99432 Make --force-warns a normal lint level option 2021-07-17 23:13:59 -07:00
Guillaume Gomez
c1b9bbf1e7
Rollup merge of #87145 - jsgf:fix-lint-opt-hash, r=michaelwoerister
Make --cap-lints and related options leave crate hash alone

Closes: #87144
2021-07-16 10:08:07 +02:00
Jeremy Fitzhardinge
51142a0f5f Make --cap-lints and related options leave crate hash alone
Closes: #87144
2021-07-14 17:04:55 -07:00
Eric Huss
636fcacb44 Add -Zfuture-incompat-test to assist with testing future-incompat reports. 2021-07-14 08:37:58 -07:00
bors
ca99e3eb3a Auto merge of #86922 - joshtriplett:target-abi, r=oli-obk
target abi

Implement cfg(target_abi) (RFC 2992)

Add an `abi` field to `TargetOptions`, defaulting to "". Support using
`cfg(target_abi = "...")` for conditional compilation on that field.

Gated by `feature(cfg_target_abi)`.

Add a test for `target_abi`, and a test for the feature gate.

Add `target_abi` to tidy as a platform-specific cfg.

Update targets to use `target_abi`

All eabi targets have `target_abi = "eabi".`
All eabihf targets have `target_abi = "eabihf"`.
`armv6_unknown_freebsd` and `armv7_unknown_freebsd` have `target_abi = "eabihf"`.
All abi64 targets have `target_abi = "abi64"`.
All ilp32 targets have `target_abi = "ilp32"`.
All softfloat targets have `target_abi = "softfloat"`.
All *-uwp-windows-* targets have `target_abi = "uwp"`.
All spe targets have `target_abi = "spe"`.
All macabi targets have `target_abi = "macabi"`.
aarch64-apple-ios-sim has `target_abi = "sim"`.
`x86_64-fortanix-unknown-sgx` has `target_abi = "fortanix"`.
`x86_64-unknown-linux-gnux32` has `target_abi = "x32"`.

Add FIXME entries for targets for which existing values need to change
once `cfg_target_abi` becomes stable. (All of them are tier 3 targets.)

Add a test for `target_abi` in `--print cfg`.
2021-07-13 12:25:10 +00:00
Eric Huss
4d1daf8683 Simplify future incompatible reporting. 2021-07-11 13:08:58 -07:00
Josh Triplett
84d6e8aed3 Implement cfg(target_abi) (RFC 2992)
Add an `abi` field to `TargetOptions`, defaulting to "". Support using
`cfg(target_abi = "...")` for conditional compilation on that field.

Gated by `feature(cfg_target_abi)`.

Add a test for `target_abi`, and a test for the feature gate.

Add `target_abi` to tidy as a platform-specific cfg.

This does not add an abi to any existing target.
2021-07-07 08:52:35 -07:00
Ryan Levick
6e33dce9c2 Profile incremental hashing 2021-07-07 10:43:30 +02:00
bors
238fd72880 Auto merge of #86572 - rylev:force-warnings-always, r=nikomatsakis
Force warnings even when can_emit_warnings == false

Fixes an issue mentioned in #85512 with --cap-lints overriding --force-warnings.

Fixes https://github.com/rust-lang/rust/issues/86751

r? `@ehuss`
2021-07-06 16:50:33 +00:00
Tomasz Miąsko
9792179648 Add flag to configure large_assignments lint
The `large_assignments` lints detects moves over specified limit.  The
limit is configured through `move_size_limit = "N"` attribute placed at
the root of a crate. When attribute is absent, the lint is disabled.

Make it possible to enable the lint without making any changes to the
source code, through a new flag `-Zmove-size-limit=N`.  For example, to
detect moves exceeding 1023 bytes in a cargo crate, including all
dependencies one could use:

```
$ env RUSTFLAGS=-Zmove-size-limit=1024 cargo build -vv
```
2021-07-06 17:47:15 +02:00
bjorn3
489ad8b8b5 Revert "Revert "Merge CrateDisambiguator into StableCrateId""
This reverts commit 8176ab8bc1.
2021-07-06 11:28:04 +02:00
Aaron Hill
7e5a88a56c
Combine individual limit queries into single limits query 2021-07-04 13:02:51 -05:00
Aaron Hill
ff15b5e2c7
Query-ify global limit attribute handling 2021-07-04 12:33:14 -05:00
Yuki Okushi
45470a3bcd
Rollup merge of #84029 - drahnr:master, r=petrochenkov
add `track_path::path` fn for usage in `proc_macro`s

Adds a way to declare a dependency on external files without including them, to either re-trigger the build of a file as well as covering the use case of including dependencies within the `rustc` invocation, such that tools like `sccache`/`cachepot` are able to handle references to external files which are not included.

Ref #73921
2021-07-03 03:15:07 +09:00
Bernhard Schuster
67e6a81315 add track_path::path fn for proc-macro usage
Ref #73921
2021-07-02 07:13:19 +02:00
Ryan Levick
33cc7b1fe2 New force_warn diagnostic builder and ensure cap-lints doesn't reduce force_warn level 2021-07-01 12:29:20 +02:00
Guillaume Gomez
dfd30d7b70
Rollup merge of #86652 - nagisa:nagisa/non-leaf-fp, r=petrochenkov
Add support for leaf function frame pointer elimination

This PR adds ability for the target specifications to specify frame
pointer emission type that's not just “always” or “whatever cg decides”.

In particular there's a new mode that allows omission of the frame
pointer for leaf functions (those that don't call any other functions).

We then set this new mode for Aarch64-based Apple targets.

Fixes #86196
2021-07-01 11:15:41 +02:00
bors
1034282bca Auto merge of #86617 - joshtriplett:prune-dependencies, r=Mark-Simulacrum
Remove unused dependencies from compiler crates

Various compiler crates have dependencies that they don't appear to use. I used some scripting to detect such dependencies, filtered them based on some manual review, and removed those that do indeed appear to be entirely unused.
2021-07-01 03:49:47 +00:00
Simonas Kazlauskas
9b67cba4f6 Add support for leaf fn frame pointer elimination
This PR adds ability for the target specifications to specify frame
pointer emission type that's not just “always” or “whatever cg decides”.

In particular there's a new mode that allows omission of the frame
pointer for leaf functions (those that don't call any other functions).

We then set this new mode for Aarch64-based Apple targets.

Fixes #86196
2021-06-30 19:45:17 +03:00
Ryan Levick
a3d6905053 Force warnings even when can_emit_warnings == false 2021-06-30 11:18:33 +02:00
Aman Arora
fc273e9bf2 Introduce -Zprofile-closures to evaluate the impact of 2229
This creates a CSV with name "closure_profile_XXXXX.csv", where the
variable part is the process id of the compiler.

To profile a cargo project you can run one of the following depending on
if you're compiling a library or a binary:

```
cargo +stage1 rustc --lib -- -Zprofile-closures
cargo +stage1 rustc --bin -- -Zprofile-closures
```
2021-06-28 14:21:55 -04:00
bors
a1411de9de Auto merge of #86267 - ZuseZ4:master, r=nagisa
Allow loading of llvm plugins on nightly

Based on a discussion in  #82734 / with `@wsmoses.`
Mainly moves [this](0149bc4e7e) behind a -Z flag, so it can only be used on nightly,
as requested by `@nagisa` in https://github.com/rust-lang/rust/issues/82734#issuecomment-835863940

This change allows loading of llvm plugins like Enzyme.
Right now it also requires a shared library LLVM build of rustc for symbol resolution.

```rust
// test.rs
extern { fn __enzyme_autodiff(_: usize, ...) -> f64; }

fn square(x : f64) -> f64 {
   return x * x;
}

fn main() {
   unsafe {
      println!("Hello, world {} {}!", square(3.0), __enzyme_autodiff(square as usize, 3.0));
   }
}
```
```
./rustc test.rs -Z llvm-plugins="./LLVMEnzyme-12.so" -C passes="enzyme"
./test
Hello, world 9 6!
```

I will try to figure out how to simplify the usage and get this into stable in a later iteration,
but having this on nightly will already help testing further steps.
2021-06-26 19:20:41 +00:00
Josh Triplett
f20aec4cbd rustc_session: Remove unused dependency bitflags
Unused since commit 64af7eae1e
("Move SanitizerSet to rustc_target").
2021-06-25 01:13:00 -07:00
Aaron Hill
99f652ff22 Only hash OutputTypes keys in non-crate-hash mode
This effectively turns OutputTypes into a hybrid where keys (OutputType)
are TRACKED and the values (optional paths) are TRACKED_NO_CRATE_HASH.
2021-06-21 17:22:35 -07:00
Jeremy Fitzhardinge
f1f7f2f508 make -Zno-codegen TRACKED_NO_CRATE_HASH 2021-06-21 17:22:35 -07:00
Jeremy Fitzhardinge
a26d99f348 In --emit KIND=PATH options, only hash KIND
The PATH has no material effect on the emitted artifact, and setting
the patch via `-o` or `--out-dir` does not affect the hash.

Closes https://github.com/rust-lang/rust/issues/86044
2021-06-21 17:22:35 -07:00
bors
d789de67dc Auto merge of #85775 - adamrk:warn-unused-target-fields, r=nagisa
Emit warnings for unused fields in custom targets.

Add a warning which lists any fields in a custom target `json` file that aren't used. Currently unrecognized fields are ignored so, for example, a typo in the `json` will silently produce a target which isn't the one intended.
2021-06-21 06:56:51 +00:00
bors
ed33787335 Auto merge of #85284 - eggyal:custom-profiler-runtime, r=jackh726
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-18 04:39:01 +00:00
Adam Bratschi-Kaye
88b01f1178 Emit warnings for unused fields in custom targets. 2021-06-17 21:48:02 +02:00
bors
6936ca8c99 Auto merge of #86311 - LeSeulArtichaut:cleanup-array-iter, r=jackh726
Use the now available implementation of `IntoIterator` for arrays
2021-06-15 07:46:48 +00:00
LeSeulArtichaut
e3ca81fd5a Use the now available implementation of IntoIterator for arrays 2021-06-14 23:40:09 +02:00
bors
304441960e Auto merge of #86117 - ehuss:force-warns-underscore, r=rylev
Fix force-warns to allow dashes.

The `--force-warns` flag was not allowing lint names with dashes, only supporting underscores.  This changes it to allow dashes to match the behavior of the A/W/D/F flags.
2021-06-14 17:21:28 +00:00
Manuel Drehwald
4dbdcd1c5c allow loading of llvm plugins on nightly 2021-06-13 18:23:01 +02:00
Eric Huss
7905473021 Fix force-warns to allow dashes. 2021-06-10 08:38:26 -07:00
1000teslas
2a76762695 gcc-lld mvp
ignore test if rust-lld not found

create ld -> rust-lld symlink at build time instead of run time

for testing in ci

copy instead of symlinking

remove linux check

test for linker, suggestions from bjorn3

fix overly restrictive lld matcher

use -Zgcc-ld flag instead of -Clinker-flavor

refactor code adding lld to gcc path

revert ci changes

suggestions from petrochenkov

rename gcc_ld to gcc-ld in dirs
2021-06-10 17:10:40 +10:00
bjorn3
8176ab8bc1 Revert "Merge CrateDisambiguator into StableCrateId"
This reverts commit d0ec85d3fb.
2021-06-07 10:37:45 +02:00
bors
9e6f0e878d Auto merge of #84234 - jyn514:blanket-hash, r=Aaron1011
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-05 01:08:51 +00:00
bors
595088d602 Auto merge of #85788 - rylev:force-warns, r=nikomatsakis
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-04 13:31:51 +00:00
Joshua Nelson
76502deb53 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.
2021-06-04 08:46:59 -04:00
Ryan Levick
3b206b7a70 Force warn on lint groups as well 2021-06-02 17:09:07 +02:00
Tomasz Miąsko
c1f6495b8e Miscellaneous inlining improvements 2021-06-02 08:49:58 +02:00
Guillaume Gomez
2ffe87a434
Rollup merge of #85473 - infinity0:master, r=jackh726
fix split-debuginfo error message
2021-06-01 11:29:42 +02:00
bors
657bc01888 Auto merge of #85702 - Aaron1011:no-vec-sort, r=michaelwoerister
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-31 20:03:18 +00:00
bors
aab93ca37f Auto merge of #85559 - 12101111:sanitizer-crt-static, r=nagisa
Diagnose use sanitizers with crt-static

Fix: https://github.com/rust-lang/rust/issues/85459
2021-05-30 23:38:10 +00:00
bors
758c00ea40 Auto merge of #85362 - jsgf:fix-emit-metadata, r=estebank
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-30 17:39:45 +00:00
bjorn3
d0ec85d3fb Merge CrateDisambiguator into StableCrateId 2021-05-30 12:51:34 +02:00
Jeremy Fitzhardinge
2835351feb Use command line metadata path if provided
If the command-line has `--emit metadata=some/path/libfoo.rmeta` then
use that.

Closes #85356
2021-05-28 22:24:24 -07:00
Ryan Levick
69a19bfd43 Initial support for force-warns 2021-05-28 18:19:59 +02:00
12101111
4376484439
Diagnose use sanitizers with crt-static 2021-05-29 00:15:28 +08:00
Aaron Hill
605513a513
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-25 22:11:39 -05:00
Guillaume Gomez
6b0b81b098
Rollup merge of #85361 - bjorn3:rustdoc_target_json_path_canonicalize, r=jyn514
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-25 13:05:09 +02:00
bjorn3
f22a80890a Use parse_target_triple in rustdoc 2021-05-24 19:53:44 +02:00
Pietro Albini
9e22b844dd remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
Ximin Luo
96a5e6b01e fix split-debuginfo error message 2021-05-19 15:39:59 +01:00
Alan Egerton
93c636211c
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-05-17 08:31:33 +01:00
bors
17b60b8738 Auto merge of #83129 - LeSeulArtichaut:thir-unsafeck, r=nikomatsakis
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-13 10:49:29 +00:00
bors
e1ff91f439 Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister
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-12 11:05:56 +00:00
bors
ac923d94f8 Auto merge of #83610 - bjorn3:driver_cleanup, r=cjgillot
rustc_driver cleanup

Best reviewed one commit at a time.
2021-05-12 08:38:03 +00:00
Aaron Hill
f916b0474a
Implement span quoting for proc-macros
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-12 00:51:31 -04:00
LeSeulArtichaut
29780f43e2 Introduce the (WIP) THIR unsafety checker 2021-05-11 15:33:00 +02:00
LingMan
41779f60ec
Fix typo in variable name
All other sibling functions call this variable "slot", so "slote" was most likely a typo.
2021-05-11 01:17:08 +02:00
Guillaume Gomez
6ec1de7d4f
Rollup merge of #85152 - nagisa:target-search-rustlib, r=Mark-Simulacrum
Adjust target search algorithm for rustlib path

With this the concerns expressed in #83800 should be addressed.

r? `@Mark-Simulacrum`
2021-05-10 20:05:27 +02:00
Simonas Kazlauskas
b7c5599d22 Adjust target search algorithm for rustlib path
With this the concerns expressed in #83800 should be addressed.
2021-05-10 19:15:19 +03:00
Vadim Petrochenkov
273e0a2a05 rustc_session: Use Iterator::find instead of manual search 2021-05-10 14:52:31 +03:00