Commit Graph

579 Commits

Author SHA1 Message Date
Jonathan Brouwer
f03631c43d Rename rustc_driver_impl/session_diagnostics.rs to diagnostics.rs 2026-08-08 14:58:18 +02:00
Jonathan Brouwer
900f0bcb32 Rollup merge of #159225 - bjorn3:split_incr_comp_session, r=oli-obk
Split IncrCompSession out of Session

This will allow introducing a separate incr comp session dir for the post LTO artifacts in the future. In addition it statically encodes the lifetime of the incr comp session rather than requiring an enum behind a mutex stored in the Session.

Based on https://github.com/rust-lang/rust/pull/159000
Part of https://github.com/rust-lang/compiler-team/issues/908
2026-08-05 13:36:11 +02:00
Jonathan Brouwer
cf80286afb Rollup merge of #160360 - mejrs:hir_pretty, r=nnethercote
Remove rustc_middle dependency on rustc_hir_pretty

There is a `impl PpAnn for TyCtxt`  that is unneeded. None of the big crates (middle, trait_selection) actually do any hir pretty printing so it can be removed and can either be implemented for local structs elsewhere or done by casting to `&dyn PpAnn` instead.

This probably doesn't have any perf effects (its not bottlenecking in timings) but I expect it to compose with https://github.com/rust-lang/rust/pull/160336 and its followup works quite well.

Old graph:
<img width="1999" height="2171" alt="graph" src="https://github.com/user-attachments/assets/756e6a50-a413-4a8d-a0f3-7bbf4de07933" />

New graph:
<img width="1853" height="2171" alt="graph_hir_pretty" src="https://github.com/user-attachments/assets/f9607e5a-d00b-4a86-8f6a-cefb45b75ad7" />
2026-08-05 13:36:05 +02:00
mejrs
180c6379b8 Remove rustc_middle dependency on rustc_hir_pretty
There is a `impl PpAnn for TyCtxt`  that is unneeded. None of the big crates (middle, trait_selection) actually do any hir pretty printing so it can be removed and can either be implemented for local structs elsewhere or done by casting to `&dyn PpAnn` instead.
2026-08-04 19:04:34 +02:00
John Kåre Alsaker
5aff738d05 Derive the allocator used by tools from rustc's allocator 2026-08-03 22:39:22 +02:00
Jonathan Brouwer
581f75e736 Rollup merge of #158460 - ZuseZ4:simplify-enzyme-feature, r=bjorn3
Remove llvm_enzyme feature outside of bootstrap

r? bjorn3
I think you were the one who did the last refactoring on how we pass this feature.

We originally introduced and used this compile-time cfg since we were suspecting that some of the work we did for autodiff was causing a compile time regression even when no autodiff was used. It turned out later that we just did extra work due to a bug, which was fixed.

Thanks to the dlopen work our checks are now much simpler. We only do autodiff work if the -Zautodiff=Enable flag was set. If the flag is set we also just check if libEnzyme is in the sysroot, and if we can not find it, we error out.

I noticed it while fixing some related checks in https://github.com/rust-lang/rust/pull/158333
2026-07-29 14:10:29 +02:00
Manuel Drehwald
ba877845ee Remove llvm_enzyme feature outside of bootstrap 2026-07-28 16:11:31 -04:00
Gary Guo
75999c498f Split register_tool into register_attribute_tool and register_lint_tool
This splits the functionality to two parts per RFC. The `#![register_tool]`
attribute registers the tool in both ways.

Semantics remain unchanged and will be adjusted in later commit.
2026-07-27 19:06:33 +01:00
bjorn3
f9679fa4df Split IncrCompSession out of Session
This will allow introducing a separate incr comp session dir for the
post LTO artifacts in the future. In addition it statically encodes the
lifetime of the incr comp session rather than requiring an enum behind a
mutex stored in the Session.
2026-07-23 12:14:56 +02:00
Nicholas Nethercote
a235d0d0d0 Use two local variables 2026-07-21 18:16:18 +10:00
Nicholas Nethercote
b663a947c7 Remove early_exit closures
There are two `early_exit` closures in `run_compiler` that ensure
`abort_if_errors` is called on all the early exit paths.

