diff options
Diffstat (limited to 'src/librustc_incremental')
| -rw-r--r-- | src/librustc_incremental/Cargo.toml | 4 | ||||
| -rw-r--r-- | src/librustc_incremental/assert_dep_graph.rs | 28 | ||||
| -rw-r--r-- | src/librustc_incremental/assert_module_sources.rs | 19 | ||||
| -rw-r--r-- | src/librustc_incremental/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/README.md | 4 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/data.rs | 2 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/dirty_clean.rs | 42 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/file_format.rs | 2 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/fs.rs | 8 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/load.rs | 12 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/save.rs | 23 | ||||
| -rw-r--r-- | src/librustc_incremental/persist/work_product.rs | 23 |
12 files changed, 77 insertions, 92 deletions
diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml index 09b33a6c83d..5caf1d411e6 100644 --- a/src/librustc_incremental/Cargo.toml +++ b/src/librustc_incremental/Cargo.toml @@ -13,11 +13,11 @@ doctest = false graphviz = { path = "../libgraphviz" } log = "0.4" rand = "0.7" -rustc = { path = "../librustc" } +rustc_middle = { path = "../librustc_middle" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_hir = { path = "../librustc_hir" } rustc_serialize = { path = "../libserialize", package = "serialize" } -syntax = { path = "../libsyntax" } +rustc_ast = { path = "../librustc_ast" } rustc_span = { path = "../librustc_span" } rustc_fs_util = { path = "../librustc_fs_util" } rustc_session = { path = "../librustc_session" } diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 51cc091b6c0..807ae586348 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -34,18 +34,18 @@ //! ``` use graphviz as dot; -use rustc::dep_graph::debug::{DepNodeFilter, EdgeFilter}; -use rustc::dep_graph::{DepGraphQuery, DepKind, DepNode}; -use rustc::hir::map::Map; -use rustc::ty::TyCtxt; +use rustc_ast::ast; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::graph::implementation::{Direction, NodeIndex, INCOMING, OUTGOING}; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc_span::symbol::sym; +use rustc_middle::dep_graph::debug::{DepNodeFilter, EdgeFilter}; +use rustc_middle::dep_graph::{DepGraphQuery, DepKind, DepNode, DepNodeExt}; +use rustc_middle::hir::map::Map; +use rustc_middle::ty::TyCtxt; +use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; -use syntax::ast; use std::env; use std::fs::{self, File}; @@ -68,7 +68,7 @@ pub fn assert_dep_graph(tcx: TyCtxt<'_>) { let (if_this_changed, then_this_would_need) = { let mut visitor = IfThisChanged { tcx, if_this_changed: vec![], then_this_would_need: vec![] }; - visitor.process_attrs(hir::CRATE_HIR_ID, &tcx.hir().krate().attrs); + visitor.process_attrs(hir::CRATE_HIR_ID, &tcx.hir().krate().item.attrs); tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); (visitor.if_this_changed, visitor.then_this_would_need) }; @@ -89,7 +89,7 @@ pub fn assert_dep_graph(tcx: TyCtxt<'_>) { } type Sources = Vec<(Span, DefId, DepNode)>; -type Targets = Vec<(Span, ast::Name, hir::HirId, DepNode)>; +type Targets = Vec<(Span, Symbol, hir::HirId, DepNode)>; struct IfThisChanged<'tcx> { tcx: TyCtxt<'tcx>, @@ -98,7 +98,7 @@ struct IfThisChanged<'tcx> { } impl IfThisChanged<'tcx> { - fn argument(&self, attr: &ast::Attribute) -> Option<ast::Name> { + fn argument(&self, attr: &ast::Attribute) -> Option<Symbol> { let mut value = None; for list_item in attr.meta_item_list().unwrap_or_default() { match list_item.ident() { @@ -115,12 +115,12 @@ impl IfThisChanged<'tcx> { fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) { let def_id = self.tcx.hir().local_def_id(hir_id); - let def_path_hash = self.tcx.def_path_hash(def_id); + let def_path_hash = self.tcx.def_path_hash(def_id.to_def_id()); for attr in attrs { if attr.check_name(sym::rustc_if_this_changed) { let dep_node_interned = self.argument(attr); let dep_node = match dep_node_interned { - None => def_path_hash.to_dep_node(DepKind::Hir), + None => DepNode::from_def_path_hash(def_path_hash, DepKind::hir_owner), Some(n) => match DepNode::from_label_string(&n.as_str(), def_path_hash) { Ok(n) => n, Err(()) => { @@ -131,7 +131,7 @@ impl IfThisChanged<'tcx> { } }, }; - self.if_this_changed.push((attr.span, def_id, dep_node)); + self.if_this_changed.push((attr.span, def_id.to_def_id(), dep_node)); } else if attr.check_name(sym::rustc_then_this_would_need) { let dep_node_interned = self.argument(attr); let dep_node = match dep_node_interned { @@ -162,8 +162,8 @@ impl IfThisChanged<'tcx> { impl Visitor<'tcx> for IfThisChanged<'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { - NestedVisitorMap::OnlyBodies(&self.tcx.hir()) + fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> { + NestedVisitorMap::OnlyBodies(self.tcx.hir()) } fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) { diff --git a/src/librustc_incremental/assert_module_sources.rs b/src/librustc_incremental/assert_module_sources.rs index 70abb38278a..eee6e73ed10 100644 --- a/src/librustc_incremental/assert_module_sources.rs +++ b/src/librustc_incremental/assert_module_sources.rs @@ -21,13 +21,13 @@ //! allows for doing a more fine-grained check to see if pre- or post-lto data //! was re-used. -use rustc::mir::mono::CodegenUnitNameBuilder; -use rustc::ty::TyCtxt; +use rustc_ast::ast; use rustc_hir::def_id::LOCAL_CRATE; +use rustc_middle::mir::mono::CodegenUnitNameBuilder; +use rustc_middle::ty::TyCtxt; use rustc_session::cgu_reuse_tracker::*; use rustc_span::symbol::{sym, Symbol}; use std::collections::BTreeSet; -use syntax::ast; pub fn assert_module_sources(tcx: TyCtxt<'_>) { tcx.dep_graph.with_ignore(|| { @@ -44,7 +44,7 @@ pub fn assert_module_sources(tcx: TyCtxt<'_>) { let ams = AssertModuleSource { tcx, available_cgus }; - for attr in tcx.hir().krate().attrs { + for attr in tcx.hir().krate().item.attrs { ams.check_attr(attr); } }) @@ -81,10 +81,7 @@ impl AssertModuleSource<'tcx> { if !self.tcx.sess.opts.debugging_opts.query_dep_graph { self.tcx.sess.span_fatal( attr.span, - &format!( - "found CGU-reuse attribute but `-Zquery-dep-graph` \ - was not specified" - ), + "found CGU-reuse attribute but `-Zquery-dep-graph` was not specified", ); } @@ -107,7 +104,7 @@ impl AssertModuleSource<'tcx> { } // Split of the "special suffix" if there is one. - let (user_path, cgu_special_suffix) = if let Some(index) = user_path.rfind(".") { + let (user_path, cgu_special_suffix) = if let Some(index) = user_path.rfind('.') { (&user_path[..index], Some(&user_path[index + 1..])) } else { (&user_path[..], None) @@ -150,7 +147,7 @@ impl AssertModuleSource<'tcx> { ); } - fn field(&self, attr: &ast::Attribute, name: Symbol) -> ast::Name { + fn field(&self, attr: &ast::Attribute, name: Symbol) -> Symbol { for item in attr.meta_item_list().unwrap_or_else(Vec::new) { if item.check_name(name) { if let Some(value) = item.value_str() { @@ -178,6 +175,6 @@ impl AssertModuleSource<'tcx> { return true; } debug!("check_config: no match found"); - return false; + false } } diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index ca824fde7ef..dd715c6c81d 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -6,7 +6,7 @@ #![recursion_limit = "256"] #[macro_use] -extern crate rustc; +extern crate rustc_middle; #[macro_use] extern crate log; diff --git a/src/librustc_incremental/persist/README.md b/src/librustc_incremental/persist/README.md index 8131d2840b4..b01fe219e1e 100644 --- a/src/librustc_incremental/persist/README.md +++ b/src/librustc_incremental/persist/README.md @@ -1,3 +1,3 @@ -For info on how the incremental compilation works, see the [rustc guide]. +For info on how the incremental compilation works, see the [rustc dev guide]. -[rustc guide]: https://rust-lang.github.io/rustc-guide/query.html +[rustc dev guide]: https://rustc-dev-guide.rust-lang.org/query.html diff --git a/src/librustc_incremental/persist/data.rs b/src/librustc_incremental/persist/data.rs index 49b4bb06114..ea0fd4eb7ee 100644 --- a/src/librustc_incremental/persist/data.rs +++ b/src/librustc_incremental/persist/data.rs @@ -1,6 +1,6 @@ //! The data that we will serialize and deserialize. -use rustc::dep_graph::{WorkProduct, WorkProductId}; +use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; #[derive(Debug, RustcEncodable, RustcDecodable)] pub struct SerializedWorkProduct { diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 1fa57f1ecf2..9bf992537df 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -13,9 +13,7 @@ //! Errors are reported if we are in the suitable configuration but //! the required condition is not met. -use rustc::dep_graph::{label_strs, DepNode}; -use rustc::hir::map::Map; -use rustc::ty::TyCtxt; +use rustc_ast::ast::{self, Attribute, NestedMetaItem}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; @@ -24,11 +22,13 @@ use rustc_hir::intravisit; use rustc_hir::itemlikevisit::ItemLikeVisitor; use rustc_hir::Node as HirNode; use rustc_hir::{ImplItemKind, ItemKind as HirItem, TraitItemKind}; +use rustc_middle::dep_graph::{label_strs, DepNode, DepNodeExt}; +use rustc_middle::hir::map::Map; +use rustc_middle::ty::TyCtxt; use rustc_span::symbol::{sym, Symbol}; use rustc_span::Span; use std::iter::FromIterator; use std::vec::Vec; -use syntax::ast::{self, Attribute, NestedMetaItem}; const EXCEPT: Symbol = sym::except; const LABEL: Symbol = sym::label; @@ -53,9 +53,9 @@ const BASE_FN: &[&str] = &[ /// DepNodes for Hir, which is pretty much everything const BASE_HIR: &[&str] = &[ - // Hir and HirBody should be computed for all nodes - label_strs::Hir, - label_strs::HirBody, + // hir_owner and hir_owner_nodes should be computed for all nodes + label_strs::hir_owner, + label_strs::hir_owner_nodes, ]; /// `impl` implementation of struct/trait @@ -168,7 +168,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) { // Note that we cannot use the existing "unused attribute"-infrastructure // here, since that is running before codegen. This is also the reason why - // all codegen-specific attributes are `Whitelisted` in syntax::feature_gate. + // all codegen-specific attributes are `Whitelisted` in rustc_ast::feature_gate. all_attrs.report_unchecked_attrs(&dirty_clean_visitor.checked_attrs); }) } @@ -306,7 +306,7 @@ impl DirtyCleanVisitor<'tcx> { // michaelwoerister and vitiral came up with a possible solution, // to just do this before every query // ``` - // ::rustc::ty::query::plumbing::force_from_dep_node(tcx, dep_node) + // ::rustc_middle::ty::query::plumbing::force_from_dep_node(tcx, dep_node) // ``` // // However, this did not seem to work effectively and more bugs were hit. @@ -328,12 +328,12 @@ impl DirtyCleanVisitor<'tcx> { } } HirNode::TraitItem(item) => match item.kind { - TraitItemKind::Method(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT), + TraitItemKind::Fn(..) => ("Node::TraitItem", LABELS_FN_IN_TRAIT), TraitItemKind::Const(..) => ("NodeTraitConst", LABELS_CONST_IN_TRAIT), TraitItemKind::Type(..) => ("NodeTraitType", LABELS_CONST_IN_TRAIT), }, HirNode::ImplItem(item) => match item.kind { - ImplItemKind::Method(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL), + ImplItemKind::Fn(..) => ("Node::ImplItem", LABELS_FN_IN_IMPL), ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL), ImplItemKind::TyAlias(..) => ("NodeImplType", LABELS_CONST_IN_IMPL), ImplItemKind::OpaqueTy(..) => ("NodeImplType", LABELS_CONST_IN_IMPL), @@ -343,7 +343,8 @@ impl DirtyCleanVisitor<'tcx> { &format!("clean/dirty auto-assertions not yet defined for {:?}", node), ), }; - let labels = Labels::from_iter(labels.iter().flat_map(|s| s.iter().map(|l| l.to_string()))); + let labels = + Labels::from_iter(labels.iter().flat_map(|s| s.iter().map(|l| (*l).to_string()))); (name, labels) } @@ -433,16 +434,16 @@ impl DirtyCleanVisitor<'tcx> { fn check_item(&mut self, item_id: hir::HirId, item_span: Span) { let def_id = self.tcx.hir().local_def_id(item_id); - for attr in self.tcx.get_attrs(def_id).iter() { + for attr in self.tcx.get_attrs(def_id.to_def_id()).iter() { let assertion = match self.assertion_maybe(item_id, attr) { Some(a) => a, None => continue, }; self.checked_attrs.insert(attr.id); - for dep_node in self.dep_nodes(&assertion.clean, def_id) { + for dep_node in self.dep_nodes(&assertion.clean, def_id.to_def_id()) { self.assert_clean(item_span, dep_node); } - for dep_node in self.dep_nodes(&assertion.dirty, def_id) { + for dep_node in self.dep_nodes(&assertion.dirty, def_id.to_def_id()) { self.assert_dirty(item_span, dep_node); } } @@ -498,7 +499,7 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool { } } -fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> ast::Name { +fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol { if let Some(value) = item.value_str() { value } else { @@ -537,10 +538,7 @@ impl FindAllAttrs<'tcx> { if !checked_attrs.contains(&attr.id) { self.tcx.sess.span_err( attr.span, - &format!( - "found unchecked \ - `#[rustc_dirty]` / `#[rustc_clean]` attribute" - ), + "found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute", ); } } @@ -550,8 +548,8 @@ impl FindAllAttrs<'tcx> { impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> { type Map = Map<'tcx>; - fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { - intravisit::NestedVisitorMap::All(&self.tcx.hir()) + fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> { + intravisit::NestedVisitorMap::All(self.tcx.hir()) } fn visit_attribute(&mut self, attr: &'tcx Attribute) { diff --git a/src/librustc_incremental/persist/file_format.rs b/src/librustc_incremental/persist/file_format.rs index 5c72b049d97..048a81b81ba 100644 --- a/src/librustc_incremental/persist/file_format.rs +++ b/src/librustc_incremental/persist/file_format.rs @@ -14,8 +14,8 @@ use std::fs; use std::io::{self, Read}; use std::path::Path; -use rustc::session::config::nightly_options; use rustc_serialize::opaque::Encoder; +use rustc_session::config::nightly_options; /// The first few bytes of files generated by incremental compilation. const FILE_MAGIC: &[u8] = b"RSIC"; diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index ba20006d73c..4926f726f35 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -103,11 +103,11 @@ //! unsupported file system and emit a warning in that case. This is not yet //! implemented. -use rustc::session::{CrateDisambiguator, Session}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::svh::Svh; use rustc_data_structures::{base_n, flock}; use rustc_fs_util::{link_or_copy, LinkOrCopy}; +use rustc_session::{CrateDisambiguator, Session}; use std::fs as std_fs; use std::io; @@ -152,7 +152,7 @@ pub fn lock_file_path(session_dir: &Path) -> PathBuf { let directory_name = session_dir.file_name().unwrap().to_string_lossy(); assert_no_characters_lost(&directory_name); - let dash_indices: Vec<_> = directory_name.match_indices("-").map(|(idx, _)| idx).collect(); + let dash_indices: Vec<_> = directory_name.match_indices('-').map(|(idx, _)| idx).collect(); if dash_indices.len() != 3 { bug!( "Encountered incremental compilation session directory with \ @@ -342,7 +342,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Svh) { // Keep the 's-{timestamp}-{random-number}' prefix, but replace the // '-working' part with the SVH of the crate - let dash_indices: Vec<_> = old_sub_dir_name.match_indices("-").map(|(idx, _)| idx).collect(); + let dash_indices: Vec<_> = old_sub_dir_name.match_indices('-').map(|(idx, _)| idx).collect(); if dash_indices.len() != 3 { bug!( "Encountered incremental compilation session directory with \ @@ -594,7 +594,7 @@ fn extract_timestamp_from_session_dir(directory_name: &str) -> Result<SystemTime return Err(()); } - let dash_indices: Vec<_> = directory_name.match_indices("-").map(|(idx, _)| idx).collect(); + let dash_indices: Vec<_> = directory_name.match_indices('-').map(|(idx, _)| idx).collect(); if dash_indices.len() != 3 { return Err(()); } diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index 6c57f79e1a7..99c799950c0 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -1,12 +1,12 @@ //! Code to save/load the dep-graph from files. -use rustc::dep_graph::{PreviousDepGraph, SerializedDepGraph, WorkProduct, WorkProductId}; -use rustc::session::Session; -use rustc::ty::query::OnDiskCache; -use rustc::ty::TyCtxt; use rustc_data_structures::fx::FxHashMap; +use rustc_middle::dep_graph::{PreviousDepGraph, SerializedDepGraph, WorkProduct, WorkProductId}; +use rustc_middle::ty::query::OnDiskCache; +use rustc_middle::ty::TyCtxt; use rustc_serialize::opaque::Decoder; use rustc_serialize::Decodable as RustcDecodable; +use rustc_session::Session; use std::path::Path; use super::data::*; @@ -134,7 +134,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture { for swp in work_products { let mut all_files_exist = true; - for &(_, ref file_name) in swp.work_product.saved_files.iter() { + for file_name in swp.work_product.saved_files.iter() { let path = in_incr_comp_dir_sess(sess, file_name); if !path.exists() { all_files_exist = false; @@ -195,7 +195,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture { } pub fn load_query_result_cache(sess: &Session) -> OnDiskCache<'_> { - if sess.opts.incremental.is_none() || !sess.opts.debugging_opts.incremental_queries { + if sess.opts.incremental.is_none() { return OnDiskCache::new_empty(sess.source_map()); } diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index 87f39dedd02..4db6297712c 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -1,10 +1,10 @@ -use rustc::dep_graph::{DepGraph, DepKind, WorkProduct, WorkProductId}; -use rustc::session::Session; -use rustc::ty::TyCtxt; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::join; +use rustc_middle::dep_graph::{DepGraph, DepKind, WorkProduct, WorkProductId}; +use rustc_middle::ty::TyCtxt; use rustc_serialize::opaque::Encoder; use rustc_serialize::Encodable as RustcEncodable; +use rustc_session::Session; use std::fs; use std::path::PathBuf; @@ -31,11 +31,9 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) { join( move || { - if tcx.sess.opts.debugging_opts.incremental_queries { - sess.time("incr_comp_persist_result_cache", || { - save_in(sess, query_cache_path, |e| encode_query_cache(tcx, e)); - }); - } + sess.time("incr_comp_persist_result_cache", || { + save_in(sess, query_cache_path, |e| encode_query_cache(tcx, e)); + }); }, || { sess.time("incr_comp_persist_dep_graph", || { @@ -76,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(|&(_, ref file_name)| { - !in_incr_comp_dir_sess(sess, file_name).exists() - }) + wp.saved_files + .iter() + .all(|file_name| { !in_incr_comp_dir_sess(sess, file_name).exists() }) ); } } @@ -87,7 +85,7 @@ pub fn save_work_product_index( debug_assert!({ new_work_products .iter() - .flat_map(|(_, wp)| wp.saved_files.iter().map(|&(_, ref name)| name)) + .flat_map(|(_, wp)| wp.saved_files.iter()) .map(|name| in_incr_comp_dir_sess(sess, name)) .all(|path| path.exists()) }); @@ -132,7 +130,6 @@ where } Err(err) => { sess.err(&format!("failed to write dep-graph to `{}`: {}", path_buf.display(), err)); - return; } } } diff --git a/src/librustc_incremental/persist/work_product.rs b/src/librustc_incremental/persist/work_product.rs index 65a742a202d..a15ee6d81db 100644 --- a/src/librustc_incremental/persist/work_product.rs +++ b/src/librustc_incremental/persist/work_product.rs @@ -1,34 +1,27 @@ //! This module contains files for saving intermediate work-products. use crate::persist::fs::*; -use rustc::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId}; -use rustc::session::Session; use rustc_fs_util::link_or_copy; +use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; +use rustc_session::Session; use std::fs as std_fs; use std::path::PathBuf; pub fn copy_cgu_workproducts_to_incr_comp_cache_dir( sess: &Session, cgu_name: &str, - files: &[(WorkProductFileKind, PathBuf)], + files: &[PathBuf], ) -> Option<(WorkProductId, WorkProduct)> { debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})", cgu_name, files); - if sess.opts.incremental.is_none() { - return None; - } + sess.opts.incremental.as_ref()?; let saved_files = files .iter() - .map(|&(kind, ref path)| { - let extension = match kind { - WorkProductFileKind::Object => "o", - WorkProductFileKind::Bytecode => "bc", - WorkProductFileKind::BytecodeCompressed => "bc.z", - }; - let file_name = format!("{}.{}", cgu_name, extension); + .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((kind, file_name)), + Ok(_) => Some(file_name), Err(err) => { sess.warn(&format!( "error copying object file `{}` \ @@ -50,7 +43,7 @@ pub fn copy_cgu_workproducts_to_incr_comp_cache_dir( } pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) { - for &(_, ref file_name) in &work_product.saved_files { + for file_name in &work_product.saved_files { let path = in_incr_comp_dir_sess(sess, file_name); match std_fs::remove_file(&path) { Ok(()) => {} |
