Skip to content

Commit 1318a92

Browse files
committed
Auto merge of rust-lang#120196 - matthiaskrgr:rollup-id2zocf, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#120005 (Update Readme) - rust-lang#120045 (Un-hide `iter::repeat_n`) - rust-lang#120128 (Make stable_mir::with_tables sound) - rust-lang#120145 (fix: Drop guard was deallocating with the incorrect size) - rust-lang#120158 (`rustc_mir_dataflow`: Restore removed exports) - rust-lang#120167 (Capture the rationale for `-Zallow-features=` in bootstrap.py) - rust-lang#120174 (Warn users about limited review for tier 2 and 3 code) - rust-lang#120180 (Document some alternatives to `Vec::split_off`) Failed merges: - rust-lang#120171 (Fix assume and assert in jump threading) r? `@ghost` `@rustbot` modify labels: rollup
2 parents fa40433 + 3eb7fe3 commit 1318a92

File tree

22 files changed

+575
-406
lines changed

22 files changed

+575
-406
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ If you wish to _contribute_ to the compiler, you should read
1515
<summary>Table of Contents</summary>
1616

1717
- [Quick Start](#quick-start)
18+
- [Installing from Source](#installing-from-source)
1819
- [Getting Help](#getting-help)
1920
- [Contributing](#contributing)
2021
- [License](#license)
@@ -29,9 +30,10 @@ Read ["Installation"] from [The Book].
2930
["Installation"]: https://doc.rust-lang.org/book/ch01-01-installation.html
3031
[The Book]: https://doc.rust-lang.org/book/index.html
3132

32-
## Installing from source
33+
## Installing from Source
3334

34-
If you really want to install from source (though this is not recommended), see [INSTALL.md](INSTALL.md).
35+
If you really want to install from source (though this is not recommended), see
36+
[INSTALL.md](INSTALL.md).
3537

3638
## Getting Help
3739

compiler/rustc_arena/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,19 @@ impl DroplessArena {
484484
}
485485
}
486486

487+
/// Used by `Lift` to check whether this slice is allocated
488+
/// in this arena.
489+
#[inline]
490+
pub fn contains_slice<T>(&self, slice: &[T]) -> bool {
491+
for chunk in self.chunks.borrow_mut().iter_mut() {
492+
let ptr = slice.as_ptr().cast::<u8>().cast_mut();
493+
if chunk.start() <= ptr && chunk.end() >= ptr {
494+
return true;
495+
}
496+
}
497+
false
498+
}
499+
487500
/// Allocates a string slice that is copied into the `DroplessArena`, returning a
488501
/// reference to it. Will panic if passed an empty string.
489502
///

compiler/rustc_middle/src/mir/consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<'tcx> ConstValue<'tcx> {
195195
/// Constants
196196
197197
#[derive(Clone, Copy, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable, Debug)]
198-
#[derive(TypeFoldable, TypeVisitable)]
198+
#[derive(TypeFoldable, TypeVisitable, Lift)]
199199
pub enum Const<'tcx> {
200200
/// This constant came from the type system.
201201
///
@@ -456,7 +456,7 @@ impl<'tcx> Const<'tcx> {
456456

457457
/// An unevaluated (potentially generic) constant used in MIR.
458458
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable)]
459-
#[derive(Hash, HashStable, TypeFoldable, TypeVisitable)]
459+
#[derive(Hash, HashStable, TypeFoldable, TypeVisitable, Lift)]
460460
pub struct UnevaluatedConst<'tcx> {
461461
pub def: DefId,
462462
pub args: GenericArgsRef<'tcx>,

compiler/rustc_middle/src/ty/context.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,7 @@ nop_lift! {const_; Const<'a> => Const<'tcx>}
14161416
nop_lift! {const_allocation; ConstAllocation<'a> => ConstAllocation<'tcx>}
14171417
nop_lift! {predicate; Predicate<'a> => Predicate<'tcx>}
14181418
nop_lift! {predicate; Clause<'a> => Clause<'tcx>}
1419+
nop_lift! {layout; Layout<'a> => Layout<'tcx>}
14191420

14201421
nop_list_lift! {type_lists; Ty<'a> => Ty<'tcx>}
14211422
nop_list_lift! {poly_existential_predicates; PolyExistentialPredicate<'a> => PolyExistentialPredicate<'tcx>}
@@ -1424,8 +1425,28 @@ nop_list_lift! {bound_variable_kinds; ty::BoundVariableKind => ty::BoundVariable
14241425
// This is the impl for `&'a GenericArgs<'a>`.
14251426
nop_list_lift! {args; GenericArg<'a> => GenericArg<'tcx>}
14261427

1428+
macro_rules! nop_slice_lift {
1429+
($ty:ty => $lifted:ty) => {
1430+
impl<'a, 'tcx> Lift<'tcx> for &'a [$ty] {
1431+
type Lifted = &'tcx [$lifted];
1432+
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
1433+
if self.is_empty() {
1434+
return Some(&[]);
1435+
}
1436+
tcx.interners
1437+
.arena
1438+
.dropless
1439+
.contains_slice(self)
1440+
.then(|| unsafe { mem::transmute(self) })
1441+
}
1442+
}
1443+
};
1444+
}
1445+
1446+
nop_slice_lift! {ty::ValTree<'a> => ty::ValTree<'tcx>}
1447+
14271448
TrivialLiftImpls! {
1428-
ImplPolarity,
1449+
ImplPolarity, Promoted
14291450
}
14301451

14311452
macro_rules! sty_debug_print {

compiler/rustc_mir_dataflow/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ extern crate rustc_middle;
1616

1717
use rustc_middle::ty;
1818

19+
// Please change the public `use` directives cautiously, as they might be used by external tools.
20+
// See issue #120130.
1921
pub use self::drop_flag_effects::{
2022
drop_flag_effects_for_function_entry, drop_flag_effects_for_location,
2123
move_path_children_matching, on_all_children_bits, on_lookup_result_bits,
2224
};
2325
pub use self::framework::{
24-
fmt, lattice, visit_results, Analysis, AnalysisDomain, Direction, GenKill, GenKillAnalysis,
25-
JoinSemiLattice, MaybeReachable, Results, ResultsCursor, ResultsVisitable, ResultsVisitor,
26+
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, Backward, Direction, Engine,
27+
Forward, GenKill, GenKillAnalysis, JoinSemiLattice, MaybeReachable, Results, ResultsCursor,
28+
ResultsVisitable, ResultsVisitor, SwitchIntEdgeEffects,
2629
};
27-
use self::framework::{Backward, SwitchIntEdgeEffects};
2830
use self::move_paths::MoveData;
2931

3032
pub mod debuginfo;

0 commit comments

Comments
 (0)