Rollup merge of #104317 - RalfJung:ctfe-error-reporting, r=oli-obk
cleanup and dedupe CTFE and Miri error reporting It looks like most of the time, this error raised from const_prop_lint is just redundant -- it duplicates the error reported when evaluating the const-eval query. This lets us make `ConstEvalErr` private to the const_eval module which I think is a good step. The Miri change mostly replaces a `match` by `if let`, and dedupes the "this error is impossible in Miri" checks. r? ``@oli-obk`` Fixes https://github.com/rust-lang/rust/issues/75461
This commit is contained in:
commit
353b915fec
105 changed files with 724 additions and 601 deletions
|
@ -47,7 +47,7 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, '_>) -> bool {
|
||||||
if let Err(err) = fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {
|
if let Err(err) = fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {
|
||||||
all_constants_ok = false;
|
all_constants_ok = false;
|
||||||
match err {
|
match err {
|
||||||
ErrorHandled::Reported(_) | ErrorHandled::Linted => {
|
ErrorHandled::Reported(_) => {
|
||||||
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
|
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
|
||||||
}
|
}
|
||||||
ErrorHandled::TooGeneric => {
|
ErrorHandled::TooGeneric => {
|
||||||
|
|
|
@ -189,7 +189,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
all_consts_ok = false;
|
all_consts_ok = false;
|
||||||
match err {
|
match err {
|
||||||
// errored or at least linted
|
// errored or at least linted
|
||||||
ErrorHandled::Reported(_) | ErrorHandled::Linted => {}
|
ErrorHandled::Reported(_) => {}
|
||||||
ErrorHandled::TooGeneric => {
|
ErrorHandled::TooGeneric => {
|
||||||
span_bug!(const_.span, "codegen encountered polymorphic constant: {:?}", err)
|
span_bug!(const_.span, "codegen encountered polymorphic constant: {:?}", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl Error for ConstEvalErrKind {}
|
||||||
/// When const-evaluation errors, this type is constructed with the resulting information,
|
/// When const-evaluation errors, this type is constructed with the resulting information,
|
||||||
/// and then used to emit the error as a lint or hard error.
|
/// and then used to emit the error as a lint or hard error.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ConstEvalErr<'tcx> {
|
pub(super) struct ConstEvalErr<'tcx> {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub error: InterpError<'tcx>,
|
pub error: InterpError<'tcx>,
|
||||||
pub stacktrace: Vec<FrameInfo<'tcx>>,
|
pub stacktrace: Vec<FrameInfo<'tcx>>,
|
||||||
|
@ -82,8 +82,8 @@ impl<'tcx> ConstEvalErr<'tcx> {
|
||||||
ConstEvalErr { error: error.into_kind(), stacktrace, span }
|
ConstEvalErr { error: error.into_kind(), stacktrace, span }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn report_as_error(&self, tcx: TyCtxtAt<'tcx>, message: &str) -> ErrorHandled {
|
pub(super) fn report(&self, tcx: TyCtxtAt<'tcx>, message: &str) -> ErrorHandled {
|
||||||
self.struct_error(tcx, message, |_| {})
|
self.report_decorated(tcx, message, |_| {})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a diagnostic for this const eval error.
|
/// Create a diagnostic for this const eval error.
|
||||||
|
@ -95,7 +95,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
|
||||||
/// If `lint_root.is_some()` report it as a lint, else report it as a hard error.
|
/// If `lint_root.is_some()` report it as a lint, else report it as a hard error.
|
||||||
/// (Except that for some errors, we ignore all that -- see `must_error` below.)
|
/// (Except that for some errors, we ignore all that -- see `must_error` below.)
|
||||||
#[instrument(skip(self, tcx, decorate), level = "debug")]
|
#[instrument(skip(self, tcx, decorate), level = "debug")]
|
||||||
pub fn struct_error(
|
pub(super) fn report_decorated(
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxtAt<'tcx>,
|
tcx: TyCtxtAt<'tcx>,
|
||||||
message: &str,
|
message: &str,
|
||||||
|
|
|
@ -255,7 +255,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
|
||||||
return eval_nullary_intrinsic(tcx, key.param_env, def_id, substs).map_err(|error| {
|
return eval_nullary_intrinsic(tcx, key.param_env, def_id, substs).map_err(|error| {
|
||||||
let span = tcx.def_span(def_id);
|
let span = tcx.def_span(def_id);
|
||||||
let error = ConstEvalErr { error: error.into_kind(), stacktrace: vec![], span };
|
let error = ConstEvalErr { error: error.into_kind(), stacktrace: vec![], span };
|
||||||
error.report_as_error(tcx.at(span), "could not evaluate nullary intrinsic")
|
error.report(tcx.at(span), "could not evaluate nullary intrinsic")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Err(err.report_as_error(ecx.tcx.at(err.span), &msg))
|
Err(err.report(ecx.tcx.at(err.span), &msg))
|
||||||
}
|
}
|
||||||
Ok(mplace) => {
|
Ok(mplace) => {
|
||||||
// Since evaluation had no errors, validate the resulting constant.
|
// Since evaluation had no errors, validate the resulting constant.
|
||||||
|
@ -358,7 +358,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
|
||||||
if let Err(error) = validation {
|
if let Err(error) = validation {
|
||||||
// Validation failed, report an error. This is always a hard error.
|
// Validation failed, report an error. This is always a hard error.
|
||||||
let err = ConstEvalErr::new(&ecx, error, None);
|
let err = ConstEvalErr::new(&ecx, error, None);
|
||||||
Err(err.struct_error(
|
Err(err.report_decorated(
|
||||||
ecx.tcx,
|
ecx.tcx,
|
||||||
"it is undefined behavior to use this value",
|
"it is undefined behavior to use this value",
|
||||||
|diag| {
|
|diag| {
|
||||||
|
|
|
@ -103,7 +103,7 @@ pub(crate) fn try_destructure_mir_constant<'tcx>(
|
||||||
) -> InterpResult<'tcx, mir::DestructuredConstant<'tcx>> {
|
) -> InterpResult<'tcx, mir::DestructuredConstant<'tcx>> {
|
||||||
trace!("destructure_mir_constant: {:?}", val);
|
trace!("destructure_mir_constant: {:?}", val);
|
||||||
let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false);
|
let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false);
|
||||||
let op = ecx.const_to_op(&val, None)?;
|
let op = ecx.eval_mir_constant(&val, None, None)?;
|
||||||
|
|
||||||
// We go to `usize` as we cannot allocate anything bigger anyway.
|
// We go to `usize` as we cannot allocate anything bigger anyway.
|
||||||
let (field_count, variant, down) = match val.ty().kind() {
|
let (field_count, variant, down) = match val.ty().kind() {
|
||||||
|
@ -139,7 +139,7 @@ pub(crate) fn deref_mir_constant<'tcx>(
|
||||||
val: mir::ConstantKind<'tcx>,
|
val: mir::ConstantKind<'tcx>,
|
||||||
) -> mir::ConstantKind<'tcx> {
|
) -> mir::ConstantKind<'tcx> {
|
||||||
let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false);
|
let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false);
|
||||||
let op = ecx.const_to_op(&val, None).unwrap();
|
let op = ecx.eval_mir_constant(&val, None, None).unwrap();
|
||||||
let mplace = ecx.deref_operand(&op).unwrap();
|
let mplace = ecx.deref_operand(&op).unwrap();
|
||||||
if let Some(alloc_id) = mplace.ptr.provenance {
|
if let Some(alloc_id) = mplace.ptr.provenance {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::mem;
|
||||||
use rustc_hir::{self as hir, def_id::DefId, definitions::DefPathData};
|
use rustc_hir::{self as hir, def_id::DefId, definitions::DefPathData};
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_middle::mir;
|
use rustc_middle::mir;
|
||||||
use rustc_middle::mir::interpret::{InterpError, InvalidProgramInfo};
|
use rustc_middle::mir::interpret::{ErrorHandled, InterpError, InvalidProgramInfo};
|
||||||
use rustc_middle::ty::layout::{
|
use rustc_middle::ty::layout::{
|
||||||
self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf, LayoutOfHelpers,
|
self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf, LayoutOfHelpers,
|
||||||
TyAndLayout,
|
TyAndLayout,
|
||||||
|
@ -696,12 +696,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
for ct in &body.required_consts {
|
for ct in &body.required_consts {
|
||||||
let span = ct.span;
|
let span = ct.span;
|
||||||
let ct = self.subst_from_current_frame_and_normalize_erasing_regions(ct.literal)?;
|
let ct = self.subst_from_current_frame_and_normalize_erasing_regions(ct.literal)?;
|
||||||
self.const_to_op(&ct, None).map_err(|err| {
|
self.eval_mir_constant(&ct, Some(span), None)?;
|
||||||
// If there was an error, set the span of the current frame to this constant.
|
|
||||||
// Avoiding doing this when evaluation succeeds.
|
|
||||||
self.frame_mut().loc = Err(span);
|
|
||||||
err
|
|
||||||
})?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Most locals are initially dead.
|
// Most locals are initially dead.
|
||||||
|
@ -912,9 +907,32 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eval_to_allocation(
|
/// Call a query that can return `ErrorHandled`. If `span` is `Some`, point to that span when an error occurs.
|
||||||
|
pub fn ctfe_query<T>(
|
||||||
|
&self,
|
||||||
|
span: Option<Span>,
|
||||||
|
query: impl FnOnce(TyCtxtAt<'tcx>) -> Result<T, ErrorHandled>,
|
||||||
|
) -> InterpResult<'tcx, T> {
|
||||||
|
// Use a precise span for better cycle errors.
|
||||||
|
query(self.tcx.at(span.unwrap_or_else(|| self.cur_span()))).map_err(|err| {
|
||||||
|
match err {
|
||||||
|
ErrorHandled::Reported(err) => {
|
||||||
|
if let Some(span) = span {
|
||||||
|
// To make it easier to figure out where this error comes from, also add a note at the current location.
|
||||||
|
self.tcx.sess.span_note_without_error(span, "erroneous constant used");
|
||||||
|
}
|
||||||
|
err_inval!(AlreadyReported(err))
|
||||||
|
}
|
||||||
|
ErrorHandled::TooGeneric => err_inval!(TooGeneric),
|
||||||
|
}
|
||||||
|
.into()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn eval_global(
|
||||||
&self,
|
&self,
|
||||||
gid: GlobalId<'tcx>,
|
gid: GlobalId<'tcx>,
|
||||||
|
span: Option<Span>,
|
||||||
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> {
|
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> {
|
||||||
// For statics we pick `ParamEnv::reveal_all`, because statics don't have generics
|
// For statics we pick `ParamEnv::reveal_all`, because statics don't have generics
|
||||||
// and thus don't care about the parameter environment. While we could just use
|
// and thus don't care about the parameter environment. While we could just use
|
||||||
|
@ -927,8 +945,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
self.param_env
|
self.param_env
|
||||||
};
|
};
|
||||||
let param_env = param_env.with_const();
|
let param_env = param_env.with_const();
|
||||||
// Use a precise span for better cycle errors.
|
let val = self.ctfe_query(span, |tcx| tcx.eval_to_allocation_raw(param_env.and(gid)))?;
|
||||||
let val = self.tcx.at(self.cur_span()).eval_to_allocation_raw(param_env.and(gid))?;
|
|
||||||
self.raw_const_to_mplace(val)
|
self.raw_const_to_mplace(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,8 +177,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
sym::type_name => self.tcx.mk_static_str(),
|
sym::type_name => self.tcx.mk_static_str(),
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
let val =
|
let val = self.ctfe_query(None, |tcx| {
|
||||||
self.tcx.const_eval_global_id(self.param_env, gid, Some(self.tcx.span))?;
|
tcx.const_eval_global_id(self.param_env, gid, Some(tcx.span))
|
||||||
|
})?;
|
||||||
let val = self.const_val_to_op(val, ty, Some(dest.layout))?;
|
let val = self.const_val_to_op(val, ty, Some(dest.layout))?;
|
||||||
self.copy_op(&val, dest, /*allow_transmute*/ false)?;
|
self.copy_op(&val, dest, /*allow_transmute*/ false)?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,8 +501,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
throw_unsup!(ReadExternStatic(def_id));
|
throw_unsup!(ReadExternStatic(def_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a precise span for better cycle errors.
|
// We don't give a span -- statics don't need that, they cannot be generic or associated.
|
||||||
(self.tcx.at(self.cur_span()).eval_static_initializer(def_id)?, Some(def_id))
|
let val = self.ctfe_query(None, |tcx| tcx.eval_static_initializer(def_id))?;
|
||||||
|
(val, Some(def_id))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
M::before_access_global(*self.tcx, &self.machine, id, alloc, def_id, is_write)?;
|
M::before_access_global(*self.tcx, &self.machine, id, alloc, def_id, is_write)?;
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
use rustc_hir::def::Namespace;
|
use rustc_hir::def::Namespace;
|
||||||
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
|
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt, TyAndLayout};
|
||||||
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
|
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
|
||||||
use rustc_middle::ty::{ConstInt, Ty};
|
use rustc_middle::ty::{ConstInt, Ty, ValTree};
|
||||||
use rustc_middle::{mir, ty};
|
use rustc_middle::{mir, ty};
|
||||||
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::{self, Abi, Align, HasDataLayout, Size, TagEncoding};
|
use rustc_target::abi::{self, Abi, Align, HasDataLayout, Size, TagEncoding};
|
||||||
use rustc_target::abi::{VariantIdx, Variants};
|
use rustc_target::abi::{VariantIdx, Variants};
|
||||||
|
|
||||||
|
@ -527,14 +528,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
Copy(place) | Move(place) => self.eval_place_to_op(place, layout)?,
|
Copy(place) | Move(place) => self.eval_place_to_op(place, layout)?,
|
||||||
|
|
||||||
Constant(ref constant) => {
|
Constant(ref constant) => {
|
||||||
let val =
|
let c =
|
||||||
self.subst_from_current_frame_and_normalize_erasing_regions(constant.literal)?;
|
self.subst_from_current_frame_and_normalize_erasing_regions(constant.literal)?;
|
||||||
|
|
||||||
// This can still fail:
|
// This can still fail:
|
||||||
// * During ConstProp, with `TooGeneric` or since the `required_consts` were not all
|
// * During ConstProp, with `TooGeneric` or since the `required_consts` were not all
|
||||||
// checked yet.
|
// checked yet.
|
||||||
// * During CTFE, since promoteds in `const`/`static` initializer bodies can fail.
|
// * During CTFE, since promoteds in `const`/`static` initializer bodies can fail.
|
||||||
self.const_to_op(&val, layout)?
|
self.eval_mir_constant(&c, Some(constant.span), layout)?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
trace!("{:?}: {:?}", mir_op, *op);
|
trace!("{:?}: {:?}", mir_op, *op);
|
||||||
|
@ -549,9 +550,35 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
ops.iter().map(|op| self.eval_operand(op, None)).collect()
|
ops.iter().map(|op| self.eval_operand(op, None)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn const_to_op(
|
fn eval_ty_constant(
|
||||||
|
&self,
|
||||||
|
val: ty::Const<'tcx>,
|
||||||
|
span: Option<Span>,
|
||||||
|
) -> InterpResult<'tcx, ValTree<'tcx>> {
|
||||||
|
Ok(match val.kind() {
|
||||||
|
ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(..) => {
|
||||||
|
throw_inval!(TooGeneric)
|
||||||
|
}
|
||||||
|
ty::ConstKind::Error(reported) => {
|
||||||
|
throw_inval!(AlreadyReported(reported))
|
||||||
|
}
|
||||||
|
ty::ConstKind::Unevaluated(uv) => {
|
||||||
|
let instance = self.resolve(uv.def, uv.substs)?;
|
||||||
|
let cid = GlobalId { instance, promoted: None };
|
||||||
|
self.ctfe_query(span, |tcx| tcx.eval_to_valtree(self.param_env.and(cid)))?
|
||||||
|
.unwrap_or_else(|| bug!("unable to create ValTree for {uv:?}"))
|
||||||
|
}
|
||||||
|
ty::ConstKind::Bound(..) | ty::ConstKind::Infer(..) => {
|
||||||
|
span_bug!(self.cur_span(), "unexpected ConstKind in ctfe: {val:?}")
|
||||||
|
}
|
||||||
|
ty::ConstKind::Value(valtree) => valtree,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn eval_mir_constant(
|
||||||
&self,
|
&self,
|
||||||
val: &mir::ConstantKind<'tcx>,
|
val: &mir::ConstantKind<'tcx>,
|
||||||
|
span: Option<Span>,
|
||||||
layout: Option<TyAndLayout<'tcx>>,
|
layout: Option<TyAndLayout<'tcx>>,
|
||||||
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
|
) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> {
|
||||||
// FIXME(const_prop): normalization needed b/c const prop lint in
|
// FIXME(const_prop): normalization needed b/c const prop lint in
|
||||||
|
@ -563,44 +590,20 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
let val = self.tcx.normalize_erasing_regions(self.param_env, *val);
|
let val = self.tcx.normalize_erasing_regions(self.param_env, *val);
|
||||||
match val {
|
match val {
|
||||||
mir::ConstantKind::Ty(ct) => {
|
mir::ConstantKind::Ty(ct) => {
|
||||||
match ct.kind() {
|
let ty = ct.ty();
|
||||||
ty::ConstKind::Param(_) | ty::ConstKind::Placeholder(..) => {
|
let valtree = self.eval_ty_constant(ct, span)?;
|
||||||
throw_inval!(TooGeneric)
|
let const_val = self.tcx.valtree_to_const_val((ty, valtree));
|
||||||
}
|
self.const_val_to_op(const_val, ty, layout)
|
||||||
ty::ConstKind::Error(reported) => {
|
|
||||||
throw_inval!(AlreadyReported(reported))
|
|
||||||
}
|
|
||||||
ty::ConstKind::Unevaluated(uv) => {
|
|
||||||
// NOTE: We evaluate to a `ValTree` here as a check to ensure
|
|
||||||
// we're working with valid constants, even though we never need it.
|
|
||||||
let instance = self.resolve(uv.def, uv.substs)?;
|
|
||||||
let cid = GlobalId { instance, promoted: None };
|
|
||||||
let _valtree = self
|
|
||||||
.tcx
|
|
||||||
.eval_to_valtree(self.param_env.and(cid))?
|
|
||||||
.unwrap_or_else(|| bug!("unable to create ValTree for {uv:?}"));
|
|
||||||
|
|
||||||
Ok(self.eval_to_allocation(cid)?.into())
|
|
||||||
}
|
|
||||||
ty::ConstKind::Bound(..) | ty::ConstKind::Infer(..) => {
|
|
||||||
span_bug!(self.cur_span(), "unexpected ConstKind in ctfe: {ct:?}")
|
|
||||||
}
|
|
||||||
ty::ConstKind::Value(valtree) => {
|
|
||||||
let ty = ct.ty();
|
|
||||||
let const_val = self.tcx.valtree_to_const_val((ty, valtree));
|
|
||||||
self.const_val_to_op(const_val, ty, layout)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mir::ConstantKind::Val(val, ty) => self.const_val_to_op(val, ty, layout),
|
mir::ConstantKind::Val(val, ty) => self.const_val_to_op(val, ty, layout),
|
||||||
mir::ConstantKind::Unevaluated(uv, _) => {
|
mir::ConstantKind::Unevaluated(uv, _) => {
|
||||||
let instance = self.resolve(uv.def, uv.substs)?;
|
let instance = self.resolve(uv.def, uv.substs)?;
|
||||||
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())
|
Ok(self.eval_global(GlobalId { instance, promoted: uv.promoted }, span)?.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn const_val_to_op(
|
pub(super) fn const_val_to_op(
|
||||||
&self,
|
&self,
|
||||||
val_val: ConstValue<'tcx>,
|
val_val: ConstValue<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
|
|
|
@ -16,8 +16,6 @@ pub enum ErrorHandled {
|
||||||
/// Already reported an error for this evaluation, and the compilation is
|
/// Already reported an error for this evaluation, and the compilation is
|
||||||
/// *guaranteed* to fail. Warnings/lints *must not* produce `Reported`.
|
/// *guaranteed* to fail. Warnings/lints *must not* produce `Reported`.
|
||||||
Reported(ErrorGuaranteed),
|
Reported(ErrorGuaranteed),
|
||||||
/// Already emitted a lint for this evaluation.
|
|
||||||
Linted,
|
|
||||||
/// Don't emit an error, the evaluation failed because the MIR was generic
|
/// Don't emit an error, the evaluation failed because the MIR was generic
|
||||||
/// and the substs didn't fully monomorphize it.
|
/// and the substs didn't fully monomorphize it.
|
||||||
TooGeneric,
|
TooGeneric,
|
||||||
|
@ -89,18 +87,6 @@ fn print_backtrace(backtrace: &Backtrace) {
|
||||||
eprintln!("\n\nAn error occurred in miri:\n{}", backtrace);
|
eprintln!("\n\nAn error occurred in miri:\n{}", backtrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ErrorHandled> for InterpErrorInfo<'_> {
|
|
||||||
fn from(err: ErrorHandled) -> Self {
|
|
||||||
match err {
|
|
||||||
ErrorHandled::Reported(ErrorGuaranteed { .. }) | ErrorHandled::Linted => {
|
|
||||||
err_inval!(ReferencedConstant)
|
|
||||||
}
|
|
||||||
ErrorHandled::TooGeneric => err_inval!(TooGeneric),
|
|
||||||
}
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ErrorGuaranteed> for InterpErrorInfo<'_> {
|
impl From<ErrorGuaranteed> for InterpErrorInfo<'_> {
|
||||||
fn from(err: ErrorGuaranteed) -> Self {
|
fn from(err: ErrorGuaranteed) -> Self {
|
||||||
InterpError::InvalidProgram(InvalidProgramInfo::AlreadyReported(err)).into()
|
InterpError::InvalidProgram(InvalidProgramInfo::AlreadyReported(err)).into()
|
||||||
|
@ -138,9 +124,6 @@ impl<'tcx> From<InterpError<'tcx>> for InterpErrorInfo<'tcx> {
|
||||||
pub enum InvalidProgramInfo<'tcx> {
|
pub enum InvalidProgramInfo<'tcx> {
|
||||||
/// Resolution can fail if we are in a too generic context.
|
/// Resolution can fail if we are in a too generic context.
|
||||||
TooGeneric,
|
TooGeneric,
|
||||||
/// Cannot compute this constant because it depends on another one
|
|
||||||
/// which already produced an error.
|
|
||||||
ReferencedConstant,
|
|
||||||
/// Abort in case errors are already reported.
|
/// Abort in case errors are already reported.
|
||||||
AlreadyReported(ErrorGuaranteed),
|
AlreadyReported(ErrorGuaranteed),
|
||||||
/// An error occurred during layout computation.
|
/// An error occurred during layout computation.
|
||||||
|
@ -158,9 +141,11 @@ impl fmt::Display for InvalidProgramInfo<'_> {
|
||||||
use InvalidProgramInfo::*;
|
use InvalidProgramInfo::*;
|
||||||
match self {
|
match self {
|
||||||
TooGeneric => write!(f, "encountered overly generic constant"),
|
TooGeneric => write!(f, "encountered overly generic constant"),
|
||||||
ReferencedConstant => write!(f, "referenced constant has errors"),
|
|
||||||
AlreadyReported(ErrorGuaranteed { .. }) => {
|
AlreadyReported(ErrorGuaranteed { .. }) => {
|
||||||
write!(f, "encountered constants with type errors, stopping evaluation")
|
write!(
|
||||||
|
f,
|
||||||
|
"an error has already been reported elsewhere (this sould not usually be printed)"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Layout(ref err) => write!(f, "{err}"),
|
Layout(ref err) => write!(f, "{err}"),
|
||||||
FnAbiAdjustForForeignAbi(ref err) => write!(f, "{err}"),
|
FnAbiAdjustForForeignAbi(ref err) => write!(f, "{err}"),
|
||||||
|
|
|
@ -175,6 +175,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
|
|
||||||
impl<'tcx> TyCtxtAt<'tcx> {
|
impl<'tcx> TyCtxtAt<'tcx> {
|
||||||
/// Evaluate a static's initializer, returning the allocation of the initializer's memory.
|
/// Evaluate a static's initializer, returning the allocation of the initializer's memory.
|
||||||
|
///
|
||||||
|
/// The span is entirely ignored here, but still helpful for better query cycle errors.
|
||||||
pub fn eval_static_initializer(
|
pub fn eval_static_initializer(
|
||||||
self,
|
self,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
|
@ -187,6 +189,8 @@ impl<'tcx> TyCtxtAt<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Evaluate anything constant-like, returning the allocation of the final memory.
|
/// Evaluate anything constant-like, returning the allocation of the final memory.
|
||||||
|
///
|
||||||
|
/// The span is entirely ignored here, but still helpful for better query cycle errors.
|
||||||
fn eval_to_allocation(
|
fn eval_to_allocation(
|
||||||
self,
|
self,
|
||||||
gid: GlobalId<'tcx>,
|
gid: GlobalId<'tcx>,
|
||||||
|
|
|
@ -2304,7 +2304,7 @@ impl<'tcx> ConstantKind<'tcx> {
|
||||||
// FIXME: We might want to have a `try_eval`-like function on `Unevaluated`
|
// FIXME: We might want to have a `try_eval`-like function on `Unevaluated`
|
||||||
match tcx.const_eval_resolve(param_env, uneval, None) {
|
match tcx.const_eval_resolve(param_env, uneval, None) {
|
||||||
Ok(val) => Self::Val(val, ty),
|
Ok(val) => Self::Val(val, ty),
|
||||||
Err(ErrorHandled::TooGeneric | ErrorHandled::Linted) => self,
|
Err(ErrorHandled::TooGeneric) => self,
|
||||||
Err(ErrorHandled::Reported(guar)) => {
|
Err(ErrorHandled::Reported(guar)) => {
|
||||||
Self::Ty(tcx.const_error_with_guaranteed(ty, guar))
|
Self::Ty(tcx.const_error_with_guaranteed(ty, guar))
|
||||||
}
|
}
|
||||||
|
|
|
@ -463,9 +463,7 @@ impl<'tcx> AdtDef<'tcx> {
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let msg = match err {
|
let msg = match err {
|
||||||
ErrorHandled::Reported(_) | ErrorHandled::Linted => {
|
ErrorHandled::Reported(_) => "enum discriminant evaluation failed",
|
||||||
"enum discriminant evaluation failed"
|
|
||||||
}
|
|
||||||
ErrorHandled::TooGeneric => "enum discriminant depends on generics",
|
ErrorHandled::TooGeneric => "enum discriminant depends on generics",
|
||||||
};
|
};
|
||||||
tcx.sess.delay_span_bug(tcx.def_span(expr_did), msg);
|
tcx.sess.delay_span_bug(tcx.def_span(expr_did), msg);
|
||||||
|
|
|
@ -226,7 +226,7 @@ impl<'tcx> ConstKind<'tcx> {
|
||||||
// (which may be identity substs, see above),
|
// (which may be identity substs, see above),
|
||||||
// can leak through `val` into the const we return.
|
// can leak through `val` into the const we return.
|
||||||
Ok(val) => Some(Ok(EvalResult::ValTree(val?))),
|
Ok(val) => Some(Ok(EvalResult::ValTree(val?))),
|
||||||
Err(ErrorHandled::TooGeneric | ErrorHandled::Linted) => None,
|
Err(ErrorHandled::TooGeneric) => None,
|
||||||
Err(ErrorHandled::Reported(e)) => Some(Err(e)),
|
Err(ErrorHandled::Reported(e)) => Some(Err(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ impl<'tcx> ConstKind<'tcx> {
|
||||||
// (which may be identity substs, see above),
|
// (which may be identity substs, see above),
|
||||||
// can leak through `val` into the const we return.
|
// can leak through `val` into the const we return.
|
||||||
Ok(val) => Some(Ok(EvalResult::ConstVal(val))),
|
Ok(val) => Some(Ok(EvalResult::ConstVal(val))),
|
||||||
Err(ErrorHandled::TooGeneric | ErrorHandled::Linted) => None,
|
Err(ErrorHandled::TooGeneric) => None,
|
||||||
Err(ErrorHandled::Reported(e)) => Some(Err(e)),
|
Err(ErrorHandled::Reported(e)) => Some(Err(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -471,7 +471,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.ecx.const_to_op(&c.literal, None).ok()
|
// No span, we don't want errors to be shown.
|
||||||
|
self.ecx.eval_mir_constant(&c.literal, None, None).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the value, if any, of evaluating `place`.
|
/// Returns the value, if any, of evaluating `place`.
|
||||||
|
|
|
@ -5,7 +5,6 @@ use crate::const_prop::CanConstProp;
|
||||||
use crate::const_prop::ConstPropMachine;
|
use crate::const_prop::ConstPropMachine;
|
||||||
use crate::const_prop::ConstPropMode;
|
use crate::const_prop::ConstPropMode;
|
||||||
use crate::MirLint;
|
use crate::MirLint;
|
||||||
use rustc_const_eval::const_eval::ConstEvalErr;
|
|
||||||
use rustc_const_eval::interpret::Immediate;
|
use rustc_const_eval::interpret::Immediate;
|
||||||
use rustc_const_eval::interpret::{
|
use rustc_const_eval::interpret::{
|
||||||
self, InterpCx, InterpResult, LocalState, LocalValue, MemoryKind, OpTy, Scalar, StackPopCleanup,
|
self, InterpCx, InterpResult, LocalState, LocalValue, MemoryKind, OpTy, Scalar, StackPopCleanup,
|
||||||
|
@ -286,25 +285,13 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the value, if any, of evaluating `c`.
|
/// Returns the value, if any, of evaluating `c`.
|
||||||
fn eval_constant(
|
fn eval_constant(&mut self, c: &Constant<'tcx>, source_info: SourceInfo) -> Option<OpTy<'tcx>> {
|
||||||
&mut self,
|
|
||||||
c: &Constant<'tcx>,
|
|
||||||
_source_info: SourceInfo,
|
|
||||||
) -> Option<OpTy<'tcx>> {
|
|
||||||
// FIXME we need to revisit this for #67176
|
// FIXME we need to revisit this for #67176
|
||||||
if c.needs_subst() {
|
if c.needs_subst() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.ecx.const_to_op(&c.literal, None) {
|
self.use_ecx(source_info, |this| this.ecx.eval_mir_constant(&c.literal, Some(c.span), None))
|
||||||
Ok(op) => Some(op),
|
|
||||||
Err(error) => {
|
|
||||||
let tcx = self.ecx.tcx.at(c.span);
|
|
||||||
let err = ConstEvalErr::new(&self.ecx, error, Some(c.span));
|
|
||||||
err.report_as_error(tcx, "erroneous constant used");
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the value, if any, of evaluating `place`.
|
/// Returns the value, if any, of evaluating `place`.
|
||||||
|
|
|
@ -773,7 +773,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
||||||
match self.tcx.const_eval_resolve(param_env, ct.expand(), None) {
|
match self.tcx.const_eval_resolve(param_env, ct.expand(), None) {
|
||||||
// The `monomorphize` call should have evaluated that constant already.
|
// The `monomorphize` call should have evaluated that constant already.
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(ErrorHandled::Reported(_) | ErrorHandled::Linted) => return,
|
Err(ErrorHandled::Reported(_)) => return,
|
||||||
Err(ErrorHandled::TooGeneric) => span_bug!(
|
Err(ErrorHandled::TooGeneric) => span_bug!(
|
||||||
self.body.source_info(location).span,
|
self.body.source_info(location).span,
|
||||||
"collection encountered polymorphic constant: {:?}",
|
"collection encountered polymorphic constant: {:?}",
|
||||||
|
@ -788,7 +788,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
||||||
match self.tcx.const_eval_resolve(param_env, uv, None) {
|
match self.tcx.const_eval_resolve(param_env, uv, None) {
|
||||||
// The `monomorphize` call should have evaluated that constant already.
|
// The `monomorphize` call should have evaluated that constant already.
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(ErrorHandled::Reported(_) | ErrorHandled::Linted) => return,
|
Err(ErrorHandled::Reported(_)) => return,
|
||||||
Err(ErrorHandled::TooGeneric) => span_bug!(
|
Err(ErrorHandled::TooGeneric) => span_bug!(
|
||||||
self.body.source_info(location).span,
|
self.body.source_info(location).span,
|
||||||
"collection encountered polymorphic constant: {:?}",
|
"collection encountered polymorphic constant: {:?}",
|
||||||
|
|
|
@ -198,13 +198,6 @@ pub fn is_const_evaluatable<'tcx>(
|
||||||
.sess
|
.sess
|
||||||
.delay_span_bug(span, "Missing value for constant, but no error reported?"),
|
.delay_span_bug(span, "Missing value for constant, but no error reported?"),
|
||||||
)),
|
)),
|
||||||
Err(ErrorHandled::Linted) => {
|
|
||||||
let reported = infcx
|
|
||||||
.tcx
|
|
||||||
.sess
|
|
||||||
.delay_span_bug(span, "constant in type had error reported as lint");
|
|
||||||
Err(NotConstEvaluatable::Error(reported))
|
|
||||||
}
|
|
||||||
Err(ErrorHandled::Reported(e)) => Err(NotConstEvaluatable::Error(e)),
|
Err(ErrorHandled::Reported(e)) => Err(NotConstEvaluatable::Error(e)),
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
}
|
}
|
||||||
|
@ -254,11 +247,6 @@ pub fn is_const_evaluatable<'tcx>(
|
||||||
|
|
||||||
Err(err)
|
Err(err)
|
||||||
},
|
},
|
||||||
Err(ErrorHandled::Linted) => {
|
|
||||||
let reported =
|
|
||||||
infcx.tcx.sess.delay_span_bug(span, "constant in type had error reported as lint");
|
|
||||||
Err(NotConstEvaluatable::Error(reported))
|
|
||||||
}
|
|
||||||
Err(ErrorHandled::Reported(e)) => Err(NotConstEvaluatable::Error(e)),
|
Err(ErrorHandled::Reported(e)) => Err(NotConstEvaluatable::Error(e)),
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
}
|
}
|
||||||
|
|
|
@ -558,12 +558,6 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
NotConstEvaluatable::Error(reported),
|
NotConstEvaluatable::Error(reported),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
|
|
||||||
span_bug!(
|
|
||||||
obligation.cause.span(),
|
|
||||||
"ConstEquate: const_eval_resolve returned an unexpected error"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
||||||
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
||||||
ProcessResult::Unchanged
|
ProcessResult::Unchanged
|
||||||
|
|
|
@ -727,12 +727,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
(Err(ErrorHandled::Reported(_)), _)
|
(Err(ErrorHandled::Reported(_)), _)
|
||||||
| (_, Err(ErrorHandled::Reported(_))) => Ok(EvaluatedToErr),
|
| (_, Err(ErrorHandled::Reported(_))) => Ok(EvaluatedToErr),
|
||||||
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
|
|
||||||
span_bug!(
|
|
||||||
obligation.cause.span(),
|
|
||||||
"ConstEquate: const_eval_resolve returned an unexpected error"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
(Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => {
|
||||||
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
if c1.has_non_region_infer() || c2.has_non_region_infer() {
|
||||||
Ok(EvaluatedToAmbig)
|
Ok(EvaluatedToAmbig)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
error[E0391]: cycle detected when const-evaluating + checking `Tr::A`
|
error[E0391]: cycle detected when const-evaluating + checking `Tr::A`
|
||||||
--> $DIR/defaults-cyclic-fail.rs:5:5
|
--> $DIR/defaults-cyclic-fail.rs:5:19
|
||||||
|
|
|
|
||||||
LL | const A: u8 = Self::B;
|
LL | const A: u8 = Self::B;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
|
|
||||||
note: ...which requires const-evaluating + checking `Tr::B`...
|
note: ...which requires const-evaluating + checking `Tr::B`...
|
||||||
--> $DIR/defaults-cyclic-fail.rs:8:5
|
--> $DIR/defaults-cyclic-fail.rs:8:19
|
||||||
|
|
|
|
||||||
LL | const B: u8 = Self::A;
|
LL | const B: u8 = Self::A;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^
|
||||||
= note: ...which again requires const-evaluating + checking `Tr::A`, completing the cycle
|
= note: ...which again requires const-evaluating + checking `Tr::A`, completing the cycle
|
||||||
note: cycle used when const-evaluating + checking `main::promoted[1]`
|
note: cycle used when const-evaluating + checking `main::promoted[1]`
|
||||||
--> $DIR/defaults-cyclic-fail.rs:16:16
|
--> $DIR/defaults-cyclic-fail.rs:16:16
|
||||||
|
|
|
@ -31,8 +31,7 @@ impl Tr for u32 {
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_eq!(<() as Tr>::A, 255);
|
assert_eq!(<() as Tr>::A, 255);
|
||||||
assert_eq!(<() as Tr>::B, 0); // causes the error above
|
assert_eq!(<() as Tr>::B, 0); // causes the error above
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
//~| ERROR erroneous constant used
|
|
||||||
|
|
||||||
assert_eq!(<u8 as Tr>::A, 254);
|
assert_eq!(<u8 as Tr>::A, 254);
|
||||||
assert_eq!(<u8 as Tr>::B, 255);
|
assert_eq!(<u8 as Tr>::B, 255);
|
||||||
|
|
|
@ -4,20 +4,36 @@ error[E0080]: evaluation of `<() as Tr>::B` failed
|
||||||
LL | const B: u8 = Self::A + 1;
|
LL | const B: u8 = Self::A + 1;
|
||||||
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
|
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/defaults-not-assumed-fail.rs:33:16
|
--> $DIR/defaults-not-assumed-fail.rs:33:16
|
||||||
|
|
|
|
||||||
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
|
||||||
| ^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/defaults-not-assumed-fail.rs:33:5
|
--> $DIR/defaults-not-assumed-fail.rs:33:5
|
||||||
|
|
|
|
||||||
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/defaults-not-assumed-fail.rs:33:5
|
||||||
|
|
|
||||||
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/defaults-not-assumed-fail.rs:33:5
|
||||||
|
|
|
||||||
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -10,10 +10,10 @@ note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
|
||||||
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
|
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
|
note: ...which requires const-evaluating + checking `IMPL_REF_BAR`...
|
||||||
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1
|
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:27
|
||||||
|
|
|
|
||||||
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
|
LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 11:19>::BAR`...
|
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 11:19>::BAR`...
|
||||||
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
|
--> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5
|
||||||
|
|
|
|
||||||
|
|
|
@ -10,10 +10,10 @@ note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
|
||||||
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
|
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
|
note: ...which requires const-evaluating + checking `DEFAULT_REF_BAR`...
|
||||||
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1
|
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:30
|
||||||
|
|
|
|
||||||
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
|
LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
note: ...which requires const-evaluating + checking `FooDefault::BAR`...
|
note: ...which requires const-evaluating + checking `FooDefault::BAR`...
|
||||||
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
|
--> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5
|
||||||
|
|
|
|
||||||
|
|
|
@ -10,10 +10,10 @@ note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
|
||||||
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
|
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
|
note: ...which requires const-evaluating + checking `TRAIT_REF_BAR`...
|
||||||
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1
|
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:28
|
||||||
|
|
|
|
||||||
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
|
LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 11:28>::BAR`...
|
note: ...which requires const-evaluating + checking `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 11:28>::BAR`...
|
||||||
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
|
--> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
// The `panic!()` below is important to trigger the fixed ICE.
|
// The `panic!()` below is important to trigger the fixed ICE.
|
||||||
|
|
||||||
const _CONST: &[u8] = &f(&[], |_| {});
|
const _CONST: &[u8] = &f(&[], |_| {});
|
||||||
//~^ ERROR constant
|
//~^ constant
|
||||||
|
|
||||||
const fn f<F>(_: &[u8], _: F) -> &[u8]
|
const fn f<F>(_: &[u8], _: F) -> &[u8]
|
||||||
where
|
where
|
||||||
F: FnMut(&u8),
|
F: FnMut(&u8),
|
||||||
{
|
{
|
||||||
panic!() //~ ERROR: evaluation of constant value failed
|
panic!() //~ ERROR evaluation of constant value failed
|
||||||
|
//~^ panic
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -12,12 +12,12 @@ LL | panic!()
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-81899.rs:4:23
|
--> $DIR/issue-81899.rs:4:23
|
||||||
|
|
|
|
||||||
LL | const _CONST: &[u8] = &f(&[], |_| {});
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
|
||||||
| ^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
// Regression test related to issue 88434
|
// Regression test related to issue 88434
|
||||||
|
|
||||||
const _CONST: &() = &f(&|_| {});
|
const _CONST: &() = &f(&|_| {});
|
||||||
//~^ ERROR constant
|
//~^ constant
|
||||||
|
|
||||||
const fn f<F>(_: &F)
|
const fn f<F>(_: &F)
|
||||||
where
|
where
|
||||||
F: FnMut(&u8),
|
F: FnMut(&u8),
|
||||||
{
|
{
|
||||||
panic!() //~ ERROR evaluation of constant value failed
|
panic!() //~ ERROR evaluation of constant value failed
|
||||||
|
//~^ panic
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
|
@ -12,12 +12,12 @@ LL | panic!()
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-88434-minimal-example.rs:3:21
|
--> $DIR/issue-88434-minimal-example.rs:3:21
|
||||||
|
|
|
|
||||||
LL | const _CONST: &() = &f(&|_| {});
|
LL | const _CONST: &() = &f(&|_| {});
|
||||||
| ^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
// Regression test for issue 88434
|
// Regression test for issue 88434
|
||||||
|
|
||||||
const _CONST: &[u8] = &f(&[], |_| {});
|
const _CONST: &[u8] = &f(&[], |_| {});
|
||||||
//~^ ERROR constant
|
//~^ constant
|
||||||
|
|
||||||
const fn f<F>(_: &[u8], _: F) -> &[u8]
|
const fn f<F>(_: &[u8], _: F) -> &[u8]
|
||||||
where
|
where
|
||||||
F: FnMut(&u8),
|
F: FnMut(&u8),
|
||||||
{
|
{
|
||||||
panic!() //~ ERROR evaluation of constant value failed
|
panic!() //~ ERROR evaluation of constant value failed
|
||||||
|
//~^ panic
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
|
@ -12,12 +12,12 @@ LL | panic!()
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-88434-removal-index-should-be-less.rs:3:23
|
--> $DIR/issue-88434-removal-index-should-be-less.rs:3:23
|
||||||
|
|
|
|
||||||
LL | const _CONST: &[u8] = &f(&[], |_| {});
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
|
||||||
| ^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -16,7 +16,5 @@ impl<T> S<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
black_box((S::<i32>::FOO, S::<u32>::FOO));
|
black_box((S::<i32>::FOO, S::<u32>::FOO)); //~ constant
|
||||||
//~^ ERROR erroneous constant
|
|
||||||
//~| ERROR erroneous constant
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,17 @@ error[E0080]: evaluation of `S::<i32>::FOO` failed
|
||||||
LL | const FOO: u8 = [5u8][1];
|
LL | const FOO: u8 = [5u8][1];
|
||||||
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/const-err-late.rs:19:16
|
--> $DIR/const-err-late.rs:19:16
|
||||||
|
|
|
|
||||||
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
||||||
| ^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/const-err-late.rs:19:16
|
||||||
|
|
|
||||||
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of `S::<u32>::FOO` failed
|
error[E0080]: evaluation of `S::<u32>::FOO` failed
|
||||||
--> $DIR/const-err-late.rs:13:21
|
--> $DIR/const-err-late.rs:13:21
|
||||||
|
@ -16,12 +22,30 @@ error[E0080]: evaluation of `S::<u32>::FOO` failed
|
||||||
LL | const FOO: u8 = [5u8][1];
|
LL | const FOO: u8 = [5u8][1];
|
||||||
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/const-err-late.rs:19:31
|
--> $DIR/const-err-late.rs:19:31
|
||||||
|
|
|
|
||||||
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
||||||
| ^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/const-err-late.rs:19:31
|
||||||
|
|
|
||||||
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/const-err-late.rs:19:16
|
||||||
|
|
|
||||||
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/const-err-late.rs:19:31
|
||||||
|
|
|
||||||
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
pub const A: i8 = -i8::MIN;
|
pub const A: i8 = -i8::MIN;
|
||||||
//~^ ERROR constant
|
//~^ ERROR constant
|
||||||
pub const B: i8 = A;
|
pub const B: i8 = A;
|
||||||
//~^ ERROR constant
|
//~^ constant
|
||||||
pub const C: u8 = A as u8;
|
pub const C: u8 = A as u8;
|
||||||
//~^ ERROR constant
|
//~^ constant
|
||||||
pub const D: i8 = 50 - A;
|
pub const D: i8 = 50 - A;
|
||||||
//~^ ERROR constant
|
//~^ constant
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = (A, B, C, D);
|
let _ = (A, B, C, D);
|
||||||
|
|
|
@ -4,24 +4,24 @@ error[E0080]: evaluation of constant value failed
|
||||||
LL | pub const A: i8 = -i8::MIN;
|
LL | pub const A: i8 = -i8::MIN;
|
||||||
| ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
|
| ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-err-multi.rs:3:19
|
--> $DIR/const-err-multi.rs:3:19
|
||||||
|
|
|
|
||||||
LL | pub const B: i8 = A;
|
LL | pub const B: i8 = A;
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-err-multi.rs:5:19
|
--> $DIR/const-err-multi.rs:5:19
|
||||||
|
|
|
|
||||||
LL | pub const C: u8 = A as u8;
|
LL | pub const C: u8 = A as u8;
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-err-multi.rs:7:24
|
--> $DIR/const-err-multi.rs:7:24
|
||||||
|
|
|
|
||||||
LL | pub const D: i8 = 50 - A;
|
LL | pub const D: i8 = 50 - A;
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -10,7 +10,7 @@ const fn no_codegen<T>() {
|
||||||
if false {
|
if false {
|
||||||
// This bad constant is only used in dead code in a no-codegen function... and yet we still
|
// This bad constant is only used in dead code in a no-codegen function... and yet we still
|
||||||
// must make sure that the build fails.
|
// must make sure that the build fails.
|
||||||
let _ = PrintName::<T>::VOID; //~ERROR could not evaluate static initializer
|
let _ = PrintName::<T>::VOID; //~ constant
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,12 @@ error[E0080]: evaluation of `PrintName::<i32>::VOID` failed
|
||||||
LL | const VOID: () = [()][2];
|
LL | const VOID: () = [()][2];
|
||||||
| ^^^^^^^ index out of bounds: the length is 1 but the index is 2
|
| ^^^^^^^ index out of bounds: the length is 1 but the index is 2
|
||||||
|
|
||||||
error[E0080]: could not evaluate static initializer
|
note: erroneous constant used
|
||||||
--> $DIR/erroneous-const.rs:13:17
|
--> $DIR/erroneous-const.rs:13:17
|
||||||
|
|
|
|
||||||
LL | let _ = PrintName::<T>::VOID;
|
LL | let _ = PrintName::<T>::VOID;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
| |
|
|
||||||
| referenced constant has errors
|
|
||||||
| inside `no_codegen::<i32>` at $DIR/erroneous-const.rs:13:17
|
|
||||||
...
|
|
||||||
LL | pub static FOO: () = no_codegen::<i32>();
|
|
||||||
| ------------------- inside `FOO` at $DIR/erroneous-const.rs:17:22
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub static FOO: () = {
|
||||||
if false {
|
if false {
|
||||||
// This bad constant is only used in dead code in a static initializer... and yet we still
|
// This bad constant is only used in dead code in a static initializer... and yet we still
|
||||||
// must make sure that the build fails.
|
// must make sure that the build fails.
|
||||||
let _ = PrintName::<i32>::VOID; //~ERROR could not evaluate static initializer
|
let _ = PrintName::<i32>::VOID; //~ constant
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@ error[E0080]: evaluation of `PrintName::<i32>::VOID` failed
|
||||||
LL | const VOID: () = [()][2];
|
LL | const VOID: () = [()][2];
|
||||||
| ^^^^^^^ index out of bounds: the length is 1 but the index is 2
|
| ^^^^^^^ index out of bounds: the length is 1 but the index is 2
|
||||||
|
|
||||||
error[E0080]: could not evaluate static initializer
|
note: erroneous constant used
|
||||||
--> $DIR/erroneous-const2.rs:13:17
|
--> $DIR/erroneous-const2.rs:13:17
|
||||||
|
|
|
|
||||||
LL | let _ = PrintName::<i32>::VOID;
|
LL | let _ = PrintName::<i32>::VOID;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
const fn failure() {
|
const fn failure() {
|
||||||
panic!("{:?}", 0);
|
panic!("{:?}", 0);
|
||||||
//~^ ERROR cannot call non-const formatting macro in constant functions
|
//~^ ERROR cannot call non-const formatting macro in constant functions
|
||||||
//~| ERROR erroneous constant used
|
|
||||||
//~| ERROR erroneous constant used
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn print() {
|
const fn print() {
|
||||||
|
@ -10,8 +8,6 @@ const fn print() {
|
||||||
//~^ ERROR cannot call non-const formatting macro in constant functions
|
//~^ ERROR cannot call non-const formatting macro in constant functions
|
||||||
//~| ERROR `Arguments::<'a>::new_v1` is not yet stable as a const fn
|
//~| ERROR `Arguments::<'a>::new_v1` is not yet stable as a const fn
|
||||||
//~| ERROR cannot call non-const fn `_print` in constant functions
|
//~| ERROR cannot call non-const fn `_print` in constant functions
|
||||||
//~| ERROR erroneous constant used
|
|
||||||
//~| ERROR erroneous constant used
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ LL | panic!("{:?}", 0);
|
||||||
= note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0015]: cannot call non-const formatting macro in constant functions
|
error[E0015]: cannot call non-const formatting macro in constant functions
|
||||||
--> $DIR/format.rs:9:22
|
--> $DIR/format.rs:7:22
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", 0);
|
LL | println!("{:?}", 0);
|
||||||
| ^
|
| ^
|
||||||
|
@ -17,7 +17,7 @@ LL | println!("{:?}", 0);
|
||||||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: `Arguments::<'a>::new_v1` is not yet stable as a const fn
|
error: `Arguments::<'a>::new_v1` is not yet stable as a const fn
|
||||||
--> $DIR/format.rs:9:5
|
--> $DIR/format.rs:7:5
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", 0);
|
LL | println!("{:?}", 0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -26,7 +26,7 @@ LL | println!("{:?}", 0);
|
||||||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0015]: cannot call non-const fn `_print` in constant functions
|
error[E0015]: cannot call non-const fn `_print` in constant functions
|
||||||
--> $DIR/format.rs:9:5
|
--> $DIR/format.rs:7:5
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", 0);
|
LL | println!("{:?}", 0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -34,35 +34,62 @@ LL | println!("{:?}", 0);
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
= note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/format.rs:2:12
|
--> $DIR/format.rs:2:12
|
||||||
|
|
|
|
||||||
LL | panic!("{:?}", 0);
|
LL | panic!("{:?}", 0);
|
||||||
| ^^^^^^ referenced constant has errors
|
| ^^^^^^
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
|
--> $DIR/format.rs:2:12
|
||||||
|
|
|
||||||
|
LL | panic!("{:?}", 0);
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
--> $DIR/format.rs:2:20
|
--> $DIR/format.rs:2:20
|
||||||
|
|
|
|
||||||
LL | panic!("{:?}", 0);
|
LL | panic!("{:?}", 0);
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/format.rs:9:14
|
--> $DIR/format.rs:2:20
|
||||||
|
|
|
||||||
|
LL | panic!("{:?}", 0);
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/format.rs:7:14
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", 0);
|
LL | println!("{:?}", 0);
|
||||||
| ^^^^^^ referenced constant has errors
|
| ^^^^^^
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/format.rs:9:22
|
--> $DIR/format.rs:7:14
|
||||||
|
|
|
|
||||||
LL | println!("{:?}", 0);
|
LL | println!("{:?}", 0);
|
||||||
| ^ referenced constant has errors
|
| ^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/format.rs:7:22
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
LL | println!("{:?}", 0);
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 8 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/format.rs:7:22
|
||||||
|
|
|
||||||
|
LL | println!("{:?}", 0);
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0080.
|
error: aborting due to 4 previous errors
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
|
||||||
|
For more information about this error, try `rustc --explain E0015`.
|
||||||
|
|
|
@ -23,6 +23,5 @@ impl Foo for u16 {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
//~| ERROR erroneous constant used
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,20 +4,36 @@ error[E0080]: evaluation of `<Bar<u16, u8> as Foo>::AMT` failed
|
||||||
LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize];
|
LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize];
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-44578.rs:25:20
|
--> $DIR/issue-44578.rs:25:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/issue-44578.rs:25:20
|
--> $DIR/issue-44578.rs:25:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/issue-44578.rs:25:20
|
||||||
|
|
|
||||||
|
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/issue-44578.rs:25:20
|
||||||
|
|
|
||||||
|
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -15,7 +15,7 @@ impl<T: C> Foo<T> for A<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo<T: C>() -> &'static usize {
|
fn foo<T: C>() -> &'static usize {
|
||||||
&<A<T> as Foo<T>>::BAR //~ ERROR E0080
|
&<A<T> as Foo<T>>::BAR //~ constant
|
||||||
}
|
}
|
||||||
|
|
||||||
impl C for () {
|
impl C for () {
|
||||||
|
|
|
@ -4,11 +4,11 @@ error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed
|
||||||
LL | const BAR: usize = [5, 6, 7][T::BOO];
|
LL | const BAR: usize = [5, 6, 7][T::BOO];
|
||||||
| ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42
|
| ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42
|
||||||
|
|
||||||
error[E0080]: evaluation of `foo::<()>` failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-50814-2.rs:18:6
|
--> $DIR/issue-50814-2.rs:18:6
|
||||||
|
|
|
|
||||||
LL | &<A<T> as Foo<T>>::BAR
|
LL | &<A<T> as Foo<T>>::BAR
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
note: the above error was encountered while instantiating `fn foo::<()>`
|
note: the above error was encountered while instantiating `fn foo::<()>`
|
||||||
--> $DIR/issue-50814-2.rs:30:22
|
--> $DIR/issue-50814-2.rs:30:22
|
||||||
|
@ -16,6 +16,6 @@ note: the above error was encountered while instantiating `fn foo::<()>`
|
||||||
LL | println!("{:x}", foo::<()>() as *const usize as usize);
|
LL | println!("{:x}", foo::<()>() as *const usize as usize);
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -18,7 +18,7 @@ impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> {
|
||||||
|
|
||||||
fn foo<T>(_: T) -> &'static u8 {
|
fn foo<T>(_: T) -> &'static u8 {
|
||||||
&Sum::<U8, U8>::MAX
|
&Sum::<U8, U8>::MAX
|
||||||
//~^ ERROR evaluation of `foo::<i32>` failed [E0080]
|
//~^ constant
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -4,11 +4,11 @@ error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
|
||||||
LL | const MAX: u8 = A::MAX + B::MAX;
|
LL | const MAX: u8 = A::MAX + B::MAX;
|
||||||
| ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow
|
| ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow
|
||||||
|
|
||||||
error[E0080]: evaluation of `foo::<i32>` failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-50814.rs:20:6
|
--> $DIR/issue-50814.rs:20:6
|
||||||
|
|
|
|
||||||
LL | &Sum::<U8, U8>::MAX
|
LL | &Sum::<U8, U8>::MAX
|
||||||
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
note: the above error was encountered while instantiating `fn foo::<i32>`
|
note: the above error was encountered while instantiating `fn foo::<i32>`
|
||||||
--> $DIR/issue-50814.rs:25:5
|
--> $DIR/issue-50814.rs:25:5
|
||||||
|
@ -16,6 +16,6 @@ note: the above error was encountered while instantiating `fn foo::<i32>`
|
||||||
LL | foo(0);
|
LL | foo(0);
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -11,6 +11,5 @@ impl PrintName {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = PrintName::VOID;
|
let _ = PrintName::VOID; //~ constant
|
||||||
//~^ ERROR erroneous constant used [E0080]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,18 @@ LL | const VOID: ! = panic!();
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/panic-assoc-never-type.rs:14:13
|
--> $DIR/panic-assoc-never-type.rs:14:13
|
||||||
|
|
|
|
||||||
LL | let _ = PrintName::VOID;
|
LL | let _ = PrintName::VOID;
|
||||||
| ^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/panic-assoc-never-type.rs:14:13
|
||||||
|
|
|
||||||
|
LL | let _ = PrintName::VOID;
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -60,14 +60,14 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
||||||
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
||||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-ref-ptr.rs:34:38
|
--> $DIR/ub-ref-ptr.rs:34:38
|
||||||
|
|
|
|
||||||
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/ub-ref-ptr.rs:38:86
|
--> $DIR/ub-ref-ptr.rs:37:86
|
||||||
|
|
|
|
||||||
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
||||||
|
@ -75,14 +75,14 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us
|
||||||
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
||||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-ref-ptr.rs:38:85
|
--> $DIR/ub-ref-ptr.rs:37:85
|
||||||
|
|
|
|
||||||
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:42:1
|
--> $DIR/ub-ref-ptr.rs:40:1
|
||||||
|
|
|
|
||||||
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (address 0x539 is unallocated)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (address 0x539 is unallocated)
|
||||||
|
@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:45:1
|
--> $DIR/ub-ref-ptr.rs:43:1
|
||||||
|
|
|
|
||||||
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (address 0x539 is unallocated)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (address 0x539 is unallocated)
|
||||||
|
@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/ub-ref-ptr.rs:48:41
|
--> $DIR/ub-ref-ptr.rs:46:41
|
||||||
|
|
|
|
||||||
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
|
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:52:1
|
--> $DIR/ub-ref-ptr.rs:50:1
|
||||||
|
|
|
|
||||||
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
|
||||||
|
@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/ub-ref-ptr.rs:54:38
|
--> $DIR/ub-ref-ptr.rs:52:38
|
||||||
|
|
|
|
||||||
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
|
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:57:1
|
--> $DIR/ub-ref-ptr.rs:55:1
|
||||||
|
|
|
|
||||||
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
|
||||||
|
@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:59:1
|
--> $DIR/ub-ref-ptr.rs:57:1
|
||||||
|
|
|
|
||||||
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer
|
||||||
|
@ -148,6 +148,6 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
||||||
╾─alloc41─╼ │ ╾──╼
|
╾─alloc41─╼ │ ╾──╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error: aborting due to 16 previous errors
|
error: aborting due to 14 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -60,14 +60,14 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
||||||
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
||||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-ref-ptr.rs:34:38
|
--> $DIR/ub-ref-ptr.rs:34:38
|
||||||
|
|
|
|
||||||
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/ub-ref-ptr.rs:38:86
|
--> $DIR/ub-ref-ptr.rs:37:86
|
||||||
|
|
|
|
||||||
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
||||||
|
@ -75,14 +75,14 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us
|
||||||
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
||||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-ref-ptr.rs:38:85
|
--> $DIR/ub-ref-ptr.rs:37:85
|
||||||
|
|
|
|
||||||
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:42:1
|
--> $DIR/ub-ref-ptr.rs:40:1
|
||||||
|
|
|
|
||||||
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (address 0x539 is unallocated)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (address 0x539 is unallocated)
|
||||||
|
@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:45:1
|
--> $DIR/ub-ref-ptr.rs:43:1
|
||||||
|
|
|
|
||||||
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (address 0x539 is unallocated)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (address 0x539 is unallocated)
|
||||||
|
@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/ub-ref-ptr.rs:48:41
|
--> $DIR/ub-ref-ptr.rs:46:41
|
||||||
|
|
|
|
||||||
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
|
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:52:1
|
--> $DIR/ub-ref-ptr.rs:50:1
|
||||||
|
|
|
|
||||||
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
|
||||||
|
@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/ub-ref-ptr.rs:54:38
|
--> $DIR/ub-ref-ptr.rs:52:38
|
||||||
|
|
|
|
||||||
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
|
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:57:1
|
--> $DIR/ub-ref-ptr.rs:55:1
|
||||||
|
|
|
|
||||||
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
|
||||||
|
@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-ref-ptr.rs:59:1
|
--> $DIR/ub-ref-ptr.rs:57:1
|
||||||
|
|
|
|
||||||
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer
|
||||||
|
@ -148,6 +148,6 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
||||||
╾───────alloc41───────╼ │ ╾──────╼
|
╾───────alloc41───────╼ │ ╾──────╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error: aborting due to 16 previous errors
|
error: aborting due to 14 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -33,11 +33,9 @@ const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
|
||||||
|
|
||||||
const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ ERROR evaluation of constant value failed
|
||||||
//~| ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ ERROR evaluation of constant value failed
|
||||||
//~| ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
|
|
|
@ -139,11 +139,11 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||||
╾─allocN─╼ │ ╾──╼
|
╾─allocN─╼ │ ╾──╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-wide-ptr.rs:83:40
|
--> $DIR/ub-wide-ptr.rs:83:40
|
||||||
|
|
|
|
||||||
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:90:1
|
--> $DIR/ub-wide-ptr.rs:90:1
|
||||||
|
@ -156,11 +156,11 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
|
||||||
╾allocN─╼ │ ╾──╼
|
╾allocN─╼ │ ╾──╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-wide-ptr.rs:90:42
|
--> $DIR/ub-wide-ptr.rs:90:42
|
||||||
|
|
|
|
||||||
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:94:1
|
--> $DIR/ub-wide-ptr.rs:94:1
|
||||||
|
@ -173,11 +173,11 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
|
||||||
╾allocN─╼ │ ╾──╼
|
╾allocN─╼ │ ╾──╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-wide-ptr.rs:94:42
|
--> $DIR/ub-wide-ptr.rs:94:42
|
||||||
|
|
|
|
||||||
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/ub-wide-ptr.rs:102:1
|
--> $DIR/ub-wide-ptr.rs:102:1
|
||||||
|
@ -292,6 +292,6 @@ error[E0080]: could not evaluate static initializer
|
||||||
LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
|
LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable
|
||||||
|
|
||||||
error: aborting due to 32 previous errors
|
error: aborting due to 29 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -139,11 +139,11 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||||
╾───────allocN───────╼ │ ╾──────╼
|
╾───────allocN───────╼ │ ╾──────╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-wide-ptr.rs:83:40
|
--> $DIR/ub-wide-ptr.rs:83:40
|
||||||
|
|
|
|
||||||
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:90:1
|
--> $DIR/ub-wide-ptr.rs:90:1
|
||||||
|
@ -156,11 +156,11 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
|
||||||
╾──────allocN───────╼ │ ╾──────╼
|
╾──────allocN───────╼ │ ╾──────╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-wide-ptr.rs:90:42
|
--> $DIR/ub-wide-ptr.rs:90:42
|
||||||
|
|
|
|
||||||
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-wide-ptr.rs:94:1
|
--> $DIR/ub-wide-ptr.rs:94:1
|
||||||
|
@ -173,11 +173,11 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
|
||||||
╾──────allocN───────╼ │ ╾──────╼
|
╾──────allocN───────╼ │ ╾──────╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/ub-wide-ptr.rs:94:42
|
--> $DIR/ub-wide-ptr.rs:94:42
|
||||||
|
|
|
|
||||||
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/ub-wide-ptr.rs:102:1
|
--> $DIR/ub-wide-ptr.rs:102:1
|
||||||
|
@ -292,6 +292,6 @@ error[E0080]: could not evaluate static initializer
|
||||||
LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
|
LL | mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using allocN as vtable pointer but it does not point to a vtable
|
||||||
|
|
||||||
error: aborting due to 32 previous errors
|
error: aborting due to 29 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -82,18 +82,18 @@ const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
|
||||||
// bad data *inside* the slice
|
// bad data *inside* the slice
|
||||||
const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
//~| ERROR evaluation of constant value failed
|
//~| constant
|
||||||
|
|
||||||
// good MySliceBool
|
// good MySliceBool
|
||||||
const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]);
|
const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]);
|
||||||
// bad: sized field is not okay
|
// bad: sized field is not okay
|
||||||
const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
//~| ERROR evaluation of constant value failed
|
//~| constant
|
||||||
// bad: unsized part is not okay
|
// bad: unsized part is not okay
|
||||||
const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
||||||
//~^ ERROR it is undefined behavior to use this value
|
//~^ ERROR it is undefined behavior to use this value
|
||||||
//~| ERROR evaluation of constant value failed
|
//~| constant
|
||||||
|
|
||||||
// # raw slice
|
// # raw slice
|
||||||
const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok
|
const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok
|
||||||
|
|
|
@ -29,7 +29,6 @@ const fn read_field3() -> Field3 {
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ ERROR evaluation of constant value failed
|
||||||
//~| uninitialized
|
//~| uninitialized
|
||||||
FIELD3
|
FIELD3
|
||||||
//~^ ERROR erroneous constant used [E0080]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -4,12 +4,18 @@ error[E0080]: evaluation of constant value failed
|
||||||
LL | const FIELD3: Field3 = unsafe { UNION.field3 };
|
LL | const FIELD3: Field3 = unsafe { UNION.field3 };
|
||||||
| ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
| ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/union-const-eval-field.rs:31:5
|
--> $DIR/union-const-eval-field.rs:31:5
|
||||||
|
|
|
|
||||||
LL | FIELD3
|
LL | FIELD3
|
||||||
| ^^^^^^ referenced constant has errors
|
| ^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/union-const-eval-field.rs:31:5
|
||||||
|
|
|
||||||
|
LL | FIELD3
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// compile-flags: -Zmir-opt-level=0
|
// compile-flags: -Zmir-opt-level=0
|
||||||
|
// error-pattern: cannot use f32::to_bits on a NaN
|
||||||
#![feature(const_float_bits_conv)]
|
#![feature(const_float_bits_conv)]
|
||||||
#![feature(const_float_classify)]
|
#![feature(const_float_classify)]
|
||||||
|
|
||||||
|
@ -25,22 +26,21 @@ fn f32() {
|
||||||
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
|
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
|
||||||
// ...actually, let's just check that these break. :D
|
// ...actually, let's just check that these break. :D
|
||||||
const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA;
|
const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA;
|
||||||
|
//~^ inside
|
||||||
const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555;
|
const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555;
|
||||||
|
//~^ inside
|
||||||
|
|
||||||
|
// The rest of the code is dead because the constants already fail to evaluate.
|
||||||
|
|
||||||
const_assert!(f32::from_bits(MASKED_NAN1).is_nan());
|
const_assert!(f32::from_bits(MASKED_NAN1).is_nan());
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
const_assert!(f32::from_bits(MASKED_NAN1).is_nan());
|
const_assert!(f32::from_bits(MASKED_NAN1).is_nan());
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
// LLVM does not guarantee that loads and stores of NaNs preserve their exact bit pattern.
|
// LLVM does not guarantee that loads and stores of NaNs preserve their exact bit pattern.
|
||||||
// In practice, this seems to only cause a problem on x86, since the most widely used calling
|
// In practice, this seems to only cause a problem on x86, since the most widely used calling
|
||||||
// convention mandates that floating point values are returned on the x87 FPU stack. See #73328.
|
// convention mandates that floating point values are returned on the x87 FPU stack. See #73328.
|
||||||
if !cfg!(target_arch = "x86") {
|
// However, during CTFE we still preserve bit patterns (though that is not a guarantee).
|
||||||
const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
|
const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
|
||||||
//~^ ERROR evaluation of constant value failed
|
const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
|
||||||
const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
|
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f64() {
|
fn f64() {
|
||||||
|
@ -48,20 +48,18 @@ fn f64() {
|
||||||
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
|
// 0xA is 0b1010; 0x5 is 0b0101 -- so these two together clobbers all the mantissa bits
|
||||||
// ...actually, let's just check that these break. :D
|
// ...actually, let's just check that these break. :D
|
||||||
const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA;
|
const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA;
|
||||||
|
//~^ inside
|
||||||
const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555;
|
const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555;
|
||||||
|
//~^ inside
|
||||||
|
|
||||||
|
// The rest of the code is dead because the constants already fail to evaluate.
|
||||||
|
|
||||||
const_assert!(f64::from_bits(MASKED_NAN1).is_nan());
|
const_assert!(f64::from_bits(MASKED_NAN1).is_nan());
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
const_assert!(f64::from_bits(MASKED_NAN1).is_nan());
|
const_assert!(f64::from_bits(MASKED_NAN1).is_nan());
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
|
|
||||||
// See comment above.
|
// See comment above.
|
||||||
if !cfg!(target_arch = "x86") {
|
const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
|
||||||
const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
|
const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
|
|
||||||
//~^ ERROR evaluation of constant value failed
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -1,22 +1,3 @@
|
||||||
error[E0080]: evaluation of constant value failed
|
|
||||||
--> $SRC_DIR/core/src/num/f32.rs:LL:COL
|
|
||||||
|
|
|
||||||
LL | panic!("const-eval error: cannot use f32::to_bits on a NaN")
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
| |
|
|
||||||
| the evaluated program panicked at 'const-eval error: cannot use f32::to_bits on a NaN', $SRC_DIR/core/src/num/f32.rs:LL:COL
|
|
||||||
| inside `core::f32::<impl f32>::to_bits::ct_f32_to_u32` at $SRC_DIR/core/src/panic.rs:LL:COL
|
|
||||||
...
|
|
||||||
LL | unsafe { intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32) }
|
|
||||||
| -------------------------------------------------------------------- inside `core::f32::<impl f32>::to_bits` at $SRC_DIR/core/src/num/f32.rs:LL:COL
|
|
||||||
|
|
|
||||||
::: $DIR/const-float-bits-reject-conv.rs:27:30
|
|
||||||
|
|
|
||||||
LL | const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA;
|
|
||||||
| ------------------ inside `f32::MASKED_NAN1` at $DIR/const-float-bits-reject-conv.rs:27:30
|
|
||||||
|
|
|
||||||
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $SRC_DIR/core/src/num/f32.rs:LL:COL
|
--> $SRC_DIR/core/src/num/f32.rs:LL:COL
|
||||||
|
|
|
|
||||||
|
@ -31,34 +12,53 @@ LL | unsafe { intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f
|
||||||
|
|
|
|
||||||
::: $DIR/const-float-bits-reject-conv.rs:28:30
|
::: $DIR/const-float-bits-reject-conv.rs:28:30
|
||||||
|
|
|
|
||||||
LL | const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555;
|
LL | const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA;
|
||||||
| ------------------ inside `f32::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:28:30
|
| ------------------ inside `f32::MASKED_NAN1` at $DIR/const-float-bits-reject-conv.rs:28:30
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const-float-bits-reject-conv.rs:30:34
|
--> $SRC_DIR/core/src/num/f32.rs:LL:COL
|
||||||
|
|
|
||||||
|
LL | panic!("const-eval error: cannot use f32::to_bits on a NaN")
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
| |
|
||||||
|
| the evaluated program panicked at 'const-eval error: cannot use f32::to_bits on a NaN', $SRC_DIR/core/src/num/f32.rs:LL:COL
|
||||||
|
| inside `core::f32::<impl f32>::to_bits::ct_f32_to_u32` at $SRC_DIR/core/src/panic.rs:LL:COL
|
||||||
|
...
|
||||||
|
LL | unsafe { intrinsics::const_eval_select((self,), ct_f32_to_u32, rt_f32_to_u32) }
|
||||||
|
| -------------------------------------------------------------------- inside `core::f32::<impl f32>::to_bits` at $SRC_DIR/core/src/num/f32.rs:LL:COL
|
||||||
|
|
|
||||||
|
::: $DIR/const-float-bits-reject-conv.rs:30:30
|
||||||
|
|
|
||||||
|
LL | const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555;
|
||||||
|
| ------------------ inside `f32::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:30:30
|
||||||
|
|
|
||||||
|
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/const-float-bits-reject-conv.rs:35:34
|
||||||
|
|
|
|
||||||
LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan());
|
LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan());
|
||||||
| ^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-float-bits-reject-conv.rs:32:34
|
--> $DIR/const-float-bits-reject-conv.rs:36:34
|
||||||
|
|
|
|
||||||
LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan());
|
LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan());
|
||||||
| ^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-float-bits-reject-conv.rs:39:38
|
--> $DIR/const-float-bits-reject-conv.rs:42:34
|
||||||
|
|
|
|
||||||
LL | const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
|
LL | const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
|
||||||
| ^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-float-bits-reject-conv.rs:41:38
|
--> $DIR/const-float-bits-reject-conv.rs:43:34
|
||||||
|
|
|
|
||||||
LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
|
LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
|
||||||
| ^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $SRC_DIR/core/src/num/f64.rs:LL:COL
|
--> $SRC_DIR/core/src/num/f64.rs:LL:COL
|
||||||
|
@ -91,37 +91,37 @@ LL | panic!("const-eval error: cannot use f64::to_bits on a
|
||||||
LL | unsafe { intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64) }
|
LL | unsafe { intrinsics::const_eval_select((self,), ct_f64_to_u64, rt_f64_to_u64) }
|
||||||
| -------------------------------------------------------------------- inside `core::f64::<impl f64>::to_bits` at $SRC_DIR/core/src/num/f64.rs:LL:COL
|
| -------------------------------------------------------------------- inside `core::f64::<impl f64>::to_bits` at $SRC_DIR/core/src/num/f64.rs:LL:COL
|
||||||
|
|
|
|
||||||
::: $DIR/const-float-bits-reject-conv.rs:51:30
|
::: $DIR/const-float-bits-reject-conv.rs:52:30
|
||||||
|
|
|
|
||||||
LL | const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555;
|
LL | const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555;
|
||||||
| ------------------ inside `f64::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:51:30
|
| ------------------ inside `f64::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:52:30
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-float-bits-reject-conv.rs:53:34
|
--> $DIR/const-float-bits-reject-conv.rs:57:34
|
||||||
|
|
|
|
||||||
LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan());
|
LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan());
|
||||||
| ^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-float-bits-reject-conv.rs:55:34
|
--> $DIR/const-float-bits-reject-conv.rs:58:34
|
||||||
|
|
|
|
||||||
LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan());
|
LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan());
|
||||||
| ^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-float-bits-reject-conv.rs:60:38
|
--> $DIR/const-float-bits-reject-conv.rs:61:34
|
||||||
|
|
|
|
||||||
LL | const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
|
LL | const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1);
|
||||||
| ^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-float-bits-reject-conv.rs:62:38
|
--> $DIR/const-float-bits-reject-conv.rs:62:34
|
||||||
|
|
|
|
||||||
LL | const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
|
LL | const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2);
|
||||||
| ^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 12 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -6,7 +6,7 @@ const X: usize = 42 && 39;
|
||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARR: [i32; X] = [99; 34];
|
const ARR: [i32; X] = [99; 34];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
const X1: usize = 42 || 39;
|
const X1: usize = 42 || 39;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
|
@ -16,7 +16,7 @@ const X1: usize = 42 || 39;
|
||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARR1: [i32; X1] = [99; 47];
|
const ARR1: [i32; X1] = [99; 47];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
const X2: usize = -42 || -39;
|
const X2: usize = -42 || -39;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
|
@ -26,7 +26,7 @@ const X2: usize = -42 || -39;
|
||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARR2: [i32; X2] = [99; 18446744073709551607];
|
const ARR2: [i32; X2] = [99; 18446744073709551607];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
const X3: usize = -42 && -39;
|
const X3: usize = -42 && -39;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
|
@ -36,43 +36,43 @@ const X3: usize = -42 && -39;
|
||||||
//~| ERROR mismatched types
|
//~| ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARR3: [i32; X3] = [99; 6];
|
const ARR3: [i32; X3] = [99; 6];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
const Y: usize = 42.0 == 42.0;
|
const Y: usize = 42.0 == 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR: [i32; Y] = [99; 1];
|
const ARRR: [i32; Y] = [99; 1];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
const Y1: usize = 42.0 >= 42.0;
|
const Y1: usize = 42.0 >= 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR1: [i32; Y1] = [99; 1];
|
const ARRR1: [i32; Y1] = [99; 1];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
const Y2: usize = 42.0 <= 42.0;
|
const Y2: usize = 42.0 <= 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR2: [i32; Y2] = [99; 1];
|
const ARRR2: [i32; Y2] = [99; 1];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
const Y3: usize = 42.0 > 42.0;
|
const Y3: usize = 42.0 > 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR3: [i32; Y3] = [99; 0];
|
const ARRR3: [i32; Y3] = [99; 0];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
const Y4: usize = 42.0 < 42.0;
|
const Y4: usize = 42.0 < 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR4: [i32; Y4] = [99; 0];
|
const ARRR4: [i32; Y4] = [99; 0];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
const Y5: usize = 42.0 != 42.0;
|
const Y5: usize = 42.0 != 42.0;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected `usize`, found `bool`
|
//~| expected `usize`, found `bool`
|
||||||
const ARRR5: [i32; Y5] = [99; 0];
|
const ARRR5: [i32; Y5] = [99; 0];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = ARR;
|
let _ = ARR;
|
||||||
|
|
|
@ -16,11 +16,11 @@ error[E0308]: mismatched types
|
||||||
LL | const X: usize = 42 && 39;
|
LL | const X: usize = 42 && 39;
|
||||||
| ^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:8:18
|
--> $DIR/const-integer-bool-ops.rs:8:18
|
||||||
|
|
|
|
||||||
LL | const ARR: [i32; X] = [99; 34];
|
LL | const ARR: [i32; X] = [99; 34];
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:11:19
|
--> $DIR/const-integer-bool-ops.rs:11:19
|
||||||
|
@ -40,11 +40,11 @@ error[E0308]: mismatched types
|
||||||
LL | const X1: usize = 42 || 39;
|
LL | const X1: usize = 42 || 39;
|
||||||
| ^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:18:19
|
--> $DIR/const-integer-bool-ops.rs:18:19
|
||||||
|
|
|
|
||||||
LL | const ARR1: [i32; X1] = [99; 47];
|
LL | const ARR1: [i32; X1] = [99; 47];
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:21:19
|
--> $DIR/const-integer-bool-ops.rs:21:19
|
||||||
|
@ -64,11 +64,11 @@ error[E0308]: mismatched types
|
||||||
LL | const X2: usize = -42 || -39;
|
LL | const X2: usize = -42 || -39;
|
||||||
| ^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:28:19
|
--> $DIR/const-integer-bool-ops.rs:28:19
|
||||||
|
|
|
|
||||||
LL | const ARR2: [i32; X2] = [99; 18446744073709551607];
|
LL | const ARR2: [i32; X2] = [99; 18446744073709551607];
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:31:19
|
--> $DIR/const-integer-bool-ops.rs:31:19
|
||||||
|
@ -88,11 +88,11 @@ error[E0308]: mismatched types
|
||||||
LL | const X3: usize = -42 && -39;
|
LL | const X3: usize = -42 && -39;
|
||||||
| ^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:38:19
|
--> $DIR/const-integer-bool-ops.rs:38:19
|
||||||
|
|
|
|
||||||
LL | const ARR3: [i32; X3] = [99; 6];
|
LL | const ARR3: [i32; X3] = [99; 6];
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:41:18
|
--> $DIR/const-integer-bool-ops.rs:41:18
|
||||||
|
@ -100,11 +100,11 @@ error[E0308]: mismatched types
|
||||||
LL | const Y: usize = 42.0 == 42.0;
|
LL | const Y: usize = 42.0 == 42.0;
|
||||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:44:19
|
--> $DIR/const-integer-bool-ops.rs:44:19
|
||||||
|
|
|
|
||||||
LL | const ARRR: [i32; Y] = [99; 1];
|
LL | const ARRR: [i32; Y] = [99; 1];
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:47:19
|
--> $DIR/const-integer-bool-ops.rs:47:19
|
||||||
|
@ -112,11 +112,11 @@ error[E0308]: mismatched types
|
||||||
LL | const Y1: usize = 42.0 >= 42.0;
|
LL | const Y1: usize = 42.0 >= 42.0;
|
||||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:50:20
|
--> $DIR/const-integer-bool-ops.rs:50:20
|
||||||
|
|
|
|
||||||
LL | const ARRR1: [i32; Y1] = [99; 1];
|
LL | const ARRR1: [i32; Y1] = [99; 1];
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:53:19
|
--> $DIR/const-integer-bool-ops.rs:53:19
|
||||||
|
@ -124,11 +124,11 @@ error[E0308]: mismatched types
|
||||||
LL | const Y2: usize = 42.0 <= 42.0;
|
LL | const Y2: usize = 42.0 <= 42.0;
|
||||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:56:20
|
--> $DIR/const-integer-bool-ops.rs:56:20
|
||||||
|
|
|
|
||||||
LL | const ARRR2: [i32; Y2] = [99; 1];
|
LL | const ARRR2: [i32; Y2] = [99; 1];
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:59:19
|
--> $DIR/const-integer-bool-ops.rs:59:19
|
||||||
|
@ -136,11 +136,11 @@ error[E0308]: mismatched types
|
||||||
LL | const Y3: usize = 42.0 > 42.0;
|
LL | const Y3: usize = 42.0 > 42.0;
|
||||||
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:62:20
|
--> $DIR/const-integer-bool-ops.rs:62:20
|
||||||
|
|
|
|
||||||
LL | const ARRR3: [i32; Y3] = [99; 0];
|
LL | const ARRR3: [i32; Y3] = [99; 0];
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:65:19
|
--> $DIR/const-integer-bool-ops.rs:65:19
|
||||||
|
@ -148,11 +148,11 @@ error[E0308]: mismatched types
|
||||||
LL | const Y4: usize = 42.0 < 42.0;
|
LL | const Y4: usize = 42.0 < 42.0;
|
||||||
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:68:20
|
--> $DIR/const-integer-bool-ops.rs:68:20
|
||||||
|
|
|
|
||||||
LL | const ARRR4: [i32; Y4] = [99; 0];
|
LL | const ARRR4: [i32; Y4] = [99; 0];
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/const-integer-bool-ops.rs:71:19
|
--> $DIR/const-integer-bool-ops.rs:71:19
|
||||||
|
@ -160,13 +160,12 @@ error[E0308]: mismatched types
|
||||||
LL | const Y5: usize = 42.0 != 42.0;
|
LL | const Y5: usize = 42.0 != 42.0;
|
||||||
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
| ^^^^^^^^^^^^ expected `usize`, found `bool`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-integer-bool-ops.rs:74:20
|
--> $DIR/const-integer-bool-ops.rs:74:20
|
||||||
|
|
|
|
||||||
LL | const ARRR5: [i32; Y5] = [99; 0];
|
LL | const ARRR5: [i32; Y5] = [99; 0];
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error: aborting due to 28 previous errors
|
error: aborting due to 18 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0308.
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
|
|
@ -9,5 +9,5 @@ const LEN: usize = ONE - TWO;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let a: [i8; LEN] = unimplemented!();
|
let a: [i8; LEN] = unimplemented!();
|
||||||
//~^ ERROR E0080
|
//~^ constant
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ error[E0080]: evaluation of constant value failed
|
||||||
LL | const LEN: usize = ONE - TWO;
|
LL | const LEN: usize = ONE - TWO;
|
||||||
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
|
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-len-underflow-separate-spans.rs:11:17
|
--> $DIR/const-len-underflow-separate-spans.rs:11:17
|
||||||
|
|
|
|
||||||
LL | let a: [i8; LEN] = unimplemented!();
|
LL | let a: [i8; LEN] = unimplemented!();
|
||||||
| ^^^ referenced constant has errors
|
| ^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -19,13 +19,13 @@ error[E0596]: cannot borrow data in a `&` reference as mutable
|
||||||
LL | const S: &'static mut str = &mut " hello ";
|
LL | const S: &'static mut str = &mut " hello ";
|
||||||
| ^^^^^^^^^^^^^^ cannot borrow as mutable
|
| ^^^^^^^^^^^^^^ cannot borrow as mutable
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-76510.rs:11:70
|
--> $DIR/issue-76510.rs:11:70
|
||||||
|
|
|
|
||||||
LL | let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
|
LL | let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0596, E0658, E0764.
|
Some errors have detailed explanations: E0596, E0658, E0764.
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
For more information about an error, try `rustc --explain E0596`.
|
||||||
|
|
|
@ -19,13 +19,13 @@ error[E0596]: cannot borrow data in a `&` reference as mutable
|
||||||
LL | const S: &'static mut str = &mut " hello ";
|
LL | const S: &'static mut str = &mut " hello ";
|
||||||
| ^^^^^^^^^^^^^^ cannot borrow as mutable
|
| ^^^^^^^^^^^^^^ cannot borrow as mutable
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-76510.rs:11:70
|
--> $DIR/issue-76510.rs:11:70
|
||||||
|
|
|
|
||||||
LL | let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
|
LL | let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0596, E0658, E0764.
|
Some errors have detailed explanations: E0596, E0658, E0764.
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
For more information about an error, try `rustc --explain E0596`.
|
||||||
|
|
|
@ -9,7 +9,7 @@ const S: &'static mut str = &mut " hello ";
|
||||||
|
|
||||||
const fn trigger() -> [(); unsafe {
|
const fn trigger() -> [(); unsafe {
|
||||||
let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
|
let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3));
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
0
|
0
|
||||||
}] {
|
}] {
|
||||||
[(); 0]
|
[(); 0]
|
||||||
|
|
|
@ -4,7 +4,7 @@ const TUP: (usize,) = 5usize << 64;
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| expected tuple, found `usize`
|
//~| expected tuple, found `usize`
|
||||||
const ARR: [i32; TUP.0] = [];
|
const ARR: [i32; TUP.0] = [];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,12 @@ help: use a trailing comma to create a tuple with one element
|
||||||
LL | const TUP: (usize,) = (5usize << 64,);
|
LL | const TUP: (usize,) = (5usize << 64,);
|
||||||
| + ++
|
| + ++
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/const-tup-index-span.rs:6:18
|
--> $DIR/const-tup-index-span.rs:6:18
|
||||||
|
|
|
|
||||||
LL | const ARR: [i32; TUP.0] = [];
|
LL | const ARR: [i32; TUP.0] = [];
|
||||||
| ^^^ referenced constant has errors
|
| ^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0308.
|
For more information about this error, try `rustc --explain E0308`.
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ const UNALIGNED_PTR: () = unsafe {
|
||||||
};
|
};
|
||||||
|
|
||||||
const UNALIGNED_READ: () = {
|
const UNALIGNED_READ: () = {
|
||||||
INNER; //[with_flag]~ERROR evaluation of constant value failed
|
INNER; //[with_flag]~ constant
|
||||||
// There is an error here but its span is in the standard library so we cannot match it...
|
// There is an error here but its span is in the standard library so we cannot match it...
|
||||||
// so we have this in a *nested* const, such that the *outer* const fails to use it.
|
// so we have this in a *nested* const, such that the *outer* const fails to use it.
|
||||||
const INNER: () = unsafe {
|
const INNER: () = unsafe {
|
||||||
|
|
|
@ -47,12 +47,12 @@ LL | unsafe { read(self) }
|
||||||
LL | ptr.read();
|
LL | ptr.read();
|
||||||
| ---------- inside `INNER` at $DIR/detect-extra-ub.rs:38:9
|
| ---------- inside `INNER` at $DIR/detect-extra-ub.rs:38:9
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/detect-extra-ub.rs:32:5
|
--> $DIR/detect-extra-ub.rs:32:5
|
||||||
|
|
|
|
||||||
LL | INNER;
|
LL | INNER;
|
||||||
| ^^^^^ referenced constant has errors
|
| ^^^^^
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -9,12 +9,24 @@ LL | fn main() {
|
||||||
╾─alloc7──╼ │ ╾──╼
|
╾─alloc7──╼ │ ╾──╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/invalid-union.rs:42:25
|
--> $DIR/invalid-union.rs:43:25
|
||||||
|
|
|
|
||||||
LL | let _: &'static _ = &C;
|
LL | let _: &'static _ = &C;
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/invalid-union.rs:43:25
|
||||||
|
|
|
||||||
|
LL | let _: &'static _ = &C;
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/invalid-union.rs:43:25
|
||||||
|
|
|
||||||
|
LL | let _: &'static _ = &C;
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -9,12 +9,24 @@ LL | fn main() {
|
||||||
╾───────alloc7────────╼ │ ╾──────╼
|
╾───────alloc7────────╼ │ ╾──────╼
|
||||||
}
|
}
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/invalid-union.rs:42:25
|
--> $DIR/invalid-union.rs:43:25
|
||||||
|
|
|
|
||||||
LL | let _: &'static _ = &C;
|
LL | let _: &'static _ = &C;
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/invalid-union.rs:43:25
|
||||||
|
|
|
||||||
|
LL | let _: &'static _ = &C;
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/invalid-union.rs:43:25
|
||||||
|
|
|
||||||
|
LL | let _: &'static _ = &C;
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -39,5 +39,6 @@ const C: S = {
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() { //~ ERROR it is undefined behavior to use this value
|
fn main() { //~ ERROR it is undefined behavior to use this value
|
||||||
let _: &'static _ = &C; //~ ERROR erroneous constant used
|
// FIXME the span here is wrong, sould be pointing at the line below, not above.
|
||||||
|
let _: &'static _ = &C;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ LL | B = A,
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
note: ...which requires const-evaluating + checking `A`...
|
note: ...which requires const-evaluating + checking `A`...
|
||||||
--> $DIR/issue-36163.rs:1:1
|
--> $DIR/issue-36163.rs:1:18
|
||||||
|
|
|
|
||||||
LL | const A: isize = Foo::B as isize;
|
LL | const A: isize = Foo::B as isize;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
= note: ...which again requires const-evaluating + checking `Foo::B::{constant#0}`, completing the cycle
|
= note: ...which again requires const-evaluating + checking `Foo::B::{constant#0}`, completing the cycle
|
||||||
note: cycle used when simplifying constant for the type system `Foo::B::{constant#0}`
|
note: cycle used when simplifying constant for the type system `Foo::B::{constant#0}`
|
||||||
--> $DIR/issue-36163.rs:4:9
|
--> $DIR/issue-36163.rs:4:9
|
||||||
|
|
|
@ -9,8 +9,8 @@ trait Tt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
//~| ERROR evaluation of constant value failed
|
//~| constant
|
||||||
z
|
z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,19 +16,19 @@ LL | | core::mem::size_of::<T>()
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_____- `Tt::const_val` defined here
|
| |_____- `Tt::const_val` defined here
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-54954.rs:11:15
|
--> $DIR/issue-54954.rs:11:15
|
||||||
|
|
|
|
||||||
LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
||||||
| ^^^^^^^ referenced constant has errors
|
| ^^^^^^^
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-54954.rs:11:34
|
--> $DIR/issue-54954.rs:11:34
|
||||||
|
|
|
|
||||||
LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] {
|
||||||
| ^^^^^^^ referenced constant has errors
|
| ^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0379, E0790.
|
Some errors have detailed explanations: E0379, E0790.
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
For more information about an error, try `rustc --explain E0379`.
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const fn foo() { (||{})() }
|
const fn foo() { (||{})() }
|
||||||
//~^ ERROR cannot call non-const closure
|
//~^ ERROR cannot call non-const closure
|
||||||
//~| ERROR erroneous constant used
|
|
||||||
|
|
||||||
const fn bad(input: fn()) {
|
const fn bad(input: fn()) {
|
||||||
input()
|
input()
|
||||||
|
|
|
@ -8,18 +8,23 @@ LL | const fn foo() { (||{})() }
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: function pointer calls are not allowed in constant functions
|
error: function pointer calls are not allowed in constant functions
|
||||||
--> $DIR/issue-56164.rs:6:5
|
--> $DIR/issue-56164.rs:5:5
|
||||||
|
|
|
|
||||||
LL | input()
|
LL | input()
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/issue-56164.rs:1:18
|
--> $DIR/issue-56164.rs:1:18
|
||||||
|
|
|
|
||||||
LL | const fn foo() { (||{})() }
|
LL | const fn foo() { (||{})() }
|
||||||
| ^^^^^^ referenced constant has errors
|
| ^^^^^^
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/issue-56164.rs:1:18
|
||||||
|
|
|
||||||
|
LL | const fn foo() { (||{})() }
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
Some errors have detailed explanations: E0015, E0080.
|
error: aborting due to 2 previous errors
|
||||||
For more information about an error, try `rustc --explain E0015`.
|
|
||||||
|
For more information about this error, try `rustc --explain E0015`.
|
||||||
|
|
|
@ -10,7 +10,6 @@ static _FOO: () = panic!(true);
|
||||||
const fn _foo() {
|
const fn _foo() {
|
||||||
panic!(&1);
|
panic!(&1);
|
||||||
//~^ ERROR: argument to `panic!()` in a const context must have type `&str`
|
//~^ ERROR: argument to `panic!()` in a const context must have type `&str`
|
||||||
//~| ERROR: erroneous constant used
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure that conforming panics don't cause an error
|
// ensure that conforming panics don't cause an error
|
||||||
|
|
|
@ -22,12 +22,17 @@ LL | panic!(&1);
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/issue-66693.rs:11:12
|
--> $DIR/issue-66693.rs:11:12
|
||||||
|
|
|
|
||||||
LL | panic!(&1);
|
LL | panic!(&1);
|
||||||
| ^^ referenced constant has errors
|
| ^^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/issue-66693.rs:11:12
|
||||||
|
|
|
||||||
|
LL | panic!(&1);
|
||||||
|
| ^^
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
|
||||||
|
|
|
@ -26,5 +26,5 @@ fn main() {
|
||||||
// this is fine, but would have been forbidden by the static checks on `F`
|
// this is fine, but would have been forbidden by the static checks on `F`
|
||||||
let x = <() as Bar<u32, ()>>::F;
|
let x = <() as Bar<u32, ()>>::F;
|
||||||
// this test only causes errors due to the line below, so post-monomorphization
|
// this test only causes errors due to the line below, so post-monomorphization
|
||||||
let y = <String as Bar<Vec<u32>, String>>::F; //~ ERROR erroneous constant
|
let y = <String as Bar<Vec<u32>, String>>::F; //~ constant
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,23 @@ LL | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
|
||||||
LL | const F: u32 = (U::X, 42).1;
|
LL | const F: u32 = (U::X, 42).1;
|
||||||
| - inside `<String as Bar<Vec<u32>, String>>::F` at $DIR/assoc_const.rs:12:31
|
| - inside `<String as Bar<Vec<u32>, String>>::F` at $DIR/assoc_const.rs:12:31
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/assoc_const.rs:29:13
|
--> $DIR/assoc_const.rs:29:13
|
||||||
|
|
|
|
||||||
LL | let y = <String as Bar<Vec<u32>, String>>::F;
|
LL | let y = <String as Bar<Vec<u32>, String>>::F;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/assoc_const.rs:29:13
|
||||||
|
|
|
||||||
|
LL | let y = <String as Bar<Vec<u32>, String>>::F;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/assoc_const.rs:29:13
|
||||||
|
|
|
||||||
|
LL | let y = <String as Bar<Vec<u32>, String>>::F;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
warning: skipping const checks
|
warning: skipping const checks
|
||||||
|
|
|
|
||||||
|
@ -27,6 +39,6 @@ help: skipping check that does not even have a feature gate
|
||||||
LL | const F: u32 = (U::X, 42).1;
|
LL | const F: u32 = (U::X, 42).1;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors; 1 warning emitted
|
error: aborting due to previous error; 1 warning emitted
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -24,5 +24,5 @@ impl Bar<String> for String {}
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = <() as Bar<()>>::F;
|
let x = <() as Bar<()>>::F;
|
||||||
// this test only causes errors due to the line below, so post-monomorphization
|
// this test only causes errors due to the line below, so post-monomorphization
|
||||||
let y = <String as Bar<String>>::F; //~ ERROR erroneous constant
|
let y = <String as Bar<String>>::F; //~ constant
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,24 @@ error[E0080]: evaluation of `<std::string::String as Bar<std::string::String>>::
|
||||||
LL | const F: u32 = 100 / U::X;
|
LL | const F: u32 = 100 / U::X;
|
||||||
| ^^^^^^^^^^ attempt to divide `100_u32` by zero
|
| ^^^^^^^^^^ attempt to divide `100_u32` by zero
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/assoc_const_2.rs:27:13
|
--> $DIR/assoc_const_2.rs:27:13
|
||||||
|
|
|
|
||||||
LL | let y = <String as Bar<String>>::F;
|
LL | let y = <String as Bar<String>>::F;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/assoc_const_2.rs:27:13
|
||||||
|
|
|
||||||
|
LL | let y = <String as Bar<String>>::F;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/assoc_const_2.rs:27:13
|
||||||
|
|
|
||||||
|
LL | let y = <String as Bar<String>>::F;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -15,5 +15,5 @@ trait Const {
|
||||||
impl<T> Const for T {}
|
impl<T> Const for T {}
|
||||||
|
|
||||||
pub fn main() -> () {
|
pub fn main() -> () {
|
||||||
dbg!(i32::CONSTANT); //~ ERROR erroneous constant used
|
dbg!(i32::CONSTANT); //~ constant
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,12 +140,24 @@ LL | fake_type()
|
||||||
LL | const CONSTANT: i32 = unsafe { fake_type() };
|
LL | const CONSTANT: i32 = unsafe { fake_type() };
|
||||||
| ----------- inside `<i32 as Const>::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:12:36
|
| ----------- inside `<i32 as Const>::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:12:36
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/uninhabited-const-issue-61744.rs:18:10
|
--> $DIR/uninhabited-const-issue-61744.rs:18:10
|
||||||
|
|
|
|
||||||
LL | dbg!(i32::CONSTANT);
|
LL | dbg!(i32::CONSTANT);
|
||||||
| ^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/uninhabited-const-issue-61744.rs:18:10
|
||||||
|
|
|
||||||
|
LL | dbg!(i32::CONSTANT);
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/uninhabited-const-issue-61744.rs:18:10
|
||||||
|
|
|
||||||
|
LL | dbg!(i32::CONSTANT);
|
||||||
|
| ^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0391]: cycle detected when const-evaluating + checking `FOO`
|
error[E0391]: cycle detected when const-evaluating + checking `FOO`
|
||||||
--> $DIR/issue-17252.rs:1:1
|
--> $DIR/issue-17252.rs:1:20
|
||||||
|
|
|
|
||||||
LL | const FOO: usize = FOO;
|
LL | const FOO: usize = FOO;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^
|
||||||
|
|
|
|
||||||
= note: ...which immediately requires const-evaluating + checking `FOO` again
|
= note: ...which immediately requires const-evaluating + checking `FOO` again
|
||||||
note: cycle used when const-evaluating + checking `main::{constant#0}`
|
note: cycle used when const-evaluating + checking `main::{constant#0}`
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
error[E0391]: cycle detected when const-evaluating + checking `A`
|
error[E0391]: cycle detected when const-evaluating + checking `A`
|
||||||
--> $DIR/issue-23302-3.rs:1:1
|
--> $DIR/issue-23302-3.rs:1:16
|
||||||
|
|
|
|
||||||
LL | const A: i32 = B;
|
LL | const A: i32 = B;
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^
|
||||||
|
|
|
|
||||||
note: ...which requires const-evaluating + checking `B`...
|
note: ...which requires const-evaluating + checking `B`...
|
||||||
--> $DIR/issue-23302-3.rs:3:1
|
--> $DIR/issue-23302-3.rs:3:16
|
||||||
|
|
|
|
||||||
LL | const B: i32 = A;
|
LL | const B: i32 = A;
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^
|
||||||
= note: ...which again requires const-evaluating + checking `A`, completing the cycle
|
= note: ...which again requires const-evaluating + checking `A`, completing the cycle
|
||||||
note: cycle used when simplifying constant for the type system `A`
|
note: cycle used when simplifying constant for the type system `A`
|
||||||
--> $DIR/issue-23302-3.rs:1:1
|
--> $DIR/issue-23302-3.rs:1:1
|
||||||
|
|
|
@ -5,7 +5,7 @@ enum Foo {
|
||||||
|
|
||||||
enum Bar {
|
enum Bar {
|
||||||
A = Foo::A as isize
|
A = Foo::A as isize
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ const
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -6,13 +6,12 @@ LL | A = "" + 1
|
||||||
| |
|
| |
|
||||||
| &str
|
| &str
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-41394.rs:7:9
|
--> $DIR/issue-41394.rs:7:9
|
||||||
|
|
|
|
||||||
LL | A = Foo::A as isize
|
LL | A = Foo::A as isize
|
||||||
| ^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0369.
|
For more information about this error, try `rustc --explain E0369`.
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
|
|
@ -19,5 +19,5 @@ impl TraitB for B { //~ ERROR not all trait items implemented, missing: `MyA`
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = [0; B::VALUE];
|
let _ = [0; B::VALUE];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,13 @@ LL | type MyA: TraitA;
|
||||||
LL | impl TraitB for B {
|
LL | impl TraitB for B {
|
||||||
| ^^^^^^^^^^^^^^^^^ missing `MyA` in implementation
|
| ^^^^^^^^^^^^^^^^^ missing `MyA` in implementation
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-69602-type-err-during-codegen-ice.rs:21:17
|
--> $DIR/issue-69602-type-err-during-codegen-ice.rs:21:17
|
||||||
|
|
|
|
||||||
LL | let _ = [0; B::VALUE];
|
LL | let _ = [0; B::VALUE];
|
||||||
| ^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0046, E0080, E0437.
|
Some errors have detailed explanations: E0046, E0437.
|
||||||
For more information about an error, try `rustc --explain E0046`.
|
For more information about an error, try `rustc --explain E0046`.
|
||||||
|
|
|
@ -9,14 +9,30 @@ LL | intrinsics::size_of::<T>()
|
||||||
LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
|
LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
|
||||||
| ---------------------------------------------- inside `main` at $DIR/issue-55878.rs:7:26
|
| ---------------------------------------------- inside `main` at $DIR/issue-55878.rs:7:26
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/issue-55878.rs:7:26
|
--> $DIR/issue-55878.rs:7:26
|
||||||
|
|
|
|
||||||
LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
|
LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
note: erroneous constant used
|
||||||
|
--> $DIR/issue-55878.rs:7:26
|
||||||
|
|
|
||||||
|
LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
note: erroneous constant used
|
||||||
|
--> $DIR/issue-55878.rs:7:26
|
||||||
|
|
|
||||||
|
LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -2,5 +2,5 @@ fn main() {
|
||||||
const N: u32 = 1_000;
|
const N: u32 = 1_000;
|
||||||
const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; //~ ERROR cannot find value
|
const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; //~ ERROR cannot find value
|
||||||
let mut digits = [0u32; M];
|
let mut digits = [0u32; M];
|
||||||
//~^ ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,12 @@ LL - const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize;
|
||||||
LL + const M: usize = (f64::from(N) * LOG10_2) as usize;
|
LL + const M: usize = (f64::from(N) * LOG10_2) as usize;
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/issue-50599.rs:4:29
|
--> $DIR/issue-50599.rs:4:29
|
||||||
|
|
|
|
||||||
LL | let mut digits = [0u32; M];
|
LL | let mut digits = [0u32; M];
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0425.
|
For more information about this error, try `rustc --explain E0425`.
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
|
|
@ -2,5 +2,5 @@ fn main() {
|
||||||
let v = vec![0];
|
let v = vec![0];
|
||||||
const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant
|
const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant
|
||||||
let s: [u32; l] = v.into_iter().collect();
|
let s: [u32; l] = v.into_iter().collect();
|
||||||
//~^ERROR evaluation of constant value failed
|
//~^ constant
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,12 @@ LL | const l: usize = v.count();
|
||||||
| |
|
| |
|
||||||
| help: consider using `let` instead of `const`: `let l`
|
| help: consider using `let` instead of `const`: `let l`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
note: erroneous constant used
|
||||||
--> $DIR/type-dependent-def-issue-49241.rs:4:18
|
--> $DIR/type-dependent-def-issue-49241.rs:4:18
|
||||||
|
|
|
|
||||||
LL | let s: [u32; l] = v.into_iter().collect();
|
LL | let s: [u32; l] = v.into_iter().collect();
|
||||||
| ^ referenced constant has errors
|
| ^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to previous error
|
||||||
|
|
||||||
Some errors have detailed explanations: E0080, E0435.
|
For more information about this error, try `rustc --explain E0435`.
|
||||||
For more information about an error, try `rustc --explain E0080`.
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ error[E0080]: evaluation of `main::{constant#3}` failed
|
||||||
LL | const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.
|
LL | const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.
|
||||||
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
|
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
|
||||||
|
|
||||||
error[E0080]: erroneous constant used
|
note: erroneous constant used
|
||||||
--> $DIR/indexing_slicing_index.rs:31:5
|
--> $DIR/indexing_slicing_index.rs:31:5
|
||||||
|
|
|
|
||||||
LL | const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.
|
LL | const { &ARR[idx4()] }; // Ok, let rustc handle const contexts.
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: indexing may panic
|
error: indexing may panic
|
||||||
--> $DIR/indexing_slicing_index.rs:22:5
|
--> $DIR/indexing_slicing_index.rs:22:5
|
||||||
|
@ -65,6 +65,6 @@ error[E0080]: evaluation of constant value failed
|
||||||
LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts.
|
LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts.
|
||||||
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
|
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0080`.
|
For more information about this error, try `rustc --explain E0080`.
|
||||||
|
|
|
@ -712,7 +712,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||||
if tcx.is_foreign_item(def_id) {
|
if tcx.is_foreign_item(def_id) {
|
||||||
throw_unsup_format!("foreign thread-local statics are not supported");
|
throw_unsup_format!("foreign thread-local statics are not supported");
|
||||||
}
|
}
|
||||||
let allocation = tcx.eval_static_initializer(def_id)?;
|
// We don't give a span -- statics don't need that, they cannot be generic or associated.
|
||||||
|
let allocation = this.ctfe_query(None, |tcx| tcx.eval_static_initializer(def_id))?;
|
||||||
let mut allocation = allocation.inner().clone();
|
let mut allocation = allocation.inner().clone();
|
||||||
// This allocation will be deallocated when the thread dies, so it is not in read-only memory.
|
// This allocation will be deallocated when the thread dies, so it is not in read-only memory.
|
||||||
allocation.mutability = Mutability::Mut;
|
allocation.mutability = Mutability::Mut;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue