Skip to content

Commit 578f05c

Browse files
Merge pull request #2769 from rust-lang/example_diagnostics
Update examples for diagnostics changes
2 parents 8a78eb2 + 8974751 commit 578f05c

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

examples/rustc-interface-example.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44

55
extern crate rustc_driver;
66
extern crate rustc_error_codes;
7-
extern crate rustc_errors;
87
extern crate rustc_hash;
98
extern crate rustc_hir;
109
extern crate rustc_interface;
1110
extern crate rustc_session;
1211
extern crate rustc_span;
1312

14-
use rustc_errors::registry;
1513
use rustc_hash::FxHashMap;
1614
use rustc_session::config;
1715

@@ -30,12 +28,11 @@ fn main() {
3028
println!("{HELLO}");
3129
}
3230
"#
33-
.into(),
31+
.into(),
3432
},
35-
output_dir: None, // Option<PathBuf>
36-
output_file: None, // Option<PathBuf>
37-
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
38-
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_owned(),
33+
output_dir: None, // Option<PathBuf>
34+
output_file: None, // Option<PathBuf>
35+
file_loader: None, // Option<Box<dyn FileLoader + Send + Sync>>
3936
lint_caps: FxHashMap::default(), // FxHashMap<lint::LintId, lint::Level>
4037
// This is a callback from the driver that is called when [`ParseSess`] is created.
4138
psess_created: None, //Option<Box<dyn FnOnce(&mut ParseSess) + Send>>
@@ -50,8 +47,6 @@ fn main() {
5047
//
5148
// The second parameter is local providers and the third parameter is external providers.
5249
override_queries: None, // Option<fn(&Session, &mut ty::query::Providers<'_>, &mut ty::query::Providers<'_>)>
53-
// Registry of diagnostics codes.
54-
registry: registry::Registry::new(rustc_errors::codes::DIAGNOSTICS),
5550
make_codegen_backend: None,
5651
expanded_args: Vec::new(),
5752
ice_file: None,
@@ -77,4 +72,4 @@ fn main() {
7772
}
7873
});
7974
});
80-
}
75+
}

examples/rustc-interface-getting-diagnostics.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern crate rustc_span;
1515
use std::sync::{Arc, Mutex};
1616

1717
use rustc_errors::emitter::Emitter;
18-
use rustc_errors::registry::{self, Registry};
18+
use rustc_errors::registry::Registry;
1919
use rustc_errors::translation::Translate;
2020
use rustc_errors::{DiagInner, FluentBundle};
2121
use rustc_session::config;
@@ -59,14 +59,13 @@ fn main() {
5959
let x: &str = 1;
6060
}
6161
"
62-
.into(),
62+
.into(),
6363
},
6464
crate_cfg: Vec::new(),
6565
crate_check_cfg: Vec::new(),
6666
output_dir: None,
6767
output_file: None,
6868
file_loader: None,
69-
locale_resources: rustc_driver::DEFAULT_LOCALE_RESOURCES.to_owned(),
7069
lint_caps: rustc_hash::FxHashMap::default(),
7170
psess_created: Some(Box::new(|parse_sess| {
7271
parse_sess.dcx().set_emitter(Box::new(DebugEmitter {
@@ -76,7 +75,6 @@ fn main() {
7675
})),
7776
register_lints: None,
7877
override_queries: None,
79-
registry: registry::Registry::new(rustc_errors::codes::DIAGNOSTICS),
8078
make_codegen_backend: None,
8179
expanded_args: Vec::new(),
8280
ice_file: None,
@@ -99,4 +97,4 @@ fn main() {
9997
buffer.lock().unwrap().iter().for_each(|diagnostic| {
10098
println!("{diagnostic:#?}");
10199
});
102-
}
100+
}

0 commit comments

Comments
 (0)