File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 11# Example: Getting diagnostic through ` rustc_interface `
22
3- ` rustc_interface ` allows you to intercept diagnostics that would otherwise be printed to stderr.
3+ The [ ` rustc_interface ` ] allows you to intercept diagnostics that would
4+ otherwise be printed to stderr.
45
56## Getting diagnostics
67
78To get diagnostics from the compiler,
8- configure ` rustc_interface::Config ` to output diagnostic to a buffer,
9- and run ` TyCtxt.analysis ` . The following was tested
9+ configure [ ` rustc_interface::Config ` ] to output diagnostic to a buffer,
10+ and run [ ` TyCtxt.analysis ` ] . The following was tested
1011with <!-- date-check: jan 2024 --> ` nightly-2024-01-19 ` :
1112
1213``` rust
1314{{#include .. / examples / rustc - driver - getting - diagnostics . rs}}
1415```
16+
17+ [ `rustc_interface` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/index.html
18+ [ `rustc_interface::Config` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/struct.Config.html
19+ [ `TyCtxt.analysis` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/passes/fn.analysis.html
Original file line number Diff line number Diff line change 11# Example: Type checking through ` rustc_interface `
22
3- ` rustc_interface ` allows you to interact with Rust code at various stages of compilation.
3+ The [ ` rustc_interface ` ] allows you to interact with Rust code at various stages of compilation.
44
55## Getting the type of an expression
66
7- To get the type of an expression, use the ` global_ctxt ` to get a ` TyCtxt ` .
7+ To get the type of an expression, use the [ ` global_ctxt ` ] query to [ get] a [ ` TyCtxt ` ] .
88The following was tested with <!-- date-check: jan 2024 --> ` nightly-2024-01-19 ` :
99
1010``` rust
1111{{#include .. / examples / rustc - driver - interacting - with - the - ast . rs}}
1212```
13+ [ get ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.GlobalCtxt.html#method.enter
14+ [ `global_ctxt` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/queries/struct.Queries.html#method.global_ctxt
15+ [ `rustc_interface` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface
16+ [ `TyCtxt` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html
You can’t perform that action at this time.
0 commit comments