Rustup to rustc 1.36.0-nightly (2268d9923 2019-05-26)
This commit is contained in:
parent
577ee79668
commit
fd2ecfcc89
2 changed files with 5 additions and 9 deletions
|
|
@ -11,7 +11,6 @@ use rustc::{bug, span_bug};
|
|||
use rustc_data_structures::sync::Lrc;
|
||||
use std::cmp::Ordering::{self, Equal};
|
||||
use std::cmp::PartialOrd;
|
||||
use std::convert::TryFrom;
|
||||
use std::convert::TryInto;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use syntax::ast::{FloatTy, LitKind};
|
||||
|
|
@ -341,7 +340,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
};
|
||||
|
||||
let result = self.lcx.tcx.const_eval(self.param_env.and(gid)).ok()?;
|
||||
let result = miri_to_const(self.lcx.tcx, &result);
|
||||
let result = miri_to_const(&result);
|
||||
if result.is_some() {
|
||||
self.needed_resolution = true;
|
||||
}
|
||||
|
|
@ -466,7 +465,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'tcx>) -> Option<Constant> {
|
||||
pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
|
||||
use rustc::mir::interpret::{ConstValue, Scalar};
|
||||
match result.val {
|
||||
ConstValue::Scalar(Scalar::Bits { bits: b, .. }) => match result.ty.sty {
|
||||
|
|
@ -487,13 +486,10 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'
|
|||
// FIXME: implement other conversions.
|
||||
_ => None,
|
||||
},
|
||||
ConstValue::Slice(Scalar::Ptr(ptr), n) => match result.ty.sty {
|
||||
ConstValue::Slice { data, start, end } => match result.ty.sty {
|
||||
ty::Ref(_, tam, _) => match tam.sty {
|
||||
ty::Str => {
|
||||
let alloc = tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id);
|
||||
let offset = ptr.offset.bytes().try_into().expect("too-large pointer offset");
|
||||
let n = usize::try_from(n).unwrap();
|
||||
String::from_utf8(alloc.bytes[offset..(offset + n)].to_owned())
|
||||
String::from_utf8(data.bytes[start..end].to_owned())
|
||||
.ok()
|
||||
.map(Constant::Str)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
|
|||
promoted: None,
|
||||
};
|
||||
let constant = cx.tcx.const_eval(param_env.and(c_id)).ok();
|
||||
if let Some(Constant::Int(val)) = constant.and_then(|c| miri_to_const(cx.tcx, &c)) {
|
||||
if let Some(Constant::Int(val)) = constant.and_then(miri_to_const) {
|
||||
let mut ty = cx.tcx.type_of(def_id);
|
||||
if let ty::Adt(adt, _) = ty.sty {
|
||||
if adt.is_enum() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue