1
Fork 0

Auto merge of #129521 - matthiaskrgr:rollup-uigv77m, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #128596 (stabilize const_fn_floating_point_arithmetic)
 - #129199 (make writes_through_immutable_pointer a hard error)
 - #129246 (Retroactively feature gate `ConstArgKind::Path`)
 - #129290 (Pin `cc` to 1.0.105)
 - #129323 (Implement `ptr::fn_addr_eq`)
 - #129500 (remove invalid `TyCompat` relation for effects)
 - #129501 (panicking: improve hint for Miri's RUST_BACKTRACE behavior)
 - #129505 (interpret: ImmTy: tighten sanity checks in offset logic)
 - #129510 (Fix `elided_named_lifetimes` in code)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-08-25 08:12:16 +00:00
commit 717aec0f8e
130 changed files with 651 additions and 630 deletions

View file

@ -410,12 +410,9 @@ version = "0.1.0"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.13" version = "1.0.105"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" checksum = "5208975e568d83b6b05cc0a063c8e7e9acc2b43bee6da15616a5b73e109d7437"
dependencies = [
"shlex",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"

View file

@ -220,7 +220,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let parent_def_id = self.current_def_id_parent; let parent_def_id = self.current_def_id_parent;
let node_id = self.next_node_id(); let node_id = self.next_node_id();
// HACK(min_generic_const_args): see lower_anon_const // HACK(min_generic_const_args): see lower_anon_const
if !expr.is_potential_trivial_const_arg() { if !self.tcx.features().const_arg_path
|| !expr.is_potential_trivial_const_arg()
{
self.create_def( self.create_def(
parent_def_id, parent_def_id,
node_id, node_id,

View file

@ -387,7 +387,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let node_id = self.next_node_id(); let node_id = self.next_node_id();
// HACK(min_generic_const_args): see lower_anon_const // HACK(min_generic_const_args): see lower_anon_const
if !arg.is_potential_trivial_const_arg() { if !self.tcx.features().const_arg_path || !arg.is_potential_trivial_const_arg() {
// Add a definition for the in-band const def. // Add a definition for the in-band const def.
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span); self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span);
} }

View file

@ -2358,7 +2358,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
span: Span, span: Span,
) -> &'hir hir::ConstArg<'hir> { ) -> &'hir hir::ConstArg<'hir> {
let ct_kind = match res { let ct_kind = match res {
Res::Def(DefKind::ConstParam, _) => { Res::Def(DefKind::ConstParam, _) if self.tcx.features().const_arg_path => {
let qpath = self.lower_qpath( let qpath = self.lower_qpath(
ty_id, ty_id,
&None, &None,
@ -2433,7 +2433,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.resolver.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res()); self.resolver.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
debug!("res={:?}", maybe_res); debug!("res={:?}", maybe_res);
// FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path // FIXME(min_generic_const_args): for now we only lower params to ConstArgKind::Path
if let Some(res) = maybe_res if self.tcx.features().const_arg_path
&& let Some(res) = maybe_res
&& let Res::Def(DefKind::ConstParam, _) = res && let Res::Def(DefKind::ConstParam, _) = res
&& let ExprKind::Path(qself, path) = &expr.kind && let ExprKind::Path(qself, path) = &expr.kind
{ {
@ -2464,7 +2465,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
/// See [`hir::ConstArg`] for when to use this function vs /// See [`hir::ConstArg`] for when to use this function vs
/// [`Self::lower_anon_const_to_const_arg`]. /// [`Self::lower_anon_const_to_const_arg`].
fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst { fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
if c.value.is_potential_trivial_const_arg() { if self.tcx.features().const_arg_path && c.value.is_potential_trivial_const_arg() {
// HACK(min_generic_const_args): see DefCollector::visit_anon_const // HACK(min_generic_const_args): see DefCollector::visit_anon_const
// Over there, we guess if this is a bare param and only create a def if // Over there, we guess if this is a bare param and only create a def if
// we think it's not. However we may can guess wrong (see there for example) // we think it's not. However we may can guess wrong (see there for example)

View file

@ -8,7 +8,7 @@ edition = "2021"
ar_archive_writer = "0.4.2" ar_archive_writer = "0.4.2"
arrayvec = { version = "0.7", default-features = false } arrayvec = { version = "0.7", default-features = false }
bitflags = "2.4.1" bitflags = "2.4.1"
cc = "1.0.90" cc = "=1.0.105" # FIXME(cc): pinned to keep support for VS2013
either = "1.5.0" either = "1.5.0"
itertools = "0.12" itertools = "0.12"
jobserver = "0.1.28" jobserver = "0.1.28"

View file

@ -125,7 +125,7 @@ pub trait ArchiveBuilderBuilder {
rlib: &'a Path, rlib: &'a Path,
outdir: &Path, outdir: &Path,
bundled_lib_file_names: &FxIndexSet<Symbol>, bundled_lib_file_names: &FxIndexSet<Symbol>,
) -> Result<(), ExtractBundledLibsError<'_>> { ) -> Result<(), ExtractBundledLibsError<'a>> {
let archive_map = unsafe { let archive_map = unsafe {
Mmap::map( Mmap::map(
File::open(rlib) File::open(rlib)

View file

@ -575,10 +575,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
Rvalue::UnaryOp(_, operand) => { Rvalue::UnaryOp(_, operand) => {
let ty = operand.ty(self.body, self.tcx); let ty = operand.ty(self.body, self.tcx);
if is_int_bool_or_char(ty) { if is_int_bool_float_or_char(ty) {
// Int, bool, and char operations are fine. // Int, bool, float, and char operations are fine.
} else if ty.is_floating_point() {
self.check_op(ops::FloatingPointOp);
} else { } else {
span_bug!(self.span, "non-primitive type in `Rvalue::UnaryOp`: {:?}", ty); span_bug!(self.span, "non-primitive type in `Rvalue::UnaryOp`: {:?}", ty);
} }
@ -588,8 +586,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
let lhs_ty = lhs.ty(self.body, self.tcx); let lhs_ty = lhs.ty(self.body, self.tcx);
let rhs_ty = rhs.ty(self.body, self.tcx); let rhs_ty = rhs.ty(self.body, self.tcx);
if is_int_bool_or_char(lhs_ty) && is_int_bool_or_char(rhs_ty) { if is_int_bool_float_or_char(lhs_ty) && is_int_bool_float_or_char(rhs_ty) {
// Int, bool, and char operations are fine. // Int, bool, float, and char operations are fine.
} else if lhs_ty.is_fn_ptr() || lhs_ty.is_unsafe_ptr() { } else if lhs_ty.is_fn_ptr() || lhs_ty.is_unsafe_ptr() {
assert_matches!( assert_matches!(
op, op,
@ -603,8 +601,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
); );
self.check_op(ops::RawPtrComparison); self.check_op(ops::RawPtrComparison);
} else if lhs_ty.is_floating_point() || rhs_ty.is_floating_point() {
self.check_op(ops::FloatingPointOp);
} else { } else {
span_bug!( span_bug!(
self.span, self.span,
@ -1009,8 +1005,8 @@ fn place_as_reborrow<'tcx>(
} }
} }
fn is_int_bool_or_char(ty: Ty<'_>) -> bool { fn is_int_bool_float_or_char(ty: Ty<'_>) -> bool {
ty.is_bool() || ty.is_integral() || ty.is_char() ty.is_bool() || ty.is_integral() || ty.is_char() || ty.is_floating_point()
} }
fn emit_unstable_in_stable_error(ccx: &ConstCx<'_, '_>, span: Span, gate: Symbol) { fn emit_unstable_in_stable_error(ccx: &ConstCx<'_, '_>, span: Span, gate: Symbol) {

View file

@ -55,28 +55,6 @@ pub trait NonConstOp<'tcx>: std::fmt::Debug {
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx>; fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx>;
} }
#[derive(Debug)]
pub struct FloatingPointOp;
impl<'tcx> NonConstOp<'tcx> for FloatingPointOp {
fn status_in_item(&self, ccx: &ConstCx<'_, 'tcx>) -> Status {
if ccx.const_kind() == hir::ConstContext::ConstFn {
Status::Unstable(sym::const_fn_floating_point_arithmetic)
} else {
Status::Allowed
}
}
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
feature_err(
&ccx.tcx.sess,
sym::const_fn_floating_point_arithmetic,
span,
format!("floating point arithmetic is not allowed in {}s", ccx.const_kind()),
)
}
}
/// A function call where the callee is a pointer. /// A function call where the callee is a pointer.
#[derive(Debug)] #[derive(Debug)]
pub struct FnCallIndirect; pub struct FnCallIndirect;
@ -440,22 +418,12 @@ impl<'tcx> NonConstOp<'tcx> for CellBorrow {
DiagImportance::Secondary DiagImportance::Secondary
} }
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> { fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> Diag<'tcx> {
// FIXME: Maybe a more elegant solution to this if else case ccx.dcx().create_err(errors::InteriorMutableDataRefer {
if let hir::ConstContext::Static(_) = ccx.const_kind() { span,
ccx.dcx().create_err(errors::InteriorMutableDataRefer { opt_help: matches!(ccx.const_kind(), hir::ConstContext::Static(_)),
span, kind: ccx.const_kind(),
opt_help: true, teach: ccx.tcx.sess.teach(E0492),
kind: ccx.const_kind(), })
teach: ccx.tcx.sess.teach(E0492),
})
} else {
ccx.dcx().create_err(errors::InteriorMutableDataRefer {
span,
opt_help: false,
kind: ccx.const_kind(),
teach: ccx.tcx.sess.teach(E0492),
})
}
} }
} }

View file

@ -22,6 +22,7 @@ pub enum ConstEvalErrKind {
RecursiveStatic, RecursiveStatic,
AssertFailure(AssertKind<ConstInt>), AssertFailure(AssertKind<ConstInt>),
Panic { msg: Symbol, line: u32, col: u32, file: Symbol }, Panic { msg: Symbol, line: u32, col: u32, file: Symbol },
WriteThroughImmutablePointer,
} }
impl MachineStopType for ConstEvalErrKind { impl MachineStopType for ConstEvalErrKind {
@ -35,12 +36,16 @@ impl MachineStopType for ConstEvalErrKind {
Panic { .. } => const_eval_panic, Panic { .. } => const_eval_panic,
RecursiveStatic => const_eval_recursive_static, RecursiveStatic => const_eval_recursive_static,
AssertFailure(x) => x.diagnostic_message(), AssertFailure(x) => x.diagnostic_message(),
WriteThroughImmutablePointer => const_eval_write_through_immutable_pointer,
} }
} }
fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagArgName, DiagArgValue)) { fn add_args(self: Box<Self>, adder: &mut dyn FnMut(DiagArgName, DiagArgValue)) {
use ConstEvalErrKind::*; use ConstEvalErrKind::*;
match *self { match *self {
RecursiveStatic | ConstAccessesMutGlobal | ModifiedGlobal => {} RecursiveStatic
| ConstAccessesMutGlobal
| ModifiedGlobal
| WriteThroughImmutablePointer => {}
AssertFailure(kind) => kind.add_args(adder), AssertFailure(kind) => kind.add_args(adder),
Panic { msg, line, col, file } => { Panic { msg, line, col, file } => {
adder("msg".into(), msg.into_diag_arg()); adder("msg".into(), msg.into_diag_arg());
@ -159,6 +164,7 @@ where
/// Emit a lint from a const-eval situation, with a backtrace. /// Emit a lint from a const-eval situation, with a backtrace.
// Even if this is unused, please don't remove it -- chances are we will need to emit a lint during const-eval again in the future! // Even if this is unused, please don't remove it -- chances are we will need to emit a lint during const-eval again in the future!
#[allow(unused)]
pub(super) fn lint<'tcx, L>( pub(super) fn lint<'tcx, L>(
tcx: TyCtxtAt<'tcx>, tcx: TyCtxtAt<'tcx>,
machine: &CompileTimeMachine<'tcx>, machine: &CompileTimeMachine<'tcx>,

View file

@ -12,7 +12,6 @@ use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::layout::{FnAbiOf, TyAndLayout}; use rustc_middle::ty::layout::{FnAbiOf, TyAndLayout};
use rustc_middle::ty::{self, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
use rustc_middle::{bug, mir}; use rustc_middle::{bug, mir};
use rustc_session::lint::builtin::WRITES_THROUGH_IMMUTABLE_POINTER;
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span; use rustc_span::Span;
use rustc_target::abi::{Align, Size}; use rustc_target::abi::{Align, Size};
@ -732,8 +731,8 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
} }
fn before_memory_write( fn before_memory_write(
tcx: TyCtxtAt<'tcx>, _tcx: TyCtxtAt<'tcx>,
machine: &mut Self, _machine: &mut Self,
_alloc_extra: &mut Self::AllocExtra, _alloc_extra: &mut Self::AllocExtra,
(_alloc_id, immutable): (AllocId, bool), (_alloc_id, immutable): (AllocId, bool),
range: AllocRange, range: AllocRange,
@ -744,9 +743,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
} }
// Reject writes through immutable pointers. // Reject writes through immutable pointers.
if immutable { if immutable {
super::lint(tcx, machine, WRITES_THROUGH_IMMUTABLE_POINTER, |frames| { return Err(ConstEvalErrKind::WriteThroughImmutablePointer.into());
crate::errors::WriteThroughImmutablePointer { frames }
});
} }
// Everything else is fine. // Everything else is fine.
Ok(()) Ok(())

View file

@ -407,13 +407,6 @@ pub struct ConstEvalError {
pub frame_notes: Vec<FrameNote>, pub frame_notes: Vec<FrameNote>,
} }
#[derive(LintDiagnostic)]
#[diag(const_eval_write_through_immutable_pointer)]
pub struct WriteThroughImmutablePointer {
#[subdiagnostic]
pub frames: Vec<FrameNote>,
}
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(const_eval_nullary_intrinsic_fail)] #[diag(const_eval_nullary_intrinsic_fail)]
pub struct NullaryIntrinsicError { pub struct NullaryIntrinsicError {

View file

@ -319,6 +319,7 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
// some fieldless enum variants can have non-zero size but still `Aggregate` ABI... try // some fieldless enum variants can have non-zero size but still `Aggregate` ABI... try
// to detect those here and also give them no data // to detect those here and also give them no data
_ if matches!(layout.abi, Abi::Aggregate { .. }) _ if matches!(layout.abi, Abi::Aggregate { .. })
&& matches!(layout.variants, abi::Variants::Single { .. })
&& matches!(&layout.fields, abi::FieldsShape::Arbitrary { offsets, .. } if offsets.len() == 0) => && matches!(&layout.fields, abi::FieldsShape::Arbitrary { offsets, .. } if offsets.len() == 0) =>
{ {
Immediate::Uninit Immediate::Uninit
@ -328,8 +329,9 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
assert_eq!(offset.bytes(), 0); assert_eq!(offset.bytes(), 0);
assert!( assert!(
match (self.layout.abi, layout.abi) { match (self.layout.abi, layout.abi) {
(Abi::Scalar(..), Abi::Scalar(..)) => true, (Abi::Scalar(l), Abi::Scalar(r)) => l.size(cx) == r.size(cx),
(Abi::ScalarPair(..), Abi::ScalarPair(..)) => true, (Abi::ScalarPair(l1, l2), Abi::ScalarPair(r1, r2)) =>
l1.size(cx) == r1.size(cx) && l2.size(cx) == r2.size(cx),
_ => false, _ => false,
}, },
"cannot project into {} immediate with equally-sized field {}\nouter ABI: {:#?}\nfield ABI: {:#?}", "cannot project into {} immediate with equally-sized field {}\nouter ABI: {:#?}\nfield ABI: {:#?}",
@ -344,16 +346,23 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
(Immediate::ScalarPair(a_val, b_val), Abi::ScalarPair(a, b)) => { (Immediate::ScalarPair(a_val, b_val), Abi::ScalarPair(a, b)) => {
assert_matches!(layout.abi, Abi::Scalar(..)); assert_matches!(layout.abi, Abi::Scalar(..));
Immediate::from(if offset.bytes() == 0 { Immediate::from(if offset.bytes() == 0 {
debug_assert_eq!(layout.size, a.size(cx)); // It is "okay" to transmute from `usize` to a pointer (GVN relies on that).
// So only compare the size.
assert_eq!(layout.size, a.size(cx));
a_val a_val
} else { } else {
debug_assert_eq!(offset, a.size(cx).align_to(b.align(cx).abi)); assert_eq!(offset, a.size(cx).align_to(b.align(cx).abi));
debug_assert_eq!(layout.size, b.size(cx)); assert_eq!(layout.size, b.size(cx));
b_val b_val
}) })
} }
// everything else is a bug // everything else is a bug
_ => bug!("invalid field access on immediate {}, layout {:#?}", self, self.layout), _ => bug!(
"invalid field access on immediate {} at offset {}, original layout {:#?}",
self,
offset.bytes(),
self.layout
),
}; };
ImmTy::from_immediate(inner_val, layout) ImmTy::from_immediate(inner_val, layout)

View file

@ -80,7 +80,7 @@ pub fn entrypoint(txt: &str) -> MdStream<'_> {
} }
/// Parse a buffer with specified context /// Parse a buffer with specified context
fn parse_recursive<'a>(buf: &'a [u8], ctx: Context) -> MdStream<'_> { fn parse_recursive<'a>(buf: &'a [u8], ctx: Context) -> MdStream<'a> {
use ParseOpt as Po; use ParseOpt as Po;
use Prev::{Escape, Newline, Whitespace}; use Prev::{Escape, Newline, Whitespace};

View file

@ -59,7 +59,7 @@ pub trait Translate {
&'a self, &'a self,
message: &'a DiagMessage, message: &'a DiagMessage,
args: &'a FluentArgs<'_>, args: &'a FluentArgs<'_>,
) -> Result<Cow<'_, str>, TranslateError<'_>> { ) -> Result<Cow<'a, str>, TranslateError<'a>> {
trace!(?message, ?args); trace!(?message, ?args);
let (identifier, attr) = match message { let (identifier, attr) = match message {
DiagMessage::Str(msg) | DiagMessage::Translated(msg) => { DiagMessage::Str(msg) | DiagMessage::Translated(msg) => {

View file

@ -115,6 +115,8 @@ declare_features! (
(accepted, conservative_impl_trait, "1.26.0", Some(34511)), (accepted, conservative_impl_trait, "1.26.0", Some(34511)),
/// Allows calling constructor functions in `const fn`. /// Allows calling constructor functions in `const fn`.
(accepted, const_constructor, "1.40.0", Some(61456)), (accepted, const_constructor, "1.40.0", Some(61456)),
/// Allows basic arithmetic on floating point types in a `const fn`.
(accepted, const_fn_floating_point_arithmetic, "CURRENT_RUSTC_VERSION", Some(57241)),
/// Allows using and casting function pointers in a `const fn`. /// Allows using and casting function pointers in a `const fn`.
(accepted, const_fn_fn_ptr_basics, "1.61.0", Some(57563)), (accepted, const_fn_fn_ptr_basics, "1.61.0", Some(57563)),
/// Allows trait bounds in `const fn`. /// Allows trait bounds in `const fn`.

View file

@ -193,6 +193,8 @@ declare_features! (
(unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None), (unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None),
/// Allows identifying the `compiler_builtins` crate. /// Allows identifying the `compiler_builtins` crate.
(internal, compiler_builtins, "1.13.0", None), (internal, compiler_builtins, "1.13.0", None),
/// Gating for a new desugaring of const arguments of usages of const parameters
(internal, const_arg_path, "1.81.0", None),
/// Allows writing custom MIR /// Allows writing custom MIR
(internal, custom_mir, "1.65.0", None), (internal, custom_mir, "1.65.0", None),
/// Outputs useful `assert!` messages /// Outputs useful `assert!` messages
@ -400,8 +402,6 @@ declare_features! (
(incomplete, const_closures, "1.68.0", Some(106003)), (incomplete, const_closures, "1.68.0", Some(106003)),
/// Allows the definition of `const extern fn` and `const unsafe extern fn`. /// Allows the definition of `const extern fn` and `const unsafe extern fn`.
(unstable, const_extern_fn, "1.40.0", Some(64926)), (unstable, const_extern_fn, "1.40.0", Some(64926)),
/// Allows basic arithmetic on floating point types in a `const fn`.
(unstable, const_fn_floating_point_arithmetic, "1.48.0", Some(57241)),
/// Allows `for _ in _` loops in const contexts. /// Allows `for _ in _` loops in const contexts.
(unstable, const_for, "1.56.0", Some(87575)), (unstable, const_for, "1.56.0", Some(87575)),
/// Allows using `&mut` in constant functions. /// Allows using `&mut` in constant functions.

View file

@ -331,7 +331,7 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def_id: LocalDefId, def_id: LocalDefId,
owner_def_id: LocalDefId, owner_def_id: LocalDefId,
) -> Ty<'_> { ) -> Ty<'tcx> {
let tables = tcx.typeck(owner_def_id); let tables = tcx.typeck(owner_def_id);
// Check that all of the opaques we inferred during HIR are compatible. // Check that all of the opaques we inferred during HIR are compatible.

View file

@ -106,7 +106,7 @@ fn identity(_: Ty<'_>) -> Vec<Adjustment<'_>> {
vec![] vec![]
} }
fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'_>> { fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
move |target| vec![Adjustment { kind, target }] move |target| vec![Adjustment { kind, target }]
} }

View file

@ -87,14 +87,17 @@ fn used_trait_imports(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &UnordSet<LocalDef
&tcx.typeck(def_id).used_trait_imports &tcx.typeck(def_id).used_trait_imports
} }
fn typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckResults<'tcx> { fn typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
let fallback = move || tcx.type_of(def_id.to_def_id()).instantiate_identity(); let fallback = move || tcx.type_of(def_id.to_def_id()).instantiate_identity();
typeck_with_fallback(tcx, def_id, fallback, None) typeck_with_fallback(tcx, def_id, fallback, None)
} }
/// Used only to get `TypeckResults` for type inference during error recovery. /// Used only to get `TypeckResults` for type inference during error recovery.
/// Currently only used for type inference of `static`s and `const`s to avoid type cycle errors. /// Currently only used for type inference of `static`s and `const`s to avoid type cycle errors.
fn diagnostic_only_typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckResults<'tcx> { fn diagnostic_only_typeck<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: LocalDefId,
) -> &'tcx ty::TypeckResults<'tcx> {
let fallback = move || { let fallback = move || {
let span = tcx.hir().span(tcx.local_def_id_to_hir_id(def_id)); let span = tcx.hir().span(tcx.local_def_id_to_hir_id(def_id));
Ty::new_error_with_message(tcx, span, "diagnostic only typeck table used") Ty::new_error_with_message(tcx, span, "diagnostic only typeck table used")

View file

@ -98,7 +98,7 @@ impl<'tcx> Queries<'tcx> {
self.parse.compute(|| passes::parse(&self.compiler.sess)) self.parse.compute(|| passes::parse(&self.compiler.sess))
} }
pub fn global_ctxt(&'tcx self) -> Result<QueryResult<'_, &'tcx GlobalCtxt<'tcx>>> { pub fn global_ctxt(&'tcx self) -> Result<QueryResult<'tcx, &'tcx GlobalCtxt<'tcx>>> {
self.gcx.compute(|| { self.gcx.compute(|| {
let krate = self.parse()?.steal(); let krate = self.parse()?.steal();

View file

@ -572,7 +572,8 @@ fn register_builtins(store: &mut LintStore) {
"byte_slice_in_packed_struct_with_derive", "byte_slice_in_packed_struct_with_derive",
"converted into hard error, see issue #107457 \ "converted into hard error, see issue #107457 \
<https://github.com/rust-lang/rust/issues/107457> for more information", <https://github.com/rust-lang/rust/issues/107457> for more information",
) );
store.register_removed("writes_through_immutable_pointer", "converted into hard error");
} }
fn register_internals(store: &mut LintStore) { fn register_internals(store: &mut LintStore) {

View file

@ -142,7 +142,6 @@ declare_lint_pass! {
USELESS_DEPRECATED, USELESS_DEPRECATED,
WARNINGS, WARNINGS,
WASM_C_ABI, WASM_C_ABI,
WRITES_THROUGH_IMMUTABLE_POINTER,
// tidy-alphabetical-end // tidy-alphabetical-end
] ]
} }
@ -4696,40 +4695,6 @@ declare_lint! {
}; };
} }
declare_lint! {
/// The `writes_through_immutable_pointer` lint detects writes through pointers derived from
/// shared references.
///
/// ### Example
///
/// ```rust,compile_fail
/// #![feature(const_mut_refs)]
/// const WRITE_AFTER_CAST: () = unsafe {
/// let mut x = 0;
/// let ptr = &x as *const i32 as *mut i32;
/// *ptr = 0;
/// };
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// Shared references are immutable (when there is no `UnsafeCell` involved),
/// and writing through them or through pointers derived from them is Undefined Behavior.
/// The compiler recently learned to detect such Undefined Behavior during compile-time
/// evaluation, and in the future this will raise a hard error.
///
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub WRITES_THROUGH_IMMUTABLE_POINTER,
Warn,
"shared references are immutable, and pointers derived from them must not be written to",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #X <https://github.com/rust-lang/rust/issues/X>",
};
}
declare_lint! { declare_lint! {
/// The `private_macro_use` lint detects private macros that are imported /// The `private_macro_use` lint detects private macros that are imported
/// with `#[macro_use]`. /// with `#[macro_use]`.

View file

@ -10,5 +10,5 @@ libc = "0.2.73"
[build-dependencies] [build-dependencies]
# tidy-alphabetical-start # tidy-alphabetical-start
cc = "1.0.97" cc = "=1.0.105" # FIXME(cc): pinned to keep support for VS2013
# tidy-alphabetical-end # tidy-alphabetical-end

View file

@ -1487,7 +1487,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
.decode((self, sess)) .decode((self, sess))
} }
fn get_foreign_modules(self, sess: &'a Session) -> impl Iterator<Item = ForeignModule> + '_ { fn get_foreign_modules(self, sess: &'a Session) -> impl Iterator<Item = ForeignModule> + 'a {
self.root.foreign_modules.decode((self, sess)) self.root.foreign_modules.decode((self, sess))
} }

View file

@ -240,7 +240,7 @@ impl<'tcx> Const<'tcx> {
let ty = tcx.type_of(def).no_bound_vars().expect("const parameter types cannot be generic"); let ty = tcx.type_of(def).no_bound_vars().expect("const parameter types cannot be generic");
match Self::try_from_lit(tcx, ty, expr) { match Self::try_from_lit_or_param(tcx, ty, expr) {
Some(v) => v, Some(v) => v,
None => ty::Const::new_unevaluated( None => ty::Const::new_unevaluated(
tcx, tcx,
@ -281,7 +281,11 @@ impl<'tcx> Const<'tcx> {
} }
#[instrument(skip(tcx), level = "debug")] #[instrument(skip(tcx), level = "debug")]
fn try_from_lit(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, expr: &'tcx hir::Expr<'tcx>) -> Option<Self> { fn try_from_lit_or_param(
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
expr: &'tcx hir::Expr<'tcx>,
) -> Option<Self> {
// Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments // Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
// currently have to be wrapped in curly brackets, so it's necessary to special-case. // currently have to be wrapped in curly brackets, so it's necessary to special-case.
let expr = match &expr.kind { let expr = match &expr.kind {
@ -291,6 +295,22 @@ impl<'tcx> Const<'tcx> {
_ => expr, _ => expr,
}; };
if let hir::ExprKind::Path(
qpath @ hir::QPath::Resolved(
_,
&hir::Path { res: Res::Def(DefKind::ConstParam, _), .. },
),
) = expr.kind
{
if tcx.features().const_arg_path {
span_bug!(
expr.span,
"try_from_lit: received const param which shouldn't be possible"
);
}
return Some(Const::from_param(tcx, qpath, expr.hir_id));
};
let lit_input = match expr.kind { let lit_input = match expr.kind {
hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }), hir::ExprKind::Lit(lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }),
hir::ExprKind::Unary(hir::UnOp::Neg, expr) => match expr.kind { hir::ExprKind::Unary(hir::UnOp::Neg, expr) => match expr.kind {
@ -318,14 +338,6 @@ impl<'tcx> Const<'tcx> {
} }
} }
if let hir::ExprKind::Path(hir::QPath::Resolved(
_,
&hir::Path { res: Res::Def(DefKind::ConstParam, _), .. },
)) = expr.kind
{
span_bug!(expr.span, "try_from_lit: received const param which shouldn't be possible")
}
None None
} }

View file

@ -269,7 +269,7 @@ impl<'tcx> Generics {
} }
/// Returns the `GenericParamDef` associated with this `ParamConst`. /// Returns the `GenericParamDef` associated with this `ParamConst`.
pub fn const_param(&'tcx self, param: ParamConst, tcx: TyCtxt<'tcx>) -> &GenericParamDef { pub fn const_param(&'tcx self, param: ParamConst, tcx: TyCtxt<'tcx>) -> &'tcx GenericParamDef {
let param = self.param_at(param.index as usize, tcx); let param = self.param_at(param.index as usize, tcx);
match param.kind { match param.kind {
GenericParamDefKind::Const { .. } => param, GenericParamDefKind::Const { .. } => param,

View file

@ -493,7 +493,7 @@ pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'p, 'tcx, 'm> {
} }
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> { impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_, '_> {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'_, G> { fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let mut diag = let mut diag =
Diag::new(dcx, level, fluent::mir_build_non_exhaustive_patterns_type_not_empty); Diag::new(dcx, level, fluent::mir_build_non_exhaustive_patterns_type_not_empty);
diag.span(self.scrut_span); diag.span(self.scrut_span);

View file

@ -314,13 +314,15 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
} }
fn visit_anon_const(&mut self, constant: &'a AnonConst) { fn visit_anon_const(&mut self, constant: &'a AnonConst) {
// HACK(min_generic_const_args): don't create defs for anon consts if we think they will if self.resolver.tcx.features().const_arg_path
// later be turned into ConstArgKind::Path's. because this is before resolve is done, we && constant.value.is_potential_trivial_const_arg()
// may accidentally identify a construction of a unit struct as a param and not create a {
// def. we'll then create a def later in ast lowering in this case. the parent of nested // HACK(min_generic_const_args): don't create defs for anon consts if we think they will
// items will be messed up, but that's ok because there can't be any if we're just looking // later be turned into ConstArgKind::Path's. because this is before resolve is done, we
// for bare idents. // may accidentally identify a construction of a unit struct as a param and not create a
if constant.value.is_potential_trivial_const_arg() { // def. we'll then create a def later in ast lowering in this case. the parent of nested
// items will be messed up, but that's ok because there can't be any if we're just looking
// for bare idents.
visit::walk_anon_const(self, constant) visit::walk_anon_const(self, constant)
} else { } else {
let def = let def =

View file

@ -595,6 +595,7 @@ symbols! {
conservative_impl_trait, conservative_impl_trait,
console, console,
const_allocate, const_allocate,
const_arg_path,
const_async_blocks, const_async_blocks,
const_closures, const_closures,
const_compare_raw_pointers, const_compare_raw_pointers,

View file

@ -366,7 +366,7 @@ fn adt_consider_insignificant_dtor<'tcx>(
fn adt_drop_tys<'tcx>( fn adt_drop_tys<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def_id: DefId, def_id: DefId,
) -> Result<&ty::List<Ty<'tcx>>, AlwaysRequiresDrop> { ) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
// This is for the "adt_drop_tys" query, that considers all `Drop` impls, therefore all dtors are // This is for the "adt_drop_tys" query, that considers all `Drop` impls, therefore all dtors are
// significant. // significant.
let adt_has_dtor = let adt_has_dtor =

View file

@ -193,6 +193,7 @@
// Language features: // Language features:
// tidy-alphabetical-start // tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(asm_const))] #![cfg_attr(bootstrap, feature(asm_const))]
#![cfg_attr(bootstrap, feature(const_fn_floating_point_arithmetic))]
#![cfg_attr(bootstrap, feature(min_exhaustive_patterns))] #![cfg_attr(bootstrap, feature(min_exhaustive_patterns))]
#![feature(abi_unadjusted)] #![feature(abi_unadjusted)]
#![feature(adt_const_params)] #![feature(adt_const_params)]
@ -202,7 +203,6 @@
#![feature(cfg_sanitize)] #![feature(cfg_sanitize)]
#![feature(cfg_target_has_atomic)] #![feature(cfg_target_has_atomic)]
#![feature(cfg_target_has_atomic_equal_alignment)] #![feature(cfg_target_has_atomic_equal_alignment)]
#![feature(const_fn_floating_point_arithmetic)]
#![feature(const_for)] #![feature(const_for)]
#![feature(const_mut_refs)] #![feature(const_mut_refs)]
#![feature(const_precise_live_drops)] #![feature(const_precise_live_drops)]

View file

@ -1097,7 +1097,6 @@ pub mod effects {
pub trait TyCompat<T: ?Sized> {} pub trait TyCompat<T: ?Sized> {}
impl<T: ?Sized> TyCompat<T> for T {} impl<T: ?Sized> TyCompat<T> for T {}
impl<T: ?Sized> TyCompat<T> for Maybe {}
impl<T: ?Sized> TyCompat<Maybe> for T {} impl<T: ?Sized> TyCompat<Maybe> for T {}
#[lang = "EffectsIntersection"] #[lang = "EffectsIntersection"]

View file

@ -2130,6 +2130,33 @@ pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool {
(p as *const ()) == (q as *const ()) (p as *const ()) == (q as *const ())
} }
/// Compares the *addresses* of the two function pointers for equality.
///
/// Function pointers comparisons can have surprising results since
/// they are never guaranteed to be unique and could vary between different
/// code generation units. Furthermore, different functions could have the
/// same address after being merged together.
///
/// This is the same as `f == g` but using this function makes clear
/// that you are aware of these potentially surprising semantics.
///
/// # Examples
///
/// ```
/// #![feature(ptr_fn_addr_eq)]
/// use std::ptr;
///
/// fn a() { println!("a"); }
/// fn b() { println!("b"); }
/// assert!(!ptr::fn_addr_eq(a as fn(), b as fn()));
/// ```
#[unstable(feature = "ptr_fn_addr_eq", issue = "129322")]
#[inline(always)]
#[must_use = "function pointer comparison produces a value"]
pub fn fn_addr_eq<T: FnPtr, U: FnPtr>(f: T, g: U) -> bool {
f.addr() == g.addr()
}
/// Hash a raw pointer. /// Hash a raw pointer.
/// ///
/// This can be used to hash a `&T` reference (which coerces to `*const T` implicitly) /// This can be used to hash a `&T` reference (which coerces to `*const T` implicitly)

View file

@ -275,7 +275,7 @@ fn default_hook(info: &PanicHookInfo<'_>) {
if cfg!(miri) { if cfg!(miri) {
let _ = writeln!( let _ = writeln!(
err, err,
"note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` \ "note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` \
for the environment variable to have an effect" for the environment variable to have an effect"
); );
} }

View file

@ -53,7 +53,7 @@ fn filter_assoc_items_by_name_and_namespace<'a>(
assoc_items_of: DefId, assoc_items_of: DefId,
ident: Ident, ident: Ident,
ns: Namespace, ns: Namespace,
) -> impl Iterator<Item = &ty::AssocItem> + 'a { ) -> impl Iterator<Item = &'a ty::AssocItem> + 'a {
tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name).filter(move |item| { tcx.associated_items(assoc_items_of).filter_by_name_unhygienic(ident.name).filter(move |item| {
item.kind.namespace() == ns && tcx.hygienic_eq(ident, item.ident(tcx), assoc_items_of) item.kind.namespace() == ns && tcx.hygienic_eq(ident, item.ident(tcx), assoc_items_of)
}) })

View file

@ -235,7 +235,7 @@ fn unpack_match<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
/// If `expr` is an (e).await, return the inner expression "e" that's being /// If `expr` is an (e).await, return the inner expression "e" that's being
/// waited on. Otherwise return None. /// waited on. Otherwise return None.
fn unpack_await<'a>(expr: &'a hir::Expr<'a>) -> &hir::Expr<'a> { fn unpack_await<'a>(expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> {
if let ExprKind::Match(expr, _, hir::MatchSource::AwaitDesugar) = expr.kind { if let ExprKind::Match(expr, _, hir::MatchSource::AwaitDesugar) = expr.kind {
if let ExprKind::Call(func, [ref arg_0, ..]) = expr.kind { if let ExprKind::Call(func, [ref arg_0, ..]) = expr.kind {
if matches!( if matches!(

View file

@ -1,4 +1,3 @@
#![feature(const_fn_floating_point_arithmetic)]
#![warn(clippy::suboptimal_flops)] #![warn(clippy::suboptimal_flops)]
/// Allow suboptimal ops in constant context /// Allow suboptimal ops in constant context

View file

@ -1,4 +1,3 @@
#![feature(const_fn_floating_point_arithmetic)]
#![warn(clippy::suboptimal_flops)] #![warn(clippy::suboptimal_flops)]
/// Allow suboptimal ops in constant context /// Allow suboptimal ops in constant context

View file

@ -1,5 +1,5 @@
error: manual implementation of `abs` method error: manual implementation of `abs` method
--> tests/ui/floating_point_abs.rs:15:5 --> tests/ui/floating_point_abs.rs:14:5
| |
LL | if num >= 0.0 { num } else { -num } LL | if num >= 0.0 { num } else { -num }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()`
@ -8,43 +8,43 @@ LL | if num >= 0.0 { num } else { -num }
= help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]`
error: manual implementation of `abs` method error: manual implementation of `abs` method
--> tests/ui/floating_point_abs.rs:19:5 --> tests/ui/floating_point_abs.rs:18:5
| |
LL | if 0.0 < num { num } else { -num } LL | if 0.0 < num { num } else { -num }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()`
error: manual implementation of `abs` method error: manual implementation of `abs` method
--> tests/ui/floating_point_abs.rs:23:5 --> tests/ui/floating_point_abs.rs:22:5
| |
LL | if a.a > 0.0 { a.a } else { -a.a } LL | if a.a > 0.0 { a.a } else { -a.a }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()`
error: manual implementation of `abs` method error: manual implementation of `abs` method
--> tests/ui/floating_point_abs.rs:27:5 --> tests/ui/floating_point_abs.rs:26:5
| |
LL | if 0.0 >= num { -num } else { num } LL | if 0.0 >= num { -num } else { num }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.abs()`
error: manual implementation of `abs` method error: manual implementation of `abs` method
--> tests/ui/floating_point_abs.rs:31:5 --> tests/ui/floating_point_abs.rs:30:5
| |
LL | if a.a < 0.0 { -a.a } else { a.a } LL | if a.a < 0.0 { -a.a } else { a.a }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `a.a.abs()`
error: manual implementation of negation of `abs` method error: manual implementation of negation of `abs` method
--> tests/ui/floating_point_abs.rs:35:5 --> tests/ui/floating_point_abs.rs:34:5
| |
LL | if num < 0.0 { num } else { -num } LL | if num < 0.0 { num } else { -num }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()`
error: manual implementation of negation of `abs` method error: manual implementation of negation of `abs` method
--> tests/ui/floating_point_abs.rs:39:5 --> tests/ui/floating_point_abs.rs:38:5
| |
LL | if 0.0 >= num { num } else { -num } LL | if 0.0 >= num { num } else { -num }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-num.abs()`
error: manual implementation of negation of `abs` method error: manual implementation of negation of `abs` method
--> tests/ui/floating_point_abs.rs:44:12 --> tests/ui/floating_point_abs.rs:43:12
| |
LL | a: if a.a >= 0.0 { -a.a } else { a.a }, LL | a: if a.a >= 0.0 { -a.a } else { a.a },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-a.a.abs()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `-a.a.abs()`

View file

@ -1,4 +1,3 @@
#![feature(const_fn_floating_point_arithmetic)]
#![warn(clippy::suboptimal_flops)] #![warn(clippy::suboptimal_flops)]
/// Allow suboptimal_ops in constant context /// Allow suboptimal_ops in constant context

View file

@ -1,4 +1,3 @@
#![feature(const_fn_floating_point_arithmetic)]
#![warn(clippy::suboptimal_flops)] #![warn(clippy::suboptimal_flops)]
/// Allow suboptimal_ops in constant context /// Allow suboptimal_ops in constant context

View file

@ -1,5 +1,5 @@
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:20:13 --> tests/ui/floating_point_mul_add.rs:19:13
| |
LL | let _ = a * b + c; LL | let _ = a * b + c;
| ^^^^^^^^^ help: consider using: `a.mul_add(b, c)` | ^^^^^^^^^ help: consider using: `a.mul_add(b, c)`
@ -8,73 +8,73 @@ LL | let _ = a * b + c;
= help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:21:13 --> tests/ui/floating_point_mul_add.rs:20:13
| |
LL | let _ = a * b - c; LL | let _ = a * b - c;
| ^^^^^^^^^ help: consider using: `a.mul_add(b, -c)` | ^^^^^^^^^ help: consider using: `a.mul_add(b, -c)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:22:13 --> tests/ui/floating_point_mul_add.rs:21:13
| |
LL | let _ = c + a * b; LL | let _ = c + a * b;
| ^^^^^^^^^ help: consider using: `a.mul_add(b, c)` | ^^^^^^^^^ help: consider using: `a.mul_add(b, c)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:23:13 --> tests/ui/floating_point_mul_add.rs:22:13
| |
LL | let _ = c - a * b; LL | let _ = c - a * b;
| ^^^^^^^^^ help: consider using: `a.mul_add(-b, c)` | ^^^^^^^^^ help: consider using: `a.mul_add(-b, c)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:24:13 --> tests/ui/floating_point_mul_add.rs:23:13
| |
LL | let _ = a + 2.0 * 4.0; LL | let _ = a + 2.0 * 4.0;
| ^^^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4.0, a)` | ^^^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4.0, a)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:25:13 --> tests/ui/floating_point_mul_add.rs:24:13
| |
LL | let _ = a + 2. * 4.; LL | let _ = a + 2. * 4.;
| ^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4., a)` | ^^^^^^^^^^^ help: consider using: `2.0f64.mul_add(4., a)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:27:13 --> tests/ui/floating_point_mul_add.rs:26:13
| |
LL | let _ = (a * b) + c; LL | let _ = (a * b) + c;
| ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)` | ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:28:13 --> tests/ui/floating_point_mul_add.rs:27:13
| |
LL | let _ = c + (a * b); LL | let _ = c + (a * b);
| ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)` | ^^^^^^^^^^^ help: consider using: `a.mul_add(b, c)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:29:13 --> tests/ui/floating_point_mul_add.rs:28:13
| |
LL | let _ = a * b * c + d; LL | let _ = a * b * c + d;
| ^^^^^^^^^^^^^ help: consider using: `(a * b).mul_add(c, d)` | ^^^^^^^^^^^^^ help: consider using: `(a * b).mul_add(c, d)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:31:13 --> tests/ui/floating_point_mul_add.rs:30:13
| |
LL | let _ = a.mul_add(b, c) * a.mul_add(b, c) + a.mul_add(b, c) + c; LL | let _ = a.mul_add(b, c) * a.mul_add(b, c) + a.mul_add(b, c) + c;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `a.mul_add(b, c).mul_add(a.mul_add(b, c), a.mul_add(b, c))` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `a.mul_add(b, c).mul_add(a.mul_add(b, c), a.mul_add(b, c))`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:32:13 --> tests/ui/floating_point_mul_add.rs:31:13
| |
LL | let _ = 1234.567_f64 * 45.67834_f64 + 0.0004_f64; LL | let _ = 1234.567_f64 * 45.67834_f64 + 0.0004_f64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1234.567_f64.mul_add(45.67834_f64, 0.0004_f64)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `1234.567_f64.mul_add(45.67834_f64, 0.0004_f64)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:34:13 --> tests/ui/floating_point_mul_add.rs:33:13
| |
LL | let _ = (a * a + b).sqrt(); LL | let _ = (a * a + b).sqrt();
| ^^^^^^^^^^^ help: consider using: `a.mul_add(a, b)` | ^^^^^^^^^^^ help: consider using: `a.mul_add(a, b)`
error: multiply and add expressions can be calculated more efficiently and accurately error: multiply and add expressions can be calculated more efficiently and accurately
--> tests/ui/floating_point_mul_add.rs:37:13 --> tests/ui/floating_point_mul_add.rs:36:13
| |
LL | let _ = a - (b * u as f64); LL | let _ = a - (b * u as f64);
| ^^^^^^^^^^^^^^^^^^ help: consider using: `b.mul_add(-(u as f64), a)` | ^^^^^^^^^^^^^^^^^^ help: consider using: `b.mul_add(-(u as f64), a)`

View file

@ -1,4 +1,3 @@
#![feature(const_fn_floating_point_arithmetic)]
#![warn(clippy::suboptimal_flops)] #![warn(clippy::suboptimal_flops)]
/// Allow suboptimal_flops in constant context /// Allow suboptimal_flops in constant context

View file

@ -1,4 +1,3 @@
#![feature(const_fn_floating_point_arithmetic)]
#![warn(clippy::suboptimal_flops)] #![warn(clippy::suboptimal_flops)]
/// Allow suboptimal_flops in constant context /// Allow suboptimal_flops in constant context

View file

@ -1,5 +1,5 @@
error: conversion to radians can be done more accurately error: conversion to radians can be done more accurately
--> tests/ui/floating_point_rad.rs:11:13 --> tests/ui/floating_point_rad.rs:10:13
| |
LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0; LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_radians()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_radians()`
@ -8,43 +8,43 @@ LL | let _ = degrees as f64 * std::f64::consts::PI / 180.0;
= help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]` = help: to override `-D warnings` add `#[allow(clippy::suboptimal_flops)]`
error: conversion to degrees can be done more accurately error: conversion to degrees can be done more accurately
--> tests/ui/floating_point_rad.rs:12:13 --> tests/ui/floating_point_rad.rs:11:13
| |
LL | let _ = degrees as f64 * 180.0 / std::f64::consts::PI; LL | let _ = degrees as f64 * 180.0 / std::f64::consts::PI;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_degrees()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `(degrees as f64).to_degrees()`
error: conversion to degrees can be done more accurately error: conversion to degrees can be done more accurately
--> tests/ui/floating_point_rad.rs:17:13 --> tests/ui/floating_point_rad.rs:16:13
| |
LL | let _ = x * 180f32 / std::f32::consts::PI; LL | let _ = x * 180f32 / std::f32::consts::PI;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_degrees()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_degrees()`
error: conversion to degrees can be done more accurately error: conversion to degrees can be done more accurately
--> tests/ui/floating_point_rad.rs:18:13 --> tests/ui/floating_point_rad.rs:17:13
| |
LL | let _ = 90. * 180f64 / std::f64::consts::PI; LL | let _ = 90. * 180f64 / std::f64::consts::PI;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_degrees()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_degrees()`
error: conversion to degrees can be done more accurately error: conversion to degrees can be done more accurately
--> tests/ui/floating_point_rad.rs:19:13 --> tests/ui/floating_point_rad.rs:18:13
| |
LL | let _ = 90.5 * 180f64 / std::f64::consts::PI; LL | let _ = 90.5 * 180f64 / std::f64::consts::PI;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_degrees()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_degrees()`
error: conversion to radians can be done more accurately error: conversion to radians can be done more accurately
--> tests/ui/floating_point_rad.rs:20:13 --> tests/ui/floating_point_rad.rs:19:13
| |
LL | let _ = x * std::f32::consts::PI / 180f32; LL | let _ = x * std::f32::consts::PI / 180f32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_radians()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.to_radians()`
error: conversion to radians can be done more accurately error: conversion to radians can be done more accurately
--> tests/ui/floating_point_rad.rs:21:13 --> tests/ui/floating_point_rad.rs:20:13
| |
LL | let _ = 90. * std::f32::consts::PI / 180f32; LL | let _ = 90. * std::f32::consts::PI / 180f32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_radians()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.0_f64.to_radians()`
error: conversion to radians can be done more accurately error: conversion to radians can be done more accurately
--> tests/ui/floating_point_rad.rs:22:13 --> tests/ui/floating_point_rad.rs:21:13
| |
LL | let _ = 90.5 * std::f32::consts::PI / 180f32; LL | let _ = 90.5 * std::f32::consts::PI / 180f32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_radians()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `90.5_f64.to_radians()`

View file

@ -1157,7 +1157,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
} }
#[inline] #[inline]
fn get_thread_name<'c>(&'c self, thread: ThreadId) -> Option<&[u8]> fn get_thread_name<'c>(&'c self, thread: ThreadId) -> Option<&'c [u8]>
where where
'tcx: 'c, 'tcx: 'c,
{ {

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/exported_symbol_bad_unwind1.rs:LL:CC: thread 'main' panicked at $DIR/exported_symbol_bad_unwind1.rs:LL:CC:
explicit panic explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
--> $DIR/exported_symbol_bad_unwind1.rs:LL:CC --> $DIR/exported_symbol_bad_unwind1.rs:LL:CC
| |

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC: thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC:
explicit panic explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
panic in a function that cannot unwind panic in a function that cannot unwind
stack backtrace: stack backtrace:

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC: thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC:
explicit panic explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
panic in a function that cannot unwind panic in a function that cannot unwind
stack backtrace: stack backtrace:

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC: thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC:
explicit panic explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
--> $DIR/exported_symbol_bad_unwind2.rs:LL:CC --> $DIR/exported_symbol_bad_unwind2.rs:LL:CC
| |

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/return_pointer_on_unwind.rs:LL:CC: thread 'main' panicked at $DIR/return_pointer_on_unwind.rs:LL:CC:
explicit panic explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
--> $DIR/return_pointer_on_unwind.rs:LL:CC --> $DIR/return_pointer_on_unwind.rs:LL:CC
| |

View file

@ -1,7 +1,7 @@
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
aborted execution: attempted to instantiate uninhabited type `!` aborted execution: attempted to instantiate uninhabited type `!`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread caused non-unwinding panic. aborting. thread caused non-unwinding panic. aborting.
error: abnormal termination: the program aborted execution error: abnormal termination: the program aborted execution
--> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC --> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC

View file

@ -1,7 +1,7 @@
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
aborted execution: attempted to zero-initialize type `fn()`, which is invalid aborted execution: attempted to zero-initialize type `fn()`, which is invalid
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread caused non-unwinding panic. aborting. thread caused non-unwinding panic. aborting.
error: abnormal termination: the program aborted execution error: abnormal termination: the program aborted execution
--> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC --> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/bad_unwind.rs:LL:CC: thread 'main' panicked at $DIR/bad_unwind.rs:LL:CC:
explicit panic explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
--> $DIR/bad_unwind.rs:LL:CC --> $DIR/bad_unwind.rs:LL:CC
| |

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/double_panic.rs:LL:CC: thread 'main' panicked at $DIR/double_panic.rs:LL:CC:
first first
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread 'main' panicked at $DIR/double_panic.rs:LL:CC: thread 'main' panicked at $DIR/double_panic.rs:LL:CC:
second second
stack backtrace: stack backtrace:

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/panic_abort1.rs:LL:CC: thread 'main' panicked at $DIR/panic_abort1.rs:LL:CC:
panicking from libstd panicking from libstd
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
error: abnormal termination: the program aborted execution error: abnormal termination: the program aborted execution
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC --> RUSTLIB/panic_abort/src/lib.rs:LL:CC
| |

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/panic_abort2.rs:LL:CC: thread 'main' panicked at $DIR/panic_abort2.rs:LL:CC:
42-panicking from libstd 42-panicking from libstd
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
error: abnormal termination: the program aborted execution error: abnormal termination: the program aborted execution
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC --> RUSTLIB/panic_abort/src/lib.rs:LL:CC
| |

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/panic_abort3.rs:LL:CC: thread 'main' panicked at $DIR/panic_abort3.rs:LL:CC:
panicking from libcore panicking from libcore
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
error: abnormal termination: the program aborted execution error: abnormal termination: the program aborted execution
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC --> RUSTLIB/panic_abort/src/lib.rs:LL:CC
| |

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/panic_abort4.rs:LL:CC: thread 'main' panicked at $DIR/panic_abort4.rs:LL:CC:
42-panicking from libcore 42-panicking from libcore
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
error: abnormal termination: the program aborted execution error: abnormal termination: the program aborted execution
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC --> RUSTLIB/panic_abort/src/lib.rs:LL:CC
| |

View file

@ -3,7 +3,7 @@ warning: You have explicitly enabled MIR optimizations, overriding Miri's defaul
thread 'main' panicked at $DIR/terminate-terminator.rs:LL:CC: thread 'main' panicked at $DIR/terminate-terminator.rs:LL:CC:
explicit panic explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
panic in a function that cannot unwind panic in a function that cannot unwind
stack backtrace: stack backtrace:

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/unwind-action-terminate.rs:LL:CC: thread 'main' panicked at $DIR/unwind-action-terminate.rs:LL:CC:
explicit panic explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
panic in a function that cannot unwind panic in a function that cannot unwind
stack backtrace: stack backtrace:

View file

@ -1,5 +1,5 @@
thread 'main' panicked at $DIR/alloc_error_handler_hook.rs:LL:CC: thread 'main' panicked at $DIR/alloc_error_handler_hook.rs:LL:CC:
alloc error hook called alloc error hook called
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
yes we are unwinding! yes we are unwinding!

View file

@ -1,5 +1,5 @@
thread 'main' panicked at RUSTLIB/std/src/alloc.rs:LL:CC: thread 'main' panicked at RUSTLIB/std/src/alloc.rs:LL:CC:
memory allocation of 4 bytes failed memory allocation of 4 bytes failed
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
yes we are unwinding! yes we are unwinding!

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/div-by-zero-2.rs:LL:CC: thread 'main' panicked at $DIR/div-by-zero-2.rs:LL:CC:
attempt to divide by zero attempt to divide by zero
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC: thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC:
explicit panic explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC: thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC:
explicit panic explicit panic
thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC: thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC:

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/oob_subslice.rs:LL:CC: thread 'main' panicked at $DIR/oob_subslice.rs:LL:CC:
range end index 5 out of range for slice of length 4 range end index 5 out of range for slice of length 4
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/overflowing-lsh-neg.rs:LL:CC: thread 'main' panicked at $DIR/overflowing-lsh-neg.rs:LL:CC:
attempt to shift left with overflow attempt to shift left with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/overflowing-rsh-1.rs:LL:CC: thread 'main' panicked at $DIR/overflowing-rsh-1.rs:LL:CC:
attempt to shift right with overflow attempt to shift right with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/overflowing-rsh-2.rs:LL:CC: thread 'main' panicked at $DIR/overflowing-rsh-2.rs:LL:CC:
attempt to shift right with overflow attempt to shift right with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/panic2.rs:LL:CC: thread 'main' panicked at $DIR/panic2.rs:LL:CC:
42-panicking from libstd 42-panicking from libstd
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/panic3.rs:LL:CC: thread 'main' panicked at $DIR/panic3.rs:LL:CC:
panicking from libcore panicking from libcore
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/panic4.rs:LL:CC: thread 'main' panicked at $DIR/panic4.rs:LL:CC:
42-panicking from libcore 42-panicking from libcore
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/transmute_fat2.rs:LL:CC: thread 'main' panicked at $DIR/transmute_fat2.rs:LL:CC:
index out of bounds: the len is 0 but the index is 0 index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/unsupported_foreign_function.rs:LL:CC: thread 'main' panicked at $DIR/unsupported_foreign_function.rs:LL:CC:
unsupported Miri functionality: can't call foreign function `foo` on $OS unsupported Miri functionality: can't call foreign function `foo` on $OS
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,4 +1,4 @@
thread 'main' panicked at $DIR/unsupported_syscall.rs:LL:CC: thread 'main' panicked at $DIR/unsupported_syscall.rs:LL:CC:
unsupported Miri functionality: can't execute syscall with ID 0 unsupported Miri functionality: can't execute syscall with ID 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC: thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
Hello from std::panic Hello from std::panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
Caught panic message (&str): Hello from std::panic Caught panic message (&str): Hello from std::panic
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC: thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
Hello from std::panic: 1 Hello from std::panic: 1

View file

@ -3,7 +3,7 @@ Thread 1 reported it has started
thread '<unnamed>' panicked at $DIR/concurrent-panic.rs:LL:CC: thread '<unnamed>' panicked at $DIR/concurrent-panic.rs:LL:CC:
panic in thread 2 panic in thread 2
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
Thread 2 blocking on thread 1 Thread 2 blocking on thread 1
Thread 2 reported it has started Thread 2 reported it has started
Unlocking mutex Unlocking mutex

View file

@ -1,7 +1,7 @@
thread 'main' panicked at $DIR/nested_panic_caught.rs:LL:CC: thread 'main' panicked at $DIR/nested_panic_caught.rs:LL:CC:
once once
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread 'main' panicked at $DIR/nested_panic_caught.rs:LL:CC: thread 'main' panicked at $DIR/nested_panic_caught.rs:LL:CC:
twice twice
stack backtrace: stack backtrace:

View file

@ -1,6 +1,6 @@
thread '<unnamed>' panicked at $DIR/thread_panic.rs:LL:CC: thread '<unnamed>' panicked at $DIR/thread_panic.rs:LL:CC:
Hello! Hello!
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
thread 'childthread' panicked at $DIR/thread_panic.rs:LL:CC: thread 'childthread' panicked at $DIR/thread_panic.rs:LL:CC:
Hello, world! Hello, world!

View file

@ -1,5 +1,5 @@
//@ known-bug: #127962 //@ known-bug: #127962
#![feature(generic_const_exprs)] #![feature(generic_const_exprs, const_arg_path)]
fn zero_init<const usize: usize>() -> Substs1<{ (N) }> { fn zero_init<const usize: usize>() -> Substs1<{ (N) }> {
Substs1([0; { (usize) }]) Substs1([0; { (usize) }])

View file

@ -1,10 +0,0 @@
//@ known-bug: #128016
macro_rules! len {
() => {
target
};
}
fn main() {
let val: [str; len!()] = [];
}

View file

@ -17,12 +17,14 @@ extern crate rustc_driver;
extern crate rustc_interface; extern crate rustc_interface;
extern crate stable_mir; extern crate stable_mir;
use mir::{mono::Instance, TerminatorKind::*}; use std::io::Write;
use std::ops::ControlFlow;
use mir::mono::Instance;
use mir::TerminatorKind::*;
use rustc_smir::rustc_internal; use rustc_smir::rustc_internal;
use stable_mir::ty::{RigidTy, TyKind}; use stable_mir::ty::{RigidTy, TyKind};
use stable_mir::*; use stable_mir::*;
use std::io::Write;
use std::ops::ControlFlow;
const CRATE_NAME: &str = "input"; const CRATE_NAME: &str = "input";
@ -33,7 +35,7 @@ fn test_stable_mir() -> ControlFlow<()> {
// Get all items and split generic vs monomorphic items. // Get all items and split generic vs monomorphic items.
let (generic, mono): (Vec<_>, Vec<_>) = let (generic, mono): (Vec<_>, Vec<_>) =
items.into_iter().partition(|item| item.requires_monomorphization()); items.into_iter().partition(|item| item.requires_monomorphization());
assert_eq!(mono.len(), 3, "Expected 3 mono functions"); assert_eq!(mono.len(), 4, "Expected 3 mono functions");
assert_eq!(generic.len(), 2, "Expected 2 generic functions"); assert_eq!(generic.len(), 2, "Expected 2 generic functions");
// For all monomorphic items, get the correspondent instances. // For all monomorphic items, get the correspondent instances.

View file

@ -5,7 +5,9 @@
#![feature(with_negative_coherence)] #![feature(with_negative_coherence)]
trait Trait {} trait Trait {}
impl<const N: u8> Trait for [(); N] {} impl<const N: u8> Trait for [(); N] {}
//~^ ERROR: mismatched types
impl<const N: i8> Trait for [(); N] {} impl<const N: i8> Trait for [(); N] {}
//~^ ERROR: conflicting implementations of trait `Trait` //~^ ERROR: conflicting implementations of trait `Trait`
//~| ERROR: mismatched types
fn main() {} fn main() {}

View file

@ -1,11 +1,25 @@
error[E0119]: conflicting implementations of trait `Trait` for type `[(); _]` error[E0119]: conflicting implementations of trait `Trait` for type `[(); _]`
--> $DIR/generic_const_type_mismatch.rs:8:1 --> $DIR/generic_const_type_mismatch.rs:9:1
| |
LL | impl<const N: u8> Trait for [(); N] {} LL | impl<const N: u8> Trait for [(); N] {}
| ----------------------------------- first implementation here | ----------------------------------- first implementation here
LL |
LL | impl<const N: i8> Trait for [(); N] {} LL | impl<const N: i8> Trait for [(); N] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); _]` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[(); _]`
error: aborting due to 1 previous error error[E0308]: mismatched types
--> $DIR/generic_const_type_mismatch.rs:7:34
|
LL | impl<const N: u8> Trait for [(); N] {}
| ^ expected `usize`, found `u8`
For more information about this error, try `rustc --explain E0119`. error[E0308]: mismatched types
--> $DIR/generic_const_type_mismatch.rs:9:34
|
LL | impl<const N: i8> Trait for [(); N] {}
| ^ expected `usize`, found `i8`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0119, E0308.
For more information about an error, try `rustc --explain E0119`.

View file

@ -7,6 +7,7 @@ trait Q {
impl<const N: u64> Q for [u8; N] { impl<const N: u64> Q for [u8; N] {
//~^ ERROR: the constant `N` is not of type `usize` //~^ ERROR: the constant `N` is not of type `usize`
//~| ERROR: mismatched types
const ASSOC: usize = 1; const ASSOC: usize = 1;
} }

View file

@ -5,7 +5,7 @@ LL | impl<const N: u64> Q for [u8; N] {
| ^^^^^^^ expected `usize`, found `u64` | ^^^^^^^ expected `usize`, found `u64`
error: the constant `13` is not of type `u64` error: the constant `13` is not of type `u64`
--> $DIR/bad-subst-const-kind.rs:13:24 --> $DIR/bad-subst-const-kind.rs:14:24
| |
LL | pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] { LL | pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] {
| ^^^^^^^^ expected `u64`, found `usize` | ^^^^^^^^ expected `u64`, found `usize`
@ -18,5 +18,12 @@ LL | impl<const N: u64> Q for [u8; N] {
| | | |
| unsatisfied trait bound introduced here | unsatisfied trait bound introduced here
error: aborting due to 2 previous errors error[E0308]: mismatched types
--> $DIR/bad-subst-const-kind.rs:8:31
|
LL | impl<const N: u64> Q for [u8; N] {
| ^ expected `usize`, found `u64`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,21 @@
//@ check-pass
// This is a regression test for #128016.
macro_rules! len_inner {
() => {
BAR
};
}
macro_rules! len {
() => {
len_inner!()
};
}
const BAR: usize = 0;
fn main() {
let val: [bool; len!()] = [];
}

View file

@ -0,0 +1,13 @@
//@ check-pass
macro_rules! len {
($x:ident) => {
$x
};
}
fn bar<const N: usize>() {
let val: [bool; len!(N)] = [true; N];
}
fn main() {}

View file

@ -0,0 +1,13 @@
// This is a regression test for #128016.
macro_rules! len {
() => {
target
//~^ ERROR cannot find value `target`
};
}
fn main() {
let val: [str; len!()] = [];
//~^ ERROR the size for values
}

View file

@ -0,0 +1,24 @@
error[E0425]: cannot find value `target` in this scope
--> $DIR/trivial-const-arg-macro-res-error.rs:5:9
|
LL | target
| ^^^^^^ not found in this scope
...
LL | let val: [str; len!()] = [];
| ------ in this macro invocation
|
= note: this error originates in the macro `len` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> $DIR/trivial-const-arg-macro-res-error.rs:11:14
|
LL | let val: [str; len!()] = [];
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
= note: slice and array elements must have `Sized` type
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0425.
For more information about an error, try `rustc --explain E0277`.

View file

@ -0,0 +1,15 @@
//@ check-pass
// This is a regression test for #128016.
macro_rules! len {
() => {
BAR
};
}
const BAR: usize = 0;
fn main() {
let val: [bool; len!()] = [];
}

View file

@ -8,6 +8,7 @@ trait Q {
impl<const N: u64> Q for [u8; N] {} impl<const N: u64> Q for [u8; N] {}
//~^ ERROR not all trait items implemented //~^ ERROR not all trait items implemented
//~| ERROR the constant `N` is not of type `usize` //~| ERROR the constant `N` is not of type `usize`
//~| ERROR mismatched types
pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {} pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
//~^ ERROR the constant `13` is not of type `u64` //~^ ERROR the constant `13` is not of type `u64`

View file

@ -14,7 +14,7 @@ LL | impl<const N: u64> Q for [u8; N] {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation
error: the constant `13` is not of type `u64` error: the constant `13` is not of type `u64`
--> $DIR/type_mismatch.rs:12:26 --> $DIR/type_mismatch.rs:13:26
| |
LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {} LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
| ^^^^^^^^ expected `u64`, found `usize` | ^^^^^^^^ expected `u64`, found `usize`
@ -28,14 +28,20 @@ LL | impl<const N: u64> Q for [u8; N] {}
| unsatisfied trait bound introduced here | unsatisfied trait bound introduced here
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/type_mismatch.rs:12:20 --> $DIR/type_mismatch.rs:13:20
| |
LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {} LL | pub fn q_user() -> [u8; <[u8; 13] as Q>::ASSOC] {}
| ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u8; <[u8; 13] as Q>::ASSOC]`, found `()` | ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `[u8; <[u8; 13] as Q>::ASSOC]`, found `()`
| | | |
| implicitly returns `()` as its body has no tail or `return` expression | implicitly returns `()` as its body has no tail or `return` expression
error: aborting due to 4 previous errors error[E0308]: mismatched types
--> $DIR/type_mismatch.rs:8:31
|
LL | impl<const N: u64> Q for [u8; N] {}
| ^ expected `usize`, found `u64`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0046, E0308. Some errors have detailed explanations: E0046, E0308.
For more information about an error, try `rustc --explain E0046`. For more information about an error, try `rustc --explain E0046`.

View file

@ -14,8 +14,8 @@ mod v20 {
//~^ ERROR cannot find value `v8` in this scope //~^ ERROR cannot find value `v8` in this scope
//~| ERROR cannot find function `v6` in this scope //~| ERROR cannot find function `v6` in this scope
pub struct v17<const v10: usize, const v7: v11> { pub struct v17<const v10: usize, const v7: v11> {
//~^ WARN type `v17` should have an upper camel case name //~^ WARN type `v17` should have an upper camel case name
//~| ERROR `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter //~| ERROR `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter
_p: (), _p: (),
} }
@ -25,10 +25,10 @@ mod v20 {
} }
impl<const v10: usize> v17<v10, v2> { impl<const v10: usize> v17<v10, v2> {
//~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} //~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
//~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
pub const fn v21() -> v18 { pub const fn v21() -> v18 {
//~^ ERROR cannot find type `v18` in this scope //~^ ERROR cannot find type `v18` in this scope
v18 { _p: () } v18 { _p: () }
//~^ ERROR cannot find struct, variant or union type `v18` in this scope //~^ ERROR cannot find struct, variant or union type `v18` in this scope
} }

View file

@ -72,13 +72,13 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
LL + #![feature(adt_const_params)] LL + #![feature(adt_const_params)]
| |
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
--> $DIR/unevaluated-const-ice-119731.rs:27:37 --> $DIR/unevaluated-const-ice-119731.rs:27:37
| |
LL | impl<const v10: usize> v17<v10, v2> { LL | impl<const v10: usize> v17<v10, v2> {
| ^^ | ^^
error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#1}
--> $DIR/unevaluated-const-ice-119731.rs:27:37 --> $DIR/unevaluated-const-ice-119731.rs:27:37
| |
LL | impl<const v10: usize> v17<v10, v2> { LL | impl<const v10: usize> v17<v10, v2> {

View file

@ -2,108 +2,108 @@
#![feature(generic_const_exprs)] #![feature(generic_const_exprs)]
#![allow(incomplete_features)] #![allow(incomplete_features)]
fn foo<const W: usize, const H: usize>(v: [[u32;H+1]; W]) -> [[u32; W+1]; H] { fn foo<const W: usize, const H: usize>(v: [[u32; H + 1]; W]) -> [[u32; W + 1]; H] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR cannot transmute //~^ ERROR cannot transmute
} }
} }
fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] { fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
//~^ ERROR the constant `W` is not of type `usize` //~^ ERROR: the constant `W` is not of type `usize`
unsafe { //~| ERROR: mismatched types
std::mem::transmute(v) //~| ERROR: mismatched types
//~^ ERROR the constant `W` is not of type `usize` unsafe {
} std::mem::transmute(v)
//~^ ERROR: the constant `W` is not of type `usize`
}
} }
fn baz<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [u32; W * H * H] { fn baz<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [u32; W * H * H] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR cannot transmute //~^ ERROR cannot transmute
} }
} }
fn overflow(v: [[[u32; 8888888]; 9999999]; 777777777]) -> [[[u32; 9999999]; 777777777]; 8888888] { fn overflow(v: [[[u32; 8888888]; 9999999]; 777777777]) -> [[[u32; 9999999]; 777777777]; 8888888] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR cannot transmute //~^ ERROR cannot transmute
} }
} }
fn transpose<const W: usize, const H: usize>(v: [[u32;H]; W]) -> [[u32; W]; H] { fn transpose<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
} }
} }
fn ident<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [[u32; H]; W] { fn ident<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [[u32; H]; W] {
unsafe { unsafe { std::mem::transmute(v) }
std::mem::transmute(v)
}
} }
fn flatten<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [u32; W * H] { fn flatten<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [u32; W * H] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
} }
} }
fn coagulate<const W: usize, const H: usize>(v: [u32; H*W]) -> [[u32; W];H] { fn coagulate<const W: usize, const H: usize>(v: [u32; H * W]) -> [[u32; W]; H] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
} }
} }
fn flatten_3d<const W: usize, const H: usize, const D: usize>( fn flatten_3d<const W: usize, const H: usize, const D: usize>(
v: [[[u32; D]; H]; W] v: [[[u32; D]; H]; W],
) -> [u32; D * W * H] { ) -> [u32; D * W * H] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
} }
} }
fn flatten_somewhat<const W: usize, const H: usize, const D: usize>( fn flatten_somewhat<const W: usize, const H: usize, const D: usize>(
v: [[[u32; D]; H]; W] v: [[[u32; D]; H]; W],
) -> [[u32; D * W]; H] { ) -> [[u32; D * W]; H] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
} }
} }
fn known_size<const L: usize>(v: [u16; L]) -> [u8; L * 2] { fn known_size<const L: usize>(v: [u16; L]) -> [u8; L * 2] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
} }
} }
fn condense_bytes<const L: usize>(v: [u8; L * 2]) -> [u16; L] { fn condense_bytes<const L: usize>(v: [u8; L * 2]) -> [u16; L] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
} }
} }
fn singleton_each<const L: usize>(v: [u8; L]) -> [[u8;1]; L] { fn singleton_each<const L: usize>(v: [u8; L]) -> [[u8; 1]; L] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
} }
} }
fn transpose_with_const<const W: usize, const H: usize>( fn transpose_with_const<const W: usize, const H: usize>(
v: [[u32; 2 * H]; W + W] v: [[u32; 2 * H]; W + W],
) -> [[u32; W + W]; 2 * H] { ) -> [[u32; W + W]; 2 * H] {
unsafe { unsafe {
std::mem::transmute(v) std::mem::transmute(v)
//~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types //~^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
} }
} }
fn main() {} fn main() {}

