]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/compiler-calls.rs
Rollup merge of #64812 - GuillaumeGomez:add-test-for-e0543, r=Centril
[rust.git] / src / test / 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
7 #![feature(rustc_private)]
8
9 extern crate rustc_driver;
10 extern crate rustc_interface;
11
12 use rustc_interface::interface;
13
14 struct TestCalls<'a> {
15     count: &'a mut u32
16 }
17
18 impl rustc_driver::Callbacks for TestCalls<'_> {
19     fn config(&mut self, _config: &mut interface::Config) {
20         *self.count *= 2;
21     }
22 }
23
24 fn main() {
25     let mut count = 1;
26     let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
27     rustc_driver::catch_fatal_errors(|| {
28         rustc_driver::run_compiler(&args, &mut TestCalls { count: &mut count }, None, None).ok();
29     }).ok();
30     assert_eq!(count, 2);
31 }