]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass-fulldeps/compiler-calls.rs
Auto merge of #61735 - eddyb:must-use-life, r=oli-obk
[rust.git] / src / test / run-pass-fulldeps / compiler-calls.rs
1 // Test that the Callbacks interface to the compiler works.
2
3 // ignore-cross-compile
4 // ignore-stage1
5
6 #![feature(rustc_private)]
7
8 extern crate rustc_driver;
9 extern crate rustc_interface;
10
11 use rustc_interface::interface;
12
13 struct TestCalls<'a> {
14     count: &'a mut u32
15 }
16
17 impl rustc_driver::Callbacks for TestCalls<'_> {
18     fn config(&mut self, _config: &mut interface::Config) {
19         *self.count *= 2;
20     }
21 }
22
23 fn main() {
24     let mut count = 1;
25     let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
26     rustc_driver::report_ices_to_stderr_if_any(|| {
27         rustc_driver::run_compiler(&args, &mut TestCalls { count: &mut count }, None, None).ok();
28     }).ok();
29     assert_eq!(count, 2);
30 }