Commit Graph

1091 Commits

Author SHA1 Message Date
Matthias Krüger
f106496b82
Rollup merge of #128806 - estebank:color-config, r=jieyouxu
Split `ColorConfig` off of `HumanReadableErrorType`

The previous setup tied two unrelated things together. Splitting these two is a better model.

Identified by https://github.com/rust-lang/rust/pull/126597/files#r1667800754
2024-08-09 00:03:36 +02:00
Michael Goulet
524e7689a9 Add comment that bors did not see pushed before it merged 2024-08-08 17:57:31 -04:00
Esteban Küber
ae696f847d Split ColorConfig off of HumanReadableErrorType
The previous setup tied two unrelated things together. Splitting these two is a better model.
2024-08-08 14:41:33 +00:00
Michael Goulet
470ada2de0 Make validate_mir pull optimized/ctfe MIR for all bodies 2024-08-03 15:18:09 -04:00
bors
c0e32983f5 Auto merge of #127543 - carbotaniuman:more_unsafe_attr_verification, r=estebank,traviscross
More unsafe attr verification

This code denies unsafe on attributes such as `#[test]` and `#[ignore]`, while also changing the `MetaItem` parsing so `unsafe` in args like `#[allow(unsafe(dead_code))]` is not accidentally allowed.

Tracking:

- https://github.com/rust-lang/rust/issues/123757
2024-08-01 10:40:45 +00:00
carbotaniuman
49db8a5a99 Add toggle for parse_meta_item unsafe parsing
This makes it possible for the `unsafe(...)` syntax to only be
valid at the top level, and the `NestedMetaItem`s will automatically
reject `unsafe(...)`.
2024-07-30 18:28:43 -05:00
Esteban Küber
b61570ac11 Structured suggestion for extern crate foo when foo isn't resolved in import
When encountering a name in an import that could have come from a crate that wasn't imported, use a structured suggestion to suggest `extern crate foo;` pointing at the right place in the crate.

When encountering `_` in an import, do not suggest `extern crate _;`.

```
error[E0432]: unresolved import `spam`
  --> $DIR/import-from-missing-star-3.rs:2:9
   |
LL |     use spam::*;
   |         ^^^^ maybe a missing crate `spam`?
   |
help: consider importing the `spam` crate
   |
LL + extern crate spam;
   |
```
2024-07-29 23:49:51 +00:00
Mrmaxmeier
0b87af9d4f Add -Z embed-source=yes to embed source code in DWARF debug info 2024-07-29 12:35:36 +02:00
Nicholas Nethercote
84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Michael Goulet
247ad3385c Use dep: for crate dependencies 2024-07-15 12:40:10 -04:00
Jubilee
5d56572f06
Rollup merge of #126502 - cuviper:dump-mir-exclude-alloc-bytes, r=estebank
Ignore allocation bytes in some mir-opt tests

This adds `rustc -Zdump-mir-exclude-alloc-bytes` to skip writing allocation bytes in MIR dumps, and applies it to tests that were failing on s390x due to its big-endian byte order.

Fixes #126261
2024-07-12 13:47:05 -07:00
Matthias Krüger
9f8cf64105
Rollup merge of #127184 - bjorn3:interface_refactor2, r=Nadrieril
More refactorings to rustc_interface

Follow up to https://github.com/rust-lang/rust/pull/126834
2024-07-03 23:30:07 +02:00
Trevor Gross
c15a698f56 Rename the asm-comments compiler flag to verbose-asm
Since this codegen flag now only controls LLVM-generated comments rather than
all assembly comments, make the name more accurate (and also match Clang).
2024-07-02 21:42:01 -04:00
bjorn3
f27645927c Inline Query::default() 2024-07-01 11:00:49 +00:00
bjorn3
ec2d1b0ed2 Minor change 2024-07-01 11:00:49 +00:00
bjorn3
bd2ff518ce Move codegen_and_build_linker from Queries to Linker 2024-07-01 11:00:49 +00:00
bjorn3
8127461b0e Move -Zprint-type-sizes and -Zprint-vtable-sizes into codegen_and_build_linker 2024-06-30 18:01:55 +00:00
Kornel
4061fd9e4e Reduce merge conflicts from rustfmt's wrapping 2024-06-28 18:15:12 +01:00
Florian Schmiderer
8d246b0102 Updated diagnostic messages 2024-06-27 22:24:36 +02:00
Josh Stone
31851d4770 Add -Zdump-mir-exclude-alloc-bytes 2024-06-26 15:05:01 -07:00
Florian Schmiderer
7c56398e91 Updated code for changes to RFC, added additional error handling, added
tests
2024-06-25 19:00:02 +02:00
Matthew Maurer
ac7595fdb1 Support for -Z patchable-function-entry
`-Z patchable-function-entry` works like `-fpatchable-function-entry`
on clang/gcc. The arguments are total nop count and function offset.

See MCP rust-lang/compiler-team#704
2024-06-25 18:21:42 +02:00
bors
c2d2bb38c9 Auto merge of #126834 - bjorn3:interface_refactor, r=michaelwoerister
Various refactorings to rustc_interface

This should make it easier to move the driver interface away from queries in the future. Many custom drivers call queries like `queries.global_ctxt()` before they are supposed to be called, breaking some things like certain `--print` and `-Zunpretty` options, `-Zparse-only` and emitting the dep info at the wrong point in time. They are also not actually necessary at all. Passing around the query output manually would avoid recomputation too and would be just as easy. Removing driver queries would also reduce the amount of global mutable state of the compiler. I'm not removing driver queries in this PR to avoid breaking the aforementioned custom drivers.
2024-06-25 09:35:53 +00:00
Jubilee Young
b3a1975cdc compiler(nfc): -Cforce-frame-pointers is a FramePointer 2024-06-23 00:36:33 -07:00
bjorn3
e3ffbbd226 Ensure run_compiler always aborts on errors
Before if the closure passed to run_compiler emitted an error without
calling abort_if_errors and no diagnostics have been stashed,
run_compiler would return normally as if no error had occured.
2024-06-22 17:06:47 +00:00
bjorn3
7332e79d5f Inline write_dep_info query 2024-06-22 17:06:47 +00:00
bjorn3
391bdb3c12 Clarify visibility of several rustc_interface passes 2024-06-22 15:44:36 +00:00
bjorn3
d8c9dd4172 Move has_errors_or_delayed_bugs check into start_codegen 2024-06-22 15:44:36 +00:00
bjorn3
e2aadc296d Call check_for_rustc_errors_attr from start_codegen 2024-06-22 15:44:36 +00:00
bjorn3
c8380cbe6a Move almost all code from Queries::global_ctxt into passes::create_global_ctxt 2024-06-22 15:44:33 +00:00
bors
dd104ef163 Auto merge of #126623 - oli-obk:do_not_count_errors, r=davidtwco
Replace all `&DiagCtxt` with a `DiagCtxtHandle<'_>` wrapper type

r? `@davidtwco`

This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle

Basically I will add a field to the `DiagCtxtHandle` that refers back to the `InferCtxt`'s (and others) `Option<ErrorHandled>`, allowing us to immediately taint these contexts when emitting an error and not needing manual tainting anymore (which is easy to forget and we don't do in general anyway)
2024-06-18 16:49:19 +00:00
Oli Scherer
7ba82d61eb Use a dedicated type instead of a reference for the diagnostic context
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-18 15:42:11 +00:00
Guillaume Gomez
bbec736f2d
Rollup merge of #126587 - Zalathar:no-mir-spans, r=oli-obk
coverage: Add debugging flag `-Zcoverage-options=no-mir-spans`

When set, this flag skips the code that normally extracts coverage spans from MIR statements and terminators. That sometimes makes it easier to debug branch coverage and MC/DC coverage instrumentation, because the coverage output is less noisy.

For internal debugging only. If future code changes would make it hard to keep supporting this flag, it should be removed at that time.

`@rustbot` label +A-code-coverage
2024-06-18 15:30:46 +02:00
Zalathar
abc2c702af coverage: Add debugging flag -Zcoverage-options=no-mir-spans
When set, this flag skips the code that normally extracts coverage spans from
MIR statements and terminators. That sometimes makes it easier to debug branch
coverage and MC/DC coverage, because the coverage output is less noisy.

For internal debugging only. If other code changes would make it hard to keep
supporting this flag, remove it.
2024-06-17 21:16:15 +10:00
Michael Goulet
342c1b03d6 Rename InstanceDef -> InstanceKind 2024-06-16 21:35:21 -04:00
Nicholas Nethercote
75b164d836 Use tidy to sort crate attributes for all compiler crates.
We already do this for a number of crates, e.g. `rustc_middle`,
`rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`.

For the ones we don't, in many cases the attributes are a mess.
- There is no consistency about order of attribute kinds (e.g.
  `allow`/`deny`/`feature`).
