blob: d058a5838450f1a4e6f2da6d016fc05de4f44f5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
# Example: Type checking through `rustc_interface`
`rustc_interface` allows you to interact with Rust code at various stages of compilation.
## Getting the type of an expression
To get the type of an expression, use the `global_ctxt` to get a `TyCtxt`.
The following was tested with <!-- date-check: Feb 2023 --> `nightly-2023-02-13`:
```rust
{{#include ../examples/rustc-driver-interacting-with-the-ast.rs}}
```
|