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

Rollup of 8 pull requests #72202

Merged
merged 19 commits into from
May 14, 2020
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
3471bc8
Fix unused_parens false positive when using binary operations
mibac138 May 4, 2020
717a7a8
Update src/test/ui/lint/issue-71290-unused-paren-binop.rs
mibac138 May 5, 2020
4b7a928
Fix unused_parens nested binary op false positive
mibac138 May 5, 2020
e7b0204
Fix hang in lexical_region_resolve
matthewjasper May 10, 2020
98d6254
Change `WorkProduct::saved_files` to an `Option`.
nnethercote May 12, 2020
2d39f5a
Warn against thread::sleep in async fn
kornelski May 12, 2020
5320bd9
add long error explanation for E0228
imogenkinsman May 12, 2020
5f93bc7
use `require_lang_item` over `unwrap`.
lcnr May 13, 2020
9001a64
add spans to `require_lang_items`
lcnr May 13, 2020
31fbf33
Clean up E0589 explanation
GuillaumeGomez May 14, 2020
f6aa161
Don't ICE on missing `Unsize` impl
doctorn May 14, 2020
b20b200
Rollup merge of #71910 - mibac138:necessary-paren, r=cuviper
Dylan-DPC May 14, 2020
2e65f7b
Rollup merge of #72087 - matthewjasper:regionck-hang, r=nikomatsakis
Dylan-DPC May 14, 2020
96caa25
Rollup merge of #72126 - nnethercote:change-WorkProduct-saved_files, …
Dylan-DPC May 14, 2020
746b8ca
Rollup merge of #72127 - jademcgough:long-error-explanation-E0228, r=…
Dylan-DPC May 14, 2020
d732aef
Rollup merge of #72141 - kornelski:dontsleep, r=joshtriplett
Dylan-DPC May 14, 2020
62f1840
Rollup merge of #72170 - lcnr:lang_item, r=oli-obk
Dylan-DPC May 14, 2020
d7f5e56
Rollup merge of #72191 - GuillaumeGomez:cleanup-e0589, r=Dylan-DPC
Dylan-DPC May 14, 2020
7b5bc61
Rollup merge of #72194 - doctorn:dispatch-from-dyn-ice, r=estebank
Dylan-DPC May 14, 2020
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
Prev Previous commit
Next Next commit
Change WorkProduct::saved_files to an Option.
Because there is at most one file.
  • Loading branch information
nnethercote committed May 12, 2020

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
commit 98d625441501aa23284a1897c4a6511a46a86ce5
14 changes: 5 additions & 9 deletions src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ use rustc_errors::{DiagnosticId, FatalError, Handler, Level};
use rustc_fs_util::link_or_copy;
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
use rustc_incremental::{
copy_cgu_workproducts_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
};
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::middle::cstore::EncodedMetadata;
@@ -465,17 +465,13 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
return work_products;
}

let _timer = sess.timer("incr_comp_copy_cgu_workproducts");
let _timer = sess.timer("copy_all_cgu_workproducts_to_incr_comp_cache_dir");

for module in compiled_modules.modules.iter().filter(|m| m.kind == ModuleKind::Regular) {
let mut files = vec![];

if let Some(ref path) = module.object {
files.push(path.clone());
}
let path = module.object.as_ref().map(|path| path.clone());

if let Some((id, product)) =
copy_cgu_workproducts_to_incr_comp_cache_dir(sess, &module.name, &files)
copy_cgu_workproduct_to_incr_comp_cache_dir(sess, &module.name, &path)
{
work_products.insert(id, product);
}
@@ -817,7 +813,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
) -> Result<WorkItemResult<B>, FatalError> {
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
let mut object = None;
for saved_file in &module.source.saved_files {
if let Some(saved_file) = module.source.saved_file {
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name));
object = Some(obj_out.clone());
let source_file = in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
2 changes: 1 addition & 1 deletion src/librustc_incremental/lib.rs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ pub mod assert_module_sources;
mod persist;

pub use assert_dep_graph::assert_dep_graph;
pub use persist::copy_cgu_workproducts_to_incr_comp_cache_dir;
pub use persist::copy_cgu_workproduct_to_incr_comp_cache_dir;
pub use persist::delete_workproduct_files;
pub use persist::dep_graph_tcx_init;
pub use persist::finalize_session_directory;
2 changes: 1 addition & 1 deletion src/librustc_incremental/persist/load.rs
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {

for swp in work_products {
let mut all_files_exist = true;
for file_name in swp.work_product.saved_files.iter() {
if let Some(ref file_name) = swp.work_product.saved_file {
let path = in_incr_comp_dir_sess(sess, file_name);
if !path.exists() {
all_files_exist = false;
2 changes: 1 addition & 1 deletion src/librustc_incremental/persist/mod.rs
Original file line number Diff line number Diff line change
@@ -21,5 +21,5 @@ pub use load::LoadResult;
pub use load::{load_dep_graph, DepGraphFuture};
pub use save::save_dep_graph;
pub use save::save_work_product_index;
pub use work_product::copy_cgu_workproducts_to_incr_comp_cache_dir;
pub use work_product::copy_cgu_workproduct_to_incr_comp_cache_dir;
pub use work_product::delete_workproduct_files;
8 changes: 4 additions & 4 deletions src/librustc_incremental/persist/save.rs
Original file line number Diff line number Diff line change
@@ -74,9 +74,9 @@ pub fn save_work_product_index(
if !new_work_products.contains_key(id) {
work_product::delete_workproduct_files(sess, wp);
debug_assert!(
wp.saved_files
.iter()
.all(|file_name| { !in_incr_comp_dir_sess(sess, file_name).exists() })
wp.saved_file.as_ref().map_or(true, |file_name| {
!in_incr_comp_dir_sess(sess, &file_name).exists()
})
);
}
}
@@ -85,7 +85,7 @@ pub fn save_work_product_index(
debug_assert!({
new_work_products
.iter()
.flat_map(|(_, wp)| wp.saved_files.iter())
.flat_map(|(_, wp)| wp.saved_file.iter())
.map(|name| in_incr_comp_dir_sess(sess, name))
.all(|path| path.exists())
});
46 changes: 22 additions & 24 deletions src/librustc_incremental/persist/work_product.rs
Original file line number Diff line number Diff line change
@@ -7,43 +7,41 @@ use rustc_session::Session;
use std::fs as std_fs;
use std::path::PathBuf;

pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
sess: &Session,
cgu_name: &str,
files: &[PathBuf],
path: &Option<PathBuf>,
) -> Option<(WorkProductId, WorkProduct)> {
debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})", cgu_name, files);
debug!("copy_cgu_workproduct_to_incr_comp_cache_dir({:?},{:?})", cgu_name, path);
sess.opts.incremental.as_ref()?;

let saved_files = files
.iter()
.map(|path| {
let file_name = format!("{}.o", cgu_name);
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
match link_or_copy(path, &path_in_incr_dir) {
Ok(_) => Some(file_name),
Err(err) => {
sess.warn(&format!(
"error copying object file `{}` \
to incremental directory as `{}`: {}",
path.display(),
path_in_incr_dir.display(),
err
));
None
}
let saved_file = if let Some(path) = path {
let file_name = format!("{}.o", cgu_name);
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
match link_or_copy(path, &path_in_incr_dir) {
Ok(_) => Some(file_name),
Err(err) => {
sess.warn(&format!(
"error copying object file `{}` to incremental directory as `{}`: {}",
path.display(),
path_in_incr_dir.display(),
err
));
return None;
}
})
.collect::<Option<Vec<_>>>()?;
}
} else {
None
};

let work_product = WorkProduct { cgu_name: cgu_name.to_string(), saved_files };
let work_product = WorkProduct { cgu_name: cgu_name.to_string(), saved_file };

let work_product_id = WorkProductId::from_cgu_name(cgu_name);
Some((work_product_id, work_product))
}

pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
for file_name in &work_product.saved_files {
if let Some(ref file_name) = work_product.saved_file {
let path = in_incr_comp_dir_sess(sess, file_name);
match std_fs::remove_file(&path) {
Ok(()) => {}
4 changes: 2 additions & 2 deletions src/librustc_query_system/dep_graph/graph.rs
Original file line number Diff line number Diff line change
@@ -860,8 +860,8 @@ impl<K: DepKind> DepGraph<K> {
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct WorkProduct {
pub cgu_name: String,
/// Saved files associated with this CGU.
pub saved_files: Vec<String>,
/// Saved file associated with this CGU.
pub saved_file: Option<String>,
}

#[derive(Clone)]