]> git.proxmox.com Git - rustc.git/blob - src/test/ui-fulldeps/compiler-calls.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.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 // 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::run_compiler(&args, &mut TestCalls { count: &mut count }, None, None).ok();
30 }).ok();
31 assert_eq!(count, 2);
32 }