Skip to content

Commit 885c7df

Browse files
committed
Auto merge of #61418 - Centril:rollup-yvj33a1, r=Centril
Rollup of 8 pull requests Successful merges: - #60729 (Expand dynamic drop tests for cases in #47949) - #61263 (Don't generate div inside header (h4/h3/h...) elements) - #61364 (Stabilize reverse_bits feature) - #61375 (Make "panic did not include expected string" message consistent) - #61387 (Remove ty::BrFresh and RegionConstraintCollector::new_bound) - #61389 (Remove GlobalArenas and use Arena instead) - #61391 (Doc comment fixes for `rustc::mir::interpret::InterpretCx`) - #61403 (Remove unnecessary `-Z continue-parse-after-error` from tests) Failed merges: r? @ghost
2 parents 8b40a18 + 23de376 commit 885c7df

File tree

106 files changed

+295
-364
lines changed

Some content is hidden

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

106 files changed

+295
-364
lines changed

src/libcore/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
#![feature(const_str_len)]
121121
#![feature(const_int_conversion)]
122122
#![feature(const_transmute)]
123-
#![feature(reverse_bits)]
124123
#![feature(non_exhaustive)]
125124
#![feature(structural_match)]
126125
#![feature(abi_unadjusted)]

src/libcore/num/mod.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,12 @@ assert_eq!(m, ", $swapped, ");
463463
Basic usage:
464464
465465
```
466-
#![feature(reverse_bits)]
467-
468466
let n = ", $swap_op, stringify!($SelfT), ";
469467
let m = n.reverse_bits();
470468
471469
assert_eq!(m, ", $reversed, ");
472470
```"),
473-
#[unstable(feature = "reverse_bits", issue = "48763")]
474-
#[rustc_const_unstable(feature = "const_int_conversion")]
471+
#[stable(feature = "reverse_bits", since = "1.37.0")]
475472
#[inline]
476473
#[must_use]
477474
pub const fn reverse_bits(self) -> Self {
@@ -2514,14 +2511,12 @@ assert_eq!(m, ", $swapped, ");
25142511
Basic usage:
25152512
25162513
```
2517-
#![feature(reverse_bits)]
2518-
25192514
let n = ", $swap_op, stringify!($SelfT), ";
25202515
let m = n.reverse_bits();
25212516
25222517
assert_eq!(m, ", $reversed, ");
25232518
```"),
2524-
#[unstable(feature = "reverse_bits", issue = "48763")]
2519+
#[stable(feature = "reverse_bits", since = "1.37.0")]
25252520
#[inline]
25262521
#[must_use]
25272522
pub const fn reverse_bits(self) -> Self {

src/libcore/num/wrapping.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ assert_eq!(n.trailing_zeros(), 3);
511511
/// Basic usage:
512512
///
513513
/// ```
514-
/// #![feature(reverse_bits)]
515514
/// use std::num::Wrapping;
516515
///
517516
/// let n = Wrapping(0b0000000_01010101i16);
@@ -522,7 +521,7 @@ assert_eq!(n.trailing_zeros(), 3);
522521
/// assert_eq!(m.0 as u16, 0b10101010_00000000);
523522
/// assert_eq!(m, Wrapping(-22016));
524523
/// ```
525-
#[unstable(feature = "reverse_bits", issue = "48763")]
524+
#[stable(feature = "reverse_bits", since = "1.37.0")]
526525
#[inline]
527526
#[must_use]
528527
pub const fn reverse_bits(self) -> Self {

src/libcore/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#![feature(test)]
2525
#![feature(trusted_len)]
2626
#![feature(try_trait)]
27-
#![feature(reverse_bits)]
2827
#![feature(inner_deref)]
2928
#![feature(slice_internals)]
3029
#![feature(slice_partition_dedup)]

src/librustc/arena.rs

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ use smallvec::SmallVec;
1919
macro_rules! arena_types {
2020
($macro:path, $args:tt, $tcx:lifetime) => (
2121
$macro!($args, [
22+
[] layouts: rustc::ty::layout::LayoutDetails,
23+
[] generics: rustc::ty::Generics,
24+
[] trait_def: rustc::ty::TraitDef,
25+
[] adt_def: rustc::ty::AdtDef,
26+
[] steal_mir: rustc::ty::steal::Steal<rustc::mir::Body<$tcx>>,
27+
[] mir: rustc::mir::Body<$tcx>,
28+
[] tables: rustc::ty::TypeckTables<$tcx>,
29+
[] const_allocs: rustc::mir::interpret::Allocation,
2230
[] vtable_method: Option<(
2331
rustc::hir::def_id::DefId,
2432
rustc::ty::subst::SubstsRef<$tcx>

src/librustc/ich/impls_ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ for ty::RegionKind {
100100
ty::ReClosureBound(vid) => {
101101
vid.hash_stable(hcx, hasher);
102102
}
103-
ty::ReLateBound(..) |
104103
ty::ReVar(..) |
105104
ty::RePlaceholder(..) => {
106105
bug!("StableHasher: unexpected region {:?}", *self)

src/librustc/infer/error_reporting/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
218218
format!("the anonymous lifetime #{} defined on", idx + 1),
219219
self.hir().span_by_hir_id(node),
220220
),
221-
ty::BrFresh(_) => (
222-
"an anonymous lifetime defined on".to_owned(),
223-
self.hir().span_by_hir_id(node),
224-
),
225221
_ => (
226222
format!("the lifetime {} as defined on", region),
227223
cm.def_span(self.hir().span_by_hir_id(node)),

src/librustc/infer/region_constraints/mod.rs

+2-40
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use rustc_data_structures::indexed_vec::IndexVec;
1111
use rustc_data_structures::unify as ut;
1212
use crate::ty::ReStatic;
1313
use crate::ty::{self, Ty, TyCtxt};
14-
use crate::ty::{BrFresh, ReLateBound, ReVar};
14+
use crate::ty::{ReLateBound, ReVar};
1515
use crate::ty::{Region, RegionVid};
1616

1717
use std::collections::BTreeMap;
18-
use std::{cmp, fmt, mem, u32};
18+
use std::{cmp, fmt, mem};
1919
use std::ops::Range;
2020

2121
mod leak_check;
@@ -37,10 +37,6 @@ pub struct RegionConstraintCollector<'tcx> {
3737
/// exist). This prevents us from making many such regions.
3838
glbs: CombineMap<'tcx>,
3939

40-
/// Global counter used during the GLB algorithm to create unique
41-
/// names for fresh bound regions
42-
bound_count: u32,
43-
4440
/// The undo log records actions that might later be undone.
4541
///
4642
/// Note: `num_open_snapshots` is used to track if we are actively
@@ -392,7 +388,6 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
392388
data,
393389
lubs,
394390
glbs,
395-
bound_count: _,
396391
undo_log: _,
397392
num_open_snapshots: _,
398393
unification_table,
@@ -579,39 +574,6 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
579574
}
580575
}
581576

582-
pub fn new_bound(
583-
&mut self,
584-
tcx: TyCtxt<'_, '_, 'tcx>,
585-
debruijn: ty::DebruijnIndex,
586-
) -> Region<'tcx> {
587-
// Creates a fresh bound variable for use in GLB computations.
588-
// See discussion of GLB computation in the large comment at
589-
// the top of this file for more details.
590-
//
591-
// This computation is potentially wrong in the face of
592-
// rollover. It's conceivable, if unlikely, that one might
593-
// wind up with accidental capture for nested functions in
594-
// that case, if the outer function had bound regions created
595-
// a very long time before and the inner function somehow
596-
// wound up rolling over such that supposedly fresh
597-
// identifiers were in fact shadowed. For now, we just assert
598-
// that there is no rollover -- eventually we should try to be
599-
// robust against this possibility, either by checking the set
600-
// of bound identifiers that appear in a given expression and
601-
// ensure that we generate one that is distinct, or by
602-
// changing the representation of bound regions in a fn
603-
// declaration
604-
605-
let sc = self.bound_count;
606-
self.bound_count = sc + 1;
607-
608-
if sc >= self.bound_count {
609-
bug!("rollover in RegionInference new_bound()");
610-
}
611-
612-
tcx.mk_region(ReLateBound(debruijn, BrFresh(sc)))
613-
}
614-
615577
fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
616578
// cannot add constraints once regions are resolved
617579
debug!(

src/librustc/query/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ rustc_queries! {
4242
load_cached(tcx, id) {
4343
let generics: Option<ty::Generics> = tcx.queries.on_disk_cache
4444
.try_load_query_result(tcx, id);
45-
generics.map(|x| tcx.alloc_generics(x))
45+
generics.map(|x| &*tcx.arena.alloc(x))
4646
}
4747
}
4848

@@ -118,7 +118,7 @@ rustc_queries! {
118118
load_cached(tcx, id) {
119119
let mir: Option<crate::mir::Body<'tcx>> = tcx.queries.on_disk_cache
120120
.try_load_query_result(tcx, id);
121-
mir.map(|x| tcx.alloc_mir(x))
121+
mir.map(|x| &*tcx.arena.alloc(x))
122122
}
123123
}
124124
}
@@ -353,7 +353,7 @@ rustc_queries! {
353353
.queries.on_disk_cache
354354
.try_load_query_result(tcx, id);
355355

356-
typeck_tables.map(|tables| tcx.alloc_tables(tables))
356+
typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
357357
}
358358
}
359359
}

src/librustc/ty/context.rs

+10-46
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use smallvec::SmallVec;
5353
use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
5454
StableHasher, StableHasherResult,
5555
StableVec};
56-
use arena::{TypedArena, SyncDroplessArena};
56+
use arena::SyncDroplessArena;
5757
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
5858
use rustc_data_structures::sync::{Lrc, Lock, WorkerLocal};
5959
use std::any::Any;
@@ -79,37 +79,18 @@ use syntax_pos::Span;
7979

8080
use crate::hir;
8181

82-
pub struct AllArenas<'tcx> {
83-
pub global: WorkerLocal<GlobalArenas<'tcx>>,
82+
pub struct AllArenas {
8483
pub interner: SyncDroplessArena,
8584
}
8685

87-
impl<'tcx> AllArenas<'tcx> {
86+
impl AllArenas {
8887
pub fn new() -> Self {
8988
AllArenas {
90-
global: WorkerLocal::new(|_| GlobalArenas::default()),
9189
interner: SyncDroplessArena::default(),
9290
}
9391
}
9492
}
9593

96-
/// Internal storage
97-
#[derive(Default)]
98-
pub struct GlobalArenas<'tcx> {
99-
// internings
100-
layout: TypedArena<LayoutDetails>,
101-
102-
// references
103-
generics: TypedArena<ty::Generics>,
104-
trait_def: TypedArena<ty::TraitDef>,
105-
adt_def: TypedArena<ty::AdtDef>,
106-
steal_mir: TypedArena<Steal<Body<'tcx>>>,
107-
mir: TypedArena<Body<'tcx>>,
108-
tables: TypedArena<ty::TypeckTables<'tcx>>,
109-
/// miri allocations
110-
const_allocs: TypedArena<interpret::Allocation>,
111-
}
112-
11394
type InternedSet<'tcx, T> = Lock<FxHashMap<Interned<'tcx, T>, ()>>;
11495

11596
pub struct CtxtInterners<'tcx> {
@@ -1043,7 +1024,7 @@ impl<'gcx> Deref for TyCtxt<'_, 'gcx, '_> {
10431024

10441025
pub struct GlobalCtxt<'tcx> {
10451026
pub arena: WorkerLocal<Arena<'tcx>>,
1046-
global_arenas: &'tcx WorkerLocal<GlobalArenas<'tcx>>,
1027+
10471028
global_interners: CtxtInterners<'tcx>,
10481029

10491030
cstore: &'tcx CrateStoreDyn,
@@ -1150,24 +1131,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11501131
&self.hir_map
11511132
}
11521133

1153-
pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics {
1154-
self.global_arenas.generics.alloc(generics)
1155-
}
1156-
11571134
pub fn alloc_steal_mir(self, mir: Body<'gcx>) -> &'gcx Steal<Body<'gcx>> {
1158-
self.global_arenas.steal_mir.alloc(Steal::new(mir))
1159-
}
1160-
1161-
pub fn alloc_mir(self, mir: Body<'gcx>) -> &'gcx Body<'gcx> {
1162-
self.global_arenas.mir.alloc(mir)
1163-
}
1164-
1165-
pub fn alloc_tables(self, tables: ty::TypeckTables<'gcx>) -> &'gcx ty::TypeckTables<'gcx> {
1166-
self.global_arenas.tables.alloc(tables)
1167-
}
1168-
1169-
pub fn alloc_trait_def(self, def: ty::TraitDef) -> &'gcx ty::TraitDef {
1170-
self.global_arenas.trait_def.alloc(def)
1135+
self.arena.alloc(Steal::new(mir))
11711136
}
11721137

11731138
pub fn alloc_adt_def(self,
@@ -1177,12 +1142,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11771142
repr: ReprOptions)
11781143
-> &'gcx ty::AdtDef {
11791144
let def = ty::AdtDef::new(self, did, kind, variants, repr);
1180-
self.global_arenas.adt_def.alloc(def)
1145+
self.arena.alloc(def)
11811146
}
11821147

11831148
pub fn intern_const_alloc(self, alloc: Allocation) -> &'gcx Allocation {
11841149
self.allocation_interner.borrow_mut().intern(alloc, |alloc| {
1185-
self.global_arenas.const_allocs.alloc(alloc)
1150+
self.arena.alloc(alloc)
11861151
})
11871152
}
11881153

@@ -1196,13 +1161,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
11961161

11971162
pub fn intern_stability(self, stab: attr::Stability) -> &'gcx attr::Stability {
11981163
self.stability_interner.borrow_mut().intern(stab, |stab| {
1199-
self.global_interners.arena.alloc(stab)
1164+
self.arena.alloc(stab)
12001165
})
12011166
}
12021167