View file

@ -5,119 +5,132 @@ LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
| ^^^^^^^^^^^^^ expected `usize`, found `bool` | ^^^^^^^^^^^^^ expected `usize`, found `bool`
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:7:5 --> $DIR/transmute-fail.rs:7:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[[u32; H+1]; W]` (size can vary because of [u32; H+1]) = note: source type: `[[u32; H + 1]; W]` (size can vary because of [u32; H + 1])
= note: target type: `[[u32; W+1]; H]` (size can vary because of [u32; W+1]) = note: target type: `[[u32; W + 1]; H]` (size can vary because of [u32; W + 1])
error: the constant `W` is not of type `usize` error: the constant `W` is not of type `usize`
--> $DIR/transmute-fail.rs:15:5 --> $DIR/transmute-fail.rs:17:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool` | ^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool`
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:22:5 --> $DIR/transmute-fail.rs:24:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[[u32; H]; W]` (size can vary because of [u32; H]) = note: source type: `[[u32; H]; W]` (size can vary because of [u32; H])
= note: target type: `[u32; W * H * H]` (this type does not have a fixed size) = note: target type: `[u32; W * H * H]` (this type does not have a fixed size)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:29:5 --> $DIR/transmute-fail.rs:31:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[[[u32; 8888888]; 9999999]; 777777777]` (values of the type `[[u32; 8888888]; 9999999]` are too big for the current architecture) = note: source type: `[[[u32; 8888888]; 9999999]; 777777777]` (values of the type `[[u32; 8888888]; 9999999]` are too big for the current architecture)
= note: target type: `[[[u32; 9999999]; 777777777]; 8888888]` (values of the type `[[u32; 9999999]; 777777777]` are too big for the current architecture) = note: target type: `[[[u32; 9999999]; 777777777]; 8888888]` (values of the type `[[u32; 9999999]; 777777777]` are too big for the current architecture)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:36:5 --> $DIR/transmute-fail.rs:38:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[[u32; H]; W]` (size can vary because of [u32; H]) = note: source type: `[[u32; H]; W]` (size can vary because of [u32; H])
= note: target type: `[[u32; W]; H]` (size can vary because of [u32; W]) = note: target type: `[[u32; W]; H]` (size can vary because of [u32; W])
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:49:5 --> $DIR/transmute-fail.rs:49:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[[u32; H]; W]` (size can vary because of [u32; H]) = note: source type: `[[u32; H]; W]` (size can vary because of [u32; H])
= note: target type: `[u32; W * H]` (this type does not have a fixed size) = note: target type: `[u32; W * H]` (this type does not have a fixed size)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:56:5 --> $DIR/transmute-fail.rs:56:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[u32; H*W]` (this type does not have a fixed size) = note: source type: `[u32; H * W]` (this type does not have a fixed size)
= note: target type: `[[u32; W]; H]` (size can vary because of [u32; W]) = note: target type: `[[u32; W]; H]` (size can vary because of [u32; W])
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:65:5 --> $DIR/transmute-fail.rs:65:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[[[u32; D]; H]; W]` (size can vary because of [u32; D]) = note: source type: `[[[u32; D]; H]; W]` (size can vary because of [u32; D])
= note: target type: `[u32; D * W * H]` (this type does not have a fixed size) = note: target type: `[u32; D * W * H]` (this type does not have a fixed size)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:74:5 --> $DIR/transmute-fail.rs:74:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[[[u32; D]; H]; W]` (size can vary because of [u32; D]) = note: source type: `[[[u32; D]; H]; W]` (size can vary because of [u32; D])
= note: target type: `[[u32; D * W]; H]` (size can vary because of [u32; D * W]) = note: target type: `[[u32; D * W]; H]` (size can vary because of [u32; D * W])
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:81:5 --> $DIR/transmute-fail.rs:81:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[u16; L]` (this type does not have a fixed size) = note: source type: `[u16; L]` (this type does not have a fixed size)
= note: target type: `[u8; L * 2]` (this type does not have a fixed size) = note: target type: `[u8; L * 2]` (this type does not have a fixed size)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:88:5 --> $DIR/transmute-fail.rs:88:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[u8; L * 2]` (this type does not have a fixed size) = note: source type: `[u8; L * 2]` (this type does not have a fixed size)
= note: target type: `[u16; L]` (this type does not have a fixed size) = note: target type: `[u16; L]` (this type does not have a fixed size)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:95:5 --> $DIR/transmute-fail.rs:95:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[u8; L]` (this type does not have a fixed size) = note: source type: `[u8; L]` (this type does not have a fixed size)
= note: target type: `[[u8; 1]; L]` (this type does not have a fixed size) = note: target type: `[[u8; 1]; L]` (this type does not have a fixed size)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/transmute-fail.rs:104:5 --> $DIR/transmute-fail.rs:104:9
| |
LL | std::mem::transmute(v) LL | std::mem::transmute(v)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
| |
= note: source type: `[[u32; 2 * H]; W + W]` (size can vary because of [u32; 2 * H]) = note: source type: `[[u32; 2 * H]; W + W]` (size can vary because of [u32; 2 * H])
= note: target type: `[[u32; W + W]; 2 * H]` (size can vary because of [u32; W + W]) = note: target type: `[[u32; W + W]; 2 * H]` (size can vary because of [u32; W + W])
error: aborting due to 14 previous errors error[E0308]: mismatched types
--> $DIR/transmute-fail.rs:12:53
|
LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
| ^ expected `usize`, found `bool`
For more information about this error, try `rustc --explain E0512`. error[E0308]: mismatched types
--> $DIR/transmute-fail.rs:12:67
|
LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] {
| ^ expected `usize`, found `bool`
error: aborting due to 16 previous errors
Some errors have detailed explanations: E0308, E0512.
For more information about an error, try `rustc --explain E0308`.

View file

@ -1,10 +1,12 @@
fn foo<const N: usize>() -> [u8; N] { fn foo<const N: usize>() -> [u8; N] {
bar::<N>() bar::<N>()
//~^ ERROR the constant `N` is not of type `u8` //~^ ERROR the constant `N` is not of type `u8`
//~| ERROR: mismatched types
} }
fn bar<const N: u8>() -> [u8; N] {} fn bar<const N: u8>() -> [u8; N] {}
//~^ ERROR the constant `N` is not of type `usize` //~^ ERROR the constant `N` is not of type `usize`
//~| ERROR: mismatched types
//~| ERROR mismatched types //~| ERROR mismatched types
fn main() {} fn main() {}

View file

@ -1,5 +1,5 @@
error: the constant `N` is not of type `usize` error: the constant `N` is not of type `usize`
--> $DIR/type_mismatch.rs:6:26 --> $DIR/type_mismatch.rs:7:26
| |
LL | fn bar<const N: u8>() -> [u8; N] {} LL | fn bar<const N: u8>() -> [u8; N] {}
| ^^^^^^^ expected `usize`, found `u8` | ^^^^^^^ expected `usize`, found `u8`
@ -11,19 +11,31 @@ LL | bar::<N>()
| ^ expected `u8`, found `usize` | ^ expected `u8`, found `usize`
| |
note: required by a const generic parameter in `bar` note: required by a const generic parameter in `bar`
--> $DIR/type_mismatch.rs:6:8 --> $DIR/type_mismatch.rs:7:8
| |
LL | fn bar<const N: u8>() -> [u8; N] {} LL | fn bar<const N: u8>() -> [u8; N] {}
| ^^^^^^^^^^^ required by this const generic parameter in `bar` | ^^^^^^^^^^^ required by this const generic parameter in `bar`
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/type_mismatch.rs:6:26 --> $DIR/type_mismatch.rs:7:26
| |
LL | fn bar<const N: u8>() -> [u8; N] {} LL | fn bar<const N: u8>() -> [u8; N] {}
| --- ^^^^^^^ expected `[u8; N]`, found `()` | --- ^^^^^^^ expected `[u8; N]`, found `()`
| | | |
| implicitly returns `()` as its body has no tail or `return` expression | implicitly returns `()` as its body has no tail or `return` expression
error: aborting due to 3 previous errors error[E0308]: mismatched types
--> $DIR/type_mismatch.rs:2:11
|
LL | bar::<N>()
| ^ expected `u8`, found `usize`
error[E0308]: mismatched types
--> $DIR/type_mismatch.rs:7:31
|
LL | fn bar<const N: u8>() -> [u8; N] {}
| ^ expected `usize`, found `u8`
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0308`. For more information about this error, try `rustc --explain E0308`.

