update rustc_driver examples (#1655)
This commit is contained in:
parent
1a0aa9321a
commit
7cb957b26f
|
|
@ -45,6 +45,7 @@ fn main() {
|
||||||
output_dir: None, // Option<PathBuf>
|
output_dir: None, // Option<PathBuf>
|
||||||
output_file: None, // Option<PathBuf>
|
output_file: None, // Option<PathBuf>
|
||||||
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
|
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
|
||||||
|
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES,
|
||||||
lint_caps: FxHashMap::default(), // FxHashMap<lint::LintId, lint::Level>
|
lint_caps: FxHashMap::default(), // FxHashMap<lint::LintId, lint::Level>
|
||||||
// This is a callback from the driver that is called when [`ParseSess`] is created.
|
// This is a callback from the driver that is called when [`ParseSess`] is created.
|
||||||
parse_sess_created: None, //Option<Box<dyn FnOnce(&mut ParseSess) + Send>>
|
parse_sess_created: None, //Option<Box<dyn FnOnce(&mut ParseSess) + Send>>
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ fn main() {
|
||||||
output_dir: None,
|
output_dir: None,
|
||||||
output_file: None,
|
output_file: None,
|
||||||
file_loader: None,
|
file_loader: None,
|
||||||
|
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES,
|
||||||
lint_caps: rustc_hash::FxHashMap::default(),
|
lint_caps: rustc_hash::FxHashMap::default(),
|
||||||
parse_sess_created: None,
|
parse_sess_created: None,
|
||||||
register_lints: None,
|
register_lints: None,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
To get diagnostics from the compiler,
|
To get diagnostics from the compiler,
|
||||||
configure `rustc_interface::Config` to output diagnostic to a buffer,
|
configure `rustc_interface::Config` to output diagnostic to a buffer,
|
||||||
and run `TyCtxt.analysis`. The following was tested
|
and run `TyCtxt.analysis`. The following was tested
|
||||||
with <!-- date-check: Feb 2023 --> `nightly-2023-02-13`:
|
with <!-- date-check: mar 2023 --> `nightly-2023-03-27`:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
{{#include ../examples/rustc-driver-getting-diagnostics.rs}}
|
{{#include ../examples/rustc-driver-getting-diagnostics.rs}}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
## Getting the type of an expression
|
## Getting the type of an expression
|
||||||
|
|
||||||
To get the type of an expression, use the `global_ctxt` to get a `TyCtxt`.
|
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`:
|
The following was tested with <!-- date-check: mar 2023 --> `nightly-2023-03-27`:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
{{#include ../examples/rustc-driver-interacting-with-the-ast.rs}}
|
{{#include ../examples/rustc-driver-interacting-with-the-ast.rs}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue