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 1
1
# Example: Getting diagnostic through ` rustc_interface `
2
2
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.
4
5
5
6
## Getting diagnostics
6
7
7
8
To 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
10
11
with <!-- date-check: jan 2024 --> ` nightly-2024-01-19 ` :
11
12
12
13
``` rust
13
14
{{#include .. / examples / rustc - driver - getting - diagnostics . rs}}
14
15
```
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 1
1
# Example: Type checking through ` rustc_interface `
2
2
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.
4
4
5
5
## Getting the type of an expression
6
6
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 ` ] .
8
8
The following was tested with <!-- date-check: jan 2024 --> ` nightly-2024-01-19 ` :
9
9
10
10
``` rust
11
11
{{#include .. / examples / rustc - driver - interacting - with - the - ast . rs}}
12
12
```
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