fix examples for rustc 1.68.0-nightly (935dc0721 2022-12-19) (#1556) (#1557)

Co-authored-by: Yuki Okushi <jtitor@2k36.org>
Closes https://github.com/rust-lang/rustc-dev-guide/issues/1556
This commit is contained in:
gftea 2023-01-14 21:34:23 +01:00 committed by GitHub
parent 589841c29d
commit c58e6d14df
5 changed files with 6 additions and 16 deletions

View File

@ -3,7 +3,7 @@
// NOTE: For the example to compile, you will need to first run the following: // NOTE: For the example to compile, you will need to first run the following:
// rustup component add rustc-dev llvm-tools-preview // 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_error_codes;
extern crate rustc_errors; extern crate rustc_errors;
@ -50,7 +50,6 @@ 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>>
diagnostic_output: rustc_session::DiagnosticOutput::Default,
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>>

View File

@ -3,7 +3,7 @@
// NOTE: For the example to compile, you will need to first run the following: // NOTE: For the example to compile, you will need to first run the following:
// rustup component add rustc-dev llvm-tools-preview // 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_error_codes;
extern crate rustc_errors; extern crate rustc_errors;
@ -65,10 +65,6 @@ fn main() {
" "
.into(), .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_cfg: rustc_hash::FxHashSet::default(),
crate_check_cfg: CheckCfg::default(), crate_check_cfg: CheckCfg::default(),
input_path: None, input_path: None,

View File

@ -3,7 +3,7 @@
// NOTE: For the example to compile, you will need to first run the following: // NOTE: For the example to compile, you will need to first run the following:
// rustup component add rustc-dev llvm-tools-preview // 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_ast_pretty;
extern crate rustc_error_codes; extern crate rustc_error_codes;
@ -43,7 +43,6 @@ fn main() {
"# "#
.to_string(), .to_string(),
}, },
diagnostic_output: rustc_session::DiagnosticOutput::Default,
crate_cfg: rustc_hash::FxHashSet::default(), crate_cfg: rustc_hash::FxHashSet::default(),
crate_check_cfg: CheckCfg::default(), crate_check_cfg: CheckCfg::default(),
input_path: None, input_path: None,

View File

@ -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: 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): for the complete example):
[example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-getting-diagnostics.rs [example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-getting-diagnostics.rs
@ -25,10 +25,6 @@ let config = rustc_interface::Config {
}, },
/* other 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 */ /* other config */
}; };
rustc_interface::run_compiler(config, |compiler| { rustc_interface::run_compiler(config, |compiler| {

View File

@ -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: 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): (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 [example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-driver-interacting-with-the-ast.rs