rebase
This commit is contained in:
parent
e14b34c386
commit
15c1c06522
@ -97,7 +97,7 @@ pub(crate) fn try_destructure_const<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
const_: ty::Const<'tcx>,
|
||||
) -> Option<ty::DestructuredConst<'tcx>> {
|
||||
if let ty::ConstKind::Value(valtree) = const_.val() {
|
||||
if let ty::ConstKind::Value(valtree) = const_.kind() {
|
||||
let branches = match valtree {
|
||||
ty::ValTree::Branch(b) => b,
|
||||
_ => return None,
|
||||
@ -216,7 +216,7 @@ pub(crate) fn deref_mir_constant<'tcx>(
|
||||
let mplace = ecx.deref_operand(&op).unwrap();
|
||||
if let Some(alloc_id) = mplace.ptr.provenance {
|
||||
assert_eq!(
|
||||
tcx.get_global_alloc(alloc_id).unwrap().unwrap_memory().0 .0.mutability,
|
||||
tcx.get_global_alloc(alloc_id).unwrap().unwrap_memory().0.0.mutability,
|
||||
Mutability::Not,
|
||||
"deref_mir_constant cannot be used with mutable allocations as \
|
||||
that could allow pattern matching to observe mutable statics",
|
||||
|
@ -638,7 +638,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
span_bug!(self.cur_span(), "const_to_op: Unexpected ConstKind {:?}", c)
|
||||
}
|
||||
ty::ConstKind::Value(valtree) => {
|
||||
let ty = val.ty();
|
||||
let ty = c.ty();
|
||||
let const_val = self.tcx.valtree_to_const_val((ty, valtree));
|
||||
self.const_val_to_op(const_val, ty, layout)
|
||||
}
|
||||
|
@ -1446,11 +1446,7 @@ impl<'tcx> BasicBlockData<'tcx> {
|
||||
}
|
||||
|
||||
pub fn visitable(&self, index: usize) -> &dyn MirVisitable<'tcx> {
|
||||
if index < self.statements.len() {
|
||||
&self.statements[index]
|
||||
} else {
|
||||
&self.terminator
|
||||
}
|
||||
if index < self.statements.len() { &self.statements[index] } else { &self.terminator }
|
||||
}
|
||||
}
|
||||
|
||||
@ -2471,11 +2467,7 @@ impl<'tcx> Operand<'tcx> {
|
||||
/// find as the `func` in a [`TerminatorKind::Call`].
|
||||
pub fn const_fn_def(&self) -> Option<(DefId, SubstsRef<'tcx>)> {
|
||||
let const_ty = self.constant()?.literal.ty();
|
||||
if let ty::FnDef(def_id, substs) = *const_ty.kind() {
|
||||
Some((def_id, substs))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if let ty::FnDef(def_id, substs) = *const_ty.kind() { Some((def_id, substs)) } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
@ -2995,7 +2987,7 @@ impl<'tcx> ConstantKind<'tcx> {
|
||||
#[inline]
|
||||
pub fn try_to_scalar(self) -> Option<Scalar> {
|
||||
match self {
|
||||
ConstantKind::Ty(c) => match c.val() {
|
||||
ConstantKind::Ty(c) => match c.kind() {
|
||||
ty::ConstKind::Value(valtree) => match valtree {
|
||||
ty::ValTree::Leaf(scalar_int) => Some(Scalar::Int(scalar_int)),
|
||||
ty::ValTree::Branch(_) => None,
|
||||
@ -3291,7 +3283,7 @@ impl<'tcx> ConstantKind<'tcx> {
|
||||
}
|
||||
|
||||
pub fn from_const(c: ty::Const<'tcx>, tcx: TyCtxt<'tcx>) -> Self {
|
||||
match c.val() {
|
||||
match c.kind() {
|
||||
ty::ConstKind::Value(valtree) => {
|
||||
let const_val = tcx.valtree_to_const_val((c.ty(), valtree));
|
||||
Self::Val(const_val, c.ty())
|
||||
@ -3587,7 +3579,7 @@ fn pretty_print_const_value<'tcx>(
|
||||
}
|
||||
}
|
||||
(ConstValue::ByRef { alloc, offset }, ty::Array(t, n)) if *t == u8_type => {
|
||||
let n = n.val().try_to_bits(tcx.data_layout.pointer_size).unwrap();
|
||||
let n = n.kind().try_to_bits(tcx.data_layout.pointer_size).unwrap();
|
||||
// cast is ok because we already checked for pointer size (32 or 64 bit) above
|
||||
let range = AllocRange { start: offset, size: Size::from_bytes(n) };
|
||||
let byte_str = alloc.inner().get_bytes(&tcx, range).unwrap();
|
||||
|
@ -484,7 +484,7 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
|
||||
// This reflects what `Const` looked liked before `val` was renamed
|
||||
// as `kind`. We print it like this to avoid having to update
|
||||
// expected output in a lot of tests.
|
||||
self.push(&format!("+ literal: Const {{ ty: {}, val: {} }}", literal.ty(), kind));
|
||||
self.push(&format!("+ literal: Const {{ ty: {}, val: {} }}", literal.ty(), val));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ impl<'tcx> Const<'tcx> {
|
||||
|
||||
/// Panics if self.kind != ty::ConstKind::Value
|
||||
pub fn to_valtree(self) -> ty::ValTree<'tcx> {
|
||||
match self.val() {
|
||||
match self.kind() {
|
||||
ty::ConstKind::Value(valtree) => valtree,
|
||||
_ => bug!("expected ConstKind::Value"),
|
||||
}
|
||||
@ -286,7 +286,7 @@ impl<'tcx> Const<'tcx> {
|
||||
/// Tries to evaluate the constant if it is `Unevaluated` and creates a ConstValue if the
|
||||
/// evaluation succeeds. If it doesn't succeed, returns the unevaluated constant.
|
||||
pub fn eval_for_mir(self, tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> ConstantKind<'tcx> {
|
||||
if let Some(val) = self.val().try_eval_for_mir(tcx, param_env) {
|
||||
if let Some(val) = self.kind().try_eval_for_mir(tcx, param_env) {
|
||||
match val {
|
||||
Ok(const_val) => ConstantKind::from_value(const_val, self.ty()),
|
||||
Err(ErrorGuaranteed { .. }) => ConstantKind::Ty(tcx.const_error(self.ty())),
|
||||
|
@ -1186,7 +1186,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
};
|
||||
debug!("layout_scalar_valid_range: attr={:?}", attr);
|
||||
if let Some(
|
||||
&[ast::NestedMetaItem::Literal(ast::Lit { kind: ast::LitKind::Int(a, _), .. })],
|
||||
&[
|
||||
ast::NestedMetaItem::Literal(ast::Lit {
|
||||
kind: ast::LitKind::Int(a, _), ..
|
||||
}),
|
||||
],
|
||||
) = attr.meta_item_list().as_deref()
|
||||
{
|
||||
Bound::Included(a)
|
||||
@ -1659,7 +1663,7 @@ macro_rules! nop_lift {
|
||||
impl<'a, 'tcx> Lift<'tcx> for $ty {
|
||||
type Lifted = $lifted;
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
if tcx.interners.$set.contains_pointer_to(&InternedInSet(&*self.0 .0)) {
|
||||
if tcx.interners.$set.contains_pointer_to(&InternedInSet(&*self.0.0)) {
|
||||
// SAFETY: `self` is interned and therefore valid
|
||||
// for the entire lifetime of the `TyCtxt`.
|
||||
Some(unsafe { mem::transmute(self) })
|
||||
@ -2244,11 +2248,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
/// `*r == kind`.
|
||||
#[inline]
|
||||
pub fn reuse_or_mk_region(self, r: Region<'tcx>, kind: RegionKind) -> Region<'tcx> {
|
||||
if *r == kind {
|
||||
r
|
||||
} else {
|
||||
self.mk_region(kind)
|
||||
}
|
||||
if *r == kind { r } else { self.mk_region(kind) }
|
||||
}
|
||||
|
||||
#[allow(rustc::usage_of_ty_tykind)]
|
||||
@ -2268,11 +2268,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
pred: Predicate<'tcx>,
|
||||
binder: Binder<'tcx, PredicateKind<'tcx>>,
|
||||
) -> Predicate<'tcx> {
|
||||
if pred.kind() != binder {
|
||||
self.mk_predicate(binder)
|
||||
} else {
|
||||
pred
|
||||
}
|
||||
if pred.kind() != binder { self.mk_predicate(binder) } else { pred }
|
||||
}
|
||||
|
||||
pub fn mk_mach_int(self, tm: IntTy) -> Ty<'tcx> {
|
||||
@ -2417,11 +2413,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
|
||||
#[inline]
|
||||
pub fn mk_diverging_default(self) -> Ty<'tcx> {
|
||||
if self.features().never_type_fallback {
|
||||
self.types.never
|
||||
} else {
|
||||
self.types.unit
|
||||
}
|
||||
if self.features().never_type_fallback { self.types.never } else { self.types.unit }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -2572,9 +2564,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
eps: &[ty::Binder<'tcx, ExistentialPredicate<'tcx>>],
|
||||
) -> &'tcx List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>> {
|
||||
assert!(!eps.is_empty());
|
||||
assert!(eps
|
||||
.array_windows()
|
||||
.all(|[a, b]| a.skip_binder().stable_cmp(self, &b.skip_binder()) != Ordering::Greater));
|
||||
assert!(
|
||||
eps.array_windows()
|
||||
.all(|[a, b]| a.skip_binder().stable_cmp(self, &b.skip_binder())
|
||||
!= Ordering::Greater)
|
||||
);
|
||||
self._intern_poly_existential_predicates(eps)
|
||||
}
|
||||
|
||||
@ -2607,49 +2601,29 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
pub fn intern_substs(self, ts: &[GenericArg<'tcx>]) -> &'tcx List<GenericArg<'tcx>> {
|
||||
if ts.is_empty() {
|
||||
List::empty()
|
||||
} else {
|
||||
self._intern_substs(ts)
|
||||
}
|
||||
if ts.is_empty() { List::empty() } else { self._intern_substs(ts) }
|
||||
}
|
||||
|
||||
pub fn intern_projs(self, ps: &[ProjectionKind]) -> &'tcx List<ProjectionKind> {
|
||||
if ps.is_empty() {
|
||||
List::empty()
|
||||
} else {
|
||||
self._intern_projs(ps)
|
||||
}
|
||||
if ps.is_empty() { List::empty() } else { self._intern_projs(ps) }
|
||||
}
|
||||
|
||||
pub fn intern_place_elems(self, ts: &[PlaceElem<'tcx>]) -> &'tcx List<PlaceElem<'tcx>> {
|
||||
if ts.is_empty() {
|
||||
List::empty()
|
||||
} else {
|
||||
self._intern_place_elems(ts)
|
||||
}
|
||||
if ts.is_empty() { List::empty() } else { self._intern_place_elems(ts) }
|
||||
}
|
||||
|
||||
pub fn intern_canonical_var_infos(
|
||||
self,
|
||||
ts: &[CanonicalVarInfo<'tcx>],
|
||||
) -> CanonicalVarInfos<'tcx> {
|
||||
if ts.is_empty() {
|
||||
List::empty()
|
||||
} else {
|
||||
self._intern_canonical_var_infos(ts)
|
||||
}
|
||||
if ts.is_empty() { List::empty() } else { self._intern_canonical_var_infos(ts) }
|
||||
}
|
||||
|
||||
pub fn intern_bound_variable_kinds(
|
||||
self,
|
||||
ts: &[ty::BoundVariableKind],
|
||||
) -> &'tcx List<ty::BoundVariableKind> {
|
||||
if ts.is_empty() {
|
||||
List::empty()
|
||||
} else {
|
||||
self._intern_bound_variable_kinds(ts)
|
||||
}
|
||||
if ts.is_empty() { List::empty() } else { self._intern_bound_variable_kinds(ts) }
|
||||
}
|
||||
|
||||
pub fn mk_fn_sig<I>(
|
||||
|
@ -607,11 +607,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if verbose {
|
||||
p!(write("{:?}", infer_ty))
|
||||
} else {
|
||||
p!(write("{}", infer_ty))
|
||||
}
|
||||
if verbose { p!(write("{:?}", infer_ty)) } else { p!(write("{}", infer_ty)) }
|
||||
}
|
||||
}
|
||||
ty::Error(_) => p!("[type error]"),
|
||||
@ -1335,11 +1331,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
ty::Uint(_) | ty::Int(_) => {
|
||||
let int =
|
||||
ConstInt::new(int, matches!(ty.kind(), ty::Int(_)), ty.is_ptr_sized_integral());
|
||||
if print_ty {
|
||||
p!(write("{:#?}", int))
|
||||
} else {
|
||||
p!(write("{:?}", int))
|
||||
}
|
||||
if print_ty { p!(write("{:#?}", int)) } else { p!(write("{:?}", int)) }
|
||||
}
|
||||
// Char
|
||||
ty::Char if char::try_from(int).is_ok() => {
|
||||
@ -2294,7 +2286,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
trace!("address: {:p}", r.0 .0);
|
||||
trace!("address: {:p}", r.0.0);
|
||||
if let ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) = *r {
|
||||
self.used_region_names.insert(name);
|
||||
} else if let ty::RePlaceholder(ty::PlaceholderRegion {
|
||||
|
@ -669,7 +669,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
|
||||
.expect("tried to dereference on non-ptr type")
|
||||
.ty;
|
||||
let dereferenced_const =
|
||||
self.tcx.mk_const(ty::ConstS { val: ct.val(), ty: pointee_ty });
|
||||
self.tcx.mk_const(ty::ConstS { kind: ct.kind(), ty: pointee_ty });
|
||||
self = dereferenced_const.print(self)?;
|
||||
}
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
let pred =
|
||||
ty::Binder::dummy(infcx.replace_bound_vars_with_placeholders(binder));
|
||||
ProcessResult::Changed(mk_pending(vec![
|
||||
obligation.with(pred.to_predicate(self.selcx.tcx()))
|
||||
obligation.with(pred.to_predicate(self.selcx.tcx())),
|
||||
]))
|
||||
}
|
||||
ty::PredicateKind::TypeWellFormedFromEnv(..) => {
|
||||
|
@ -2578,11 +2578,7 @@ impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
|
||||
}
|
||||
|
||||
fn depth(&self) -> usize {
|
||||
if let Some(head) = self.head {
|
||||
head.depth
|
||||
} else {
|
||||
0
|
||||
}
|
||||
if let Some(head) = self.head { head.depth } else { 0 }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user