Commit Graph

596 Commits

Author SHA1 Message Date
bors 2deff71719 Auto merge of #105462 - oli-obk:feeding_full, r=cjgillot,petrochenkov
give the resolver access to TyCtxt

The resolver is now created after TyCtxt is created. Then macro expansion and name resolution are run and the results fed into queries just like before this PR.

Since the resolver had (before this PR) mutable access to the `CStore` and the source span table, these two datastructures are now behind a `RwLock`. To ensure that these are not mutated anymore after the resolver is done, a read lock to them is leaked right after the resolver finishes.

### PRs split out of this one and leading up to it:

* https://github.com/rust-lang/rust/pull/105423
* https://github.com/rust-lang/rust/pull/105357
* https://github.com/rust-lang/rust/pull/105603
* https://github.com/rust-lang/rust/pull/106776
* https://github.com/rust-lang/rust/pull/106810
* https://github.com/rust-lang/rust/pull/106812
* https://github.com/rust-lang/rust/pull/108032
2023-02-21 01:19:25 +00:00
Oli Scherer 1ab14ea7c2 Remove some unnecessary tcx-passing 2023-02-20 15:28:59 +00:00
Oli Scherer acbcfaaf7b Stop passing in values that one can also get from the tcx lazily 2023-02-20 15:28:59 +00:00
Oli Scherer c3522d0637 Move the resolver into a query 2023-02-20 15:28:59 +00:00
Oli Scherer 37e2f4f487 Make configure_and_expand "infalllible" by just aborting the compilation if it fails instead of bubbling out an error 2023-02-20 15:28:59 +00:00
Oli Scherer 63c8d00090 Use tcx queries instead of passing the values to configure_and_expand. 2023-02-20 15:28:59 +00:00
Oli Scherer 4953d70e2f Stuff a TyCtxt into the Resolver 2023-02-20 15:28:59 +00:00
Oli Scherer 8f132d8549 Run the resolver after TyCtxt construction 2023-02-20 15:28:58 +00:00
Oli Scherer ade3dceb38 Make untracked.cstore lockable so that resolution can still write to it when using TyCtxt 2023-02-20 15:28:58 +00:00
Jacob Pratt 378c4ab9ab Make public API, docs algorithm-agnostic 2023-02-19 04:11:10 +00:00
Nicholas Nethercote 22a5125a36 Remove save-analysis.
Most tests involving save-analysis were removed, but I kept a few where
the `-Zsave-analysis` was an add-on to the main thing being tested,
rather than the main thing being tested.

For `x.py install`, the `rust-analysis` target has been removed.

For `x.py dist`, the `rust-analysis` target has been kept in a
degenerate form: it just produces a single file `reduced.json`
indicating that save-analysis has been removed. This is necessary for
rustup to keep working.

Closes #43606.
2023-02-16 15:14:45 +11:00
Oli Scherer 241c6a4a61 Simplify expansion logic 2023-02-14 10:01:49 +00:00
Oli Scherer d15663814b Inline the expansion query 2023-02-14 10:01:40 +00:00
Oli Scherer 21f4c0723e Remove BoxedResolver 2023-02-14 10:01:30 +00:00
Oli Scherer 43a5cc383d Separate the lifetime of the session and the arena in the resolver 2023-02-14 10:01:25 +00:00
Vadim Petrochenkov fd73d01c98 rustc_resolve: Remove Resolver::clone_output
And remove `Clone` impls and `Lrc`s that are no longer necessary
2023-02-13 00:10:15 +04:00
Matthias Krüger 11e128025a Rollup merge of #107831 - nnethercote:query-refactoring, r=oli-obk
Query refactoring

Just some cleanups I found when learning about the query system.

Best reviewed one commit at a time.

r? `@oli-obk`
2023-02-10 06:09:57 +01:00
bors a12d31d5a6 Auto merge of #102963 - ilammy:xray-basic, r=estebank
Add `-Z instrument-xray` flag

Implement MCP https://github.com/rust-lang/compiler-team/issues/561, adding `-Z instrument-xray` flag which enables XRay instrumentation in LLVM.
2023-02-10 00:02:43 +00:00
Nicholas Nethercote 243944c653 Remove QueryContext.
There is a type `QueryCtxt`, which impls the trait `QueryContext`.
Confusingly, there is another type `QueryContext`. The latter is (like
`TyCtxt`) just a pointer to a `GlobalContext`. It's not used much, e.g.
its `impl` block has a single method.

