Skip to content

Commit eda4fc7

Browse files
committed
Auto merge of rust-lang#153579 - JonathanBrouwer:rollup-DFWynbC, r=JonathanBrouwer
Rollup of 6 pull requests Successful merges: - rust-lang#152535 (std: use `OnceLock` for Xous environment variables) - rust-lang#152646 (Update `UnsafeUnpin` impls involving extern types.) - rust-lang#153559 (Inline and simplify some code for saving incremental data to disk) - rust-lang#151900 (num: Separate public API from internal implementations) - rust-lang#153520 (.mailmap: fix broken line with multiple emails) - rust-lang#153573 (rustdoc-json: fix incorrect documentation for VariantKind::Struct) Failed merges: - rust-lang#153509 (Cleanup unused diagnostic emission methods - part 2)
2 parents b41f22d + 934afe3 commit eda4fc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+384
-359
lines changed

‎.mailmap‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ Ben Sago <ogham@users.noreply.github.com> <ogham@bsago.me>
8383
Ben Striegel <ben.striegel@gmail.com>
8484
Benjamin Jackman <ben@jackman.biz>
8585
Benoît Cortier <benoit.cortier@fried-world.eu>
86-
binarycat <binarycat@envs.net> lolbinarycat <dogedoge61+github@gmail.com> <dogedoge61@gmail.com>
86+
binarycat <binarycat@envs.net> lolbinarycat <dogedoge61+github@gmail.com>
87+
binarycat <binarycat@envs.net> lolbinarycat <dogedoge61@gmail.com>
8788
Bheesham Persaud <bheesham123@hotmail.com> Bheesham Persaud <bheesham.persaud@live.ca>
8889
bjorn3 <17426603+bjorn3@users.noreply.github.com> <bjorn3@users.noreply.github.com>
8990
bjorn3 <17426603+bjorn3@users.noreply.github.com> <bjorn3_gh@protonmail.com>

‎compiler/rustc_incremental/src/persist/save.rs‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::dep_graph::{
88
};
99
use rustc_middle::ty::TyCtxt;
1010
use rustc_serialize::Encodable as RustcEncodable;
11-
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
11+
use rustc_serialize::opaque::FileEncoder;
1212
use rustc_session::Session;
1313
use tracing::debug;
1414