View file

@ -1,6 +1,5 @@
//! Ensure we catch UB due to writing through a shared reference. //! Ensure we catch UB due to writing through a shared reference.
#![feature(const_mut_refs, const_refs_to_cell)] #![feature(const_mut_refs, const_refs_to_cell)]
#![deny(writes_through_immutable_pointer)]
#![allow(invalid_reference_casting)] #![allow(invalid_reference_casting)]
use std::mem; use std::mem;
@ -9,15 +8,15 @@ use std::cell::UnsafeCell;
const WRITE_AFTER_CAST: () = unsafe { const WRITE_AFTER_CAST: () = unsafe {
let mut x = 0; let mut x = 0;
let ptr = &x as *const i32 as *mut i32; let ptr = &x as *const i32 as *mut i32;
*ptr = 0; //~ERROR: writes_through_immutable_pointer *ptr = 0; //~ERROR: evaluation of constant value failed
//~^ previously accepted //~| immutable
}; };
const WRITE_AFTER_TRANSMUTE: () = unsafe { const WRITE_AFTER_TRANSMUTE: () = unsafe {
let mut x = 0; let mut x = 0;
let ptr: *mut i32 = mem::transmute(&x); let ptr: *mut i32 = mem::transmute(&x);
*ptr = 0; //~ERROR: writes_through_immutable_pointer *ptr = 0; //~ERROR: evaluation of constant value failed
//~^ previously accepted //~| immutable
}; };
// it's okay when there is interior mutability; // it's okay when there is interior mutability;

Some files were not shown because too many files have changed in this diff Show more