Skip to content

Commit ff2ac35

Browse files
committed
Auto merge of #50686 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 13 pull requests Successful merges: - #50544 (Cleanup some dependencies) - #50545 (Made some functions in time module const) - #50550 (use fmt::Result where applicable) - #50558 (Remove all reference to DepGraph::work_products) - #50602 (Update canonicalize docs) - #50607 (Allocate Symbol strings from an arena) - #50613 (Migrate the toolstate update bot to rust-highfive) - #50624 (fs::write: Add example writing a &str) - #50634 (Do not silently truncate offsets for `read_at`/`write_at` on emscripten) - #50644 (AppVeyor: Read back trace from crash dump on failure.) - #50661 (Ignore non .rs files for tidy libcoretest) - #50663 (rustc: Allow an edition's feature on that edition) - #50667 (rustc: Only suggest deleting `extern crate` if it works) Failed merges:
2 parents c0cea75 + da79ff3 commit ff2ac35

File tree

38 files changed

+354
-277
lines changed

38 files changed

+354
-277
lines changed

appveyor.yml

+5
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ test_script:
211211
- set NO_CCACHE=1
212212
- sh src/ci/run.sh
213213

214+
on_failure:
215+
# Dump crash log
216+
- set PATH=%PATH%;"C:\Program Files (x86)\Windows Kits\10\Debuggers\X64"
217+
- if exist %LOCALAPPDATA%\CrashDumps for %%f in (%LOCALAPPDATA%\CrashDumps\*) do cdb -c "k;q" -G -z "%%f"
218+
214219
branches:
215220
only:
216221
- auto

src/Cargo.lock

+16-116
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libcore/tests/time.rs

