From 7352353ae91c48b136d2ca7d03822e1448165e1e Mon Sep 17 00:00:00 2001 From: gftea <1705787+gftea@users.noreply.github.com> Date: Sat, 14 Jan 2023 21:34:23 +0100 Subject: [PATCH] fix examples for rustc 1.68.0-nightly (935dc0721 2022-12-19) (#1556) (#1557) Co-authored-by: Yuki Okushi Closes https://github.com/rust-lang/rustc-dev-guide/issues/1556 --- examples/rustc-driver-example.rs | 3 +-- examples/rustc-driver-getting-diagnostics.rs | 6 +----- examples/rustc-driver-interacting-with-the-ast.rs | 3 +-- src/rustc-driver-getting-diagnostics.md | 8 ++------ src/rustc-driver-interacting-with-the-ast.md | 2 +- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/examples/rustc-driver-example.rs b/examples/rustc-driver-example.rs index 4203fe96a..8d8b40cd7 100644 --- a/examples/rustc-driver-example.rs +++ b/examples/rustc-driver-example.rs @@ -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; @@ -50,7 +50,6 @@ fn main() { output_dir: None, // Option output_file: None, // Option file_loader: None, // Option> - diagnostic_output: rustc_session::DiagnosticOutput::Default, lint_caps: FxHashMap::default(), // FxHashMap // This is a callback from the driver that is called when [`ParseSess`] is created. parse_sess_created: None, //Option> diff --git a/examples/rustc-driver-getting-diagnostics.rs b/examples/rustc-driver-getting-diagnostics.rs index 1d3a4034e..49ee9ff44 100644 --- a/examples/rustc-driver-getting-diagnostics.rs +++ b/examples/rustc-driver-getting-diagnostics.rs @@ -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; @@ -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, diff --git a/examples/rustc-driver-interacting-with-the-ast.rs b/examples/rustc-driver-interacting-with-the-ast.rs index 231994a97..07b09e9df 100644 --- a/examples/rustc-driver-interacting-with-the-ast.rs +++ b/examples/rustc-driver-interacting-with-the-ast.rs @@ -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; @@ -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, diff --git a/src/rustc-driver-getting-diagnostics.md b/src/rustc-driver-getting-diagnostics.md index 5ce93c3df..bb19ad9d3 100644 --- a/src/rustc-driver-getting-diagnostics.md +++ b/src/rustc-driver-getting-diagnostics.md @@ -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 `nightly-2022-06-05` (See [here][example] +with `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 @@ -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| { diff --git a/src/rustc-driver-interacting-with-the-ast.md b/src/rustc-driver-interacting-with-the-ast.md index ce53f3861..5b495b4fe 100644 --- a/src/rustc-driver-interacting-with-the-ast.md +++ b/src/rustc-driver-interacting-with-the-ast.md @@ -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 `nightly-2022-06-05` +The following was tested with `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