Skip to content

Commit e319f12

Browse files
authored
Rollup merge of rust-lang#57308 - Zoxc:controller-sync, r=michaelwoerister
Make CompileController thread-safe
2 parents c89b07a + 75b2e14 commit e319f12

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/librustc_data_structures/sync.rs

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ cfg_if! {
323323
}
324324

325325
pub fn assert_sync<T: ?Sized + Sync>() {}
326+
pub fn assert_send<T: ?Sized + Send>() {}
326327
pub fn assert_send_val<T: ?Sized + Send>(_t: &T) {}
327328
pub fn assert_send_sync_val<T: ?Sized + Sync + Send>(_t: &T) {}
328329

src/librustc_driver/driver.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -402,14 +402,15 @@ pub struct CompileController<'a> {
402402

403403
/// Allows overriding default rustc query providers,
404404
/// after `default_provide` has installed them.
405-
pub provide: Box<dyn Fn(&mut ty::query::Providers) + 'a>,
405+
pub provide: Box<dyn Fn(&mut ty::query::Providers) + 'a + sync::Send>,
406406
/// Same as `provide`, but only for non-local crates,
407407
/// applied after `default_provide_extern`.
408-
pub provide_extern: Box<dyn Fn(&mut ty::query::Providers) + 'a>,
408+
pub provide_extern: Box<dyn Fn(&mut ty::query::Providers) + 'a + sync::Send>,
409409
}
410410

411411
impl<'a> CompileController<'a> {
412412
pub fn basic() -> CompileController<'a> {
413+
sync::assert_send::<Self>();
413414
CompileController {
414415
after_parse: PhaseController::basic(),
415416
after_expand: PhaseController::basic(),
@@ -499,7 +500,7 @@ pub struct PhaseController<'a> {
499500
// If true then the compiler will try to run the callback even if the phase
500501
// ends with an error. Note that this is not always possible.
501502
pub run_callback_on_error: bool,
502-
pub callback: Box<dyn Fn(&mut CompileState) + 'a>,
503+
pub callback: Box<dyn Fn(&mut CompileState) + 'a + sync::Send>,
503504
}
504505

505506
impl<'a> PhaseController<'a> {

0 commit comments

Comments
 (0)