Commit Graph

37 Commits

Author SHA1 Message Date
Tshepang Mbambo ed9122f534 add rustfmt settings file 2025-03-30 00:31:44 +02:00
Tshepang Mbambo eb3d07befc example assumes a static exists
This was removed, likely by mistake, during a refactor.
2025-03-30 00:16:39 +02:00
Tshepang Mbambo 550dc9b31b update rustc-{driver,interface} examples 2025-03-29 23:52:57 +02:00
Yang Lin 832299550c Following commit 401dd84 in the Rust project
(https://github.com/rust-lang/rust),
`ErrorGuaranteed` was replaced by fatal errors.
As a result, `tcx.analysis()` now aborts directly
instead of returning an error guard.
To accommodate this change, this update replaces
`tcx.analysis()` with `typeck()`
to perform type checking in the example.
2025-03-16 23:43:17 +08:00
Yang Lin 971366b58b Adapt to rust-lang/rust#136466:
Start removing `rustc_middle::hir::map::Map`

Following commit f86f7ad from pull request #136466
in the Rust project
(https://github.com/rust-lang/rust),
some methods in `Map` were moved to `TyCtxt`.
This update reimplements `rustc-drive-example.rs`,
`rustc-driver-interacting-with-the-ast.rs`,
and `rustc-interface-example.rs` using the new
versions of these methods, ensuring compatibility
with the nightly-2025-03-08 toolchain.
2025-03-16 23:27:10 +08:00
Boxy 3a4c5b0447 Merge from rustc 2025-02-25 21:27:44 +00:00
Nicholas Nethercote 35c8087bff Move some `Map` methods onto `TyCtxt`.
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17 13:21:02 +11:00
Florian Brucker 1979d85189 Fix examples to work with nightly-2025-02-13
While there were comments indicating which nightly versions the examples
were tested with, those versions did not work for me: neither did the
examples compile, nor did they produce the expected output.

This commit fixes the compilation issues, using nightly-2025-02-13 for
all examples (previously the version differed between the examples) and,
in the case of the `rustc_driver` examples, also fixes the argument
passing: rustc ignores the first argument, so we need to pass the
filename as the second (otherwise we only get the help text printed).

Note that the `rustc-interface-getting-diagnostics.rs` example still
does not produce any output, which I assume is not how it is intended.
However, I don't know enough to fix it.

To avoid inconsistencies between the documented version and the actually
required version I've moved the version comment from the Markdown into
the Rust code where it hopefully won't be forgotten as easily.

Finally I've clarified in the examples' README that you also need to use
the proper nightly version when compiling the examples, not just when
running them.
2025-02-15 19:44:32 +01:00
Askar Safin 9f683c9070 tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` 2025-02-03 13:25:57 +03:00
bjorn3 65daf3b01a Replace ParseSess::set_dcx with DiagCtxt::set_emitter
Replacing the error emitter doesn't accidentally clear the error count.
2025-02-02 16:09:39 +00:00
Mohammad Omidvar 936683c1c9 Make crate AST mutation accessible for driver callback 2025-01-28 19:45:20 +00:00
bjorn3 76f7584f6a Remove RunCompiler
It has become nothing other than a wrapper around run_compiler.
2025-01-23 09:38:58 +00:00
bjorn3 851d9a5b20 Remove set_make_codegen_backend and set_file_loader
They can both be set inside the config callback too.
2025-01-23 09:38:58 +00:00
bjorn3 e70f551db6 Rework the driver docs (#2162) 2024-12-27 20:40:32 +08:00
Vetle Rasmussen 06f9ccf1f2 Fix getting diagnostics example 2024-09-24 19:53:51 +02:00
Matthew Woodcraft 0bfce7989f Update the rustc_interface examples for current rustc (#1974) 2024-05-11 00:06:30 +01:00
Nicholas Nethercote af8bfec148 More updates for recent diagnostics changes.
A sequel to #1883, this covers diagnostic naming changes from
rust-lang/rust/pull/121489, rust-lang/rust/pull/121780, and
rust-lang/rust/pull/122132.
2024-03-12 02:12:31 +01:00
Shoyu Vanilla 4c7c97aad1 Get diagnostics directly in `rustc-driver-getting-diagnostics` example (#1857) 2024-01-22 04:41:55 +09:00
Shoyu Vanilla a51498f7ed Update examples (#1856)
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2024-01-21 22:26:41 +09:00
Timo 1b826bea1d update rustc_driver examples (#1803) 2023-10-05 19:19:12 +09:00
Tshepang Mbambo 7cb957b26f update rustc_driver examples (#1655) 2023-04-01 09:35:35 -04:00
Nathan Hammond 1a0aa9321a Add locale_resources (#1651) 2023-03-26 12:55:53 -05:00
Tshepang Mbambo c816f20abe howto run the examples (#1593) 2023-02-15 11:40:25 -03:00
Hiroki Fujino 342f72310d update examples for rustc 1.69.0-nightly (e1eaa2d5d 2023-02-06) (#1590)
Closes https://github.com/rust-lang/rustc-dev-guide/issues/1581
2023-02-09 18:56:06 +09:00
gftea c58e6d14df fix examples for rustc 1.68.0-nightly (935dc0721 2022-12-19) (#1556) (#1557)
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
Closes https://github.com/rust-lang/rustc-dev-guide/issues/1556
2023-01-15 05:34:23 +09:00
Tshepang Mbambo 6445e007fe improve rustc_interface examples a little (#1362) 2022-06-07 08:42:07 +09:00
Yuki Okushi 388142f167 Update rustc-driver related examples 2022-05-30 13:57:16 +02:00
Ujjawal 211776c627 Update examples with 1.61.0-nightly (latest version) (#1330)
Co-authored-by: Ujjawal Kumar <u.kumar@ukumar-ltmit1s.internal.salesforce.com>
2022-04-11 22:48:30 +09:00
Simon Perriard 8240b96f33 make it compile with 1.56.0 no warning 2021-11-24 09:00:37 -05:00
Simon Perriard f7192cb802 make it compile with 1.56.0 2021-11-24 09:00:37 -05:00
Simon Perriard 80eae9a303 make it compile with 1.56.0 2021-11-24 09:00:37 -05:00
Undxxx 64504ada90 Update rustc-driver-*.rs examples (#1095) 2021-03-28 19:15:09 +09:00
Joshua Nelson 95a3cfa327 Add some more examples of using the compiler 2020-11-10 20:02:56 -05:00
Takayuki Nakata f28f707be4 Fix examples not working 2020-08-03 08:50:58 -05:00
George Fraser 3a5328d4f7 Reference complete examples 2020-05-07 17:30:27 -05:00
George Fraser ea4db5371c run_compiler is exported by rustc_interface 2020-03-22 14:33:47 -05:00
George Fraser 68905c231d Example of rustc interface (#621)
* Example of rustc interface (https://internals.rust-lang.org/t/using-the-rustc-interface-crate/11982)
2020-03-22 08:26:04 +09:00