2019-07-26 21:54:25 +00:00
|
|
|
// run-pass
|
2018-12-08 19:30:23 +00:00
|
|
|
// Test that the Callbacks interface to the compiler works.
|
2015-01-30 08:44:27 +00:00
|
|
|
|
2015-04-22 22:20:57 +00:00
|
|
|
// ignore-cross-compile
|
2020-05-28 16:32:12 +00:00
|
|
|
// ignore-remote
|
2015-02-03 00:40:52 +00:00
|
|
|
|
2018-07-24 17:24:12 +00:00
|
|
|
#![feature(rustc_private)]
|
2015-01-30 08:44:27 +00:00
|
|
|
|
|
|
|
extern crate rustc_driver;
|
2018-12-08 19:30:23 +00:00
|
|
|
extern crate rustc_interface;
|
2015-01-30 08:44:27 +00:00
|
|
|
|
2018-12-08 19:30:23 +00:00
|
|
|
use rustc_interface::interface;
|
2015-01-30 08:44:27 +00:00
|
|
|
|
2018-05-17 18:32:09 +00:00
|
|
|
struct TestCalls<'a> {
|
|
|
|
count: &'a mut u32
|
2015-01-30 08:44:27 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 19:30:23 +00:00
|
|
|
impl rustc_driver::Callbacks for TestCalls<'_> {
|
|
|
|
fn config(&mut self, _config: &mut interface::Config) {
|
2018-05-17 18:32:09 +00:00
|
|
|
*self.count *= 2;
|
2015-01-30 08:44:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2018-05-17 18:32:09 +00:00
|
|
|
let mut count = 1;
|
2018-12-08 19:30:23 +00:00
|
|
|
let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
|
2019-05-06 11:47:58 +00:00
|
|
|
rustc_driver::catch_fatal_errors(|| {
|
2020-10-07 12:09:59 +00:00
|
|
|
rustc_driver::RunCompiler::new(&args, &mut TestCalls { count: &mut count }).run().ok();
|
|
|
|
})
|
|
|
|
.ok();
|
2018-12-08 19:30:23 +00:00
|
|
|
assert_eq!(count, 2);
|
2015-01-30 08:44:27 +00:00
|
|
|
}
|