However, these early exit paths all occur in the closure passed to
`interface::run_compiler`. And what does `interface::run_compiler` do
after calling the passed-in closure? It calls `finish_diagnostic`
(always) and then `abort_if_errors` (if the closure didn't panic).
So we can drop the `early_exit` calls and get the same behaviour.
2026-07-21 18:16:08 +10:00
reidliu
bc585ed04e Fix the stale metrics directory warning 2026-07-15 19:39:01 +08:00
blyxyas
8ecf21cdb0 Propagate error downwards and emit it, even if not related to file
extension. Fix tests and update docs.
2026-07-09 12:19:01 +00:00
Alejandra Gonzalez
90496ea27d fix: Actually take error and panic by default, only emitting a custom
error if file ends in .rs
2026-07-08 18:40:44 +02:00
blyxyas
bbba4966b2 Propagate errors from list_file_metadata into list_metadata
Update unstable book with ls valid values
2026-07-07 12:29:51 +00:00
Alejandra Gonzalez
ae82b10c36 Improve error message on -Zls, to direct the user to input .rmeta files instead of .rs files 2026-07-06 19:34:38 +02:00
Camille GILLOT
5464994cdd Split-up the AST to index it. 2026-06-16 00:10:07 +00:00
Camille Gillot
334a95f9f4 Make lowering incremental.
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2026-06-16 00:08:10 +00:00
Camille Gillot
bfe40ed753 Stop stealing ResolverAstLowering. 2026-06-15 23:24:10 +00:00
fallofpheonix
5a93cdbc09 Remove useless -Zunpretty=identified option
Fixes #10671

The `-Zunpretty=identified` option (without `expanded`) is effectively
useless because `NodeId`s are unassigned prior to macro expansion,
leading them to just be `NodeId::MAX_AS_U32`.

This commit removes the `Identified` variant from `PpSourceMode` and
removes `-Zunpretty=identified` from the command-line options. Users
should use `-Zunpretty=expanded,identified` instead (which is retained)
if they want to inspect `NodeId`s.
2026-05-24 17:36:25 +05:30
Guillaume Gomez
1f5737c853 Rollup merge of #156564 - nnethercote:LevelSpec, r=GuillaumeGomez
Lint level cleanups

Some naming improvements, some type safety improvements, and some simplifications. Details in individual commits.

r? @GuillaumeGomez
2026-05-14 16:51:08 +02:00
Nicholas Nethercote
530a73f17e Prevent invalid LevelSpec values
`LevelSpec` has two related fields, `level` and `lint_id`. This commit
makes the fields private (and introduces getters) to ensure they are set
together using only valid combinations.

The commit also introduces `is_allow` and `is_expect` methods because
those are useful.
2026-05-14 16:28:50 +10:00
Nicholas Nethercote
ccfac5469a Rename LevelAndSource
It is misnamed, given that it has three fields: `level`, `lint_id`, and
`src`. (Presumably the `lint_id` was added later.)

This commit renames it as `LevelSpec`. (I also considered `LevelInfo`
but that's very generic. `Spec` has pre-existing uses in
`LintLevelsProvider::current_specs` and `LintSet::specs` and
`ShallowLintLevelMap::specs`.)

Related things renamed as well:
- `level` -> `level_spec` (where appropriate)
- `lint_levels` -> `lint_level_specs`
- `get_lint_level` -> `get_lint_level_spec`
- `level_and_source` -> `level_spec`
- `CodegenLintLevels` -> `CodegenLintLevelSpecs`
- `raw_lint_id_level` -> `raw_lint_level_spec`
- `lint_level_at_node` -> `lint_level_spec_at_node`
- `reveal_actual_level` -> `reveal_actual_level_spec`
- `probe_for_lint_level` -> `probe_for_lint_level_spec`

This clears up a lot of `Level` vs. `LevelSpec` ambiguity. E.g. no more
`level.level` expressions.
2026-05-14 13:20:57 +10:00
Jonathan Brouwer
f24b05a9d2 Rollup merge of #156344 - estebank:issue-156326, r=petrochenkov
Do not index past end of buffer when checking heuristic in error index syntax highlighter

When checking whether the current token is a function indentifier by inspecting the syntax, do not attempt to access past the end of the code buffer.

Fix rust-lang/rust#156326.
2026-05-14 00:35:36 +02:00
Esteban Küber
530c69bbc2 Do not index past end of buffer when checking heuristic in error index syntax highlighter
When checking whether the current token is a function indentifier by inspecting the syntax, do not attempt to access past the end of the code buffer.
2026-05-13 17:52:04 +00:00
Zalathar
ccb9305e20 Move emit_mir out of rustc_mir_transform::dump_mir
This function doesn't have an obvious home, but there's little reason for it to
be in mir-transform, and having it in `rustc_driver_impl::pretty` at least puts
it near other callers of `write_mir_pretty`.
2026-05-13 14:54:31 +10:00
Jonathan Brouwer
7843355462 Rollup merge of #156384 - Zalathar:pretty-def-id, r=tiif
Remove some dead code for dumping MIR for a single DefId

The functions that call `dump_mir_def_ids` are themselves never called with a specific DefId; they always dump MIR for the entire crate.
2026-05-11 10:29:20 +02:00
Zalathar
9d01bf83f9 Remove some dead code for dumping MIR for a single DefId 2026-05-10 17:18:35 +10:00
bjorn3
c2ab95fb61 Handle --print=backend-has-mnemonic in cg_clif
And introduce a has_mnemonic method on CodegenBackend just like
--print=backend-has-zstd
2026-05-08 16:08:56 +02:00
Nicholas Nethercote
01e933f888 Move four fields from ParseSess to Session.
`ParseSess` is separate from, but sits within, `Session`. The separation
is because there are some places (e.g. `Parser` methods) where
`ParseSess` is available but `Session` is not.

However, `ParseSess` has four fields that are only accessed from places
where `Session` is also available. This commit moves those fields to
`Session`. This means that `ParseSess` only contains the fields it
genuinely needs, and various `sess.psess.foo` occurrences are reduced to
`sess.foo`.
2026-04-29 09:27:04 +10:00
Eddy (Eduard) Stefes
2a8e588c90 Add --print=backend-has-mnemonic and needs-asm-mnemonic directive
Add infrastructure to query LLVM backend for specific assembly mnemonics
and use it in compiletest to conditionally run tests based on instruction
availability.

This fixes test failures with naked-dead-code-elimination which requires
the `RET` mnemonic.

Co-authored-by: Folkert de Vries <flokkievids@gmail.com>
2026-04-28 10:21:15 +02:00
Jonathan Brouwer
c5f6afc3e8 Remove target arguments & features from parse_limited 2026-04-18 19:13:30 +02:00
Nicholas Nethercote
9b64d52d78 Reduce diagnostic type visibilities.
Most diagnostic types are only used within their own crate, and so have
a `pub(crate)` visibility. We have some diagnostic types that are
unnecessarily `pub`. This is bad because (a) information hiding, and (b)
if a `pub(crate)` type becomes unused the compiler will warn but it
won't warn for a `pub` type.

This commit eliminates unnecessary `pub` visibilities for some
diagnostic types, and also some related things due to knock-on effects.
(I found these types with some ad hoc use of `grep`.)
2026-04-16 07:42:17 +10:00
Nicholas Nethercote
0db4e3a883 De-pluralize the names of two error enums.
Error enum names should not be plural. Even though there are multiple
possible errors, each instance of an error enum describes a single
error. There are dozens of singular error enum names, and only two
plural error enum names. This commit makes them both singular.
2026-03-30 14:15:44 +11:00
Stuart Cook
44c87292ac Rollup merge of #153778 - bjorn3:driver_cleanups, r=TaKO8Ki
Couple of driver interface improvements

* Pass Session to `make_codegen_backend` callback. This simplifies some code in miri.
* Move env/file_depinfo from ParseSess to Session. There is no reason it has to be in ParseSess rather than Session.
* Rename hash_untracked_state to track_state to indicate that it isn't just used for hashing state, but also for adding env vars and files to be tracked through the dep info file.
2026-03-18 15:07:31 +11:00
bjorn3
2199d07e2b Move env/file_depinfo from ParseSess to Session 2026-03-12 15:35:27 +00:00
Nicholas Nethercote
282e8ec275 Rename some parameters.
`tcx` is the usual name for `TyCtxt` parameters.
2026-03-11 16:04:40 +11:00
Josh Stone
eb093cfd5d Reformat with the new stage0 2026-03-07 10:42:02 -08:00
Jonathan Brouwer
1c44dbd580 Rollup merge of #152164 - mu001999-contrib:lint/unused_features, r=JonathanBrouwer
Lint unused features

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152164)*

