Fix rebase issues
This commit is contained in:
parent
d0209c44a6
commit
71722b9cef
@ -647,7 +647,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
.map(|v| Variant(v.did))
|
||||
.collect()
|
||||
}
|
||||
ty::TyChar if exhaustive_integer_patterns => {
|
||||
ty::Char if exhaustive_integer_patterns => {
|
||||
let endpoint = |c: char| {
|
||||
let ty = ty::ParamEnv::empty().and(cx.tcx.types.char);
|
||||
ty::Const::from_bits(cx.tcx, c as u128, ty)
|
||||
@ -658,7 +658,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
ConstantRange(endpoint('\u{E000}'), endpoint('\u{10FFFF}'), RangeEnd::Included),
|
||||
]
|
||||
}
|
||||
ty::TyInt(ity) if exhaustive_integer_patterns => {
|
||||
ty::Int(ity) if exhaustive_integer_patterns => {
|
||||
// FIXME(49937): refactor these bit manipulations into interpret.
|
||||
let bits = Integer::from_attr(cx.tcx, SignedInt(ity)).size().bits() as u128;
|
||||
let min = 1u128 << (bits - 1);
|
||||
@ -668,7 +668,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
ty::Const::from_bits(cx.tcx, max as u128, ty),
|
||||
RangeEnd::Included)]
|
||||
}
|
||||
ty::TyUint(uty) if exhaustive_integer_patterns => {
|
||||
ty::Uint(uty) if exhaustive_integer_patterns => {
|
||||
// FIXME(49937): refactor these bit manipulations into interpret.
|
||||
let bits = Integer::from_attr(cx.tcx, UnsignedInt(uty)).size().bits() as u128;
|
||||
let max = !0u128 >> (128 - bits);
|
||||
@ -861,7 +861,7 @@ impl<'tcx> IntRange<'tcx> {
|
||||
// The return value of `signed_bias` should be XORed with an endpoint to encode/decode it.
|
||||
fn signed_bias(tcx: TyCtxt<'_, 'tcx, 'tcx>, ty: Ty<'tcx>) -> u128 {
|
||||
match ty.sty {
|
||||
ty::TyInt(ity) => {
|
||||
ty::Int(ity) => {
|
||||
let bits = Integer::from_attr(tcx, SignedInt(ity)).size().bits() as u128;
|
||||
1u128 << (bits - 1)
|
||||
}
|
||||
@ -1382,7 +1382,7 @@ fn slice_pat_covered_by_constructor<'tcx>(
|
||||
fn should_treat_range_exhaustively(tcx: TyCtxt<'_, 'tcx, 'tcx>, ctor: &Constructor<'tcx>) -> bool {
|
||||
if tcx.features().exhaustive_integer_patterns {
|
||||
if let ConstantValue(value) | ConstantRange(value, _, _) = ctor {
|
||||
if let ty::TyChar | ty::TyInt(_) | ty::TyUint(_) = value.ty.sty {
|
||||
if let ty::Char | ty::Int(_) | ty::Uint(_) = value.ty.sty {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ use super::{EvalContext, Machine, PlaceTy, OpTy, Value};
|
||||
impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
fn type_is_fat_ptr(&self, ty: Ty<'tcx>) -> bool {
|
||||
match ty.sty {
|
||||
ty::TyRawPtr(ty::TypeAndMut { ty, .. }) |
|
||||
ty::TyRef(_, ty, _) => !self.type_is_sized(ty),
|
||||
ty::TyAdt(def, _) if def.is_box() => !self.type_is_sized(ty.boxed_ty()),
|
||||
ty::RawPtr(ty::TypeAndMut { ty, .. }) |
|
||||
ty::Ref(_, ty, _) => !self.type_is_sized(ty),
|
||||
ty::Adt(def, _) if def.is_box() => !self.type_is_sized(ty.boxed_ty()),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -313,19 +313,19 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
let (src_pointee_ty, dest_pointee_ty) = self.tcx.struct_lockstep_tails(sty, dty);
|
||||
|
||||
match (&src_pointee_ty.sty, &dest_pointee_ty.sty) {
|
||||
(&ty::TyArray(_, length), &ty::TySlice(_)) => {
|
||||
(&ty::Array(_, length), &ty::Slice(_)) => {
|
||||
let ptr = self.read_value(src)?.to_scalar_ptr()?;
|
||||
// u64 cast is from usize to u64, which is always good
|
||||
let val = Value::new_slice(ptr, length.unwrap_usize(self.tcx.tcx), self.tcx.tcx);
|
||||
self.write_value(val, dest)
|
||||
}
|
||||
(&ty::TyDynamic(..), &ty::TyDynamic(..)) => {
|
||||
(&ty::Dynamic(..), &ty::Dynamic(..)) => {
|
||||
// For now, upcasts are limited to changes in marker
|
||||
// traits, and hence never actually require an actual
|
||||
// change to the vtable.
|
||||
self.copy_op(src, dest)
|
||||
}
|
||||
(_, &ty::TyDynamic(ref data, _)) => {
|
||||
(_, &ty::Dynamic(ref data, _)) => {
|
||||
// Initial cast from sized to dyn trait
|
||||
let trait_ref = data.principal().unwrap().with_self_ty(
|
||||
*self.tcx,
|
||||
@ -348,13 +348,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
dest: PlaceTy<'tcx>,
|
||||
) -> EvalResult<'tcx> {
|
||||
match (&src.layout.ty.sty, &dest.layout.ty.sty) {
|
||||
(&ty::TyRef(_, s, _), &ty::TyRef(_, d, _)) |
|
||||
(&ty::TyRef(_, s, _), &ty::TyRawPtr(TypeAndMut { ty: d, .. })) |
|
||||
(&ty::TyRawPtr(TypeAndMut { ty: s, .. }),
|
||||
&ty::TyRawPtr(TypeAndMut { ty: d, .. })) => {
|
||||
(&ty::Ref(_, s, _), &ty::Ref(_, d, _)) |
|
||||
(&ty::Ref(_, s, _), &ty::RawPtr(TypeAndMut { ty: d, .. })) |
|
||||
(&ty::RawPtr(TypeAndMut { ty: s, .. }),
|
||||
&ty::RawPtr(TypeAndMut { ty: d, .. })) => {
|
||||
self.unsize_into_ptr(src, dest, s, d)
|
||||
}
|
||||
(&ty::TyAdt(def_a, _), &ty::TyAdt(def_b, _)) => {
|
||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
|
||||
assert_eq!(def_a, def_b);
|
||||
if def_a.is_box() || def_b.is_box() {
|
||||
if !def_a.is_box() || !def_b.is_box() {
|
||||
|
@ -236,7 +236,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
let pointee_type = val.layout.ty.builtin_deref(true).unwrap().ty;
|
||||
let layout = self.layout_of(pointee_type)?;
|
||||
let mplace = match self.tcx.struct_tail(pointee_type).sty {
|
||||
ty::TyDynamic(..) => {
|
||||
ty::Dynamic(..) => {
|
||||
let (ptr, vtable) = val.to_scalar_dyn_trait()?;
|
||||
MemPlace {
|
||||
ptr,
|
||||
@ -244,7 +244,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
extra: PlaceExtra::Vtable(vtable),
|
||||
}
|
||||
}
|
||||
ty::TyStr | ty::TySlice(_) => {
|
||||
ty::Str | ty::Slice(_) => {
|
||||
let (ptr, len) = val.to_scalar_slice(self)?;
|
||||
MemPlace {
|
||||
ptr,
|
||||
@ -358,9 +358,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
// Compute extra and new layout
|
||||
let inner_len = len - to - from;
|
||||
let (extra, ty) = match base.layout.ty.sty {
|
||||
ty::TyArray(inner, _) =>
|
||||
ty::Array(inner, _) =>
|
||||
(PlaceExtra::None, self.tcx.mk_array(inner, inner_len)),
|
||||
ty::TySlice(..) =>
|
||||
ty::Slice(..) =>
|
||||
(PlaceExtra::Length(inner_len), base.layout.ty),
|
||||
_ =>
|
||||
bug!("cannot subslice non-array type: `{:?}`", base.layout.ty),
|
||||
|
@ -139,7 +139,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
// char gets a special treatment, because its number space is not contiguous so `TyLayout`
|
||||
// has no special checks for chars
|
||||
match ty.sty {
|
||||
ty::TyChar => {
|
||||
ty::Char => {
|
||||
debug_assert_eq!(size.bytes(), 4);
|
||||
if ::std::char::from_u32(bits as u32).is_none() {
|
||||
return validation_failure!(
|
||||
@ -323,23 +323,23 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
fn aggregate_field_path_elem(&self, ty: Ty<'tcx>, variant: usize, field: usize) -> PathElem {
|
||||
match ty.sty {
|
||||
// generators and closures.
|
||||
ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => {
|
||||
ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => {
|
||||
let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap();
|
||||
let freevar = self.tcx.with_freevars(node_id, |fv| fv[field]);
|
||||
PathElem::ClosureVar(self.tcx.hir.name(freevar.var_id()))
|
||||
}
|
||||
|
||||
// tuples
|
||||
ty::TyTuple(_) => PathElem::TupleElem(field),
|
||||
ty::Tuple(_) => PathElem::TupleElem(field),
|
||||
|
||||
// enums
|
||||
ty::TyAdt(def, ..) if def.is_enum() => {
|
||||
ty::Adt(def, ..) if def.is_enum() => {
|
||||
let variant = &def.variants[variant];
|
||||
PathElem::Field(variant.fields[field].ident.name)
|
||||
}
|
||||
|
||||
// other ADTs
|
||||
ty::TyAdt(def, _) => PathElem::Field(def.non_enum_variant().fields[field].ident.name),
|
||||
ty::Adt(def, _) => PathElem::Field(def.non_enum_variant().fields[field].ident.name),
|
||||
|
||||
// nothing else has an aggregate layout
|
||||
_ => bug!("aggregate_field_path_elem: got non-aggregate type {:?}", ty),
|
||||
|
@ -11,9 +11,9 @@
|
||||
// Original Levenshtein distance for both of this is 1. We improved accuracy with
|
||||
// additional case insensitive comparison.
|
||||
|
||||
struct Uint {}
|
||||
struct TyUint {}
|
||||
|
||||
struct Int {}
|
||||
struct TyInt {}
|
||||
|
||||
fn main() {
|
||||
TyUInt {};
|
||||
|
@ -11,7 +11,7 @@
|
||||
trait Arr0 {
|
||||
fn arr0_secret(&self);
|
||||
}
|
||||
trait Param {
|
||||
trait TyParam {
|
||||
fn ty_param_secret(&self);
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ mod m {
|
||||
struct Priv;
|
||||
|
||||
impl ::Arr0 for [Priv; 0] { fn arr0_secret(&self) {} }
|
||||
impl ::Param for Option<Priv> { fn ty_param_secret(&self) {} }
|
||||
impl ::TyParam for Option<Priv> { fn ty_param_secret(&self) {} }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
Loading…
Reference in New Issue
Block a user