Commit graph

387 commits

Author SHA1 Message Date
bors
f836ae4e66 Auto merge of #124141 - nnethercote:rm-Nonterminal-and-TokenKind-Interpolated, r=petrochenkov
Remove `Nonterminal` and `TokenKind::Interpolated`

A third attempt at this; the first attempt was #96724 and the second was #114647.

r? `@ghost`
2025-04-14 03:56:55 +00:00
John Kåre Alsaker
927ad1659a Add a dep kind for use of the anon node with zero dependencies 2025-04-02 07:35:05 +02:00
Nicholas Nethercote
1830245a22 Remove recursion_limit increases.
These are no longer needed now that `Nonterminal` is gone.
2025-04-02 16:25:27 +11:00
John Kåre Alsaker
6ca2af6434 Use a function to create QueryStackDeferred to ensure context is Copy 2025-03-26 13:09:36 +01:00
John Kåre Alsaker
6319bb38cc Avoiding calling queries when collecting active queries 2025-03-26 09:36:36 +01:00
Matthias Krüger
43297ffc22
Rollup merge of #138581 - Zoxc:abort-handler-if-locked, r=SparrowLii
Abort in deadlock handler if we fail to get a query map

Resolving query cycles requires the complete active query map, or it may miss query cycles. We did not check that the map is completely constructed before. If there is some error collecting the map, something has gone wrong already. This adds a check to abort/panic if we fail to construct the complete map.

This can help differentiate errors from the `deadlock detected` case if constructing query map has errors in practice.

An `Option` is not used for `collect_active_jobs` as the panic handler can still make use of a partial map.
2025-03-25 18:09:05 +01:00
bors
4510e86a41 Auto merge of #138629 - Zoxc:graph-anon-hashmap, r=oli-obk
Only use the new node hashmap for anonymous nodes

This is a rebase of https://github.com/rust-lang/rust/pull/112469.

cc `@cjgillot`
2025-03-24 15:02:09 +00:00
John Kåre Alsaker
34244c1477 Address comments 2025-03-21 08:14:27 +01:00
John Kåre Alsaker
157008d711 Update comments 2025-03-21 07:37:56 +01:00
John Kåre Alsaker
077b8d5c37 Abort in deadlock handler if we fail to get a query map 2025-03-21 07:37:56 +01:00
Nicholas Nethercote
8121958fda Use -Wunused_crate_dependencies for compiler crates.
It's very useful. There are some false positives involving integration
tests in `rustc_pattern_analysis` and `rustc_serialize`. There is also a
false positive involving `rustc_driver_impl`'s
`rustc_randomized_layouts` feature. And I removed a `rustc_span` mention
in a doc comment in `rustc_log` because it wasn't integral to the
comment but caused a dev-dependency.
2025-03-20 08:59:43 +11:00
John Kåre Alsaker
68fd771bc1 Pass in dep kind names to the duplicate dep node check 2025-03-19 20:12:37 +01:00
bors
1aeb99d248 Auto merge of #122156 - Zoxc:side-effect-dep-node, r=oli-obk
Represent diagnostic side effects as dep nodes

This changes diagnostic to be tracked as a special dep node (`SideEffect`) instead of having a list of side effects associated with each dep node. `SideEffect` is always red and when forced, it emits the diagnostic and marks itself green. Each emitted diagnostic generates a new `SideEffect` with an unique dep node index.

Some implications of this:

- Diagnostic may now be emitted more than once as they can be emitted once when the `SideEffect` gets marked green and again if the task it depends on needs to be re-executed due to another node being red. It relies on deduplicating of diagnostics to avoid that.

- Anon tasks which emits diagnostics will no longer *incorrectly* be merged with other anon tasks.

- Reusing a CGU will now emit diagnostics from the task generating it.
2025-03-19 15:51:54 +00:00
bors
227690a258 Auto merge of #137011 - LuuuXXX:promote-ohos-with-host-tools, r=Amanieu
Promote ohos targets to tier2 with host tools.

### What does this PR try to resolve?

