Skip to content

Commit 15c1c06

Browse files
committed
rebase
1 parent e14b34c commit 15c1c06

File tree

10 files changed

+36
-82
lines changed

10 files changed

+36
-82
lines changed

Diff for: compiler/rustc_const_eval/src/const_eval/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub(crate) fn try_destructure_const<'tcx>(
9797
tcx: TyCtxt<'tcx>,
9898
const_: ty::Const<'tcx>,
9999
) -> Option<ty::DestructuredConst<'tcx>> {
100-
if let ty::ConstKind::Value(valtree) = const_.val() {
100+
if let ty::ConstKind::Value(valtree) = const_.kind() {
101101
let branches = match valtree {
102102
ty::ValTree::Branch(b) => b,
103103
_ => return None,
@@ -216,7 +216,7 @@ pub(crate) fn deref_mir_constant<'tcx>(
216216
let mplace = ecx.deref_operand(&op).unwrap();
217217
if let Some(alloc_id) = mplace.ptr.provenance {
218218
assert_eq!(
219-
tcx.get_global_alloc(alloc_id).unwrap().unwrap_memory().0 .0.mutability,
219+
tcx.get_global_alloc(alloc_id).unwrap().unwrap_memory().0.0.mutability,
220220
Mutability::Not,
221221
"deref_mir_constant cannot be used with mutable allocations as \
222222
that could allow pattern matching to observe mutable statics",

Diff for: compiler/rustc_const_eval/src/interpret/operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
638638
span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", c)
639639
}
640640
ty::ConstKind::Value(valtree) => {
641-
let ty = val.ty();
641+
let ty = c.ty();
642642
let const_val = self.tcx.valtree_to_const_val((ty, valtree));
643643
self.const_val_to_op(const_val, ty, layout)
644644
}

Diff for: compiler/rustc_middle/src/mir/mod.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -1446,11 +1446,7 @@ impl<'tcx> BasicBlockData<'tcx> {
14461446
}
14471447

14481448
pub fn visitable(&self, index: usize) -> &dyn MirVisitable<'tcx> {
1449-
if index < self.statements.len() {
1450-
&self.statements[index]
1451-
} else {
1452-
&self.terminator
1453-
}
1449+
if index < self.statements.len() { &self.statements[index] } else { &self.terminator }
14541450
}
14551451
}
14561452

@@ -2471,11 +2467,7 @@ impl<'tcx> Operand<'tcx> {
24712467
/// find as the `func` in a [`TerminatorKind::Call`].
24722468
pub fn const_fn_def(&self) -> Option<(DefId, SubstsRef<'tcx>)> {
24732469
let const_ty = self.constant()?.literal.ty();
2474-
if let ty::FnDef(def_id, substs) = *const_ty.kind() {
2475-
Some((def_id, substs))
2476-
} else {
2477-
None
2478-
}
2470+
if let ty::FnDef(def_id, substs) = *const_ty.kind() { Some((def_id, substs)) } else { None }
24792471
}
24802472
}
24812473

@@ -2995,7 +2987,7 @@ impl<'tcx> ConstantKind<'tcx> {
29952987
#[inline]
29962988
pub fn try_to_scalar(self) -> Option<Scalar> {
29972989
match self {
2998-
ConstantKind::Ty(c) => match c.val() {
2990+
ConstantKind::Ty(c) => match c.kind() {
29992991
ty::ConstKind::Value(valtree) => match valtree {
30002992
ty::ValTree::Leaf(scalar_int) => Some(Scalar::Int(scalar_int)),
30012993
ty::ValTree::Branch(_) => None,
@@ -3291,7 +3283,7 @@ impl<'tcx> ConstantKind<'tcx> {
32913283
}
32923284

32933285
pub fn from_const(c: ty::Const<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
3294-
match c.val() {
3286+
match c.kind() {
32953287
ty::ConstKind::Value(valtree) => {
32963288
let const_val = tcx.valtree_to_const_val((c.ty(), valtree));
32973289
Self::Val(const_val, c.ty())
@@ -3587,7 +3579,7 @@ fn pretty_print_const_value<'tcx>(
35873579
}
35883580
}
35893581
(ConstValue::ByRef { alloc, offset }, ty::Array(t, n)) if *t == u8_type => {
3590-
let n = n.val().try_to_bits(tcx.data_layout.pointer_size).unwrap();
3582+
let n = n.kind().try_to_bits(tcx.data_layout.pointer_size).unwrap();
35913583
// cast is ok because we already checked for pointer size (32 or 64 bit) above
35923584
let range = AllocRange { start: offset, size: Size::from_bytes(n) };
35933585
let byte_str = alloc.inner().get_bytes(&tcx, range).unwrap();

Diff for: compiler/rustc_middle/src/mir/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
484484
// This reflects what `Const` looked liked before `val` was renamed
485485
// as `kind`. We print it like this to avoid having to update
486486
// expected output in a lot of tests.
487-
self.push(&format!("+ literal: Const {{ ty: {}, val: {} }}", literal.ty(), kind));
487+
self.push(&format!("+ literal: Const {{ ty: {}, val: {} }}", literal.ty(), val));
488488
}
489489
}
490490

Diff for: compiler/rustc_middle/src/ty/consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'tcx> Const<'tcx> {
201201

202202
/// Panics if self.kind != ty::ConstKind::Value
203203
pub fn to_valtree(self) -> ty::ValTree<'tcx> {
204-
match self.val() {
204+
match self.kind() {
205205
ty::ConstKind::Value(valtree) => valtree,
206206
_ => bug!("expected ConstKind::Value"),
207207
}
@@ -286,7 +286,7 @@ impl<'tcx> Const<'tcx> {
286286
/// Tries to evaluate the constant if it is `Unevaluated` and creates a ConstValue if the
287287
/// evaluation succeeds. If it doesn't succeed, returns the unevaluated constant.
288288
pub fn eval_for_mir(self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> ConstantKind<'tcx> {
289-
if let Some(val) = self.val().try_eval_for_mir(tcx, param_env) {
289+
if let Some(val) = self.kind().try_eval_for_mir(tcx, param_env) {
290290
match val {
291291
Ok(const_val) => ConstantKind::from_value(const_val, self.ty()),
292292
Err(ErrorGuaranteed { .. }) => ConstantKind::Ty(tcx.const_error(self.ty())),

Diff for: compiler/rustc_middle/src/ty/context.rs

+19-45
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,11 @@ impl<'tcx> TyCtxt<'tcx> {
11861186
};
11871187
debug!("layout_scalar_valid_range: attr={:?}", attr);
11881188
if let Some(
1189-
&[ast::NestedMetaItem::Literal(ast::Lit { kind: ast::LitKind::Int(a, _), .. })],
1189+
&[
1190+
ast::NestedMetaItem::Literal(ast::Lit {
1191+
kind: ast::LitKind::Int(a, _), ..
1192+
}),
1193+
],
11901194
) = attr.meta_item_list().as_deref()
11911195
{
11921196
Bound::Included(a)
@@ -1659,7 +1663,7 @@ macro_rules! nop_lift {
16591663
impl<'a, 'tcx> Lift<'tcx> for $ty {
16601664
type Lifted = $lifted;
16611665
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
1662-
if tcx.interners.$set.contains_pointer_to(&InternedInSet(&*self.0 .0)) {
1666+
if tcx.interners.$set.contains_pointer_to(&InternedInSet(&*self.0.0)) {
16631667
// SAFETY: `self` is interned and therefore valid
16641668
// for the entire lifetime of the `TyCtxt`.
16651669
Some(unsafe { mem::transmute(self) })
@@ -2244,11 +2248,7 @@ impl<'tcx> TyCtxt<'tcx> {
22442248
/// `*r == kind`.
22452249
#[inline]
22462250
pub fn reuse_or_mk_region(self, r: Region<'tcx>, kind: RegionKind) -> Region<'tcx> {
2247-
if *r == kind {
2248-
r
2249-
} else {
2250-
self.mk_region(kind)
2251-
}
2251+
if *r == kind { r } else { self.mk_region(kind) }
22522252
}
22532253

22542254
#[allow(rustc::usage_of_ty_tykind)]
@@ -2268,11 +2268,7 @@ impl<'tcx> TyCtxt<'tcx> {
22682268
pred: Predicate<'tcx>,
22692269
binder: Binder<'tcx, PredicateKind<'tcx>>,
22702270
) -> Predicate<'tcx> {
2271-
if pred.kind() != binder {
2272-
self.mk_predicate(binder)
2273-
} else {
2274-
pred
2275-
}
2271+
if pred.kind() != binder { self.mk_predicate(binder) } else { pred }
22762272
}
22772273

22782274
pub fn mk_mach_int(self, tm: IntTy) -> Ty<'tcx> {
@@ -2417,11 +2413,7 @@ impl<'tcx> TyCtxt<'tcx> {
24172413

24182414
#[inline]
24192415
pub fn mk_diverging_default(self) -> Ty<'tcx> {
2420-
if self.features().never_type_fallback {
2421-
self.types.never
2422-
} else {
2423-
self.types.unit
2424-
}
2416+
if self.features().never_type_fallback { self.types.never } else { self.types.unit }
24252417
}
24262418

24272419
#[inline]
@@ -2572,9 +2564,11 @@ impl<'tcx> TyCtxt<'tcx> {
25722564
eps: &[ty::Binder<'tcx, ExistentialPredicate<'tcx>>],
25732565
) -> &'tcx List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>> {
25742566
assert!(!eps.is_empty());
2575-
assert!(eps
2576-
.array_windows()
2577-
.all(|[a, b]| a.skip_binder().stable_cmp(self, &b.skip_binder()) != Ordering::Greater));
2567+
assert!(
2568+
eps.array_windows()
2569+
.all(|[a, b]| a.skip_binder().stable_cmp(self, &b.skip_binder())
2570+
!= Ordering::Greater)
2571+
);
25782572
self._intern_poly_existential_predicates(eps)
25792573
}
25802574

@@ -2607,49 +2601,29 @@ impl<'tcx> TyCtxt<'tcx> {
26072601
}
26082602

26092603
pub fn intern_substs(self, ts: &[GenericArg<'tcx>]) -> &'tcx List<GenericArg<'tcx>> {
2610-
if ts.is_empty() {
2611-
List::empty()
2612-
} else {
2613-
self._intern_substs(ts)
2614-
}
2604+
if ts.is_empty() { List::empty() } else { self._intern_substs(ts) }
26152605
}
26162606

26172607
pub fn intern_projs(self, ps: &[ProjectionKind]) -> &'tcx List<ProjectionKind> {
2618-
if ps.is_empty() {
2619-
List::empty()
2620-
} else {
2621-
self._intern_projs(ps)
2622-
}
2608+
if ps.is_empty() { List::empty() } else { self._intern_projs(ps) }
26232609
}
26242610

26252611
pub fn intern_place_elems(self, ts: &[PlaceElem<'tcx>]) -> &'tcx List<PlaceElem<'tcx>> {
2626-
if ts.is_empty() {
2627-
List::empty()
2628-
} else {
2629-
self._intern_place_elems(ts)
2630-
}
2612+
if ts.is_empty() { List::empty() } else { self._intern_place_elems(ts) }
26312613
}
26322614

26332615
pub fn intern_canonical_var_infos(
26342616
self,
26352617
ts: &[CanonicalVarInfo<'tcx>],
26362618
) -> CanonicalVarInfos<'tcx> {
2637-
if ts.is_empty() {
2638-
List::empty()
2639-
} else {
2640-
self._intern_canonical_var_infos(ts)
2641-
}
2619+
if ts.is_empty() { List::empty() } else { self._intern_canonical_var_infos(ts) }
26422620
}
26432621

26442622
pub fn intern_bound_variable_kinds(
26452623
self,
26462624
ts: &[ty::BoundVariableKind],
26472625
) -> &'tcx List<ty::BoundVariableKind> {
2648-
if ts.is_empty() {
2649-
List::empty()
2650-
} else {
2651-
self._intern_bound_variable_kinds(ts)
2652-
}
2626+
if ts.is_empty() { List::empty() } else { self._intern_bound_variable_kinds(ts) }
26532627
}
26542628

26552629
pub fn mk_fn_sig<I>(

Diff for: compiler/rustc_middle/src/ty/print/pretty.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,7 @@ pub trait PrettyPrinter<'tcx>:
607607
}
608608
}
609609
} else {
610-
if verbose {
611-
p!(write("{:?}", infer_ty))
612-
} else {
613-
p!(write("{}", infer_ty))
614-
}
610+
if verbose { p!(write("{:?}", infer_ty)) } else { p!(write("{}", infer_ty)) }
615611
}
616612
}
617613
ty::Error(_) => p!("[type error]"),
@@ -1335,11 +1331,7 @@ pub trait PrettyPrinter<'tcx>:
13351331
ty::Uint(_) | ty::Int(_) => {
13361332
let int =
13371333
ConstInt::new(int, matches!(ty.kind(), ty::Int(_)), ty.is_ptr_sized_integral());
1338-
if print_ty {
1339-
p!(write("{:#?}", int))
1340-
} else {
1341-
p!(write("{:?}", int))
1342-
}
1334+
if print_ty { p!(write("{:#?}", int)) } else { p!(write("{:?}", int)) }
13431335
}
13441336
// Char
13451337
ty::Char if char::try_from(int).is_ok() => {
@@ -2294,7 +2286,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
22942286
type BreakTy = ();
22952287

22962288
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
2297-
trace!("address: {:p}", r.0 .0);
2289+
trace!("address: {:p}", r.0.0);
22982290
if let ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) = *r {
22992291
self.used_region_names.insert(name);
23002292
} else if let ty::RePlaceholder(ty::PlaceholderRegion {

Diff for: compiler/rustc_symbol_mangling/src/v0.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
669669
.expect("tried to dereference on non-ptr type")
670670
.ty;
671671
let dereferenced_const =
672-
self.tcx.mk_const(ty::ConstS { val: ct.val(), ty: pointee_ty });
672+
self.tcx.mk_const(ty::ConstS { kind: ct.kind(), ty: pointee_ty });
673673
self = dereferenced_const.print(self)?;
674674
}
675675
}

Diff for: compiler/rustc_trait_selection/src/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
407407
let pred =
408408
ty::Binder::dummy(infcx.replace_bound_vars_with_placeholders(binder));
409409
ProcessResult::Changed(mk_pending(vec![
410-
obligation.with(pred.to_predicate(self.selcx.tcx()))
410+
obligation.with(pred.to_predicate(self.selcx.tcx())),
411411
]))
412412
}
413413
ty::PredicateKind::TypeWellFormedFromEnv(..) => {

Diff for: compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -2578,11 +2578,7 @@ impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
25782578
}
25792579

25802580
fn depth(&self) -> usize {
2581-
if let Some(head) = self.head {
2582-
head.depth
2583-
} else {
2584-
0
2585-
}
2581+
if let Some(head) = self.head { head.depth } else { 0 }
25862582
}
25872583
}
25882584

0 commit comments

Comments
 (0)