Fixes rust-lang/rust#44232
Fixes rust-lang/rust#151752

---

This PR records used features through query side effect, then reports unsued features finally.
2026-03-04 19:30:36 +01:00
bjorn3
5aa980e6dc Replace CodegenResults with CompiledModules
This is already CodegenResults without CrateInfo. The driver can
calculate the CrateInfo and pass it by-ref to the backend. Using
CompiledModules makes it a bit easier to move some other things out of
the backend as will be necessary for moving LTO to the link phase.
2026-03-02 16:39:41 +00:00
bjorn3
a192c617ec Use CompiledModules inside CodegenResults
In preparation for fully replacing CodegenResults with CompiledModules.
2026-03-02 16:39:13 +00:00
mu001999
7f3bbe371f Report unused features 2026-03-02 09:38:03 +08:00
Jonathan Brouwer
07bf6ae810 Use the new parser throughout the compiler
Co-authored-by: Jana Dönszelmann <jana@donsz.nl>
2026-02-24 09:34:59 +01:00
Jonathan Brouwer
8f300d02fe Remove the Translator type 2026-02-11 17:52:00 +01:00
Jonathan Brouwer
7fbde8b9c8 Rollup merge of #152250 - JonathanBrouwer:convert_finish, r=jdonszelmann
Remove support for slugs in diagnostic messages

