Commit graph

37 commits

Author SHA1 Message Date
Tshepang Mbambo
9302f4d94f add rustfmt settings file 2025-03-30 00:31:44 +02:00
Tshepang Mbambo
471a2a8b87 example assumes a static exists
This was removed, likely by mistake, during a refactor.
2025-03-30 00:16:39 +02:00
Tshepang Mbambo
1faf7ff9a4 update rustc-{driver,interface} examples 2025-03-29 23:52:57 +02:00
Yang Lin
9a2d1fdb14 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
a4b76e31f8 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
d9683df7c2 Merge from rustc 2025-02-25 21:27:44 +00:00
Nicholas Nethercote
f86f7ad5f2 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
dce265224a 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
0a21f1d0a2 tree-wide: parallel: Fully removed all Lrc, replaced with Arc 2025-02-03 13:25:57 +03:00
bjorn3
6a566ee092 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
5dfe0f8cf4 Make crate AST mutation accessible for driver callback 2025-01-28 19:45:20 +00:00
bjorn3
a77776cc1d Remove RunCompiler
It has become nothing other than a wrapper around run_compiler.
2025-01-23 09:38:58 +00:00
bjorn3
974db1a6e4 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
1289e54d58 Rework the driver docs (#2162) 2024-12-27 20:40:32 +08:00
Vetle Rasmussen
5e73e70eaa Fix getting diagnostics example 2024-09-24 19:53:51 +02:00
Matthew Woodcraft
417afb2145 Update the rustc_interface examples for current rustc (#1974) 2024-05-11 00:06:30 +01:00
Nicholas Nethercote
cf09d77147 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
351c9f37e1 Get diagnostics directly in rustc-driver-getting-diagnostics example (#1857) 2024-01-22 04:41:55 +09:00
Shoyu Vanilla
20a0cb4762 Update examples (#1856)
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2024-01-21 22:26:41 +09:00
Timo
1e89c75aeb update rustc_driver examples (#1803) 2023-10-05 19:19:12 +09:00
Tshepang Mbambo
09c828b188 update rustc_driver examples (#1655) 2023-04-01 09:35:35 -04:00
Nathan Hammond
4bd5748f9f Add locale_resources (#1651) 2023-03-26 12:55:53 -05:00
Tshepang Mbambo
648cf5f8ac howto run the examples (#1593) 2023-02-15 11:40:25 -03:00
Hiroki Fujino
c1658f32a0 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
e04658acc1 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
370fe5964b improve rustc_interface examples a little (#1362) 2022-06-07 08:42:07 +09:00
Yuki Okushi
93771d84e0 Update rustc-driver related examples 2022-05-30 13:57:16 +02:00
Ujjawal
ede045c69d 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
81d42b558b make it compile with 1.56.0 no warning 2021-11-24 09:00:37 -05:00
Simon Perriard
5c79aa782f make it compile with 1.56.0 2021-11-24 09:00:37 -05:00
Simon Perriard
d199d090b6 make it compile with 1.56.0 2021-11-24 09:00:37 -05:00
Undxxx
2351ca9755 Update rustc-driver-*.rs examples (#1095) 2021-03-28 19:15:09 +09:00
Joshua Nelson
ad2ef2af6b Add some more examples of using the compiler 2020-11-10 20:02:56 -05:00
Takayuki Nakata
43cc8ec16f Fix examples not working 2020-08-03 08:50:58 -05:00
George Fraser
d4de7a663d Reference complete examples 2020-05-07 17:30:27 -05:00
George Fraser
6e9fd16039 run_compiler is exported by rustc_interface 2020-03-22 14:33:47 -05:00
George Fraser
ebc31a1f5f 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