Skip to content

Commit

Permalink
fix examples for rustc 1.68.0-nightly (935dc0721 2022-12-19) (#1556) (#…
Browse files Browse the repository at this point in the history
…1557)

Co-authored-by: Yuki Okushi <jtitor@2k36.org>
Closes #1556
  • Loading branch information
gftea authored Jan 14, 2023
1 parent de053e2 commit 7352353
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 16 deletions.
3 changes: 1 addition & 2 deletions examples/rustc-driver-example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// NOTE: For the example to compile, you will need to first run the following:
// rustup component add rustc-dev llvm-tools-preview

// version: 1.62.0-nightly (7c4b47696 2022-04-30)
// version: rustc 1.68.0-nightly (935dc0721 2022-12-19)

extern crate rustc_error_codes;
extern crate rustc_errors;
Expand Down Expand Up @@ -50,7 +50,6 @@ fn main() {
output_dir: None, // Option<PathBuf>
output_file: None, // Option<PathBuf>
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
diagnostic_output: rustc_session::DiagnosticOutput::Default,
lint_caps: FxHashMap::default(), // FxHashMap<lint::LintId, lint::Level>
// 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>>
Expand Down
6 changes: 1 addition & 5 deletions examples/rustc-driver-getting-diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// NOTE: For the example to compile, you will need to first run the following:
// rustup component add rustc-dev llvm-tools-preview

// version: 1.62.0-nightly (7c4b47696 2022-04-30)
// version: rustc 1.68.0-nightly (935dc0721 2022-12-19)

extern crate rustc_error_codes;
extern crate rustc_errors;
Expand Down Expand Up @@ -65,10 +65,6 @@ fn main() {
"
.into(),
},
// Redirect the diagnostic output of the compiler to a buffer.
diagnostic_output: rustc_session::DiagnosticOutput::Raw(Box::from(DiagnosticSink(
buffer.clone(),
))),
crate_cfg: rustc_hash::FxHashSet::default(),
crate_check_cfg: CheckCfg::default(),
input_path: None,
Expand Down
3 changes: 1 addition & 2 deletions examples/rustc-driver-interacting-with-the-ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// NOTE: For the example to compile, you will need to first run the following:
// rustup component add rustc-dev llvm-tools-preview

// version: 1.62.0-nightly (7c4b47696 2022-04-30)
// version: rustc 1.68.0-nightly (935dc0721 2022-12-19)

extern crate rustc_ast_pretty;
extern crate rustc_error_codes;
Expand Down Expand Up @@ -43,7 +43,6 @@ fn main() {
"#
.to_string(),
},
diagnostic_output: rustc_session::DiagnosticOutput::Default,
crate_cfg: rustc_hash::FxHashSet::default(),
crate_check_cfg: CheckCfg::default(),
input_path: None,
Expand Down
8 changes: 2 additions & 6 deletions src/rustc-driver-getting-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
To get diagnostics from the compiler,
configure `rustc_interface::Config` to output diagnostic to a buffer,
and run `TyCtxt.analysis`. The following was tested
with <!-- date-check: June 2022 --> `nightly-2022-06-05` (See [here][example]
with <!-- date-check: Jan 2023 --> `nightly-2022-12-19` (See [here][example]
for the complete example):

[example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-getting-diagnostics.rs
Expand All @@ -24,11 +24,7 @@ let config = rustc_interface::Config {
),
},
/* other config */
},
// Redirect the diagnostic output of the compiler to a buffer.
diagnostic_output: rustc_session::DiagnosticOutput::Raw(Box::from(DiagnosticSink(
buffer.clone(),
))),
},
/* other config */
};
rustc_interface::run_compiler(config, |compiler| {
Expand Down
2 changes: 1 addition & 1 deletion src/rustc-driver-interacting-with-the-ast.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## 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: June 2022 --> `nightly-2022-06-05`
The following was tested with <!-- date-check: Jan 2023 --> `nightly-2022-12-19`
(see [here][example] for the complete example):

[example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-interacting-with-the-ast.rs
Expand Down

0 comments on commit 7352353

Please sign in to comment.