- Within attribute kind groups (e.g. the `feature` attributes),
  sometimes the order is alphabetical, and sometimes there is no
  particular order.
- Sometimes the attributes of a particular kind aren't even grouped
  all together, e.g. there might be a `feature`, then an `allow`, then
  another `feature`.

This commit extends the existing sorting to all compiler crates,
increasing consistency. If any new attribute line is added there is now
only one place it can go -- no need for arbitrary decisions.

Exceptions:
- `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`,
  because they have no crate attributes.
- `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's
  ignored in `rustfmt.toml`).
2024-06-12 15:49:10 +10:00
Rémy Rakic
0a4176a831 Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"
This reverts commit eda4a35f36, reversing
changes made to eb6b35b5bc.
2024-06-06 10:06:28 +00:00
Nicholas Nethercote
b9037339cb Make top-level rustc_parse functions fallible.
Currently we have an awkward mix of fallible and infallible functions:
```
       new_parser_from_source_str
 maybe_new_parser_from_source_str
       new_parser_from_file
(maybe_new_parser_from_file)        // missing
      (new_parser_from_source_file) // missing
 maybe_new_parser_from_source_file
       source_str_to_stream
 maybe_source_file_to_stream
```
We could add the two missing functions, but instead this commit removes
of all the infallible ones and renames the fallible ones leaving us with
these which are all fallible:
```
new_parser_from_source_str
new_parser_from_file
new_parser_from_source_file
source_str_to_stream
source_file_to_stream
```
This requires making `unwrap_or_emit_fatal` public so callers of
formerly infallible functions can still work.

This does make some of the call sites slightly more verbose, but I think
it's worth it for the simpler API. Also, there are two `catch_unwind`
calls and one `catch_fatal_errors` call in this diff that become
removable thanks this change. (I will do that in a follow-up PR.)
2024-06-05 10:38:03 +10:00
Nicholas Nethercote
25972aec67 Inline and remove parse_crate{,_attrs}_from_{file,source_str}.
All four functions are simple and have a single call site.

This requires making `Parser::parse_inner_attributes` public, which is
no big deal.
2024-06-05 10:38:02 +10:00
Michael Goulet
511f1cf7c8 check_is_object_safe -> is_object_safe 2024-06-03 09:49:30 -04:00
Matthias Krüger
d0311c1303
Rollup merge of #124655 - Darksonn:fixed-x18, r=lqd,estebank
Add `-Zfixed-x18`

This PR is a follow-up to #124323 that proposes a different implementation. Please read the description of that PR for motivation.

See the equivalent flag in [the clang docs](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-ffixed-x18).

MCP: https://github.com/rust-lang/compiler-team/issues/748
Fixes https://github.com/rust-lang/rust/issues/121970
r? rust-lang/compiler
2024-05-29 20:12:32 +02:00
Alice Ryhl
40f0172c6a Add -Zfixed-x18
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
2024-05-03 14:32:08 +02:00
Zalathar
f9263374fb coverage: Replace boolean options with a CoverageLevel enum 2024-04-29 20:04:22 +10:00
Vadim Petrochenkov
98804c1786 debuginfo: Stabilize -Z debug-macros, -Z collapse-macro-debuginfo and #[collapse_debuginfo]
`-Z debug-macros` is "stabilized" by enabling it by default and removing.

`-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`.
It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no.

Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local).
`#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.
2024-04-25 22:14:47 +03:00
bors
244da22fab Auto merge of #123126 - oli-obk:feed_crate_num, r=davidtwco
Enable `CrateNum` query feeding via `TyCtxt`

Instead of having a magic function that violates some `TyCtxtFeed` invariants, add a `create_def` equivalent for `CrateNum`s.

Note that this still isn't tracked by the query system (unlike `create_def`), and that feeding most `CrateNum` queries for crates other than the local one will likely cause performance regressions.

These things should be attempted on their own separately, but this PR should stand on its own
2024-04-23 20:46:48 +00:00
León Orell Valerian Liehr
5ff1fa9921
Rollup merge of #124285 - ferrocene:unstable-L-rust-builtin, r=petrochenkov
Mark `@RUSTC_BUILTIN` search path usage as unstable

Follow up to https://github.com/rust-lang/rust/pull/121843

r? `@petrochenkov`
2024-04-23 17:25:17 +02:00
León Orell Valerian Liehr
e15d6f9d85
Rollup merge of #123993 - compiler-errors:coroutine-obl, r=lcnr
Do `check_coroutine_obligations` once per typeck root

