Skip to content

Commit dcf532b

Browse files
committed
Auto merge of #44062 - alexcrichton:beta-next, r=alexcrichton
[beta] Final round of beta backports Includes: * [x] #43723 * [x] #43830 * [x] #43844 * [x] #44013 * [x] #44049 * [x] #43948
2 parents 9e012f4 + 0e9969c commit dcf532b

File tree

28 files changed

+275
-165
lines changed

28 files changed

+275
-165
lines changed

src/bootstrap/channel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub const CFG_RELEASE_NUM: &str = "1.20.0";
2828
// An optional number to put after the label, e.g. '.2' -> '-beta.2'
2929
// Be sure to make this starts with a dot to conform to semver pre-release
3030
// versions (section 9)
31-
pub const CFG_PRERELEASE_VERSION: &str = ".2";
31+
pub const CFG_PRERELEASE_VERSION: &str = ".3";
3232

3333
pub struct GitInfo {
3434
inner: Option<Info>,

src/liballoc/allocator.rs

+21
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,27 @@ impl fmt::Display for CannotReallocInPlace {
452452
/// * if a layout `k` fits a memory block (denoted by `ptr`)
453453
/// currently allocated via an allocator `a`, then it is legal to
454454
/// use that layout to deallocate it, i.e. `a.dealloc(ptr, k);`.
455+
///
456+
/// # Unsafety
457+
///
458+
/// The `Alloc` trait is an `unsafe` trait for a number of reasons, and
459+
/// implementors must ensure that they adhere to these contracts:
460+
///
461+
/// * Pointers returned from allocation functions must point to valid memory and
462+
/// retain their validity until at least the instance of `Alloc` is dropped
463+
/// itself.
464+
///
465+
/// * Implementations of `Alloc` are not currently memory safe if they unwind.
466+
/// This restriction may be lifted in the future, but currently an panic from
467+
/// any of these functions may lead to memory unsafety.
468+
///
469+
/// * `Layout` queries and calculations in general must be correct. Callers of
470+
/// this trait are allowed to rely on the contracts defined on each method,
471+
/// and implementors must ensure such contracts remain true.
472+
///
473+
/// Note that this list may get tweaked over time as clarifications are made in
474+
/// the future. Additionally global allocators may gain unique requirements for
475+
/// how to safely implement one in the future as well.
455476
pub unsafe trait Alloc {
456477

457478
// (Note: existing allocators have unspecified but well-defined

src/liballoc/heap.rs

+11
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,46 @@ pub mod __core {
2727

2828
extern "Rust" {
2929
#[allocator]
30+
#[allocator_nounwind]
3031
fn __rust_alloc(size: usize, align: usize, err: *mut u8) -> *mut u8;
32+
#[cold]
33+
#[allocator_nounwind]
3134
fn __rust_oom(err: *const u8) -> !;
35+
#[allocator_nounwind]
3236
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
37+
#[allocator_nounwind]
3338
fn __rust_usable_size(layout: *const u8,
3439
min: *mut usize,
3540
max: *mut usize);
41+
#[allocator_nounwind]
3642
fn __rust_realloc(ptr: *mut u8,
3743
old_size: usize,
3844
old_align: usize,
3945
new_size: usize,
4046
new_align: usize,
4147
err: *mut u8) -> *mut u8;
48+
#[allocator_nounwind]
4249
fn __rust_alloc_zeroed(size: usize, align: usize, err: *mut u8) -> *mut u8;
50+
#[allocator_nounwind]
4351
fn __rust_alloc_excess(size: usize,
4452
align: usize,
4553
excess: *mut usize,
4654
err: *mut u8) -> *mut u8;
55+
#[allocator_nounwind]
4756
fn __rust_realloc_excess(ptr: *mut u8,
4857
old_size: usize,
4958
old_align: usize,
5059
new_size: usize,
5160
new_align: usize,
5261
excess: *mut usize,
5362
err: *mut u8) -> *mut u8;
63+
#[allocator_nounwind]
5464
fn __rust_grow_in_place(ptr: *mut u8,
5565
old_size: usize,
5666
old_align: usize,
5767
new_size: usize,
5868
new_align: usize) -> u8;
69+
#[allocator_nounwind]
5970
fn __rust_shrink_in_place(ptr: *mut u8,
6071
old_size: usize,
6172
old_align: usize,

src/librustc/traits/error_reporting.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
278278
let mut self_match_impls = vec![];
279279
let mut fuzzy_match_impls = vec![];
280280

281-
self.tcx.trait_def(trait_ref.def_id)
282-
.for_each_relevant_impl(self.tcx, trait_self_ty, |def_id| {
281+
self.tcx.for_each_relevant_impl(
282+
trait_ref.def_id, trait_self_ty, |def_id| {
283283
let impl_substs = self.fresh_substs_for_item(obligation.cause.span, def_id);
284284
let impl_trait_ref = tcx
285285
.impl_trait_ref(def_id)
@@ -396,10 +396,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
396396
trait_ref.skip_binder().self_ty(),
397397
true);
398398
let mut impl_candidates = Vec::new();
399-
let trait_def = self.tcx.trait_def(trait_ref.def_id());
400399

401400
match simp {
402-
Some(simp) => trait_def.for_each_impl(self.tcx, |def_id| {
401+
Some(simp) => self.tcx.for_each_impl(trait_ref.def_id(), |def_id| {
403402
let imp = self.tcx.impl_trait_ref(def_id).unwrap();
404403
let imp_simp = fast_reject::simplify_type(self.tcx,
405404
imp.self_ty(),
@@ -411,7 +410,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
411410
}
412411
impl_candidates.push(imp);
413412
}),
414-
None => trait_def.for_each_impl(self.tcx, |def_id| {
413+
None => self.tcx.for_each_impl(trait_ref.def_id(), |def_id| {
415414
impl_candidates.push(
416415
self.tcx.impl_trait_ref(def_id).unwrap());
417416
})

src/librustc/traits/select.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1430,10 +1430,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
14301430
{
14311431
debug!("assemble_candidates_from_impls(obligation={:?})", obligation);
14321432

1433-
let def = self.tcx().trait_def(obligation.predicate.def_id());
1434-
1435-
def.for_each_relevant_impl(
1436-
self.tcx(),
1433+
self.tcx().for_each_relevant_impl(
1434+
obligation.predicate.def_id(),
14371435
obligation.predicate.0.trait_ref.self_ty(),
14381436
|impl_def_id| {
14391437
self.probe(|this, snapshot| { /* [1] */

src/librustc/traits/specialize/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
300300
-> Rc<specialization_graph::Graph> {
301301
let mut sg = specialization_graph::Graph::new();
302302

303-
let mut trait_impls: Vec<DefId> = tcx.trait_impls_of(trait_id).iter().collect();
303+
let mut trait_impls = Vec::new();
304+
tcx.for_each_impl(trait_id, |impl_did| trait_impls.push(impl_did));
304305

305306
// The coherence checking implementation seems to rely on impls being
306307
// iterated over (roughly) in definition order, so we are sorting by

src/librustc/ty/maps.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,6 @@ impl<'tcx> QueryDescription for queries::trait_impls_of<'tcx> {
470470
}
471471
}
472472

473-
impl<'tcx> QueryDescription for queries::relevant_trait_impls_for<'tcx> {
474-
fn describe(tcx: TyCtxt, (def_id, ty): (DefId, SimplifiedType)) -> String {
475-
format!("relevant impls for: `({}, {:?})`", tcx.item_path_str(def_id), ty)
476-
}
477-
}
478-
479473
impl<'tcx> QueryDescription for queries::is_object_safe<'tcx> {
480474
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
481475
format!("determine object safety of trait `{}`", tcx.item_path_str(def_id))
@@ -966,10 +960,7 @@ define_maps! { <'tcx>
966960
[] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
967961
[] is_mir_available: IsMirAvailable(DefId) -> bool,
968962

969-
[] trait_impls_of: TraitImpls(DefId) -> ty::trait_def::TraitImpls,
970-
// Note that TraitDef::for_each_relevant_impl() will do type simplication for you.
971-
[] relevant_trait_impls_for: relevant_trait_impls_for((DefId, SimplifiedType))
972-
-> ty::trait_def::TraitImpls,
963+
[] trait_impls_of: TraitImpls(DefId) -> Rc<ty::trait_def::TraitImpls>,
973964
[] specialization_graph_of: SpecializationGraph(DefId) -> Rc<specialization_graph::Graph>,
974965
[] is_object_safe: ObjectSafety(DefId) -> bool,
975966

@@ -1045,10 +1036,6 @@ fn crate_variances<'tcx>(_: CrateNum) -> DepConstructor<'tcx> {
10451036
DepConstructor::CrateVariances
10461037
}
10471038

1048-
fn relevant_trait_impls_for<'tcx>((def_id, t): (DefId, SimplifiedType)) -> DepConstructor<'tcx> {
1049-
DepConstructor::RelevantTraitImpls(def_id, t)
1050-
}
1051-
10521039
fn is_copy_dep_node<'tcx>(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> {
10531040
let def_id = ty::item_path::characteristic_def_id_of_type(key.value)
10541041
.unwrap_or(DefId::local(CRATE_DEF_INDEX));

src/librustc/ty/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,6 @@ pub fn provide(providers: &mut ty::maps::Providers) {
25302530
param_env,
25312531
trait_of_item,
25322532
trait_impls_of: trait_def::trait_impls_of_provider,
2533-
relevant_trait_impls_for: trait_def::relevant_trait_impls_provider,
25342533
..*providers
25352534
};
25362535
}
@@ -2540,7 +2539,6 @@ pub fn provide_extern(providers: &mut ty::maps::Providers) {
25402539
adt_sized_constraint,
25412540
adt_dtorck_constraint,
25422541
trait_impls_of: trait_def::trait_impls_of_provider,
2543-
relevant_trait_impls_for: trait_def::relevant_trait_impls_provider,
25442542
param_env,
25452543
..*providers
25462544
};

0 commit comments

Comments
 (0)