Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CompileController thread-safe #57308

Merged
merged 1 commit into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustc_data_structures/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ cfg_if! {
}

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

Expand Down
7 changes: 4 additions & 3 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,14 +403,15 @@ pub struct CompileController<'a> {

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

impl<'a> CompileController<'a> {
pub fn basic() -> CompileController<'a> {
sync::assert_send::<Self>();
CompileController {
after_parse: PhaseController::basic(),
after_expand: PhaseController::basic(),
Expand Down Expand Up @@ -500,7 +501,7 @@ pub struct PhaseController<'a> {
// If true then the compiler will try to run the callback even if the phase
// ends with an error. Note that this is not always possible.
pub run_callback_on_error: bool,
pub callback: Box<dyn Fn(&mut CompileState) + 'a>,
pub callback: Box<dyn Fn(&mut CompileState) + 'a + sync::Send>,
}

impl<'a> PhaseController<'a> {
Expand Down