This PR contains 5 commits, and is best reviewed commit-by-commit:
- ea8733133c Removes support from slugs from `rustc_errors`
- 62dd37131f Removes support from slugs from `rustc_macros` (which declares `derive(Diagnostic)`)
- 2289e6cfb7 Adjuist the `ui-fulldeps` testsuite to match the changes in `rustc_macros`
- 0db0acd699 Removes support for the fallback bundle (which previously contained all messages, but is now empty) from `rustc_driver_impl` and `rustc_session`
- 81d4214604 Removes an integration test that tested the translation system using fluent
2026-02-08 19:15:25 +01:00
Jonathan Brouwer
0db0acd699 Remove the fallback bundle 2026-02-08 11:06:42 +01:00
Stuart Cook
68f4a99963 Rollup merge of #151887 - scottmcm:homogeneous-try-in-compiler, r=jackh726
Remove some unnecessary `try`-related type annotations

I left a few, like
```rust
let result: Result<_, ModError<'_>> = try {
```
where it felt like seeing it might still be useful for the reader.

Feel free to push back on any of these changes if you think they should be left alone.
2026-02-08 16:58:23 +11:00
Jonathan Brouwer
c814f76c06 Convert to inline diagnostics in rustc_lint 2026-02-07 19:34:21 +01:00
Jonathan Brouwer
9a114c686f Convert to inline diagnostics in rustc_parse 2026-02-07 10:30:40 +01:00
Jonathan Brouwer
edd43c9e1f Fix existing messages in the diag structs 2026-02-07 09:11:34 +01:00