This commit removes `QueryContext`, replacing its use with direct
`GlobalCtxt` use.
2023-02-09 16:14:51 +11:00
Nicholas Nethercote f7b3e39502 Simplify tls::enter_context. 2023-02-09 15:25:45 +11:00
Oleksii Lozovskyi 0e60df9ed1 Parse "-Z instrument-xray" codegen option
Recognize all bells and whistles that LLVM's XRay pass is capable of.
The always/never settings are a bit dumb without attributes but they're
still there. The default instruction count is chosen by the compiler,
not LLVM pass. We'll do it later.
2023-02-09 12:25:21 +09:00
Oli Scherer f95b553eb4 Replace a command line flag with an env var to allow tools to initialize the tracing loggers at their own discretion 2023-02-07 16:33:03 +00:00
klensy 4f5f9f0a13 remove unused imports 2023-02-06 17:40:18 +03:00
est31 b4a20abc48 rustc_interface: remove huge error imports 2023-02-05 03:48:08 +01:00
David Wood 2575b1abc9 session: diagnostic migration lint on more fns
Apply the diagnostic migration lint to more functions on `Session`.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-01-30 17:11:35 +00:00
bors 3cdd0197e7 Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obk
Use stable metric for const eval limit instead of current terminator-based logic

This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only.

The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made).

Also see: #103877
2023-01-29 04:11:27 +00:00
Camille GILLOT 60e04d1e8c Compute generator saved locals on MIR. 2023-01-27 20:10:06 +00:00
Bryan Garza eea42733ac Replace terminator-based const eval limit
- Remove logic that limits const eval based on terminators, and use the
  stable metric instead (back edges + fn calls)
- Add unstable flag `tiny-const-eval-limit` to add UI tests that do not
  have to go up to the regular 2M step limit
2023-01-23 23:56:22 +00:00
Oli Scherer 261bbd7dba Store the gctxt instead of fetching it twice. 2023-01-23 10:35:21 +00:00
Oli Scherer bcc8b05d5c Make output_filenames a real query 2023-01-23 10:35:21 +00:00
Oli Scherer abee6137f7 Remove another unneeded use of the resolver 2023-01-23 10:18:45 +00:00
bors 56ee85274e Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstrieb
Remove some `ref` patterns from the compiler

Previous PR: https://github.com/rust-lang/rust/pull/105368

r? `@Nilstrieb`
2023-01-20 04:52:28 +00:00
Maybe Waffle 360e978437 Don't call closures immediately, use try{} blocks 2023-01-17 07:48:19 +00:00
Oli Scherer c8a0561321 Avoid one more call site to Compiler::expansion 2023-01-16 14:46:44 +00:00
Oli Scherer 9f5cd03153 Move compiler input and ouput paths into session 2023-01-16 14:46:44 +00:00
Oli Scherer 42f75f1e46 Group some commonly passed together values into a struct 2023-01-16 14:46:40 +00:00
Oli Scherer f5c601492e Remove redundant input_path field from Config 2023-01-16 08:03:06 +00:00
Oli Scherer 6b1a789fb6 remove some arguments that can also be fed at the caller side 2023-01-16 08:03:06 +00:00
Oli Scherer 9e9c871a78 Remove prepare_outputs 2023-01-16 08:03:06 +00:00
Matthias Krüger e4d0104754 Rollup merge of #106678 - Veykril:proc-macro-panic-abort, r=eholk
Warn when using panic-strategy abort for proc-macro crates

See https://github.com/rust-lang/rust/issues/82320, this simply warns for now as that seems like the best step that can be immediately taken (opposed to straight up rejecting or ignoring)
2023-01-13 19:16:43 +01:00
Matthias Krüger 96bb02f35c Rollup merge of #104645 - yukiomoto:log-backtrace-option, r=oli-obk
Add log-backtrace option to show backtraces along with logging

according to #90698, I added a compiler option, `-Zlog-backtrace=filter`, where `filter` is a module name, to show backtraces for logging without rebuilding.

resolve #90698
2023-01-13 19:16:41 +01:00
Lukas Wirth 549ece7033 Warn when using panic-strategy abort for proc-macro crates 2023-01-13 10:13:49 +01:00
Oli Scherer d36db0d2a0 Feed the features_query instead of grabbing it from the session lazily 2023-01-12 17:14:17 +00:00
Oli Scherer fbe2d5aad2 Remove output_filenames field from TyCtxt and feed the query instead 2023-01-12 17:14:17 +00:00
Oli Scherer 33b6a7790e Remove untracked_crate field and instead pass it along with the resolver. 2023-01-12 17:14:17 +00:00
Oli Scherer 194b4a2adb Feed crate_name query 2023-01-12 17:14:17 +00:00
Oli Scherer 408ae0fcb9 Feed resolutions query instead of it being a thin wrapper around an untracked field 2023-01-12 17:14:17 +00:00
Oli Scherer 58782a8842 Harden the pre-tyctxt query system against accidental recomputation 2023-01-12 09:26:28 +00:00
Yuki Omoto 4e2a3567bc Add log-backtrace option to show backtraces along with logging 2023-01-12 00:17:48 +09:00
Tomasz Miąsko 72f8d6a659 Change type of box_noalias to bool 2023-01-10 10:14:59 +01:00