@@ -60,13 +60,30 @@ pub(crate) fn save_dep_graph(tcx: TyCtxt<'_>) {
6060
// We execute this after `incr_comp_persist_dep_graph` for the serial compiler
6161
// to catch any potential query execution writing to the dep graph.
6262
sess.time("incr_comp_persist_result_cache", || {
63+
// The on-disk cache struct is always present in incremental mode,
64+
// even if there was no previous session.
65+
let on_disk_cache = tcx.query_system.on_disk_cache.as_ref().unwrap();
66+
67+
// For every green dep node that has a disk-cached value from the
68+
// previous session, make sure the value is loaded into the memory
69+
// cache, so that it will be serialized as part of this session.
70+
//
71+
// This reads data from the previous session, so it needs to happen
72+
// before dropping the mmap.
73+
//
74+
// FIXME(Zalathar): This step is intended to be cheap, but still does
75+
// quite a lot of work, especially in builds with few or no changes.
76+
// Can we be smarter about how we identify values that need promotion?
77+
// Can we promote values without decoding them into the memory cache?
78+
tcx.dep_graph.exec_cache_promotions(tcx);
79+
6380
// Drop the memory map so that we can remove the file and write to it.
64-
if let Some(odc) = &tcx.query_system.on_disk_cache {
65-
odc.drop_serialized_data(tcx);
66-
}
81+
on_disk_cache.close_serialized_data_mmap();
6782

68-
file_format::save_in(sess, query_cache_path, "query cache", |e| {
69-
encode_query_cache(tcx, e)
83+
file_format::save_in(sess, query_cache_path, "query cache", |encoder| {
84+
tcx.sess.time("incr_comp_serialize_result_cache", || {
85+
on_disk_cache.serialize(tcx, encoder)
86+
})
7087
});
7188
});
7289
},
@@ -132,10 +149,6 @@ fn encode_work_product_index(
132149
serialized_products.encode(encoder)
133150
}
134151

135-
fn encode_query_cache(tcx: TyCtxt<'_>, encoder: FileEncoder) -> FileEncodeResult {
136-
tcx.sess.time("incr_comp_serialize_result_cache", || tcx.serialize_query_result_cache(encoder))
137-
}
138-
139152
/// Builds the dependency graph.
140153
///
141154
/// This function creates the *staging dep-graph*. When the dep-graph is modified by a query

‎compiler/rustc_middle/src/query/on_disk_cache.rs‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,9 @@ impl OnDiskCache {
202202
}
203203
}
204204

205-
/// Execute all cache promotions and release the serialized backing Mmap.
206-
///
207-
/// Cache promotions require invoking queries, which needs to read the serialized data.
208-
/// In order to serialize the new on-disk cache, the former on-disk cache file needs to be
209-
/// deleted, hence we won't be able to refer to its memmapped data.
210-
pub fn drop_serialized_data(&self, tcx: TyCtxt<'_>) {
211-
// Load everything into memory so we can write it out to the on-disk
212-
// cache. The vast majority of cacheable query results should already
213-
// be in memory, so this should be a cheap operation.
214-
// Do this *before* we clone 'latest_foreign_def_path_hashes', since
215-
// loading existing queries may cause us to create new DepNodes, which
216-
// may in turn end up invoking `store_foreign_def_id_hash`
217-
tcx.dep_graph.exec_cache_promotions(tcx);
218-
205+
/// Release the serialized backing `Mmap`.
206+
pub fn close_serialized_data_mmap(&self) {
207+
// Obtain a write lock, and replace the mmap with None to drop it.
219208
*self.serialized_data.write() = None;
220209
}
221210

‎compiler/rustc_middle/src/ty/context.rs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use rustc_hir::lang_items::LangItem;
3838
use rustc_hir::limit::Limit;
3939
use rustc_hir::{self as hir, CRATE_HIR_ID, HirId, Node, TraitCandidate, find_attr};
4040
use rustc_index::IndexVec;
41-
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
4241
use rustc_session::Session;
4342
use rustc_session::config::CrateType;
4443
use rustc_session::cstore::{CrateStoreDyn, Untracked};
@@ -1495,10 +1494,6 @@ impl<'tcx> TyCtxt<'tcx> {
14951494
f(StableHashingContext::new(self.sess, &self.untracked))
14961495
}
14971496

1498-
pub fn serialize_query_result_cache(self, encoder: FileEncoder) -> FileEncodeResult {
1499-
self.query_system.on_disk_cache.as_ref().map_or(Ok(0), |c| c.serialize(self, encoder))
1500-
}
1501-
15021497
#[inline]
15031498
pub fn local_crate_exports_generics(self) -> bool {
15041499
// compiler-builtins has some special treatment in codegen, which can result in confusing

‎library/core/src/fmt/float.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::fmt::{Debug, Display, Formatter, LowerExp, Result, UpperExp};
22
use crate::mem::MaybeUninit;
3-
use crate::num::{flt2dec, fmt as numfmt};
3+
use crate::num::imp::{flt2dec, fmt as numfmt};
44

55
#[doc(hidden)]
66
trait GeneralFormat: PartialOrd {

‎library/core/src/fmt/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell};
66
use crate::char::EscapeDebugExtArgs;
77
use crate::hint::assert_unchecked;
88
use crate::marker::{PhantomData, PointeeSized};
9-
use crate::num::fmt as numfmt;
9+
use crate::num::imp::fmt as numfmt;
1010
use crate::ops::Deref;
1111
use crate::ptr::NonNull;
1212
use crate::{iter, mem, result, str};

‎library/core/src/fmt/num.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::fmt::NumBuffer;
44
use crate::mem::MaybeUninit;
5-
use crate::num::fmt as numfmt;
5+
use crate::num::imp::fmt as numfmt;
66
use crate::{fmt, str};
77

88
/// Formatting of integers with a non-decimal radix.

‎library/core/src/marker.rs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ use crate::pin::UnsafePinned;
4646
/// marker_impls! {
4747
/// MarkerTrait for
4848
/// u8, i8,
49-
/// {T: ?Sized} *const T,
50-
/// {T: ?Sized} *mut T,
49+
/// {T: PointeeSized} *const T,
50+
/// {T: PointeeSized} *mut T,
5151
/// {T: MarkerTrait} PhantomData<T>,
5252
/// u32,
5353
/// }
@@ -931,15 +931,15 @@ marker_impls! {
931931
pub unsafe auto trait UnsafeUnpin {}
932932

933933
#[unstable(feature = "unsafe_unpin", issue = "125735")]
934-
impl<T: ?Sized> !UnsafeUnpin for UnsafePinned<T> {}
934+
impl<T: PointeeSized> !UnsafeUnpin for UnsafePinned<T> {}
935935
marker_impls! {
936936
#[unstable(feature = "unsafe_unpin", issue = "125735")]
937937
unsafe UnsafeUnpin for
938-
{T: ?Sized} PhantomData<T>,
939-
{T: ?Sized} *const T,
940-
{T: ?Sized} *mut T,
941-
{T: ?Sized} &T,
942-
{T: ?Sized} &mut T,
938+
{T: PointeeSized} PhantomData<T>,
939+
{T: PointeeSized} *const T,
940+
{T: PointeeSized} *mut T,
941+
{T: PointeeSized} &T,
942+
{T: PointeeSized} &mut T,
943943
}
944944

945945
/// Types that do not require any pinning guarantees.

‎library/core/src/num/f16.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use crate::convert::FloatToInt;
1515
use crate::num::FpCategory;
1616
#[cfg(not(test))]
17-
use crate::num::libm;
17+
use crate::num::imp::libm;
1818
use crate::panic::const_assert;
1919
use crate::{intrinsics, mem};
2020

‎library/core/src/num/f32.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ impl f32 {
16921692
#[unstable(feature = "core_float_math", issue = "137578")]
16931693
pub mod math {
16941694
use crate::intrinsics;
1695-
use crate::num::libm;
1695+
use crate::num::imp::libm;
16961696

16971697
/// Experimental version of `floor` in `core`. See [`f32::floor`] for details.
16981698
///

0 commit comments

Comments
 (0)