]> git.lizzy.rs Git - rust.git/blob - tests/ui-fulldeps/compiler-calls.rs
Rollup merge of #107596 - Kobzol:stage-build-timer, r=Mark-Simulacrum
[rust.git] / tests / ui-fulldeps / compiler-calls.rs
1 // run-pass
2 // Test that the Callbacks interface to the compiler works.
3
4 // ignore-cross-compile
5 // ignore-stage1
6 // ignore-remote
7
8 #![feature(rustc_private)]
9
10 extern crate rustc_driver;
11 extern crate rustc_interface;
12
13 use rustc_interface::interface;
14
15 struct TestCalls<'a> {
16     count: &'a mut u32
17 }
18
19 impl rustc_driver::Callbacks for TestCalls<'_> {
20     fn config(&mut self, _config: &mut interface::Config) {
21         *self.count *= 2;
22     }
23 }
24
25 fn main() {
26     let mut count = 1;
27     let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
28     rustc_driver::catch_fatal_errors(|| {
29         rustc_driver::RunCompiler::new(&args, &mut TestCalls { count: &mut count }).run().ok();
30     })
31     .ok();
32     assert_eq!(count, 2);
33 }