Skip to content

Commit 5c43d90

Browse files
authored
Unrolled build for #159975
Rollup merge of #159975 - panstromek:simplify-debuginfos, r=davidtwco Use real ThinVec in StmtDebugInfos This is now possible, because thin vec has may_dangle Drop impl. Depends on #159974
2 parents 1ed2df6 + bbbe0e1 commit 5c43d90

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

compiler/rustc_middle/src/mir/statement.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::ops;
44

55
use rustc_data_structures::outline;
6+
use thin_vec::ThinVec;
67
use tracing::{debug, instrument};
78

89
use super::interpret::GlobalAlloc;
@@ -1041,17 +1042,15 @@ impl RawPtrKind {
10411042
}
10421043
}
10431044

1044-
// FIXME(panstromek)
1045-
// I'd like to use real ThinVec here, but it fails to borrow check,
1046-
// probably because ThinVec doesn't have #[may_dangle] on Drop impl?
1047-
type ThinVec<T> = Option<Box<Vec<T>>>;
1048-
10491045
// This collection is almost always empty, so we
10501046
// use thin representation and optimize all methods
10511047
// for that by inlining the empty check
1052-
// and outlining the rest.
1048+
// and outlining the rest. Note that Option is
1049+
// technically not needed, because empty ThinVec
1050+
// points to a static singleton, this version performed
1051+
// better in our benchmarks
10531052
#[derive(Default, Debug, Clone, TyEncodable, TyDecodable, StableHash, TypeFoldable, TypeVisitable)]
1054-
pub struct StmtDebugInfos<'tcx>(ThinVec<StmtDebugInfo<'tcx>>);
1053+
pub struct StmtDebugInfos<'tcx>(Option<ThinVec<StmtDebugInfo<'tcx>>>);
10551054

10561055
impl<'tcx> StmtDebugInfos<'tcx> {
10571056
pub fn push(&mut self, debuginfo: StmtDebugInfo<'tcx>) {
@@ -1087,9 +1086,7 @@ impl<'tcx> StmtDebugInfos<'tcx> {
10871086
if debuginfos.is_empty() {
10881087
return;
10891088
};
1090-
outline(move || {
1091-
self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap().as_mut())
1092-
});
1089+
outline(move || self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap()));
10931090
}
10941091
#[inline]
10951092
pub fn extend(&mut self, debuginfos: &Self) {

0 commit comments

Comments
 (0)