]>
Commit | Line | Data |
---|---|---|
416331ca | 1 | // run-pass |
532ac7d7 | 2 | // Test that the Callbacks interface to the compiler works. |
85aaf69f | 3 | |
d9579d0f | 4 | // ignore-cross-compile |
a1dfa0c6 | 5 | // ignore-stage1 |
f035d41b | 6 | // ignore-remote |
85aaf69f | 7 | |
b7449926 | 8 | #![feature(rustc_private)] |
85aaf69f | 9 | |
85aaf69f | 10 | extern crate rustc_driver; |
532ac7d7 | 11 | extern crate rustc_interface; |
85aaf69f | 12 | |
532ac7d7 | 13 | use rustc_interface::interface; |
85aaf69f | 14 | |
94b46f34 XL |
15 | struct TestCalls<'a> { |
16 | count: &'a mut u32 | |
85aaf69f SL |
17 | } |
18 | ||
532ac7d7 XL |
19 | impl rustc_driver::Callbacks for TestCalls<'_> { |
20 | fn config(&mut self, _config: &mut interface::Config) { | |
94b46f34 | 21 | *self.count *= 2; |
85aaf69f SL |
22 | } |
23 | } | |
24 | ||
85aaf69f | 25 | fn main() { |
94b46f34 | 26 | let mut count = 1; |
532ac7d7 | 27 | let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()]; |
e1599b0c | 28 | rustc_driver::catch_fatal_errors(|| { |
2a314972 XL |
29 | rustc_driver::RunCompiler::new(&args, &mut TestCalls { count: &mut count }).run().ok(); |
30 | }) | |
31 | .ok(); | |
532ac7d7 | 32 | assert_eq!(count, 2); |
85aaf69f | 33 | } |