Move everything over from middle::const_val
to mir::interpret
This commit is contained in:
parent
6005b0ad2f
commit
05994779ea
@ -370,11 +370,11 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::FieldDef {
|
||||
}
|
||||
|
||||
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
|
||||
for ::middle::const_val::ConstVal<'gcx> {
|
||||
for ::mir::interpret::ConstVal<'gcx> {
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
hcx: &mut StableHashingContext<'a>,
|
||||
hasher: &mut StableHasher<W>) {
|
||||
use middle::const_val::ConstVal::*;
|
||||
use mir::interpret::ConstVal::*;
|
||||
|
||||
mem::discriminant(self).hash_stable(hcx, hasher);
|
||||
|
||||
@ -503,13 +503,13 @@ impl_stable_hash_for!(struct ty::Const<'tcx> {
|
||||
val
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct ::middle::const_val::ConstEvalErr<'tcx> {
|
||||
impl_stable_hash_for!(struct ::mir::interpret::ConstEvalErr<'tcx> {
|
||||
span,
|
||||
stacktrace,
|
||||
error
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct ::middle::const_val::FrameInfo {
|
||||
impl_stable_hash_for!(struct ::mir::interpret::FrameInfo {
|
||||
span,
|
||||
lint_root,
|
||||
location
|
||||
|
@ -132,7 +132,6 @@ pub mod middle {
|
||||
pub mod allocator;
|
||||
pub mod borrowck;
|
||||
pub mod expr_use_visitor;
|
||||
pub mod const_val;
|
||||
pub mod cstore;
|
||||
pub mod dataflow;
|
||||
pub mod dead;
|
||||
|
@ -1,125 +0,0 @@
|
||||
// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use ty;
|
||||
use ty::subst::Substs;
|
||||
use ty::query::TyCtxtAt;
|
||||
use mir::interpret::ConstValue;
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
use syntax_pos::Span;
|
||||
use syntax::ast;
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
||||
pub type EvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, Lrc<ConstEvalErr<'tcx>>>;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)]
|
||||
pub enum ConstVal<'tcx> {
|
||||
Unevaluated(DefId, &'tcx Substs<'tcx>),
|
||||
Value(ConstValue<'tcx>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub struct ConstEvalErr<'tcx> {
|
||||
pub span: Span,
|
||||
pub error: ::mir::interpret::EvalError<'tcx>,
|
||||
pub stacktrace: Vec<FrameInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub struct FrameInfo {
|
||||
pub span: Span,
|
||||
pub location: String,
|
||||
pub lint_root: Option<ast::NodeId>,
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
|
||||
pub fn struct_error(&self,
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
message: &str)
|
||||
-> Option<DiagnosticBuilder<'tcx>>
|
||||
{
|
||||
self.struct_generic(tcx, message, None)
|
||||
}
|
||||
|
||||
pub fn report_as_error(&self,
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
message: &str
|
||||
) {
|
||||
let err = self.struct_generic(tcx, message, None);
|
||||
if let Some(mut err) = err {
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn report_as_lint(&self,
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
message: &str,
|
||||
lint_root: ast::NodeId,
|
||||
) {
|
||||
let lint = self.struct_generic(
|
||||
tcx,
|
||||
message,
|
||||
Some(lint_root),
|
||||
);
|
||||
if let Some(mut lint) = lint {
|
||||
lint.emit();
|
||||
}
|
||||
}
|
||||
|
||||
fn struct_generic(
|
||||
&self,
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
message: &str,
|
||||
lint_root: Option<ast::NodeId>,
|
||||
) -> Option<DiagnosticBuilder<'tcx>> {
|
||||
match self.error.kind {
|
||||
::mir::interpret::EvalErrorKind::TypeckError |
|
||||
::mir::interpret::EvalErrorKind::TooGeneric |
|
||||
::mir::interpret::EvalErrorKind::CheckMatchError |
|
||||
::mir::interpret::EvalErrorKind::Layout(_) => return None,
|
||||
::mir::interpret::EvalErrorKind::ReferencedConstant(ref inner) => {
|
||||
inner.struct_generic(tcx, "referenced constant", lint_root)?.emit();
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
trace!("reporting const eval failure at {:?}", self.span);
|
||||
let mut err = if let Some(lint_root) = lint_root {
|
||||
let node_id = self.stacktrace
|
||||
.iter()
|
||||
.rev()
|
||||
.filter_map(|frame| frame.lint_root)
|
||||
.next()
|
||||
.unwrap_or(lint_root);
|
||||
tcx.struct_span_lint_node(
|
||||
::rustc::lint::builtin::CONST_ERR,
|
||||
node_id,
|
||||
tcx.span,
|
||||
message,
|
||||
)
|
||||
} else {
|
||||
struct_error(tcx, message)
|
||||
};
|
||||
err.span_label(self.span, self.error.to_string());
|
||||
for FrameInfo { span, location, .. } in &self.stacktrace {
|
||||
err.span_label(*span, format!("inside call to `{}`", location));
|
||||
}
|
||||
Some(err)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn struct_error<'a, 'gcx, 'tcx>(
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
use std::{fmt, env};
|
||||
|
||||
use mir;
|
||||
use middle::const_val::ConstEvalErr;
|
||||
use ty::{FnSig, Ty, layout};
|
||||
use ty::layout::{Size, Align};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
@ -12,6 +11,115 @@ use super::{
|
||||
|
||||
use backtrace::Backtrace;
|
||||
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use ty;
|
||||
use ty::subst::Substs;
|
||||
use ty::query::TyCtxtAt;
|
||||
use mir::interpret::ConstValue;
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
use syntax_pos::Span;
|
||||
use syntax::ast;
|
||||
|
||||
pub type ConstEvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, Lrc<ConstEvalErr<'tcx>>>;
|
||||
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub struct ConstEvalErr<'tcx> {
|
||||
pub span: Span,
|
||||
pub error: ::mir::interpret::EvalError<'tcx>,
|
||||
pub stacktrace: Vec<FrameInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub struct FrameInfo {
|
||||
pub span: Span,
|
||||
pub location: String,
|
||||
pub lint_root: Option<ast::NodeId>,
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
|
||||
pub fn struct_error(&self,
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
message: &str)
|
||||
-> Option<DiagnosticBuilder<'tcx>>
|
||||
{
|
||||
self.struct_generic(tcx, message, None)
|
||||
}
|
||||
|
||||
pub fn report_as_error(&self,
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
message: &str
|
||||
) {
|
||||
let err = self.struct_generic(tcx, message, None);
|
||||
if let Some(mut err) = err {
|
||||
err.emit();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn report_as_lint(&self,
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
message: &str,
|
||||
lint_root: ast::NodeId,
|
||||
) {
|
||||
let lint = self.struct_generic(
|
||||
tcx,
|
||||
message,
|
||||
Some(lint_root),
|
||||
);
|
||||
if let Some(mut lint) = lint {
|
||||
lint.emit();
|
||||
}
|
||||
}
|
||||
|
||||
fn struct_generic(
|
||||
&self,
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
message: &str,
|
||||
lint_root: Option<ast::NodeId>,
|
||||
) -> Option<DiagnosticBuilder<'tcx>> {
|
||||
match self.error.kind {
|
||||
::mir::interpret::EvalErrorKind::TypeckError |
|
||||
::mir::interpret::EvalErrorKind::TooGeneric |
|
||||
::mir::interpret::EvalErrorKind::CheckMatchError |
|
||||
::mir::interpret::EvalErrorKind::Layout(_) => return None,
|
||||
::mir::interpret::EvalErrorKind::ReferencedConstant(ref inner) => {
|
||||
inner.struct_generic(tcx, "referenced constant", lint_root)?.emit();
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
trace!("reporting const eval failure at {:?}", self.span);
|
||||
let mut err = if let Some(lint_root) = lint_root {
|
||||
let node_id = self.stacktrace
|
||||
.iter()
|
||||
.rev()
|
||||
.filter_map(|frame| frame.lint_root)
|
||||
.next()
|
||||
.unwrap_or(lint_root);
|
||||
tcx.struct_span_lint_node(
|
||||
::rustc::lint::builtin::CONST_ERR,
|
||||
node_id,
|
||||
tcx.span,
|
||||
message,
|
||||
)
|
||||
} else {
|
||||
struct_error(tcx, message)
|
||||
};
|
||||
err.span_label(self.span, self.error.to_string());
|
||||
for FrameInfo { span, location, .. } in &self.stacktrace {
|
||||
err.span_label(*span, format!("inside call to `{}`", location));
|
||||
}
|
||||
Some(err)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn struct_error<'a, 'gcx, 'tcx>(
|
||||
tcx: TyCtxtAt<'a, 'gcx, 'tcx>,
|
||||
msg: &str,
|
||||
) -> DiagnosticBuilder<'tcx> {
|
||||
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, RustcEncodable, RustcDecodable)]
|
||||
pub struct EvalError<'tcx> {
|
||||
pub kind: EvalErrorKind<'tcx, u64>,
|
||||
|
@ -8,7 +8,10 @@ macro_rules! err {
|
||||
mod error;
|
||||
mod value;
|
||||
|
||||
pub use self::error::{EvalError, EvalResult, EvalErrorKind, AssertMessage};
|
||||
pub use self::error::{
|
||||
EvalError, EvalResult, EvalErrorKind, AssertMessage, ConstVal, ConstEvalErr, struct_error,
|
||||
FrameInfo, ConstEvalResult,
|
||||
};
|
||||
|
||||
pub use self::value::{Scalar, Value, ConstValue};
|
||||
|
||||
|
@ -5,10 +5,18 @@ use ty;
|
||||
|
||||
use super::{EvalResult, Pointer, PointerArithmetic, Allocation};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)]
|
||||
pub enum ConstVal<'tcx> {
|
||||
Value(ConstValue<'tcx>),
|
||||
}
|
||||
|
||||
/// Represents a constant value in Rust. ByVal and ScalarPair are optimizations which
|
||||
/// matches Value's optimizations for easy conversions between these two types
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash)]
|
||||
pub enum ConstValue<'tcx> {
|
||||
/// Never returned from the `const_eval` query, but the HIR contains these frequently in order
|
||||
/// to allow HIR creation to happen for everything before needing
|
||||
Unevaluated(DefId, &'tcx Substs<'tcx>),
|
||||
/// Used only for types with layout::abi::Scalar ABI and ZSTs which use Scalar::undef()
|
||||
Scalar(Scalar),
|
||||
/// Used only for types with layout::abi::ScalarPair
|
||||
|
@ -2164,7 +2164,7 @@ impl<'tcx> Debug for Literal<'tcx> {
|
||||
|
||||
/// Write a `ConstVal` in a way closer to the original source code than the `Debug` output.
|
||||
pub fn fmt_const_val<W: Write>(fmt: &mut W, const_val: &ty::Const) -> fmt::Result {
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::ConstVal;
|
||||
match const_val.val {
|
||||
ConstVal::Unevaluated(..) => write!(fmt, "{:?}", const_val),
|
||||
ConstVal::Value(val) => {
|
||||
|
@ -16,7 +16,7 @@ use rustc_data_structures::obligation_forest::{Error, ForestObligation, Obligati
|
||||
use rustc_data_structures::obligation_forest::{ObligationProcessor, ProcessResult};
|
||||
use std::marker::PhantomData;
|
||||
use hir::def_id::DefId;
|
||||
use middle::const_val::ConstEvalErr;
|
||||
use mir::interpret::ConstEvalErr;
|
||||
use mir::interpret::EvalErrorKind;
|
||||
|
||||
use super::CodeAmbiguity;
|
||||
|
@ -22,7 +22,7 @@ use hir;
|
||||
use hir::def_id::DefId;
|
||||
use infer::outlives::env::OutlivesEnvironment;
|
||||
use middle::region;
|
||||
use middle::const_val::ConstEvalErr;
|
||||
use mir::interpret::ConstEvalErr;
|
||||
use ty::subst::Substs;
|
||||
use ty::{self, AdtKind, Slice, Ty, TyCtxt, GenericParamDefKind, ToPredicate};
|
||||
use ty::error::{ExpectedFound, TypeError};
|
||||
|
@ -28,7 +28,7 @@ use super::util;
|
||||
use hir::def_id::DefId;
|
||||
use infer::{InferCtxt, InferOk};
|
||||
use infer::type_variable::TypeVariableOrigin;
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::ConstVal;
|
||||
use mir::interpret::{GlobalId};
|
||||
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
|
||||
use syntax::symbol::Symbol;
|
||||
|
@ -14,8 +14,7 @@
|
||||
|
||||
use infer::{InferCtxt, InferOk};
|
||||
use infer::at::At;
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::GlobalId;
|
||||
use mir::interpret::{GlobalId, ConstVal};
|
||||
use traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
|
||||
use traits::project::Normalized;
|
||||
use ty::{self, Ty, TyCtxt};
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::ConstVal;
|
||||
use ty::subst::Substs;
|
||||
use ty::{self, Ty, TypeFlags, TypeFoldable};
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
//! These methods return true to indicate that the visitor has found what it is looking for
|
||||
//! and does not need to visit anything else.
|
||||
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::ConstVal;
|
||||
use hir::def_id::DefId;
|
||||
use ty::{self, Binder, Ty, TyCtxt, TypeFlags};
|
||||
|
||||
|
@ -2065,7 +2065,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||
})
|
||||
} else {
|
||||
info!("invalid enum discriminant: {:#?}", val);
|
||||
::middle::const_val::struct_error(
|
||||
::mir::interpret::struct_error(
|
||||
tcx.at(tcx.def_span(expr_did)),
|
||||
"constant evaluation of enum discriminant resulted in non-integer",
|
||||
).emit();
|
||||
|
@ -26,7 +26,7 @@ use middle::resolve_lifetime::{ResolveLifetimes, Region, ObjectLifetimeDefault};
|
||||
use middle::stability::{self, DeprecationEntry};
|
||||
use middle::lang_items::{LanguageItems, LangItem};
|
||||
use middle::exported_symbols::{SymbolExportLevel, ExportedSymbol};
|
||||
use middle::const_val::EvalResult;
|
||||
use mir::interpret::ConstEvalResult;
|
||||
use mir::mono::{CodegenUnit, Stats};
|
||||
use mir;
|
||||
use mir::interpret::{GlobalId, Allocation, ConstValue};
|
||||
@ -230,7 +230,7 @@ define_queries! { <'tcx>
|
||||
/// Results of evaluating const items or constants embedded in
|
||||
/// other items (such as enum variant explicit discriminants).
|
||||
[] fn const_eval: const_eval_dep_node(ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
|
||||
-> EvalResult<'tcx>,
|
||||
-> ConstEvalResult<'tcx>,
|
||||
|
||||
/// Converts a constant value to an constant allocation
|
||||
[] fn const_value_to_allocation: const_value_to_allocation(
|
||||
|
@ -14,7 +14,7 @@
|
||||
//! type equality, etc.
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::ConstVal;
|
||||
use ty::subst::{Kind, UnpackedKind, Substs};
|
||||
use ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||
use ty::error::{ExpectedFound, TypeError};
|
||||
|
@ -13,7 +13,7 @@
|
||||
//! hand, though we've recently added some macros (e.g.,
|
||||
//! `BraceStructLiftImpl!`) to help with the tedium.
|
||||
|
||||
use middle::const_val::{ConstVal, ConstEvalErr};
|
||||
use mir::interpret::{ConstVal, ConstEvalErr};
|
||||
use ty::{self, Lift, Ty, TyCtxt};
|
||||
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||
use rustc_data_structures::accumulate_vec::AccumulateVec;
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
use hir::def_id::DefId;
|
||||
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::ConstVal;
|
||||
use middle::region;
|
||||
use polonius_engine::Atom;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
|
@ -11,7 +11,7 @@
|
||||
//! An iterator over the type substructure.
|
||||
//! WARNING: this does not keep track of the region depth.
|
||||
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::ConstVal;
|
||||
use ty::{self, Ty};
|
||||
use rustc_data_structures::small_vec::SmallVec;
|
||||
use rustc_data_structures::accumulate_vec::IntoIter as AccIntoIter;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::ConstVal;
|
||||
use infer::InferCtxt;
|
||||
use ty::subst::Substs;
|
||||
use traits;
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use hir::map::definitions::DefPathData;
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::ConstVal;
|
||||
use middle::region::{self, BlockRemainder};
|
||||
use ty::subst::{self, Subst};
|
||||
use ty::{BrAnon, BrEnv, BrFresh, BrNamed};
|
||||
|
@ -1381,7 +1381,7 @@ mod temp_stable_hash_impls {
|
||||
|
||||
fn fetch_wasm_section(tcx: TyCtxt, id: DefId) -> (String, Vec<u8>) {
|
||||
use rustc::mir::interpret::GlobalId;
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::mir::interpret::ConstVal;
|
||||
|
||||
info!("loading wasm section {:?}", id);
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
use llvm::{self, ValueRef};
|
||||
use rustc::middle::const_val::{ConstVal, ConstEvalErr};
|
||||
use rustc::mir::interpret::{ConstVal, ConstEvalErr};
|
||||
use rustc_mir::interpret::{read_target_uint, const_val_field};
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::mir;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
use llvm::{ValueRef, LLVMConstInBoundsGEP};
|
||||
use rustc::middle::const_val::ConstEvalErr;
|
||||
use rustc::mir::interpret::ConstEvalErr;
|
||||
use rustc::mir;
|
||||
use rustc::mir::interpret::ConstValue;
|
||||
use rustc::ty;
|
||||
|
@ -12,7 +12,7 @@ use self::Constructor::*;
|
||||
use self::Usefulness::*;
|
||||
use self::WitnessPreference::*;
|
||||
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::mir::interpret::ConstVal;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
|
@ -140,13 +140,13 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||
}
|
||||
PatternError::FloatBug => {
|
||||
// FIXME(#31407) this is only necessary because float parsing is buggy
|
||||
::rustc::middle::const_val::struct_error(
|
||||
::rustc::mir::interpret::struct_error(
|
||||
self.tcx.at(pat_span),
|
||||
"could not evaluate float literal (see issue #31407)",
|
||||
).emit();
|
||||
}
|
||||
PatternError::NonConstPath(span) => {
|
||||
::rustc::middle::const_val::struct_error(
|
||||
::rustc::mir::interpret::struct_error(
|
||||
self.tcx.at(span),
|
||||
"runtime values cannot be referenced in patterns",
|
||||
).emit();
|
||||
|
@ -18,7 +18,7 @@ pub(crate) use self::check_match::check_match;
|
||||
|
||||
use interpret::{const_val_field, const_variant_index, self};
|
||||
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::mir::interpret::ConstVal;
|
||||
use rustc::mir::{fmt_const_val, Field, BorrowKind, Mutability};
|
||||
use rustc::mir::interpret::{Scalar, GlobalId, ConstValue, Value};
|
||||
use rustc::ty::{self, TyCtxt, AdtDef, Ty, Region};
|
||||
|
@ -1,5 +1,5 @@
|
||||
use rustc::hir;
|
||||
use rustc::middle::const_val::{ConstEvalErr};
|
||||
use rustc::mir::interpret::{ConstEvalErr};
|
||||
use rustc::mir;
|
||||
use rustc::ty::{self, TyCtxt, Ty, Instance};
|
||||
use rustc::ty::layout::{self, LayoutOf, Primitive};
|
||||
@ -427,7 +427,7 @@ pub fn const_val_field<'a, 'tcx>(
|
||||
field: mir::Field,
|
||||
value: ConstValue<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
) -> ::rustc::middle::const_val::EvalResult<'tcx> {
|
||||
) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
|
||||
trace!("const_val_field: {:?}, {:?}, {:?}, {:?}", instance, field, value, ty);
|
||||
let mut ecx = mk_eval_cx(tcx, instance, param_env).unwrap();
|
||||
let result = (|| {
|
||||
@ -527,7 +527,7 @@ pub fn const_value_to_allocation_provider<'a, 'tcx>(
|
||||
pub fn const_eval_provider<'a, 'tcx>(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
|
||||
) -> ::rustc::middle::const_val::EvalResult<'tcx> {
|
||||
) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
|
||||
trace!("const eval: {:?}", key);
|
||||
let cid = key.value;
|
||||
let def_id = cid.instance.def.def_id();
|
||||
|
@ -3,14 +3,14 @@ use std::fmt::Write;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::hir::def::Def;
|
||||
use rustc::hir::map::definitions::DefPathData;
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::mir::interpret::ConstVal;
|
||||
use rustc::mir;
|
||||
use rustc::ty::layout::{self, Size, Align, HasDataLayout, IntegerExt, LayoutOf, TyLayout};
|
||||
use rustc::ty::subst::{Subst, Substs};
|
||||
use rustc::ty::{self, Ty, TyCtxt, TypeAndMut};
|
||||
use rustc::ty::query::TyCtxtAt;
|
||||
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
|
||||
use rustc::middle::const_val::FrameInfo;
|
||||
use rustc::mir::interpret::FrameInfo;
|
||||
use syntax::codemap::{self, Span};
|
||||
use syntax::ast::Mutability;
|
||||
use rustc::mir::interpret::{
|
||||
|
@ -7,7 +7,7 @@ use rustc::ty::ParamEnv;
|
||||
use rustc::ty::query::TyCtxtAt;
|
||||
use rustc::ty::layout::{self, Align, TargetDataLayout, Size};
|
||||
use syntax::ast::Mutability;
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::mir::interpret::ConstVal;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
|
||||
use rustc::mir::interpret::{Pointer, AllocId, Allocation, AccessKind, Value,
|
||||
|
@ -193,7 +193,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
|
||||
use rustc::hir::map as hir_map;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::mir::interpret::ConstVal;
|
||||
use rustc::mir::interpret::{AllocId, ConstValue};
|
||||
use rustc::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem};
|
||||
use rustc::ty::subst::Substs;
|
||||
|
@ -17,7 +17,7 @@ use rustc::mir::{Constant, Literal, Location, Place, Mir, Operand, Rvalue, Local
|
||||
use rustc::mir::{NullOp, StatementKind, Statement, BasicBlock, LocalKind};
|
||||
use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem};
|
||||
use rustc::mir::visit::{Visitor, PlaceContext};
|
||||
use rustc::middle::const_val::{ConstVal, ConstEvalErr};
|
||||
use rustc::mir::interpret::{ConstVal, ConstEvalErr};
|
||||
use rustc::ty::{TyCtxt, self, Instance};
|
||||
use rustc::mir::interpret::{Value, Scalar, GlobalId, EvalResult};
|
||||
use interpret::EvalContext;
|
||||
|
@ -20,7 +20,7 @@ use rustc_data_structures::indexed_vec::{IndexVec, Idx};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc::hir;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::mir::interpret::ConstVal;
|
||||
use rustc::traits::{self, TraitEngine};
|
||||
use rustc::ty::{self, TyCtxt, Ty, TypeFoldable};
|
||||
use rustc::ty::cast::CastTy;
|
||||
|
@ -29,7 +29,7 @@ use syntax::symbol::keywords::{self, Keyword};
|
||||
use syntax::symbol::{Symbol, InternedString};
|
||||
use syntax_pos::{self, DUMMY_SP, Pos, FileName};
|
||||
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::mir::interpret::ConstVal;
|
||||
use rustc::middle::privacy::AccessLevels;
|
||||
use rustc::middle::resolve_lifetime as rl;
|
||||
use rustc::ty::fold::TypeFolder;
|
||||
|
Loading…
x
Reference in New Issue
Block a user