We only need to do `check_coroutine_obligations` once per typeck root, especially since the new solver can't really (easily) associate which obligations correspond to which coroutines.

This requires us to move the checks for sized coroutine fields into `mir_coroutine_witnesses`, but that's fine imo.

r? lcnr
2024-04-23 17:25:16 +02:00
Lukas Wirth
481515500a Mark @RUSTC_BUILTIN search path usage as unstable 2024-04-23 11:01:47 +02:00
Markus Reiter
33e68aadc9
Stabilize generic NonZero. 2024-04-22 18:48:47 +02:00
Matthias Krüger
efb264fa78
Rollup merge of #123409 - ZhuUx:master, r=oli-obk
Implement Modified Condition/Decision  Coverage

This is an implementation based on llvm backend support (>= 18) by `@evodius96` and branch coverage support by `@Zalathar.`

### Major changes:

* Add -Zcoverage-options=mcdc as switch. Now coverage options accept either `no-branch`, `branch`, or `mcdc`. `mcdc` also enables `branch` because it is essential to work.
* Add coverage mapping for MCDCBranch and MCDCDecision. Note that MCDCParameter evolves from  llvm 18 to llvm 19. The mapping in rust side mainly references to 19 and is casted to 18 types in llvm wrapper.
* Add wrapper for mcdc instrinc functions from llvm. And inject associated statements to mir.
* Add BcbMappingKind::Decision, I'm not sure is it proper but can't find a better way temporarily.
* Let coverage-dump support parsing MCDCBranch and MCDCDecision from llvm ir.
* Add simple tests to check whether mcdc works.
* Same as clang, currently rustc does not generate instrument for decision with more than 6 condtions or only 1 condition due to considerations of resource.

### Implementation Details

1. To get information about conditions and decisions, `MCDCState` in `BranchInfoBuilder` is used during hir lowering to mir. For expressions with logical op we call `Builder::visit_coverage_branch_operation` to record its sub conditions, generate condition ids for them and save their spans (to construct the span of whole decision). This process mainly references to the implementation in clang and is described in comments over `MCDCState::record_conditions`. Also true marks and false marks introduced by branch coverage are used to detect where the decision evaluation ends: the next id  of the condition == 0.
2. Once the `MCDCState::decision_stack` popped all recorded conditions, we can ensure that the decision is checked over and push it into `decision_spans`. We do not manually insert decision span to avoid complexity from then_else_break in nested if scopes.
3. When constructing CoverageSpans, add condition info to BcbMappingKind::Branch and decision info to BcbMappingKind::Decision. If the branch mapping has non-zero condition id it will be transformed to MCDCBranch mapping and insert `CondBitmapUpdate` statements to its evaluated blocks. While decision bcb mapping will insert `TestVectorBitmapUpdate` in all its end blocks.

### Usage
```bash
 echo "[build]\nprofiler=true" >> config.toml
./x build --stage 1
./x test tests/coverage/mcdc_if.rs
```
to build the compiler and run tests.

```shell
export PATH=path/to/llvm-build:$PATH
rustup toolchain link mcdc build/host/stage1
cargo +mcdc rustc --bin foo -- -Cinstrument-coverage -Zcoverage-options=mcdc
cd target/debug
LLVM_PROFILE_FILE="foo.profraw" ./foo
llvm-profdata merge -sparse foo.profraw -o foo.profdata
llvm-cov show ./foo -instr-profile=foo.profdata --show-mcdc
```
to check "foo" code.

### Problems to solve

For now decision mapping will insert statements to its all end blocks, which may be optimized by inserting a final block of the decision. To do this we must also trace the evaluated value at each end of the decision and join them separately.

This implementation is not heavily tested so there should be some unrevealed issues. We are going to check our rust products in the next.  Please let me know if you had any suggestions or comments.
2024-04-20 11:10:31 +02:00
Oli Scherer
e9a2f8fef1 Remove feed_local_crate in favor of creating the CrateNum via TyCtxt 2024-04-19 14:16:18 +00:00
Oli Scherer
fbc9b94064 Move stable_crate_ids from CrateStore to Untracked
This way it's like `Definitions`, which creates `DefId`s by interning `DefPathData`s, but for interning stable crate hashes
2024-04-19 14:16:18 +00:00
bors
13e63f7490 Auto merge of #117919 - daxpedda:wasm-c-abi, r=wesleywiser
Introduce perma-unstable `wasm-c-abi` flag

Now that `wasm-bindgen` v0.2.88 supports the spec-compliant C ABI, the idea is to switch to that in a future version of Rust. In the meantime it would be good to let people test and play around with it.

This PR introduces a new perma-unstable `-Zwasm-c-abi` compiler flag, which switches to the new spec-compliant C ABI when targeting `wasm32-unknown-unknown`.

Alternatively, we could also stabilize this and then deprecate it when we switch. I will leave this to the Rust maintainers to decide.

This is a companion PR to #117918, but they could be merged independently.
MCP: https://github.com/rust-lang/compiler-team/issues/703
Tracking issue: https://github.com/rust-lang/rust/issues/122532
2024-04-19 03:35:10 +00:00
zhuyunxing
68f86381ee coverage. Add coverage-options=mcdc as gate for MC/DC instrument 2024-04-19 10:43:53 +08:00
Guillaume Gomez
14496d561e
Rollup merge of #122811 - nnethercote:mv-SourceMap-init, r=WaffleLapkin
Move `SourceMap` initialization

So it happens at the same time as `SessionGlobals` initialization, rather than shortly afterward.

r? `@WaffleLapkin`
2024-04-16 21:41:23 +02:00
Guillaume Gomez
26b6a234a1
Rollup merge of #121694 - davidtwco:stabilize-relro-level, r=Mark-Simulacrum
sess: stabilize `-Zrelro-level` as `-Crelro-level`

Stabilise `-Zrelro-level` as `-Crelro-level`. There's no tracking issue for this flag to close.
2024-04-16 15:19:10 +02:00
Nicholas Nethercote
9b0ced000a Move initialize_checked_jobserver.
Currently it's a method on `EarlyDiagCtxt`, which is not the right place
for it at all -- `EarlyDiagCtxt` is used to issue diagnostics, but
shouldn't be doing any of the actual checking.

This commit moves it into a standalone function that takes an
`EarlyDiagCtxt` as an argument, which is more sensible. This does
require adding `EarlyDiagCtxt::early_struct_warn`, so a warning can be
returned and then modified with a note. (And that likely explains why
somebody put `initialize_checked_jobserver` into `EarlyDiagCtxt` in the
first place.)
2024-04-16 13:02:55 +10:00
Nicholas Nethercote
62c32aeeab Construct SourceMap at the same time as SessionGlobals.
Currently `SourceMap` is constructed slightly later than
`SessionGlobals`, and inserted. This commit changes things so they are
done at the same time.

Benefits:
- `SessionGlobals::source_map` changes from
  `Lock<Option<Lrc<SourceMap>>>` to `Option<Lrc<SourceMap>>`. It's still
  optional, but mutability isn't required because it's initialized at
  construction.
- `set_source_map` is removed, simplifying `run_compiler`, which is
  good because that's a critical function and it's nice to make it
  simpler.

This requires moving things around a bit, so the necessary inputs are
available when `SessionGlobals` is created, in particular the `loader`
and `hash_kind`, which are no longer computed by `build_session`. These
inputs are captured by the new `SourceMapInputs` type, which is threaded
through various places.
2024-04-16 13:02:53 +10:00
Nicholas Nethercote
ff2e4ed1f1 Factor out common code in interface tests.
Replacing `mk_session` with `sess_and_cfgs`, which does a bit more of
the shared stuff -- the option parsing and the `build_configuration`
call.
2024-04-16 12:08:25 +10:00
Michael Goulet
d29178c2ef Do check_coroutine_obligations once per typeck root 2024-04-15 19:44:58 -04:00
Vadim Petrochenkov
ed62b57c86 linker: Remove laziness and caching from native search directory walks
It shouldn't be necessary for performance now.
2024-04-12 17:28:00 +03:00
Vadim Petrochenkov
4ded0b82ca linker: Avoid some allocations in search directory iteration 2024-04-12 00:41:08 +03:00
Oli Scherer
3b16ee2568 Ensure we do not accidentally insert new early aborts in the analysis passes 2024-04-08 14:44:10 +00:00
Ben Kimock
a7912cb421 Put checks that detect UB under their own flag below debug_assertions 2024-04-06 11:21:47 -04:00
Matthew Jasper
a277c901d9 Remove MIR unsafe check
This also remove safety information from MIR.
2024-04-03 08:50:12 +00:00
bors
c5e7f45b62 Auto merge of #115220 - Zoxc:revive-gcx-ptr, r=oli-obk
Add a `CurrentGcx` type to let the deadlock handler access `TyCtxt`

