diff options
| author | Florian Brucker <mail@florianbrucker.de> | 2025-02-15 19:44:32 +0100 |
|---|---|---|
| committer | Florian Brucker <mail@florianbrucker.de> | 2025-02-15 19:44:32 +0100 |
| commit | dce265224a7674814d4d81a81192bf9077ed2edd (patch) | |
| tree | dc1641280cd3bcaf9d809e0eb34e7e81069c5ea3 /src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs | |
| parent | 27566abd87367e374f5575f2799eac7350065350 (diff) | |
| download | rust-dce265224a7674814d4d81a81192bf9077ed2edd.tar.gz rust-dce265224a7674814d4d81a81192bf9077ed2edd.zip | |
Fix examples to work with nightly-2025-02-13
While there were comments indicating which nightly versions the examples were tested with, those versions did not work for me: neither did the examples compile, nor did they produce the expected output. This commit fixes the compilation issues, using nightly-2025-02-13 for all examples (previously the version differed between the examples) and, in the case of the `rustc_driver` examples, also fixes the argument passing: rustc ignores the first argument, so we need to pass the filename as the second (otherwise we only get the help text printed). Note that the `rustc-interface-getting-diagnostics.rs` example still does not produce any output, which I assume is not how it is intended. However, I don't know enough to fix it. To avoid inconsistencies between the documented version and the actually required version I've moved the version comment from the Markdown into the Rust code where it hopefully won't be forgotten as easily. Finally I've clarified in the examples' README that you also need to use the proper nightly version when compiling the examples, not just when running them.
Diffstat (limited to 'src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs')
| -rw-r--r-- | src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs b/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs index 2355cb85ab3..39b236e1783 100644 --- a/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs +++ b/src/doc/rustc-dev-guide/examples/rustc-interface-getting-diagnostics.rs @@ -1,3 +1,5 @@ +// Tested with nightly-2025-02-13 + #![feature(rustc_private)] extern crate rustc_data_structures; @@ -15,7 +17,7 @@ use std::sync::{Arc, Mutex}; use rustc_errors::emitter::Emitter; use rustc_errors::registry::{self, Registry}; use rustc_errors::translation::Translate; -use rustc_errors::{DiagCtxt, DiagInner, FluentBundle}; +use rustc_errors::{DiagInner, FluentBundle}; use rustc_session::config; use rustc_span::source_map::SourceMap; @@ -79,7 +81,7 @@ fn main() { expanded_args: Vec::new(), ice_file: None, hash_untracked_state: None, - using_internal_features: Arc::default(), + using_internal_features: &rustc_driver::USING_INTERNAL_FEATURES, }; rustc_interface::run_compiler(config, |compiler| { let krate = rustc_interface::passes::parse(&compiler.sess); |
