Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 17 pull requests #76944

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f8376b5
shim: monomorphic `FnPtrShim`s during construction
davidtwco Aug 9, 2020
a06edda
Fix segfault if pthread_getattr_np fails
tavianator Sep 9, 2020
a684153
Only call pthread_attr_destroy() after getattr_np() succeeds on all l…
tavianator Sep 9, 2020
80ce7fa
miri: correctly deal with `ConstKind::Bound`
lcnr Sep 10, 2020
ae85bbb
do not ICE on `ty::Bound` in Layout::compute
lcnr Sep 11, 2020
8f27e3c
Make some methods of `Pin` unstable const
CDirkx Sep 12, 2020
e5447a2
Fix #76432
simonvandel Sep 13, 2020
9c5d0c1
MIR pass to remove unneeded drops on types not needing drop
simonvandel Sep 13, 2020
9d47ecf
Suggestion from review
simonvandel Sep 14, 2020
94dae60
simplfy condition in ItemLowerer::with_trait_impl_ref()
matthiaskrgr Sep 16, 2020
b7c8bea
Fix wording in mir doc
pickfire Sep 17, 2020
f4a7149
Don't compile regex at every function call.
hbina Sep 17, 2020
b479139
Remove intrinsics::arith_offset use from libarena
est31 Sep 17, 2020
4fe6ca3
Replace const_generics feature gate with min_const_generics
est31 Sep 17, 2020
ebdea01
Remove redundant #![feature(...)] 's from compiler/
est31 Sep 17, 2020
5f58e00
fix array_windows docs
lcnr Sep 17, 2020
2793672
use `array_windows` instead of `windows` in the compiler
lcnr Sep 17, 2020
f193593
array pattern
lcnr Sep 17, 2020
012974d
use strip_prefix over starts_with and manual slicing based on pattern…
matthiaskrgr Sep 17, 2020
764d307
docs `array` -> `slice`
lcnr Sep 17, 2020
1dd3df6
black_box: silence unused_mut warning when building with cfg(miri)
RalfJung Sep 17, 2020
1ccfcb6
Set BUILD_TRIPLE via build script
Mark-Simulacrum Sep 6, 2020
ccdb48a
Remove support for different src directory
Mark-Simulacrum Sep 7, 2020
f0392c2
Discover Rust toolchain without Python
Mark-Simulacrum Sep 7, 2020
aac7d9e
Provide bootstrap tools with RUSTC in environment
Mark-Simulacrum Sep 10, 2020
afed561
Specify output directory for bootstrap tests
Mark-Simulacrum Sep 10, 2020
e3c6e46
Make some methods of `Pin<&mut T>` unstable const
CDirkx Sep 18, 2020
083f1d7
Validate constants during `const_eval_raw`
oli-obk Jul 30, 2020
2d7ac72
Stop using the `const_eval` query for initializers of statics
oli-obk Jul 31, 2020
6d3c7bb
Update codegen tests
oli-obk Jul 31, 2020
4397d66
Document `op_to_const`'s purpose
oli-obk Aug 10, 2020
b1bd34d
`turn_into_const` is infallible
oli-obk Aug 10, 2020
48f366f
Replace `and_then` `map_err` `and_then` chain with a match
oli-obk Aug 10, 2020
a6c60bb
Clarify a statement in UB test
oli-obk Aug 10, 2020
dd9702a
Do not call the `const_eval` query in mir interpretation except for c…
oli-obk Aug 10, 2020
40c2087
We can make const eval sound, it's just super expensive
oli-obk Aug 10, 2020
69a6be7
Rename const eval queries to reflect the validation changes
oli-obk Aug 10, 2020
888afd5
Unify the names of const eval queries and their return types
oli-obk Aug 20, 2020
90708c1
Fix rebase fallout and make the test work with debug info
oli-obk Aug 21, 2020
182ed85
Address review comments
oli-obk Sep 7, 2020
c3c8c98
Rustfmt
oli-obk Sep 9, 2020
ef04e68
Update compile-fail tests
oli-obk Sep 9, 2020
c5889e4
Update incremental tests
oli-obk Sep 9, 2020
b8e6883
Reflect the "do not call this query directly" mentality in its name
oli-obk Sep 19, 2020
673935f
Get LocalDefId from source instead of passing in
simonvandel Sep 19, 2020
30dd6cf
The optimization should also apply for DropAndReplace
simonvandel Sep 19, 2020
804f673
cleanup cfg after optimization
simonvandel Sep 19, 2020
4d1ef03
cleanup promotion const_kind checks
RalfJung Sep 6, 2020
7febd5a
fix doc comment
RalfJung Sep 7, 2020
7b99c8e
never promote non-const operations; revert STATIC promotion change
RalfJung Sep 9, 2020
9216eb8
fix some comments
RalfJung Sep 9, 2020
bb11ffc
Rollup merge of #74949 - oli-obk:validate_const_eval_raw, r=RalfJung
Dylan-DPC Sep 19, 2020
9d6d856
Rollup merge of #75346 - davidtwco:issue-69925-polymorphic-instancede…
Dylan-DPC Sep 19, 2020
71e3be0
Rollup merge of #76411 - RalfJung:promote-in-const-fn, r=ecstatic-morse
Dylan-DPC Sep 19, 2020
2f985d8
Rollup merge of #76521 - tavianator:fix-pthread-getattr-destroy, r=Am…
Dylan-DPC Sep 19, 2020
fd2251e
Rollup merge of #76544 - Mark-Simulacrum:less-python, r=alexcrichton
Dylan-DPC Sep 19, 2020
4846b1f
Rollup merge of #76581 - lcnr:bound-too-generic, r=eddyb
Dylan-DPC Sep 19, 2020
1f187ac
Rollup merge of #76655 - CDirkx:const-pin, r=ecstatic-morse
Dylan-DPC Sep 19, 2020
6a50cfa
Rollup merge of #76659 - simonvandel:76432, r=oli-obk
Dylan-DPC Sep 19, 2020
f334470
Rollup merge of #76673 - simonvandel:remove-unneeded-drops, r=oli-obk
Dylan-DPC Sep 19, 2020
6928c39
Rollup merge of #76809 - matthiaskrgr:simplify_cond, r=varkor
Dylan-DPC Sep 19, 2020
bd65273
Rollup merge of #76815 - pickfire:patch-6, r=jonas-schievink
Dylan-DPC Sep 19, 2020
daba283
Rollup merge of #76818 - hbina:dont_compile_regex_all_the_time, r=ecs…
Dylan-DPC Sep 19, 2020
16532d5
Rollup merge of #76821 - est31:remove_redundant_nightly_features, r=o…
Dylan-DPC Sep 19, 2020
57a51a5
Rollup merge of #76823 - RalfJung:black-box-warn, r=joshtriplett
Dylan-DPC Sep 19, 2020
5824de0
Rollup merge of #76825 - lcnr:array-windows-apply, r=varkor
Dylan-DPC Sep 19, 2020
0a99fbb
Rollup merge of #76827 - lcnr:array_windows-docs, r=jonas-schievink
Dylan-DPC Sep 19, 2020
1fad825
Rollup merge of #76828 - matthiaskrgr:clippy_manual_strip, r=lcnr
Dylan-DPC Sep 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/",
test(no_crate_inject, attr(deny(warnings)))
)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(new_uninit)]
#![feature(maybe_uninit_slice)]
Expand All @@ -24,7 +23,6 @@ use smallvec::SmallVec;
use std::alloc::Layout;
use std::cell::{Cell, RefCell};
use std::cmp;
use std::intrinsics;
use std::marker::{PhantomData, Send};
use std::mem::{self, MaybeUninit};
use std::ptr;
Expand Down Expand Up @@ -122,7 +120,7 @@ impl<T> TypedArena<T> {

unsafe {
if mem::size_of::<T>() == 0 {
self.ptr.set(intrinsics::arith_offset(self.ptr.get() as *mut u8, 1) as *mut T);
self.ptr.set((self.ptr.get() as *mut u8).wrapping_offset(1) as *mut T);
let ptr = mem::align_of::<T>() as *mut T;
// Don't drop the object. This `write` is equivalent to `forget`.
ptr::write(ptr, object);
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
//! This API is completely unstable and subject to change.

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
#![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(const_fn)] // For the `transmute` in `P::new`
#![feature(const_panic)]
#![feature(const_fn_transmute)]
#![feature(crate_visibility_modifier)]
#![feature(label_break_value)]
#![feature(nll)]
#![feature(or_patterns)]
#![feature(try_trait)]
#![feature(unicode_internals)]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub(super) struct ItemLowerer<'a, 'lowering, 'hir> {
impl ItemLowerer<'_, '_, '_> {
fn with_trait_impl_ref(&mut self, impl_ref: &Option<TraitRef>, f: impl FnOnce(&mut Self)) {
let old = self.lctx.is_in_trait_impl;
self.lctx.is_in_trait_impl = if let &None = impl_ref { false } else { true };
self.lctx.is_in_trait_impl = impl_ref.is_some();
f(self);
self.lctx.is_in_trait_impl = old;
}
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::Node;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::interpret::{
read_target_uint, Allocation, ConstValue, ErrorHandled, GlobalAlloc, Pointer,
read_target_uint, Allocation, ErrorHandled, GlobalAlloc, Pointer,
};
use rustc_middle::mir::mono::MonoItem;
use rustc_middle::ty::{self, Instance, Ty};
Expand Down Expand Up @@ -85,10 +85,7 @@ pub fn codegen_static_initializer(
cx: &CodegenCx<'ll, 'tcx>,
def_id: DefId,
) -> Result<(&'ll Value, &'tcx Allocation), ErrorHandled> {
let alloc = match cx.tcx.const_eval_poly(def_id)? {
ConstValue::ByRef { alloc, offset } if offset.bytes() == 0 => alloc,
val => bug!("static const eval returned {:#?}", val),
};
let alloc = cx.tcx.eval_static_initializer(def_id)?;
Ok((const_alloc_to_llvm(cx, alloc), alloc))
}

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#![feature(or_patterns)]
#![feature(trusted_len)]
#![feature(associated_type_bounds)]
#![feature(const_fn)] // for rustc_index::newtype_index
#![feature(const_panic)] // for rustc_index::newtype_index
#![recursion_limit = "256"]

//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
Expand Down
26 changes: 7 additions & 19 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_ast as ast;
use rustc_hir::lang_items::LangItem;
use rustc_index::vec::Idx;
use rustc_middle::mir;
use rustc_middle::mir::interpret::{AllocId, ConstValue, Pointer, Scalar};
use rustc_middle::mir::interpret::ConstValue;
use rustc_middle::mir::AssertKind;
use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt};
use rustc_middle::ty::print::with_no_trimmed_paths;
Expand Down Expand Up @@ -867,24 +867,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let ty = constant.literal.ty;
let size = bx.layout_of(ty).size;
let scalar = match const_value {
// Promoted constants are evaluated into a ByRef instead of a Scalar,
// but we want the scalar value here.
ConstValue::ByRef { alloc, offset } => {
let ptr = Pointer::new(AllocId(0), offset);
alloc
.read_scalar(&bx, ptr, size)
.and_then(|s| s.check_init())
.unwrap_or_else(|e| {
bx.tcx().sess.span_err(
span,
&format!("Could not evaluate asm const: {}", e),
);

// We are erroring out, just emit a dummy constant.
Scalar::from_u64(0)
})
}
_ => span_bug!(span, "expected ByRef for promoted asm const"),
ConstValue::Scalar(s) => s,
_ => span_bug!(
span,
"expected Scalar for promoted asm const, but got {:#?}",
const_value
),
};
let value = scalar.assert_bits(size);
let string = match ty.kind() {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_data_structures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![allow(incomplete_features)]
#![feature(array_windows)]
#![feature(control_flow_enum)]
#![feature(in_band_lifetimes)]
#![feature(unboxed_closures)]
#![feature(generators)]
#![feature(generator_trait)]
#![feature(fn_traits)]
#![feature(int_bits_const)]
Expand All @@ -27,7 +27,7 @@
#![feature(thread_id_value)]
#![feature(extend_one)]
#![feature(const_panic)]
#![feature(const_generics)]
#![feature(min_const_generics)]
#![feature(once_cell)]
#![allow(rustc::default_hash_types)]

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_data_structures/src/sorted_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<K: Ord, V> SortedMap<K, V> {
/// and that there are no duplicates.
#[inline]
pub fn from_presorted_elements(elements: Vec<(K, V)>) -> SortedMap<K, V> {
debug_assert!(elements.windows(2).all(|w| w[0].0 < w[1].0));
debug_assert!(elements.array_windows().all(|[fst, snd]| fst.0 < snd.0));

SortedMap { data: elements }
}
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<K: Ord, V> SortedMap<K, V> {
return;
}

debug_assert!(elements.windows(2).all(|w| w[0].0 < w[1].0));
debug_assert!(elements.array_windows().all(|[fst, snd]| fst.0 < snd.0));

let start_index = self.lookup_index_for(&elements[0].0);

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_driver/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use std::fs;
use std::io;

pub fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
if arg.starts_with('@') {
let path = &arg[1..];
if let Some(path) = arg.strip_prefix('@') {
let file = match fs::read_to_string(path) {
Ok(file) => file,
Err(ref err) if err.kind() == io::ErrorKind::InvalidData => {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(bool_to_option)]
#![feature(cow_is_borrowed)]
#![feature(crate_visibility_modifier)]
#![feature(decl_macro)]
#![feature(or_patterns)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
use rustc_middle::infer::unify_key::{ConstVarValue, ConstVariableValue};
use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind, ToType};
use rustc_middle::mir;
use rustc_middle::mir::interpret::ConstEvalResult;
use rustc_middle::mir::interpret::EvalToConstValueResult;
use rustc_middle::traits::select;
use rustc_middle::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder};
Expand Down Expand Up @@ -1542,7 +1542,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
substs: SubstsRef<'tcx>,
promoted: Option<mir::Promoted>,
span: Option<Span>,
) -> ConstEvalResult<'tcx> {
) -> EvalToConstValueResult<'tcx> {
let mut original_values = OriginalQueryValues::default();
let canonical = self.canonicalize_query(&(param_env, substs), &mut original_values);

Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_infer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! This API is completely unstable and subject to change.

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(bindings_after_at)]
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
Expand All @@ -23,7 +22,6 @@
#![feature(never_type)]
#![feature(or_patterns)]
#![feature(in_band_lifetimes)]
#![feature(crate_visibility_modifier)]
#![recursion_limit = "512"] // For rustdoc

#[macro_use]
Expand Down
16 changes: 7 additions & 9 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,21 +1474,19 @@ declare_lint_pass!(
UnusedBrokenConst => []
);

fn check_const(cx: &LateContext<'_>, body_id: hir::BodyId) {
let def_id = cx.tcx.hir().body_owner_def_id(body_id).to_def_id();
// trigger the query once for all constants since that will already report the errors
// FIXME: Use ensure here
let _ = cx.tcx.const_eval_poly(def_id);
}

impl<'tcx> LateLintPass<'tcx> for UnusedBrokenConst {
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
match it.kind {
hir::ItemKind::Const(_, body_id) => {
check_const(cx, body_id);
let def_id = cx.tcx.hir().body_owner_def_id(body_id).to_def_id();
// trigger the query once for all constants since that will already report the errors
// FIXME: Use ensure here
let _ = cx.tcx.const_eval_poly(def_id);
}
hir::ItemKind::Static(_, _, body_id) => {
check_const(cx, body_id);
let def_id = cx.tcx.hir().body_owner_def_id(body_id).to_def_id();
// FIXME: Use ensure here
let _ = cx.tcx.eval_static_initializer(def_id);
}
_ => {}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(test, feature(test))]
#![feature(array_windows)]
#![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(crate_visibility_modifier)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/nonstandard_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ fn is_camel_case(name: &str) -> bool {
// ones (some scripts don't have a concept of upper/lowercase)
!name.chars().next().unwrap().is_lowercase()
&& !name.contains("__")
&& !name.chars().collect::<Vec<_>>().windows(2).any(|pair| {
&& !name.chars().collect::<Vec<_>>().array_windows().any(|&[fst, snd]| {
// contains a capitalisable character followed by, or preceded by, an underscore
char_has_case(pair[0]) && pair[1] == '_' || char_has_case(pair[1]) && pair[0] == '_'
char_has_case(fst) && snd == '_' || char_has_case(snd) && fst == '_'
})
}

Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,29 @@
//! This API is completely unstable and subject to change.

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(array_windows)]
#![feature(backtrace)]
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(cmp_min_max_by)]
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(const_fn_transmute)]
#![feature(core_intrinsics)]
#![feature(discriminant_kind)]
#![feature(drain_filter)]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(extern_types)]
#![feature(nll)]
#![feature(once_cell)]
#![feature(option_expect_none)]
#![feature(or_patterns)]
#![feature(min_specialization)]
#![feature(trusted_len)]
#![feature(stmt_expr_attributes)]
#![feature(test)]
#![feature(in_band_lifetimes)]
#![feature(crate_visibility_modifier)]
#![feature(associated_type_bounds)]
#![feature(rustc_attrs)]
#![feature(hash_raw_entry)]
#![feature(int_error_matching)]
#![recursion_limit = "512"]

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/mir/interpret/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{AllocId, Pointer, RawConst, Scalar};
use super::{AllocId, ConstAlloc, Pointer, Scalar};

use crate::mir::interpret::ConstValue;
use crate::ty::{layout, query::TyCtxtAt, tls, FnSig, Ty};
Expand Down Expand Up @@ -27,8 +27,8 @@ CloneTypeFoldableAndLiftImpls! {
ErrorHandled,
}

pub type ConstEvalRawResult<'tcx> = Result<RawConst<'tcx>, ErrorHandled>;
pub type ConstEvalResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;
pub type EvalToAllocationRawResult<'tcx> = Result<ConstAlloc<'tcx>, ErrorHandled>;
pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>;

pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> {
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ use crate::ty::subst::GenericArgKind;
use crate::ty::{self, Instance, Ty, TyCtxt};

pub use self::error::{
struct_error, CheckInAllocMsg, ConstEvalRawResult, ConstEvalResult, ErrorHandled, InterpError,
InterpErrorInfo, InterpResult, InvalidProgramInfo, MachineStopType, ResourceExhaustionInfo,
UndefinedBehaviorInfo, UninitBytesAccess, UnsupportedOpInfo,
struct_error, CheckInAllocMsg, ErrorHandled, EvalToAllocationRawResult, EvalToConstValueResult,
InterpError, InterpErrorInfo, InterpResult, InvalidProgramInfo, MachineStopType,
ResourceExhaustionInfo, UndefinedBehaviorInfo, UninitBytesAccess, UnsupportedOpInfo,
};

pub use self::value::{get_slice_bytes, ConstValue, RawConst, Scalar, ScalarMaybeUninit};
pub use self::value::{get_slice_bytes, ConstAlloc, ConstValue, Scalar, ScalarMaybeUninit};

pub use self::allocation::{Allocation, AllocationExtra, InitMask, Relocations};

Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_middle/src/mir/interpret/queries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{ConstEvalResult, ErrorHandled, GlobalId};
use super::{ErrorHandled, EvalToConstValueResult, GlobalId};

use crate::mir;
use crate::ty::subst::{InternalSubsts, SubstsRef};
Expand All @@ -10,7 +10,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Evaluates a constant without providing any substitutions. This is useful to evaluate consts
/// that can't take any generic arguments like statics, const items or enum discriminants. If a
/// generic parameter is used within the constant `ErrorHandled::ToGeneric` will be returned.
pub fn const_eval_poly(self, def_id: DefId) -> ConstEvalResult<'tcx> {
pub fn const_eval_poly(self, def_id: DefId) -> EvalToConstValueResult<'tcx> {
// In some situations def_id will have substitutions within scope, but they aren't allowed
// to be used. So we can't use `Instance::mono`, instead we feed unresolved substitutions
// into `const_eval` which will return `ErrorHandled::ToGeneric` if any of them are
Expand Down Expand Up @@ -38,7 +38,7 @@ impl<'tcx> TyCtxt<'tcx> {
substs: SubstsRef<'tcx>,
promoted: Option<mir::Promoted>,
span: Option<Span>,
) -> ConstEvalResult<'tcx> {
) -> EvalToConstValueResult<'tcx> {
match ty::Instance::resolve_opt_const_arg(self, param_env, def, substs) {
Ok(Some(instance)) => {
let cid = GlobalId { instance, promoted };
Expand All @@ -54,7 +54,7 @@ impl<'tcx> TyCtxt<'tcx> {
param_env: ty::ParamEnv<'tcx>,
instance: ty::Instance<'tcx>,
span: Option<Span>,
) -> ConstEvalResult<'tcx> {
) -> EvalToConstValueResult<'tcx> {
self.const_eval_global_id(param_env, GlobalId { instance, promoted: None }, span)
}

Expand All @@ -64,14 +64,14 @@ impl<'tcx> TyCtxt<'tcx> {
param_env: ty::ParamEnv<'tcx>,
cid: GlobalId<'tcx>,
span: Option<Span>,
) -> ConstEvalResult<'tcx> {
) -> EvalToConstValueResult<'tcx> {
// Const-eval shouldn't depend on lifetimes at all, so we can erase them, which should
// improve caching of queries.
let inputs = self.erase_regions(&param_env.and(cid));
if let Some(span) = span {
self.at(span).const_eval_validated(inputs)
self.at(span).eval_to_const_value_raw(inputs)
} else {
self.const_eval_validated(inputs)
self.eval_to_const_value_raw(inputs)
}
}

Expand All @@ -94,7 +94,7 @@ impl<'tcx> TyCtxt<'tcx> {
param_env: ty::ParamEnv<'tcx>,
) -> Result<&'tcx mir::Allocation, ErrorHandled> {
trace!("eval_to_allocation: Need to compute {:?}", gid);
let raw_const = self.const_eval_raw(param_env.and(gid))?;
let raw_const = self.eval_to_allocation_raw(param_env.and(gid))?;
Ok(self.global_alloc(raw_const.alloc_id).unwrap_memory())
}
}
Loading