Try to promote the following [[Tier 2 without Host Tools](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-without-host-tools)](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-without-host-tools) targets to [[Tier 2 with Host Tools](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-with-host-tools)](https://doc.rust-lang.org/rustc/platform-support.html#tier-2-with-host-tools):

- `aarch64-unknown-linux-ohos`
- `armv7-unknown-linux-ohos`
- `x86_64-unknown-linux-ohos`

### More Information?

see MCP: https://github.com/rust-lang/compiler-team/issues/811

### Blockage to be solved?

- [x] Submit an MCP
- [x] Submit code of promote ohos targets
- [x] Resolve related dependencies (`measureme`)

The modified code of the measureme has been merged (see https://github.com/rust-lang/measureme/pull/238). [done]
The new version will was released (https://github.com/rust-lang/measureme/pull/240). [done]
2025-03-16 18:42:18 +00:00
Michael Goulet
19c84c8812 Move codec module back into middle 2025-03-15 06:42:48 +00:00
John Kåre Alsaker
453b51a65a Rename QuerySideEffects to QuerySideEffect 2025-03-14 18:39:27 +01:00
John Kåre Alsaker
3ca5220114 Represent diagnostic side effects as dep nodes 2025-03-14 16:01:58 +01:00
bors
249cb84316 Auto merge of #138414 - matthiaskrgr:rollup-9ablqdb, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #137314 (change definitely unproductive cycles to error)
 - #137701 (Convert `ShardedHashMap` to use `hashbrown::HashTable`)
 - #138269 (uefi: fs: Implement FileType, FilePermissions and FileAttr)
 - #138331 (Use `RUSTC_LINT_FLAGS` more)
 - #138345 (Some autodiff cleanups)
 - #138387 (intrinsics: remove unnecessary leading underscore from argument names)
 - #138390 (fix incorrect tracing log)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-12 17:27:43 +00:00
Nicholas Nethercote
ff0a5fe975 Remove #![warn(unreachable_pub)] from all compiler/ crates.
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-11 13:14:21 +11:00
许杰友 Jieyou Xu (Joe)
063ef18fdc Revert "Use workspace lints for crates in compiler/ #138084"
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to
consider options that avoids breaking downstream usages of cargo on
distributed `rustc-src` artifacts, where such cargo invocations fail due
to inability to inherit `lints` from workspace root manifest's
`workspace.lints` (this is only valid for the source rust-lang/rust
workspace, but not really the distributed `rustc-src` artifacts).

This breakage was reported in
<https://github.com/rust-lang/rust/issues/138304>.

This reverts commit 48caf81484, reversing
changes made to c6662879b2.
2025-03-10 18:12:47 +08:00
Nicholas Nethercote
8a3e03392e Remove #![warn(unreachable_pub)] from all compiler/ crates.
(Except for `rustc_codegen_cranelift`.)

It's no longer necessary now that `unreachable_pub` is in the workspace
lints.
2025-03-08 08:41:43 +11:00
Nicholas Nethercote
beba32cebb Specify rust lints for compiler/ crates via Cargo.
By naming them in `[workspace.lints.rust]` in the top-level
`Cargo.toml`, and then making all `compiler/` crates inherit them with
`[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`,
because they're a bit different.)

The advantages of this over the current approach:
- It uses a standard Cargo feature, rather than special handling in
  bootstrap. So, easier to understand, and less likely to get
  accidentally broken in the future.
- It works for proc macro crates.

It's a shame it doesn't work for rustc-specific lints, as the comments
explain.
2025-03-08 08:41:09 +11:00
Nicholas Nethercote
293fe0a966 Increase recursion_limit in numerous crates.
This is temporarily needed for `x doc compiler` to work. They can be
removed once the `Nonterminal` is removed (#124141).
2025-03-07 14:51:07 +11:00
LuuuXXX
7279acf202 use measureme-12.0.1 2025-03-04 17:13:46 +08:00
LuuuXXX
6324b39873 promote ohos targets to tier to with host tools 2025-03-04 17:13:46 +08:00
Jana Dönszelmann
dbd3b7928e
Introduce new parsing infrastructure and types for parsed attributes
fixup docs in parser
2025-02-24 14:26:06 +01:00
Michael Goulet
76d341fa09 Upgrade the compiler to edition 2024 2025-02-22 00:01:48 +00:00
Ben Kimock
4cf21866e8 Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer 2025-02-16 16:18:30 -05:00
David Venhoek
62bbaa8091 Removed dependency on the field-offset crate. 2025-02-05 17:56:06 +01:00
Nicholas Nethercote
e661514bda Remove hook calling via TyCtxtAt.
All hooks receive a `TyCtxtAt` argument.

Currently hooks can be called through `TyCtxtAt` or `TyCtxt`. In the
latter case, a `TyCtxtAt` is constructed with a dummy span and passed to
the hook.

However, in practice hooks are never called through `TyCtxtAt`, and
always receive a dummy span. (I confirmed this via code inspection, and
double-checked it by temporarily making the `TyCtxtAt` code path panic
and running all the tests.)

This commit removes all the `TyCtxtAt` machinery for hooks. All hooks
now receive `TyCtxt` instead of `TyCtxtAt`. There are two existing hooks
that use `TyCtxtAt::span`: `const_caller_location_provider` and
`try_destructure_mir_constant_for_user_output`. For both hooks the span
is always a dummy span, probably unintentionally. This dummy span use is
now explicit. If a non-dummy span is needed for these two hooks it would
be easy to add it as an extra argument because hooks are less
constrained than queries.
2025-02-03 17:02:33 +11:00
Martin Zacho
66c9a59a14 don't return an Option from try_find_dep_kind 2025-01-07 21:57:00 +01:00
Martin Zacho
38e10e5619 improve diagnostics for const eval query overflow 2025-01-06 09:43:05 +01:00
Michael Goulet
efb66e7e38 Rename ty_def_id so people will stop using it by accident 2024-12-13 16:36:38 +00:00
bjorn3
84873f8613 Remove 'tcx lifetime from OnDiskCache 2024-12-06 18:41:50 +00:00
Matthias Krüger
af1ca153d4
Rollup merge of #132410 - bjorn3:yet_another_driver_refactor_round, r=cjgillot
Some more refactorings towards removing driver queries

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

## Custom driver breaking change

The `after_analysis` callback is changed to accept `TyCtxt` instead of `Queries`. The only safe query in `Queries` to call at this point is `global_ctxt()` which allows you to enter the `TyCtxt` either way. To fix your custom driver, replace the `queries: &'tcx Queries<'tcx>` argument with `tcx: TyCtxt<'tcx>` and remove your `queries.global_ctxt().unwrap().enter(|tcx| { ... })` call and only keep the contents of the closure.

## Custom driver deprecation

The `after_crate_root_parsing` callback is now deprecated. Several custom drivers are incorrectly calling `queries.global_ctxt()` from inside of it, which causes some driver code to be skipped. As such I would like to either remove it in the future or if custom drivers still need it, change it to accept an `&rustc_ast::Crate` instead.
2024-11-27 22:23:24 +01:00
Noratrieb
505b8e1332 Delete the cfg(not(parallel)) serial compiler
Since it's inception a long time ago, the parallel compiler and its cfgs
have been a maintenance burden. This was a necessary evil the allow
iteration while not degrading performance because of synchronization
overhead.

But this time is over. Thanks to the amazing work by the parallel
working group (and the dyn sync crimes), the parallel compiler has now
been fast enough to be shipped by default in nightly for quite a while
now.
Stable and beta have still been on the serial compiler, because they
can't use `-Zthreads` anyways.
But this is quite suboptimal:
- the maintenance burden still sucks
- we're not testing the serial compiler in nightly

Because of these reasons, it's time to end it. The serial compiler has
served us well in the years since it was split from the parallel one,
but it's over now.

Let the knight slay one head of the two-headed dragon!
2024-11-12 13:38:58 +00:00
bjorn3
8e9bbc899c Move some code from Compiler::enter to GlobalCtxt::finish 2024-11-09 17:55:39 +00:00
ismailarilik
83d0d9f292 Handle rustc_query_impl cases of rustc::potential_query_instability lint 2024-10-03 12:47:08 +03:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Nicholas Nethercote
8d32578fe1 Rename and reorder lots of lifetimes.
- Replace non-standard names like 's, 'p, 'rg, 'ck, 'parent, 'this, and
  'me with vanilla 'a. These are cases where the original name isn't
  really any more informative than 'a.
- Replace names like 'cx, 'mir, and 'body with vanilla 'a when the lifetime
  applies to multiple fields and so the original lifetime name isn't
  really accurate.
- Put 'tcx last in lifetime lists, and 'a before 'b.
2024-09-13 15:46:20 +10:00
Nicholas Nethercote
2eea2d2cf1 Add warn(unreachable_pub) to rustc_query_impl. 2024-08-29 20:18:44 +10:00
Michael Goulet
0b2525c787 Simplify some redundant field names 2024-08-21 01:31:42 -04:00
Felix Rath
2bf2455925 Prevent double panic in query system, improve diagnostics 2024-08-19 17:42:42 +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
Oli Scherer
393dea8bc3 Allow tracing through item_bounds query invocations on opaques
Previously these caused cycles when printing the result
2024-06-19 08:47:55 +00: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
Nicholas Nethercote
29629d0075 Remove some unused crate dependencies.
I found these by setting the `unused_crate_dependencies` lint
temporarily to `Warn`.
2024-06-10 19:55:49 +10:00
Nicholas Nethercote
573aa9f677 Remove extern crate rustc_middle from rustc_query_impl. 2024-05-13 08:20:18 +10:00
Nicholas Nethercote
b68b92041c Simplify use crate::rustc_foo::bar occurrences.
They can just be written as `use rustc_foo::bar`, which is far more
standard. (I didn't even know that a `crate::` prefix was valid.)
2024-05-08 16:57:31 +10:00
Markus Reiter
33e68aadc9
Stabilize generic NonZero. 2024-04-22 18:48:47 +02:00