This brings back `GCX_PTR` (previously removed in https://github.com/rust-lang/rust/pull/74969) allowing the deadlock handler access to `GlobalCtxt`. This fixes https://github.com/rust-lang/rust/issues/111522.

r? `@cjgillot`
2024-03-28 14:00:08 +00:00
John Kåre Alsaker
9936a399df Add a CurrentGcx type to let the deadlock handler access TyCtxt 2024-03-27 11:44:32 +01:00
Lukas Wirth
2fae4ee92e Make sysroot mandatory for rustdoc 2024-03-25 22:19:41 +00:00
Lukas Wirth
91547573af Implement -L builtin:$path 2024-03-25 22:18:31 +00:00
Matthias Krüger
3fe9f66133
Rollup merge of #122737 - ytmimi:conditionally_ignore_fatal_diagnostic, r=davidtwco
conditionally ignore fatal diagnostic in the SilentEmitter

This change is primarily meant to allow rustfmt to ignore all diagnostics when using the `SilentEmitter`. Back in #121301 the `SilentEmitter` was shared between rustc and rustfmt. This changed rustfmt's behavior from ignoring all diagnostic to emitting fatal diagnostics, which lead to https://github.com/rust-lang/rustfmt/issues/6109.

These changes allow rustfmt to maintain its previous behaviour when using the `SilentEmitter`, while allowing rustc code to still emit fatal diagnostics.
2024-03-24 17:08:15 +01:00
Matthias Krüger
b317cda7ea
Rollup merge of #122847 - workingjubilee:suggest-rust-min-stack-workaround-on-overflow, r=TaKO8Ki
Suggest `RUST_MIN_STACK` workaround on overflow

For some Rust crates, like p384, we can't do a whole lot about it even if the stack overflow is reported like in rust-lang/rust#122357 because the problem may be inside LLVM or another codegen backend. We can, however, suggest people set a new `RUST_MIN_STACK` value while handling the SIGSEGV, as that stack-setting will carry forward into the dylib.

As a bonus, this also leads to cleaning up the stack-setting code a bit.
2024-03-22 11:37:02 +01:00
Jubilee Young
542533865a Suggest using RUST_MIN_STACK if rustc overflowed 2024-03-21 14:49:02 -07:00
Jubilee Young
60891cab33 Use less hacky STACK_SIZE 2024-03-21 14:47:26 -07:00
Nicholas Nethercote
5744be2727 Rename some target_cfg variables as target.
Because the underlying type is called `Target`. (There is also a
separate type called `TargetCfg`.)
2024-03-21 11:50:40 +11:00
Nicholas Nethercote
23ee523ea6 Remove CodegenBackend::target_override.
Backend and target selection is a mess: the target can override the
backend (via `Target::default_codegen_backend`), *and* the backend can
override the target (via `CodegenBackend::target_override`).

The code that handles this is ugly. It calls `build_target_config`
twice, once before getting the backend and once again afterward. It also
must check that both overrides aren't triggering at the same time.

This commit removes the latter override. It's used in rust-gpu but
@eddyb said via Zulip that removing it would be ok. This simplifies the
code greatly, and will allow some nice follow-up refactorings.
2024-03-21 11:48:49 +11:00
Yacin Tmimi
d49d136b3a conditionally ignore fatal diagnostic in the SilentEmitter
This change is primarily meant to allow rustfmt to ignore all
diagnostics when using the `SilentEmitter`. Back in PR 121301 the
`SilentEmitter` was shared between rustc and rustfmt. This changed
rustfmt's behavior from ignoring all diagnostic to emitting fatal
diagnostics.

These changes allow rustfmt to maintain it's previous behaviour when
using the SilentEmitter, while allowing rustc code to still emit fatal
diagnostics.
2024-03-19 13:48:07 -04:00
Matthias Krüger
4dff106433
Rollup merge of #121764 - Zoxc:incr-sess-no-source, r=oli-obk
Make incremental sessions identity no longer depend on the crate names provided by source code

This makes incremental sessions identity no longer depend on the crate names provided by source code, implementing
https://github.com/rust-lang/compiler-team/issues/726.

r? ````@oli-obk````
2024-03-14 20:00:18 +01:00
Matthias Krüger
fce6e752ab
Rollup merge of #120699 - nnethercote:rm-useless-TRACK_DIAGNOSTIC-calls, r=oli-obk
Document `TRACK_DIAGNOSTIC` calls.

r? ```````@cjgillot```````
2024-03-14 11:09:57 +01:00
bors
5ac0b2d021 Auto merge of #122347 - oli-obk:track_errors13, r=compiler-errors
Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco"

This reverts commit 65cd843ae0, reversing changes made to d255c6a57c.

reverts https://github.com/rust-lang/rust/pull/122140

It was a large regression in wall time due to trashing CPU caches
2024-03-14 02:54:10 +00:00
John Kåre Alsaker
12cd322062 Make incremental sessions identity no longer depend on the crate names provided by source code 2024-03-13 16:40:02 +01:00
Matthias Krüger
8b9ef3b996
Rollup merge of #122226 - Zalathar:zcoverage-options, r=nnethercote
coverage: Remove or migrate all unstable values of `-Cinstrument-coverage`

(This PR was substantially overhauled from its original version, which migrated all of the existing unstable values intact.)

This PR takes the three nightly-only values that are currently accepted by `-Cinstrument-coverage`, completely removes two of them (`except-unused-functions` and `except-unused-generics`), and migrates the third (`branch`) over to a newly-introduced unstable flag `-Zcoverage-options`.

I have a few motivations for wanting to do this:

- It's unclear whether anyone actually uses the `except-unused-*` values, so this serves as an opportunity to either remove them, or prompt existing users to object to their removal.
- After #117199, the stable values of `-Cinstrument-coverage` treat it as a boolean-valued flag, so having nightly-only extra values feels out-of-place.
  - Nightly-only values also require extra ad-hoc code to make sure they aren't accidentally exposed to stable users.
- The new system allows multiple different settings to be toggled independently, which isn't possible in the current single-value system.
- The new system makes it easier to introduce new behaviour behind an unstable toggle, and then gather nightly-user feedback before possibly making it the default behaviour for all users.
- The new system also gives us a convenient place to put relatively-narrow options that won't ever be the default, but that nightly users might still want access to.
- It's likely that we will eventually want to give stable users more fine-grained control over coverage instrumentation. The new flag serves as a prototype of what that stable UI might eventually look like.

The `branch` option is a placeholder that currently does nothing. It will be used by #122322 to opt into branch coverage instrumentation.

---

I see `-Zcoverage-options` as something that will exist more-or-less indefinitely, though individual sub-options might come and go as appropriate. I think there will always be some demand for nightly-only toggles, so I don't see `-Zcoverage-options` itself ever being stable, though we might eventually stabilize something similar to it.
2024-03-13 06:41:22 +01:00
bors
d3555f3d8e Auto merge of #122227 - Zoxc:query-hash-verify, r=michaelwoerister
Verify that query keys result in unique dep nodes

This implements checking that query keys result into unique dep nodes as mentioned in https://github.com/rust-lang/rust/pull/112469.

We could do a perf check to see how expensive this is.

r? `@michaelwoerister`
2024-03-13 02:01:56 +00:00
Zalathar
3407fcc12e coverage: Add -Zcoverage-options for fine control of coverage
This new nightly-only flag can be used to toggle fine-grained flags that
control the details of coverage instrumentation.

Currently the only supported flag value is `branch` (or `no-branch`), which is
a placeholder for upcoming support for branch coverage. Other flag values can
be added in the future, to prototype proposed new behaviour, or to enable
special non-default behaviour.
2024-03-13 11:14:10 +11:00
David Wood
420c58fb11
sess: stabilize relro-level
Signed-off-by: David Wood <david@davidtw.co>
2024-03-12 13:40:40 +00:00
John Kåre Alsaker
55ba7a7c62 Verify that query keys result in unique dep nodes 2024-03-12 05:31:41 +01:00
Oli Scherer
96d24f2dd1 Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco"
This reverts commit 65cd843ae0, reversing
changes made to d255c6a57c.
2024-03-11 21:28:16 +00:00
bors
6554a5645a Auto merge of #122338 - workingjubilee:rollup-xzpt4v4, r=workingjubilee
Rollup of 15 pull requests

Successful merges:

 - #116791 (Allow codegen backends to opt-out of parallel codegen)
 - #116793 (Allow targets to override default codegen backend)
 - #117458 (LLVM Bitcode Linker: A self contained linker for nvptx and other targets)
 - #119385 (Fix type resolution of associated const equality bounds (take 2))
 - #121438 (std support for wasm32 panic=unwind)
 - #121893 (Add tests (and a bit of cleanup) for interior mut handling in promotion and const-checking)
 - #122080 (Clarity improvements to `DropTree`)
 - #122152 (Improve diagnostics for parenthesized type arguments)
 - #122166 (Remove the unused `field_remapping` field from `TypeLowering`)
 - #122249 (interpret: do not call machine read hooks during validation)
 - #122299 (Store backtrace for `must_produce_diag`)
 - #122318 (Revision-related tweaks for next-solver tests)
 - #122320 (Use ptradd for vtable indexing)
 - #122328 (unix_sigpipe: Replace `inherit` with `sig_dfl` in syntax tests)
 - #122330 (bootstrap readme: fix, improve, update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-11 16:51:54 +00:00
Jubilee
86af4d25a5
Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillot
Allow targets to override default codegen backend

Implements https://github.com/rust-lang/compiler-team/issues/670.
2024-03-11 09:29:32 -07:00
Jubilee
88d387b263
Rollup merge of #116791 - WaffleLapkin:unparallel-backends, r=oli-obk
Allow codegen backends to opt-out of parallel codegen

This makes it a bit easier to write cursed codegen backends.
2024-03-11 09:29:31 -07:00
Oli Scherer
55ea94402b Run a single huge par_body_owners instead of many small ones after each other.
This improves parallel rustc parallelism by avoiding the bottleneck after each individual `par_body_owners` (because it needs to wait for queries to finish, so if there is one long running one, a lot of cores will be idle while waiting for the single query).
2024-03-11 08:48:03 +00:00
Oli Scherer
4279da583c Never bail out early while running all the type check queries 2024-03-11 08:43:50 +00:00
daxpedda
f09c19ac3a
Introduce perma-unstable wasm-c-abi flag 2024-03-10 09:00:01 +01:00
John Kåre Alsaker
87ab9e8c6e Some tweaks to the parallel query cycle handler 2024-03-09 00:24:14 +01:00
Guillaume Gomez
4de78d2a8d
Rollup merge of #121089 - oli-obk:create_def_feed, r=petrochenkov
Remove `feed_local_def_id`

best reviewed commit by commit

Basically I returned `TyCtxtFeed` from `create_def` and then preserved that in the local caches

based on https://github.com/rust-lang/rust/pull/121084

r? ````@petrochenkov````
2024-03-07 18:32:47 +01:00
Guillaume Gomez
f1fb720734
Rollup merge of #122066 - mu001999:clean, r=oli-obk
Add proper cfgs for struct HirIdValidator used only with debug-assert

See https://github.com/rust-lang/rust/pull/122065#issuecomment-1980118572.
I think it's due to #121752.
2024-03-07 15:07:06 +01:00
Matthias Krüger
efe9deace8
Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, r=davidtwco
Rework `untranslatable_diagnostic` lint

Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This PR changes it to check calls to any function with an `impl Into<{D,Subd}iagnosticMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. It also lets us add `#[rustc_lint_diagnostics]` to a number of functions that don't have an `impl Into<{D,Subd}iagnosticMessage>`, such as `Diag::span`.

r? ``@davidtwco``
2024-03-06 22:02:46 +01:00
r0cky
f41537981b Add proper cfgs for struct HirIdValidator used only with debug assertions 2024-03-06 22:54:22 +08:00
Zalathar
9f287dd7b3 Change the documented implicit value of -C instrument-coverage to =yes 2024-03-06 17:50:13 +11:00
Nicholas Nethercote
b7d58eef4b Rewrite the untranslatable_diagnostic lint.
Currently it only checks calls to functions marked with
`#[rustc_lint_diagnostics]`. This commit changes it to check calls to
any function with an `impl Into<{D,Subd}iagMessage>` parameter. This
greatly improves its coverage and doesn't rely on people remembering to
add `#[rustc_lint_diagnostics]`.

The commit also adds `#[allow(rustc::untranslatable_diagnostic)`]
attributes to places that need it that are caught by the improved lint.
These places that might be easy to convert to translatable diagnostics.

Finally, it also:
- Expands and corrects some comments.
- Does some minor formatting improvements.
- Adds missing `DecorateLint` cases to
  `tests/ui-fulldeps/internal-lints/diagnostics.rs`.
2024-03-06 14:19:01 +11:00
David Wood
2ee0409f32
errors: share SilentEmitter between rustc and rustfmt
Signed-off-by: David Wood <david@davidtw.co>
2024-03-05 10:14:36 +00:00