+40-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,43 @@ fn creation() {
2323
#[test]
2424
fn secs() {
2525
assert_eq!(Duration::new(0, 0).as_secs(), 0);
26+
assert_eq!(Duration::new(0, 500_000_005).as_secs(), 0);
27+
assert_eq!(Duration::new(0, 1_050_000_001).as_secs(), 1);
2628
assert_eq!(Duration::from_secs(1).as_secs(), 1);
2729
assert_eq!(Duration::from_millis(999).as_secs(), 0);
2830
assert_eq!(Duration::from_millis(1001).as_secs(), 1);
31+
assert_eq!(Duration::from_micros(999_999).as_secs(), 0);
32+
assert_eq!(Duration::from_micros(1_000_001).as_secs(), 1);
33+
assert_eq!(Duration::from_nanos(999_999_999).as_secs(), 0);
34+
assert_eq!(Duration::from_nanos(1_000_000_001).as_secs(), 1);
35+
}
36+
37+
#[test]
38+
fn millis() {
39+
assert_eq!(Duration::new(0, 0).subsec_millis(), 0);
40+
assert_eq!(Duration::new(0, 500_000_005).subsec_millis(), 500);
41+
assert_eq!(Duration::new(0, 1_050_000_001).subsec_millis(), 50);
42+
assert_eq!(Duration::from_secs(1).subsec_millis(), 0);
43+
assert_eq!(Duration::from_millis(999).subsec_millis(), 999);
44+
assert_eq!(Duration::from_millis(1001).subsec_millis(), 1);
45+
assert_eq!(Duration::from_micros(999_999).subsec_millis(), 999);
46+
assert_eq!(Duration::from_micros(1_001_000).subsec_millis(), 1);
47+
assert_eq!(Duration::from_nanos(999_999_999).subsec_millis(), 999);
48+
assert_eq!(Duration::from_nanos(1_001_000_000).subsec_millis(), 1);
49+
}
50+
51+
#[test]
52+
fn micros() {
53+
assert_eq!(Duration::new(0, 0).subsec_micros(), 0);
54+
assert_eq!(Duration::new(0, 500_000_005).subsec_micros(), 500_000);
55+
assert_eq!(Duration::new(0, 1_050_000_001).subsec_micros(), 50_000);
56+
assert_eq!(Duration::from_secs(1).subsec_micros(), 0);
57+
assert_eq!(Duration::from_millis(999).subsec_micros(), 999_000);
58+
assert_eq!(Duration::from_millis(1001).subsec_micros(), 1_000);
59+
assert_eq!(Duration::from_micros(999_999).subsec_micros(), 999_999);
60+
assert_eq!(Duration::from_micros(1_000_001).subsec_micros(), 1);
61+
assert_eq!(Duration::from_nanos(999_999_999).subsec_micros(), 999_999);
62+
assert_eq!(Duration::from_nanos(1_000_001_000).subsec_micros(), 1);
2963
}
3064

3165
#[test]
@@ -34,8 +68,12 @@ fn nanos() {
3468
assert_eq!(Duration::new(0, 5).subsec_nanos(), 5);
3569
assert_eq!(Duration::new(0, 1_000_000_001).subsec_nanos(), 1);
3670
assert_eq!(Duration::from_secs(1).subsec_nanos(), 0);
37-
assert_eq!(Duration::from_millis(999).subsec_nanos(), 999 * 1_000_000);
38-
assert_eq!(Duration::from_millis(1001).subsec_nanos(), 1 * 1_000_000);
71+
assert_eq!(Duration::from_millis(999).subsec_nanos(), 999_000_000);
72+
assert_eq!(Duration::from_millis(1001).subsec_nanos(), 1_000_000);
73+
assert_eq!(Duration::from_micros(999_999).subsec_nanos(), 999_999_000);
74+
assert_eq!(Duration::from_micros(1_000_001).subsec_nanos(), 1000);
75+
assert_eq!(Duration::from_nanos(999_999_999).subsec_nanos(), 999_999_999);
76+
assert_eq!(Duration::from_nanos(1_000_000_001).subsec_nanos(), 1);
3977
}
4078

4179
#[test]

src/libcore/time.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,9 @@ impl Duration {
203203
///
204204
/// [`subsec_nanos`]: #method.subsec_nanos
205205
#[stable(feature = "duration", since = "1.3.0")]
206+
#[rustc_const_unstable(feature="duration_getters")]
206207
#[inline]
207-
pub fn as_secs(&self) -> u64 { self.secs }
208+
pub const fn as_secs(&self) -> u64 { self.secs }
208209

209210
/// Returns the fractional part of this `Duration`, in milliseconds.
210211
///
@@ -222,8 +223,9 @@ impl Duration {
222223
/// assert_eq!(duration.subsec_millis(), 432);
223224
/// ```
224225
#[stable(feature = "duration_extras", since = "1.27.0")]
226+
#[rustc_const_unstable(feature="duration_getters")]
225227
#[inline]
226-
pub fn subsec_millis(&self) -> u32 { self.nanos / NANOS_PER_MILLI }
228+
pub const fn subsec_millis(&self) -> u32 { self.nanos / NANOS_PER_MILLI }
227229

228230
/// Returns the fractional part of this `Duration`, in microseconds.
229231
///
@@ -241,8 +243,9 @@ impl Duration {
241243
/// assert_eq!(duration.subsec_micros(), 234_567);
242244
/// ```
243245
#[stable(feature = "duration_extras", since = "1.27.0")]
246+
#[rustc_const_unstable(feature="duration_getters")]
244247
#[inline]
245-
pub fn subsec_micros(&self) -> u32 { self.nanos / NANOS_PER_MICRO }
248+
pub const fn subsec_micros(&self) -> u32 { self.nanos / NANOS_PER_MICRO }
246249

247250
/// Returns the fractional part of this `Duration`, in nanoseconds.
248251
///
@@ -260,8 +263,9 @@ impl Duration {
260263
/// assert_eq!(duration.subsec_nanos(), 10_000_000);
261264
/// ```
262265
#[stable(feature = "duration", since = "1.3.0")]
266+
#[rustc_const_unstable(feature="duration_getters")]
263267
#[inline]
264-
pub fn subsec_nanos(&self) -> u32 { self.nanos }
268+
pub const fn subsec_nanos(&self) -> u32 { self.nanos }
265269

266270
/// Checked `Duration` addition. Computes `self + other`, returning [`None`]
267271
/// if overflow occurred.

src/librustc/dep_graph/graph.rs

+1-24
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1313
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1414
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
1515
use rustc_data_structures::small_vec::SmallVec;
16-
use rustc_data_structures::sync::{Lrc, RwLock, ReadGuard, Lock};
16+
use rustc_data_structures::sync::{Lrc, Lock};
1717
use std::env;
1818
use std::hash::Hash;
1919
use ty::{self, TyCtxt};
@@ -80,9 +80,6 @@ struct DepGraphData {
8080
/// this map. We can later look for and extract that data.
8181
previous_work_products: FxHashMap<WorkProductId, WorkProduct>,
8282

83-
/// Work-products that we generate in this run.
84-
work_products: RwLock<FxHashMap<WorkProductId, WorkProduct>>,
85-
8683
dep_node_debug: Lock<FxHashMap<DepNode, String>>,
8784

8885
// Used for testing, only populated when -Zquery-dep-graph is specified.
@@ -103,7 +100,6 @@ impl DepGraph {
103100
DepGraph {
104101
data: Some(Lrc::new(DepGraphData {
105102
previous_work_products: prev_work_products,
106-
work_products: RwLock::new(FxHashMap()),
107103
dep_node_debug: Lock::new(FxHashMap()),
108104
current: Lock::new(CurrentDepGraph::new()),
109105
previous: prev_graph,
@@ -462,19 +458,6 @@ impl DepGraph {
462458
self.data.as_ref().unwrap().previous.node_to_index(dep_node)
463459
}
464460

465-
/// Indicates that we created the given work-product in this run
466-
/// for `v`. This record will be preserved and loaded in the next
467-
/// run.
468-
pub fn insert_work_product(&self, v: &WorkProductId, data: WorkProduct) {
469-
debug!("insert_work_product({:?}, {:?})", v, data);
470-
self.data
471-
.as_ref()
472-
.unwrap()
473-
.work_products
474-
.borrow_mut()
475-
.insert(v.clone(), data);
476-
}
477-
478461
/// Check whether a previous work product exists for `v` and, if
479462
/// so, return the path that leads to it. Used to skip doing work.
480463
pub fn previous_work_product(&self, v: &WorkProductId) -> Option<WorkProduct> {
@@ -485,12 +468,6 @@ impl DepGraph {
485468
})
486469
}
487470

488-
/// Access the map of work-products created during this run. Only
489-
/// used during saving of the dep-graph.
490-
pub fn work_products(&self) -> ReadGuard<FxHashMap<WorkProductId, WorkProduct>> {
491-
self.data.as_ref().unwrap().work_products.borrow()
492-
}
493-
494471
/// Access the map of work-products created during the cached run. Only
495472
/// used during saving of the dep-graph.
496473
pub fn previous_work_products(&self) -> &FxHashMap<WorkProductId, WorkProduct> {

src/librustc/ich/fingerprint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Fingerprint {
6767
}
6868

6969
impl ::std::fmt::Display for Fingerprint {
70-
fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
70+
fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
7171
write!(formatter, "{:x}-{:x}", self.0, self.1)
7272
}
7373
}

src/librustc_data_structures/control_flow_graph/dominators/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl<Node: Idx> DominatorTree<Node> {
175175
}
176176

177177
impl<Node: Idx> fmt::Debug for DominatorTree<Node> {
178-
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
178+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
179179
fmt::Debug::fmt(&DominatorTreeNode {
180180
tree: self,
181181
node: self.root,
@@ -190,7 +190,7 @@ struct DominatorTreeNode<'tree, Node: Idx> {
190190
}
191191

192192
impl<'tree, Node: Idx> fmt::Debug for DominatorTreeNode<'tree, Node> {
193-
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
193+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
194194
let subtrees: Vec<_> = self.tree
195195
.children(self.node)
196196
.iter()

src/librustc_data_structures/owning_ref/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ impl<O, T: ?Sized> Debug for OwningRef<O, T>
10021002
where O: Debug,
10031003
T: Debug,
10041004
{
1005-
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
1005+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10061006
write!(f,
10071007
"OwningRef {{ owner: {:?}, reference: {:?} }}",
10081008
self.owner(),
@@ -1014,7 +1014,7 @@ impl<O, T: ?Sized> Debug for OwningRefMut<O, T>
10141014
where O: Debug,
10151015
T: Debug,
10161016
{
1017-
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
1017+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10181018
write!(f,
10191019
"OwningRefMut {{ owner: {:?}, reference: {:?} }}",
10201020
self.owner(),
@@ -1047,7 +1047,7 @@ unsafe impl<O, T: ?Sized> Sync for OwningRefMut<O, T>
10471047
where O: Sync, for<'a> (&'a mut T): Sync {}
10481048

10491049
impl Debug for Erased {
1050-
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
1050+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10511051
write!(f, "<Erased>",)
10521052
}
10531053
}

src/librustc_errors/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl FatalError {
232232
}
233233

234234
impl fmt::Display for FatalError {
235-
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
235+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
236236
write!(f, "parser fatal error")
237237
}
238238
}
@@ -249,7 +249,7 @@ impl error::Error for FatalError {
249249
pub struct ExplicitBug;
250250

251251
impl fmt::Display for ExplicitBug {
252-
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
252+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
253253
write!(f, "parser internal bug")
254254
}
255255
}

src/librustc_incremental/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ pub use persist::dep_graph_tcx_init;
3636
pub use persist::load_dep_graph;
3737
pub use persist::load_query_result_cache;
3838
pub use persist::LoadResult;
39+
pub use persist::copy_cgu_workproducts_to_incr_comp_cache_dir;
3940
pub use persist::save_dep_graph;
40-
pub use persist::save_trans_partition;
41-
pub use persist::save_work_products;
41+
pub use persist::save_work_product_index;
4242
pub use persist::in_incr_comp_dir;
4343
pub use persist::prepare_session_directory;
4444
pub use persist::finalize_session_directory;

src/librustc_incremental/persist/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ pub use self::load::load_dep_graph;
2929
pub use self::load::load_query_result_cache;
3030
pub use self::load::LoadResult;
3131
pub use self::save::save_dep_graph;
32-
pub use self::save::save_work_products;
33-
pub use self::work_product::save_trans_partition;
32+
pub use self::save::save_work_product_index;
33+
pub use self::work_product::copy_cgu_workproducts_to_incr_comp_cache_dir;
3434
pub use self::work_product::delete_workproduct_files;

src/librustc_incremental/persist/save.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::dep_graph::{DepGraph, DepKind};
11+
use rustc::dep_graph::{DepGraph, DepKind, WorkProduct, WorkProductId};
1212
use rustc::session::Session;
1313
use rustc::ty::TyCtxt;
1414
use rustc::util::common::time;
@@ -55,22 +55,22 @@ pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
5555
})
5656
}
5757

58-
pub fn save_work_products(sess: &Session, dep_graph: &DepGraph) {
58+
pub fn save_work_product_index(sess: &Session,
59+
dep_graph: &DepGraph,
60+
new_work_products: FxHashMap<WorkProductId, WorkProduct>) {
5961
if sess.opts.incremental.is_none() {
6062
return;
6163
}
6264

63-
debug!("save_work_products()");
65+
debug!("save_work_product_index()");
6466
dep_graph.assert_ignored();
6567
let path = work_products_path(sess);
66-
save_in(sess, path, |e| encode_work_products(dep_graph, e));
68+
save_in(sess, path, |e| encode_work_product_index(&new_work_products, e));
6769

6870
// We also need to clean out old work-products, as not all of them are
6971
// deleted during invalidation. Some object files don't change their
7072
// content, they are just not needed anymore.
71-
let new_work_products = dep_graph.work_products();
7273
let previous_work_products = dep_graph.previous_work_products();
73-
7474
for (id, wp) in previous_work_products.iter() {
7575
if !new_work_products.contains_key(id) {
7676
work_product::delete_workproduct_files(sess, wp);
@@ -234,10 +234,9 @@ fn encode_dep_graph(tcx: TyCtxt,
234234
Ok(())
235235
}
236236

237-
fn encode_work_products(dep_graph: &DepGraph,
238-
encoder: &mut Encoder) -> io::Result<()> {
239-
let work_products: Vec<_> = dep_graph
240-
.work_products()
237+
fn encode_work_product_index(work_products: &FxHashMap<WorkProductId, WorkProduct>,
238+
encoder: &mut Encoder) -> io::Result<()> {
239+
let serialized_products: Vec<_> = work_products
241240
.iter()
242241
.map(|(id, work_product)| {
243242
SerializedWorkProduct {
@@ -247,7 +246,7 @@ fn encode_work_products(dep_graph: &DepGraph,
247246
})
248247
.collect();
249248

250-
work_products.encode(encoder)
249+
serialized_products.encode(encoder)
251250
}
252251

253252
fn encode_query_cache(tcx: TyCtxt,

src/librustc_incremental/persist/work_product.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@
1111
//! This module contains files for saving intermediate work-products.
1212
1313
use persist::fs::*;
14-
use rustc::dep_graph::{WorkProduct, WorkProductId, DepGraph, WorkProductFileKind};
14+
use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind};
1515
use rustc::session::Session;
1616
use rustc::util::fs::link_or_copy;
1717
use std::path::PathBuf;
1818
use std::fs as std_fs;
1919

20-
pub fn save_trans_partition(sess: &Session,
21-
dep_graph: &DepGraph,
22-
cgu_name: &str,
23-
files: &[(WorkProductFileKind, PathBuf)]) {
24-
debug!("save_trans_partition({:?},{:?})",
20+
pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
21+
sess: &Session,
22+
cgu_name: &str,
23+
files: &[(WorkProductFileKind, PathBuf)]
24+
) -> Option<(WorkProductId, WorkProduct)> {
25+
debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})",
2526
cgu_name,
2627
files);
2728
if sess.opts.incremental.is_none() {
28-
return
29+
return None
2930
}
3031
let work_product_id = WorkProductId::from_cgu_name(cgu_name);
3132

@@ -53,16 +54,16 @@ pub fn save_trans_partition(sess: &Session,
5354
})
5455
.collect();
5556
let saved_files = match saved_files {
57+
None => return None,
5658
Some(v) => v,
57-
None => return,
5859
};
5960

6061
let work_product = WorkProduct {
6162
cgu_name: cgu_name.to_string(),
6263
saved_files,
6364
};
6465

65-
dep_graph.insert_work_product(&work_product_id, work_product);
66+
Some((work_product_id, work_product))
6667
}
6768

6869
pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {

src/librustc_lint/builtin.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,9 @@ impl LintPass for ExternCrate {
15481548

15491549
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExternCrate {
15501550
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
1551+
if !cx.tcx.features().extern_absolute_paths {
1552+
return
1553+
}
15511554
if let hir::ItemExternCrate(ref orig) = it.node {
15521555
if it.attrs.iter().any(|a| a.check_name("macro_use")) {
15531556
return

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ impl<'tcx> RegionDefinition<'tcx> {
11851185
}
11861186

11871187
impl fmt::Debug for Constraint {
1188-
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
1188+
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
11891189
write!(
11901190
formatter,
11911191
"({:?}: {:?} @ {:?}) due to {:?}",

0 commit comments

Comments
 (0)