12031168
pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails {
12041169
self.layout_interner.borrow_mut().intern(layout, |layout| {
1205-
self.global_arenas.layout.alloc(layout)
1170+
self.arena.alloc(layout)
12061171
})
12071172
}
12081173

@@ -1250,7 +1215,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12501215
cstore: &'tcx CrateStoreDyn,
12511216
local_providers: ty::query::Providers<'tcx>,
12521217
extern_providers: ty::query::Providers<'tcx>,
1253-
arenas: &'tcx AllArenas<'tcx>,
1218+
arenas: &'tcx AllArenas,
12541219
resolutions: ty::Resolutions,
12551220
hir: hir_map::Map<'tcx>,
12561221
on_disk_query_result_cache: query::OnDiskCache<'tcx>,
@@ -1319,7 +1284,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
13191284
sess: s,
13201285
cstore,
13211286
arena: WorkerLocal::new(|_| Arena::default()),
1322-
global_arenas: &arenas.global,
13231287
global_interners: interners,
13241288
dep_graph,
13251289
common,

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub use self::sty::TyKind::*;
7575
pub use self::binding::BindingMode;
7676
pub use self::binding::BindingMode::*;
7777

78-
pub use self::context::{TyCtxt, FreeRegionInfo, GlobalArenas, AllArenas, tls, keep_local};
78+
pub use self::context::{TyCtxt, FreeRegionInfo, AllArenas, tls, keep_local};
7979
pub use self::context::{Lift, TypeckTables, CtxtInterners, GlobalCtxt};
8080
pub use self::context::{
8181
UserTypeAnnotationIndex, UserType, CanonicalUserType,

src/librustc/ty/print/pretty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,6 @@ impl<F: fmt::Write> FmtPrinter<'_, 'gcx, 'tcx, F> {
14411441
br
14421442
}
14431443
ty::BrAnon(_) |
1444-
ty::BrFresh(_) |
14451444
ty::BrEnv => {
14461445
let name = loop {
14471446
let name = name_by_region_index(region_index);

src/librustc/ty/structural_impls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ impl fmt::Debug for ty::BoundRegion {
9494
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9595
match *self {
9696
ty::BrAnon(n) => write!(f, "BrAnon({:?})", n),
97-
ty::BrFresh(n) => write!(f, "BrFresh({:?})", n),
9897
ty::BrNamed(did, name) => {
9998
write!(f, "BrNamed({:?}:{:?}, {})",
10099
did.krate, did.index, name)

src/librustc/ty/sty.rs

-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ pub enum BoundRegion {
5656
/// the event of shadowing.
5757
BrNamed(DefId, InternedString),
5858

59-
/// Fresh bound identifiers created during GLB computations.
60-
BrFresh(u32),
61-
6259
/// Anonymous region for the implicit env pointer parameter
6360
/// to a closure
6461
BrEnv,

src/librustc_metadata/cstore_impl.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ impl IntoArgs for (CrateNum, DefId) {
9494
provide! { <'tcx> tcx, def_id, other, cdata,
9595
type_of => { cdata.get_type(def_id.index, tcx) }
9696
generics_of => {
97-
tcx.alloc_generics(cdata.get_generics(def_id.index, tcx.sess))
97+
tcx.arena.alloc(cdata.get_generics(def_id.index, tcx.sess))
9898
}
9999
predicates_of => { tcx.arena.alloc(cdata.get_predicates(def_id.index, tcx)) }
100100
predicates_defined_on => {
101101
tcx.arena.alloc(cdata.get_predicates_defined_on(def_id.index, tcx))
102102
}
103103
super_predicates_of => { tcx.arena.alloc(cdata.get_super_predicates(def_id.index, tcx)) }
104104
trait_def => {
105-
tcx.alloc_trait_def(cdata.get_trait_def(def_id.index, tcx.sess))
105+
tcx.arena.alloc(cdata.get_trait_def(def_id.index, tcx.sess))
106106
}
107107
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
108108
adt_destructor => {
@@ -129,7 +129,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
129129
bug!("get_optimized_mir: missing MIR for `{:?}`", def_id)
130130
});
131131

132-
let mir = tcx.alloc_mir(mir);
132+
let mir = tcx.arena.alloc(mir);
133133

134134
mir
135135
}

0 commit comments

Comments
 (0)