Auto merge of #1280 - RalfJung:rustup, r=RalfJung

rustup; fix for TyLayout rename
This commit is contained in:
bors 2020-03-30 08:24:40 +00:00
commit a50d87f016
3 changed files with 11 additions and 8 deletions

View file

@ -1 +1 @@
150322f86d441752874a8bed603d71119f190b8b
0afdf43dc1d9be4c8b422840166b51dd99e56a16

View file

@ -4,7 +4,7 @@ use std::mem;
use rustc::mir;
use rustc::ty::{
self,
layout::{self, LayoutOf, Size, TyLayout},
layout::{self, LayoutOf, Size, TyAndLayout},
List, TyCtxt,
};
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
@ -84,8 +84,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
self.eval_libc(name)?.to_i32()
}
/// Helper function to get the `TyLayout` of a `libc` type
fn libc_ty_layout(&mut self, name: &str) -> InterpResult<'tcx, TyLayout<'tcx>> {
/// Helper function to get the `TyAndLayout` of a `libc` type
fn libc_ty_layout(&mut self, name: &str) -> InterpResult<'tcx, TyAndLayout<'tcx>> {
let this = self.eval_context_mut();
let ty = this.resolve_path(&["libc", name]).monomorphic_ty(*this.tcx);
this.layout_of(ty)
@ -469,7 +469,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
pub fn immty_from_int_checked<'tcx>(
int: impl Into<i128>,
layout: TyLayout<'tcx>,
layout: TyAndLayout<'tcx>,
) -> InterpResult<'tcx, ImmTy<'tcx, Tag>> {
let int = int.into();
Ok(ImmTy::try_from_int(int, layout).ok_or_else(|| {
@ -479,7 +479,7 @@ pub fn immty_from_int_checked<'tcx>(
pub fn immty_from_uint_checked<'tcx>(
int: impl Into<u128>,
layout: TyLayout<'tcx>,
layout: TyAndLayout<'tcx>,
) -> InterpResult<'tcx, ImmTy<'tcx, Tag>> {
let int = int.into();
Ok(ImmTy::try_from_uint(int, layout).ok_or_else(|| {

View file

@ -35,7 +35,7 @@ fn slice_index() -> u8 {
arr[5]
}
fn try_from() {
fn from() {
const N: usize = 16;
type Array = [u8; N];
let array: Array = [0; N];
@ -43,6 +43,9 @@ fn try_from() {
let result = <&Array>::try_from(slice);
assert_eq!(&array, result.unwrap());
let vec = Vec::from(array);
assert_eq!(vec.len(), N);
}
fn eq() {
@ -69,7 +72,7 @@ fn main() {
assert_eq!(array_array(), [[5, 4], [3, 2], [1, 0]]);
assert_eq!(array_repeat(), [42; 8]);
assert_eq!(mini_array(), [42]);
try_from();
from();
eq();
debug();
}