Auto merge of #69325 - Centril:rollup-vce2ko2, r=Centril

Rollup of 5 pull requests

Successful merges:

 - #68877 (On mismatched argument count point at arguments)
 - #69185 (Unify and improve const-prop lints)
 - #69305 (Tweak binding lifetime suggestion text)
 - #69311 (Clean up E0321 and E0322)
 - #69317 (Fix broken link to the rustc guide)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-02-20 19:19:54 +00:00
commit 2c462a2f77
132 changed files with 1904 additions and 1278 deletions

View File

@ -1,5 +1,7 @@
A cross-crate opt-out trait was implemented on something which wasn't a struct
or enum type. Erroneous code example:
or enum type.
Erroneous code example:
```compile_fail,E0321
#![feature(optin_builtin_traits)]

View File

@ -1,3 +1,13 @@
The `Sized` trait was implemented explicitly.
Erroneous code example:
```compile_fail,E0322
struct Foo;
impl Sized for Foo {} // error!
```
The `Sized` trait is a special trait built-in to the compiler for types with a
constant size known at compile-time. This trait is automatically implemented
for types as needed by the compiler, and it is currently disallowed to

View File

@ -1781,14 +1781,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
bound_kind: GenericKind<'tcx>,
sub: S,
) {
let consider = format!(
"consider adding an explicit lifetime bound {}",
if type_param_span.map(|(_, _, is_impl_trait)| is_impl_trait).unwrap_or(false) {
format!(" `{}` to `{}`...", sub, bound_kind)
} else {
format!("`{}: {}`...", bound_kind, sub)
},
);
let msg = "consider adding an explicit lifetime bound";
if let Some((sp, has_lifetimes, is_impl_trait)) = type_param_span {
let suggestion = if is_impl_trait {
format!("{} + {}", bound_kind, sub)
@ -1796,13 +1789,22 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
let tail = if has_lifetimes { " + " } else { "" };
format!("{}: {}{}", bound_kind, sub, tail)
};
err.span_suggestion_short(
err.span_suggestion(
sp,
&consider,
&format!("{}...", msg),
suggestion,
Applicability::MaybeIncorrect, // Issue #41966
);
} else {
let consider = format!(
"{} {}...",
msg,
if type_param_span.map(|(_, _, is_impl_trait)| is_impl_trait).unwrap_or(false) {
format!(" `{}` to `{}`", sub, bound_kind)
} else {
format!("`{}: {}`", bound_kind, sub)
},
);
err.help(&consider);
}
}

View File

@ -305,6 +305,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
store.register_renamed("unstable_name_collision", "unstable_name_collisions");
store.register_renamed("unused_doc_comment", "unused_doc_comments");
store.register_renamed("async_idents", "keyword_idents");
store.register_renamed("exceeding_bitshifts", "arithmetic_overflow");
store.register_removed("unknown_features", "replaced by an error");
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
store.register_removed("negate_unsigned", "cast a signed value instead");

View File

@ -4,7 +4,8 @@
use std::borrow::Cow;
use std::cell::Cell;
use rustc::mir::interpret::{InterpError, InterpResult, Scalar};
use rustc::lint;
use rustc::mir::interpret::{InterpResult, Scalar};
use rustc::mir::visit::{
MutVisitor, MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor,
};
@ -292,7 +293,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine {
struct ConstPropagator<'mir, 'tcx> {
ecx: InterpCx<'mir, 'tcx, ConstPropMachine>,
tcx: TyCtxt<'tcx>,
source: MirSource<'tcx>,
can_const_prop: IndexVec<Local, ConstPropMode>,
param_env: ParamEnv<'tcx>,
// FIXME(eddyb) avoid cloning these two fields more than once,
@ -372,7 +372,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
ConstPropagator {
ecx,
tcx,
source,
param_env,
can_const_prop,
// FIXME(eddyb) avoid cloning these two fields more than once,
@ -501,19 +500,20 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
}
}
fn report_panic_as_lint(&self, source_info: SourceInfo, panic: AssertKind<u64>) -> Option<()> {
// Somewhat convoluted way to re-use the CTFE error reporting code.
fn report_assert_as_lint(
&self,
lint: &'static lint::Lint,
source_info: SourceInfo,
message: &'static str,
panic: AssertKind<u64>,
) -> Option<()> {
let lint_root = self.lint_root(source_info)?;
let error = InterpError::MachineStop(Box::new(format!("{:?}", panic)));
let mut diagnostic = error_to_const_error(&self.ecx, error.into());
diagnostic.span = source_info.span; // fix the span
diagnostic.report_as_lint(
self.tcx.at(source_info.span),
"this expression will panic at runtime",
lint_root,
None,
);
None
self.tcx.struct_span_lint_hir(lint, lint_root, source_info.span, |lint| {
let mut err = lint.build(message);
err.span_label(source_info.span, format!("{:?}", panic));
err.emit()
});
return None;
}
fn check_unary_op(
@ -530,7 +530,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
// `AssertKind` only has an `OverflowNeg` variant, so make sure that is
// appropriate to use.
assert_eq!(op, UnOp::Neg, "Neg is the only UnOp that can overflow");
self.report_panic_as_lint(source_info, AssertKind::OverflowNeg)?;
self.report_assert_as_lint(
lint::builtin::ARITHMETIC_OVERFLOW,
source_info,
"this arithmetic operation will overflow",
AssertKind::OverflowNeg,
)?;
}
Some(())
@ -542,27 +547,24 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
left: &Operand<'tcx>,
right: &Operand<'tcx>,
source_info: SourceInfo,
place_layout: TyLayout<'tcx>,
) -> Option<()> {
let r =
self.use_ecx(|this| this.ecx.read_immediate(this.ecx.eval_operand(right, None)?))?;
// Check for exceeding shifts *even if* we cannot evaluate the LHS.
if op == BinOp::Shr || op == BinOp::Shl {
let left_bits = place_layout.size.bits();
// We need the type of the LHS. We cannot use `place_layout` as that is the type
// of the result, which for checked binops is not the same!
let left_ty = left.ty(&self.local_decls, self.tcx);
let left_size_bits = self.ecx.layout_of(left_ty).ok()?.size.bits();
let right_size = r.layout.size;
let r_bits = r.to_scalar().and_then(|r| r.to_bits(right_size));
if r_bits.map_or(false, |b| b >= left_bits as u128) {
let lint_root = self.lint_root(source_info)?;
self.tcx.struct_span_lint_hir(
::rustc::lint::builtin::EXCEEDING_BITSHIFTS,
lint_root,
source_info.span,
|lint| {
let dir = if op == BinOp::Shr { "right" } else { "left" };
lint.build(&format!("attempt to shift {} with overflow", dir)).emit()
},
);
return None;
if r_bits.map_or(false, |b| b >= left_size_bits as u128) {
self.report_assert_as_lint(
lint::builtin::ARITHMETIC_OVERFLOW,
source_info,
"this arithmetic operation will overflow",
AssertKind::Overflow(op),
)?;
}
}
@ -572,7 +574,12 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
let (_res, overflow, _ty) = this.ecx.overflowing_binary_op(op, l, r)?;
Ok(overflow)
})? {
self.report_panic_as_lint(source_info, AssertKind::Overflow(op))?;
self.report_assert_as_lint(
lint::builtin::ARITHMETIC_OVERFLOW,
source_info,
"this arithmetic operation will overflow",
AssertKind::Overflow(op),
)?;
}
Some(())
@ -595,8 +602,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
return None;
}
let overflow_check = self.tcx.sess.overflow_checks();
// Perform any special handling for specific Rvalue types.
// Generally, checks here fall into one of two categories:
// 1. Additional checking to provide useful lints to the user
@ -606,20 +611,25 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
// - In this case, we'll return `None` from this function to stop evaluation.
match rvalue {
// Additional checking: give lints to the user if an overflow would occur.
// If `overflow_check` is set, running const-prop on the `Assert` terminators
// will already generate the appropriate messages.
Rvalue::UnaryOp(op, arg) if !overflow_check => {
// We do this here and not in the `Assert` terminator as that terminator is
// only sometimes emitted (overflow checks can be disabled), but we want to always
// lint.
Rvalue::UnaryOp(op, arg) => {
trace!("checking UnaryOp(op = {:?}, arg = {:?})", op, arg);
self.check_unary_op(*op, arg, source_info)?;
}
// Additional checking: check for overflows on integer binary operations and report
// them to the user as lints.
// If `overflow_check` is set, running const-prop on the `Assert` terminators
// will already generate the appropriate messages.
Rvalue::BinaryOp(op, left, right) if !overflow_check => {
Rvalue::BinaryOp(op, left, right) => {
trace!("checking BinaryOp(op = {:?}, left = {:?}, right = {:?})", op, left, right);
self.check_binary_op(*op, left, right, source_info, place_layout)?;
self.check_binary_op(*op, left, right, source_info)?;
}
Rvalue::CheckedBinaryOp(op, left, right) => {
trace!(
"checking CheckedBinaryOp(op = {:?}, left = {:?}, right = {:?})",
op,
left,
right
);
self.check_binary_op(*op, left, right, source_info)?;
}
// Do not try creating references (#67862)
@ -898,54 +908,39 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
}
Operand::Constant(_) => {}
}
let span = terminator.source_info.span;
let hir_id = self
.tcx
.hir()
.as_local_hir_id(self.source.def_id())
.expect("some part of a failing const eval must be local");
self.tcx.struct_span_lint_hir(
::rustc::lint::builtin::CONST_ERR,
hir_id,
span,
|lint| {
let msg = match msg {
AssertKind::Overflow(_)
| AssertKind::OverflowNeg
| AssertKind::DivisionByZero
| AssertKind::RemainderByZero => msg.description().to_owned(),
AssertKind::BoundsCheck { ref len, ref index } => {
let len = self
.eval_operand(len, source_info)
.expect("len must be const");
let len = match self.ecx.read_scalar(len) {
Ok(ScalarMaybeUndef::Scalar(Scalar::Raw {
data,
..
})) => data,
other => bug!("const len not primitive: {:?}", other),
};
let index = self
.eval_operand(index, source_info)
.expect("index must be const");
let index = match self.ecx.read_scalar(index) {
Ok(ScalarMaybeUndef::Scalar(Scalar::Raw {
data,
..
})) => data,
other => bug!("const index not primitive: {:?}", other),
};
format!(
"index out of bounds: \
the len is {} but the index is {}",
len, index,
)
}
// Need proper const propagator for these
_ => return,
};
lint.build(&msg).emit()
},
let msg = match msg {
AssertKind::DivisionByZero => AssertKind::DivisionByZero,
AssertKind::RemainderByZero => AssertKind::RemainderByZero,
AssertKind::BoundsCheck { ref len, ref index } => {
let len =
self.eval_operand(len, source_info).expect("len must be const");
let len = self
.ecx
.read_scalar(len)
.unwrap()
.to_machine_usize(&self.tcx)
.unwrap();
let index = self
.eval_operand(index, source_info)
.expect("index must be const");
let index = self
.ecx
.read_scalar(index)
.unwrap()
.to_machine_usize(&self.tcx)
.unwrap();
AssertKind::BoundsCheck { len, index }
}
// Overflow is are already covered by checks on the binary operators.
AssertKind::Overflow(_) | AssertKind::OverflowNeg => return,
// Need proper const propagator for these.
_ => return,
};
self.report_assert_as_lint(
lint::builtin::UNCONDITIONAL_PANIC,
source_info,
"this operation will panic at runtime",
msg,
);
} else {
if self.should_const_prop(value) {

View File

@ -4,7 +4,7 @@
//! For more information about how MIR-based region-checking works,
//! see the [rustc guide].
//!
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/mir/borrowck.html
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/borrow_check.html
use rustc::hir::map::Map;
use rustc::middle::region::*;

View File

@ -41,9 +41,15 @@ declare_lint! {
}
declare_lint! {
pub EXCEEDING_BITSHIFTS,
pub ARITHMETIC_OVERFLOW,
Deny,
"shift exceeds the type's number of bits"
"arithmetic operation overflows"
}
declare_lint! {
pub UNCONDITIONAL_PANIC,
Deny,
"operation will cause a panic at runtime"
}
declare_lint! {
@ -495,7 +501,8 @@ declare_lint_pass! {
/// that are used by other parts of the compiler.
HardwiredLints => [
ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
EXCEEDING_BITSHIFTS,
ARITHMETIC_OVERFLOW,
UNCONDITIONAL_PANIC,
UNUSED_IMPORTS,
UNUSED_EXTERN_CRATES,
UNUSED_QUALIFICATIONS,

View File

@ -3843,17 +3843,58 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
error_code: &str,
c_variadic: bool,
sugg_unit: bool| {
let (span, start_span, args) = match &expr.kind {
hir::ExprKind::Call(hir::Expr { span, .. }, args) => (*span, *span, &args[..]),
hir::ExprKind::MethodCall(path_segment, span, args) => (
*span,
// `sp` doesn't point at the whole `foo.bar()`, only at `bar`.
path_segment
.args
.and_then(|args| args.args.iter().last())
// Account for `foo.bar::<T>()`.
.map(|arg| {
// Skip the closing `>`.
tcx.sess
.source_map()
.next_point(tcx.sess.source_map().next_point(arg.span()))
})
.unwrap_or(*span),
&args[1..], // Skip the receiver.
),
k => span_bug!(sp, "checking argument types on a non-call: `{:?}`", k),
};
let arg_spans = if args.is_empty() {
// foo()
// ^^^-- supplied 0 arguments
// |
// expected 2 arguments
vec![tcx.sess.source_map().next_point(start_span).with_hi(sp.hi())]
} else {
// foo(1, 2, 3)
// ^^^ - - - supplied 3 arguments
// |
// expected 2 arguments
args.iter().map(|arg| arg.span).collect::<Vec<Span>>()
};
let mut err = tcx.sess.struct_span_err_with_code(
sp,
span,
&format!(
"this function takes {}{} but {} {} supplied",
if c_variadic { "at least " } else { "" },
potentially_plural_count(expected_count, "parameter"),
potentially_plural_count(arg_count, "parameter"),
potentially_plural_count(expected_count, "argument"),
potentially_plural_count(arg_count, "argument"),
if arg_count == 1 { "was" } else { "were" }
),
DiagnosticId::Error(error_code.to_owned()),
);
let label = format!("supplied {}", potentially_plural_count(arg_count, "argument"));
for (i, span) in arg_spans.into_iter().enumerate() {
err.span_label(
span,
if arg_count == 0 || i + 1 == arg_count { &label } else { "" },
);
}
if let Some(def_s) = def_span.map(|sp| tcx.sess.source_map().def_span(sp)) {
err.span_label(def_s, "defined here");
@ -3870,11 +3911,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
);
} else {
err.span_label(
sp,
span,
format!(
"expected {}{}",
if c_variadic { "at least " } else { "" },
potentially_plural_count(expected_count, "parameter")
potentially_plural_count(expected_count, "argument")
),
);
}
@ -5622,8 +5663,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx.sess.span_err(
span,
"this function can only be invoked \
directly, not through a function pointer",
"this function can only be invoked directly, not through a function pointer",
);
}

View File

@ -23,7 +23,7 @@ pub fn test1(s: &mut S) {
// CHECK-LABEL: @test2
// CHECK: store i32 4, i32* %{{.+}}, align 4
#[allow(const_err)]
#[allow(unconditional_panic)]
#[no_mangle]
pub fn test2(s: &mut S) {
s.arr[usize::MAX / 4 + 1] = 4;

View File

@ -1,20 +0,0 @@
#![feature(rustc_attrs)]
#![deny(const_err)]
fn black_box<T>(_: T) {
unimplemented!()
}
fn main() {
let b = 200u8 + 200u8 + 200u8;
//~^ ERROR const_err
let c = 200u8 * 4;
//~^ ERROR const_err
let d = 42u8 - (42u8 + 1);
//~^ ERROR const_err
let _e = [5u8][1];
//~^ ERROR const_err
black_box(b);
black_box(c);
black_box(d);
}

View File

@ -2,8 +2,8 @@
// compile-flags: -Coverflow-checks=on
// build-pass (FIXME(62277): could be check-pass?)
#![warn(const_err)]
#![warn(arithmetic_overflow)]
fn main() {
let _ = 255u8 + 1; //~ WARNING attempt to add with overflow
let _ = 255u8 + 1; //~ WARNING operation will overflow
}

View File

@ -2,7 +2,7 @@
const C: [u32; 5] = [0; 5];
#[allow(const_err)]
#[allow(unconditional_panic)]
fn test() -> u32 {
C[10]
}

View File

@ -2,7 +2,7 @@
const C: &'static [u8; 5] = b"hello";
#[allow(const_err)]
#[allow(unconditional_panic)]
fn test() -> u8 {
C[10]
}

View File

@ -2,7 +2,7 @@
const C: &'static [u8; 5] = b"hello";
#[allow(const_err)]
#[allow(unconditional_panic)]
fn mir() -> u8 {
C[10]
}

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to add with overflow'
// compile-flags: -C debug-assertions
#![allow(const_err)]
#![allow(arithmetic_overflow)]
fn main() {
let _x = 200u8 + 200u8 + 200u8;

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow'
// compile-flags: -C debug-assertions
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
fn main() {

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow'
// compile-flags: -C debug-assertions
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
fn main() {

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to shift left with overflow'
// compile-flags: -C debug-assertions
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
fn main() {

View File

@ -4,7 +4,7 @@
// This function is checking that our automatic truncation does not
// sidestep the overflow checking.
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
fn main() {

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to multiply with overflow'
// compile-flags: -C debug-assertions
#![allow(const_err)]
#![allow(arithmetic_overflow)]
fn main() {
let x = 200u8 * 4;

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to negate with overflow'
// compile-flags: -C debug-assertions
#![allow(const_err)]
#![allow(arithmetic_overflow)]
fn main() {
let _x = -std::i8::MIN;

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
// compile-flags: -C debug-assertions
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
fn main() {

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
// compile-flags: -C debug-assertions
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
fn main() {

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
// compile-flags: -C debug-assertions
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
fn main() {

View File

@ -4,7 +4,7 @@
// This function is checking that our (type-based) automatic
// truncation does not sidestep the overflow checking.
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
fn main() {

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
// compile-flags: -C debug-assertions
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
fn main() {

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to shift right with overflow'
// compile-flags: -C debug-assertions
#![warn(exceeding_bitshifts)]
#![warn(arithmetic_overflow)]
#![warn(const_err)]
#![feature(const_indexing)]

View File

@ -1,7 +1,7 @@
// error-pattern:thread 'main' panicked at 'attempt to subtract with overflow'
// compile-flags: -C debug-assertions
#![allow(const_err)]
#![allow(arithmetic_overflow)]
fn main() {
let _x = 42u8 - (42u8 + 1);

View File

@ -1,4 +1,4 @@
#![allow(const_err)]
#![allow(unconditional_panic, const_err)]
// error-pattern: attempt to divide by zero

View File

@ -1,4 +1,4 @@
#![allow(const_err)]
#![allow(arithmetic_overflow)]
// error-pattern: overflow
// compile-flags: -C overflow-checks=yes

View File

@ -1,4 +1,4 @@
// error-pattern: parameters were supplied
// error-pattern: arguments were supplied
fn f(x: isize) { }

View File

@ -1,11 +1,13 @@
error[E0061]: this function takes 1 parameter but 0 parameters were supplied
error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/arg-count-mismatch.rs:5:28
|
LL | fn f(x: isize) { }
| -------------- defined here
LL |
LL | fn main() { let i: (); i = f(); }
| ^^^ expected 1 parameter
| ^-- supplied 0 arguments
| |
| expected 1 argument
error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error[E0310]: the parameter type `T` may not live long enough
LL | impl <T: Sync> Foo for T { }
| -- ^^^
| |
| help: consider adding an explicit lifetime bound `T: 'static`...
| help: consider adding an explicit lifetime bound...: `T: 'static +`
|
note: ...so that the type `T` will meet its required lifetime bounds
--> $DIR/builtin-superkinds-self-type.rs:10:16

View File

@ -13,8 +13,8 @@ extern "C" fn bar(f: isize, x: u8) {}
fn main() {
unsafe {
foo(); //~ ERROR this function takes at least 2 parameters but 0 parameters were supplied
foo(1); //~ ERROR this function takes at least 2 parameters but 1 parameter was supplied
foo(); //~ ERROR this function takes at least 2 arguments but 0 arguments were supplied
foo(1); //~ ERROR this function takes at least 2 arguments but 1 argument was supplied
let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~ ERROR mismatched types
let y: extern "C" fn(f: isize, x: u8, ...) = bar; //~ ERROR mismatched types

View File

@ -4,23 +4,27 @@ error[E0045]: C-variadic function must have C or cdecl calling convention
LL | fn printf(_: *const u8, ...);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention
error[E0060]: this function takes at least 2 parameters but 0 parameters were supplied
error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied
--> $DIR/variadic-ffi-1.rs:16:9
|
LL | fn foo(f: isize, x: u8, ...);
| ----------------------------- defined here
...
LL | foo();
| ^^^^^ expected at least 2 parameters
| ^^^-- supplied 0 arguments
| |
| expected at least 2 arguments
error[E0060]: this function takes at least 2 parameters but 1 parameter was supplied
error[E0060]: this function takes at least 2 arguments but 1 argument was supplied
--> $DIR/variadic-ffi-1.rs:17:9
|
LL | fn foo(f: isize, x: u8, ...);
| ----------------------------- defined here
...
LL | foo(1);
| ^^^^^^ expected at least 2 parameters
| ^^^ - supplied 1 argument
| |
| expected at least 2 arguments
error[E0308]: mismatched types
--> $DIR/variadic-ffi-1.rs:19:56

View File

@ -1,11 +1,11 @@
// build-pass
// ignore-pass (emit codegen-time warnings and verify that they are indeed warnings and not errors)
#![warn(const_err)]
#![warn(const_err, unconditional_panic)]
fn main() {
&{ [1, 2, 3][4] };
//~^ WARN index out of bounds
//~^ WARN operation will panic
//~| WARN reaching this expression at runtime will panic or abort
//~| WARN erroneous constant used [const_err]
}

View File

@ -1,14 +1,14 @@
warning: index out of bounds: the len is 3 but the index is 4
warning: this operation will panic at runtime
--> $DIR/array-literal-index-oob.rs:7:8
|
LL | &{ [1, 2, 3][4] };
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ index out of bounds: the len is 3 but the index is 4
|
note: the lint level is defined here
--> $DIR/array-literal-index-oob.rs:4:9
--> $DIR/array-literal-index-oob.rs:4:20
|
LL | #![warn(const_err)]
| ^^^^^^^^^
LL | #![warn(const_err, unconditional_panic)]
| ^^^^^^^^^^^^^^^^^^^
warning: reaching this expression at runtime will panic or abort
--> $DIR/array-literal-index-oob.rs:7:8
@ -17,6 +17,12 @@ LL | &{ [1, 2, 3][4] };
| ---^^^^^^^^^^^^--
| |
| indexing out of bounds: the len is 3 but the index is 4
|
note: the lint level is defined here
--> $DIR/array-literal-index-oob.rs:4:9
|
LL | #![warn(const_err, unconditional_panic)]
| ^^^^^^^^^
warning: erroneous constant used
--> $DIR/array-literal-index-oob.rs:7:5

View File

@ -1,7 +1,7 @@
// build-fail
// compile-flags: -Zforce-overflow-checks=on
#![allow(exceeding_bitshifts)]
#![allow(arithmetic_overflow)]
#![warn(const_err)]
fn black_box<T>(_: T) {

View File

@ -1,50 +1,48 @@
error: this expression will panic at runtime
--> $DIR/const-err2.rs:18:13
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:19:13
|
LL | let a = -std::i8::MIN;
| ^^^^^^^^^^^^^ attempt to negate with overflow
|
note: the lint level is defined here
--> $DIR/const-err2.rs:11:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
= note: `#[deny(arithmetic_overflow)]` on by default
error: this expression will panic at runtime
--> $DIR/const-err2.rs:20:18
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:21:18
|
LL | let a_i128 = -std::i128::MIN;
| ^^^^^^^^^^^^^^^ attempt to negate with overflow
error: this expression will panic at runtime
--> $DIR/const-err2.rs:22:13
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:23:13
|
LL | let b = 200u8 + 200u8 + 200u8;
| ^^^^^^^^^^^^^ attempt to add with overflow
error: this expression will panic at runtime
--> $DIR/const-err2.rs:24:18
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:25:18
|
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
error: this expression will panic at runtime
--> $DIR/const-err2.rs:26:13
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:27:13
|
LL | let c = 200u8 * 4;
| ^^^^^^^^^ attempt to multiply with overflow
error: this expression will panic at runtime
--> $DIR/const-err2.rs:28:13
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:29:13
|
LL | let d = 42u8 - (42u8 + 1);
| ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
error: index out of bounds: the len is 1 but the index is 1
--> $DIR/const-err2.rs:30:14
error: this operation will panic at runtime
--> $DIR/const-err2.rs:31:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
= note: `#[deny(unconditional_panic)]` on by default
error: aborting due to 7 previous errors

View File

@ -0,0 +1,48 @@
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:19:13
|
LL | let a = -std::i8::MIN;
| ^^^^^^^^^^^^^ attempt to negate with overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:21:18
|
LL | let a_i128 = -std::i128::MIN;
| ^^^^^^^^^^^^^^^ attempt to negate with overflow
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:23:13
|
LL | let b = 200u8 + 200u8 + 200u8;
| ^^^^^^^^^^^^^ attempt to add with overflow
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:25:18
|
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:27:13
|
LL | let c = 200u8 * 4;
| ^^^^^^^^^ attempt to multiply with overflow
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:29:13
|
LL | let d = 42u8 - (42u8 + 1);
| ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
error: this operation will panic at runtime
--> $DIR/const-err2.rs:31:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
= note: `#[deny(unconditional_panic)]` on by default
error: aborting due to 7 previous errors

View File

@ -0,0 +1,48 @@
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:19:13
|
LL | let a = -std::i8::MIN;
| ^^^^^^^^^^^^^ attempt to negate with overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:21:18
|
LL | let a_i128 = -std::i128::MIN;
| ^^^^^^^^^^^^^^^ attempt to negate with overflow
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:23:13
|
LL | let b = 200u8 + 200u8 + 200u8;
| ^^^^^^^^^^^^^ attempt to add with overflow
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:25:18
|
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:27:13
|
LL | let c = 200u8 * 4;
| ^^^^^^^^^ attempt to multiply with overflow
error: this arithmetic operation will overflow
--> $DIR/const-err2.rs:29:13
|
LL | let d = 42u8 - (42u8 + 1);
| ^^^^^^^^^^^^^^^^^ attempt to subtract with overflow
error: this operation will panic at runtime
--> $DIR/const-err2.rs:31:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
= note: `#[deny(unconditional_panic)]` on by default
error: aborting due to 7 previous errors

View File

@ -2,13 +2,14 @@
// optimized compilation and unoptimized compilation and thus would
// lead to different lints being emitted
// revisions: noopt opt opt_with_overflow_checks
//[noopt]compile-flags: -C opt-level=0
//[opt]compile-flags: -O
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
// build-fail
// compile-flags: -O
#![feature(rustc_attrs)]
#![allow(exceeding_bitshifts)]
#![deny(const_err)]
fn black_box<T>(_: T) {
unimplemented!()
@ -16,19 +17,19 @@ fn black_box<T>(_: T) {
fn main() {
let a = -std::i8::MIN;
//~^ ERROR const_err
//~^ ERROR arithmetic operation will overflow
let a_i128 = -std::i128::MIN;
//~^ ERROR const_err
//~^ ERROR arithmetic operation will overflow
let b = 200u8 + 200u8 + 200u8;
//~^ ERROR const_err
//~^ ERROR arithmetic operation will overflow
let b_i128 = std::i128::MIN - std::i128::MAX;
//~^ ERROR const_err
//~^ ERROR arithmetic operation will overflow
let c = 200u8 * 4;
//~^ ERROR const_err
//~^ ERROR arithmetic operation will overflow
let d = 42u8 - (42u8 + 1);
//~^ ERROR const_err
//~^ ERROR arithmetic operation will overflow
let _e = [5u8][1];
//~^ ERROR const_err
//~^ ERROR operation will panic
black_box(a);
black_box(a_i128);
black_box(b);

View File

@ -1,38 +0,0 @@
// needed because negating int::MIN will behave differently between
// optimized compilation and unoptimized compilation and thus would
// lead to different lints being emitted
// build-fail
// compile-flags: -C overflow-checks=on -O
#![feature(rustc_attrs)]
#![allow(exceeding_bitshifts)]
#![deny(const_err)]
fn black_box<T>(_: T) {
unimplemented!()
}
fn main() {
let a = -std::i8::MIN;
//~^ ERROR const_err
let a_i128 = -std::i128::MIN;
//~^ ERROR const_err
let b = 200u8 + 200u8 + 200u8;
//~^ ERROR const_err
let b_i128 = std::i128::MIN - std::i128::MAX;
//~^ ERROR const_err
let c = 200u8 * 4;
//~^ ERROR const_err
let d = 42u8 - (42u8 + 1);
//~^ ERROR const_err
let _e = [5u8][1];
//~^ ERROR const_err
black_box(a);
black_box(a_i128);
black_box(b);
black_box(b_i128);
black_box(c);
black_box(d);
}

View File

@ -1,50 +0,0 @@
error: attempt to negate with overflow
--> $DIR/const-err3.rs:18:13
|
LL | let a = -std::i8::MIN;
| ^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/const-err3.rs:11:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
error: attempt to negate with overflow
--> $DIR/const-err3.rs:20:18
|
LL | let a_i128 = -std::i128::MIN;
| ^^^^^^^^^^^^^^^
error: attempt to add with overflow
--> $DIR/const-err3.rs:22:13
|
LL | let b = 200u8 + 200u8 + 200u8;
| ^^^^^^^^^^^^^
error: attempt to subtract with overflow
--> $DIR/const-err3.rs:24:18
|
LL | let b_i128 = std::i128::MIN - std::i128::MAX;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: attempt to multiply with overflow
--> $DIR/const-err3.rs:26:13
|
LL | let c = 200u8 * 4;
| ^^^^^^^^^
error: attempt to subtract with overflow
--> $DIR/const-err3.rs:28:13
|
LL | let d = 42u8 - (42u8 + 1);
| ^^^^^^^^^^^^^^^^^
error: index out of bounds: the len is 1 but the index is 1
--> $DIR/const-err3.rs:30:14
|
LL | let _e = [5u8][1];
| ^^^^^^^^
error: aborting due to 7 previous errors

View File

@ -2,5 +2,5 @@
fn main() {
let array = [std::env::args().len()];
array[1]; //~ ERROR index out of bounds
array[1]; //~ ERROR operation will panic
}

View File

@ -1,10 +1,10 @@
error: index out of bounds: the len is 1 but the index is 1
error: this operation will panic at runtime
--> $DIR/index_out_of_bounds_propagated.rs:5:5
|
LL | array[1];
| ^^^^^^^^
| ^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
= note: `#[deny(const_err)]` on by default
= note: `#[deny(unconditional_panic)]` on by default
error: aborting due to previous error

View File

@ -0,0 +1,78 @@
warning: this arithmetic operation will overflow
--> $DIR/promoted_errors.rs:12:20
|
LL | println!("{}", 0u32 - 1);
| ^^^^^^^^ attempt to subtract with overflow
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:9:20
|
LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)]
| ^^^^^^^^^^^^^^^^^^^
warning: this arithmetic operation will overflow
--> $DIR/promoted_errors.rs:14:14
|
LL | let _x = 0u32 - 1;
| ^^^^^^^^ attempt to subtract with overflow
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:16:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ attempt to divide by zero
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:9:41
|
LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)]
| ^^^^^^^^^^^^^^^^^^^
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors.rs:16:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ dividing by zero
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:9:9
|
LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)]
| ^^^^^^^^^
warning: erroneous constant used
--> $DIR/promoted_errors.rs:16:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ referenced constant has errors
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:20:14
|
LL | let _x = 1 / (1 - 1);
| ^^^^^^^^^^^ attempt to divide by zero
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:22:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ attempt to divide by zero
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors.rs:22:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ dividing by zero
warning: erroneous constant used
--> $DIR/promoted_errors.rs:22:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:26:14
|
LL | let _x = 1 / (false as u32);
| ^^^^^^^^^^^^^^^^^^ attempt to divide by zero

View File

@ -0,0 +1,72 @@
warning: this arithmetic operation will overflow
--> $DIR/promoted_errors.rs:14:14
|
LL | let _x = 0u32 - 1;
| ^^^^^^^^ attempt to subtract with overflow
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:9:20
|
LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)]
| ^^^^^^^^^^^^^^^^^^^
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:16:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ attempt to divide by zero
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:9:41
|
LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)]
| ^^^^^^^^^^^^^^^^^^^
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors.rs:16:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ dividing by zero
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:9:9
|
LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)]
| ^^^^^^^^^
warning: erroneous constant used
--> $DIR/promoted_errors.rs:16:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ referenced constant has errors
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:20:14
|
LL | let _x = 1 / (1 - 1);
| ^^^^^^^^^^^ attempt to divide by zero
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:22:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ attempt to divide by zero
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors.rs:22:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ dividing by zero
warning: erroneous constant used
--> $DIR/promoted_errors.rs:22:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:26:14
|
LL | let _x = 1 / (false as u32);
| ^^^^^^^^^^^^^^^^^^ attempt to divide by zero

View File

@ -0,0 +1,78 @@
warning: this arithmetic operation will overflow
--> $DIR/promoted_errors.rs:12:20
|
LL | println!("{}", 0u32 - 1);
| ^^^^^^^^ attempt to subtract with overflow
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:9:20
|
LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)]
| ^^^^^^^^^^^^^^^^^^^
warning: this arithmetic operation will overflow
--> $DIR/promoted_errors.rs:14:14
|
LL | let _x = 0u32 - 1;
| ^^^^^^^^ attempt to subtract with overflow
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:16:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ attempt to divide by zero
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:9:41
|
LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)]
| ^^^^^^^^^^^^^^^^^^^
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors.rs:16:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ dividing by zero
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:9:9
|
LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)]
| ^^^^^^^^^
warning: erroneous constant used
--> $DIR/promoted_errors.rs:16:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ referenced constant has errors
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:20:14
|
LL | let _x = 1 / (1 - 1);
| ^^^^^^^^^^^ attempt to divide by zero
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:22:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ attempt to divide by zero
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors.rs:22:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ dividing by zero
warning: erroneous constant used
--> $DIR/promoted_errors.rs:22:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
warning: this operation will panic at runtime
--> $DIR/promoted_errors.rs:26:14
|
LL | let _x = 1 / (false as u32);
| ^^^^^^^^^^^^^^^^^^ attempt to divide by zero

View File

@ -1,23 +1,28 @@
// revisions: noopt opt opt_with_overflow_checks
//[noopt]compile-flags: -C opt-level=0
//[opt]compile-flags: -O
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
// build-pass
// ignore-pass (emit codegen-time warnings and verify that they are indeed warnings and not errors)
// compile-flags: -O
#![warn(const_err)]
#![warn(const_err, arithmetic_overflow, unconditional_panic)]
fn main() {
println!("{}", 0u32 - 1);
//[opt_with_overflow_checks,noopt]~^ WARN [arithmetic_overflow]
let _x = 0u32 - 1;
//~^ WARN const_err
//~^ WARN [arithmetic_overflow]
println!("{}", 1 / (1 - 1));
//~^ WARN attempt to divide by zero [const_err]
//~| WARN const_err
//~^ WARN [unconditional_panic]
//~| WARN panic or abort [const_err]
//~| WARN erroneous constant used [const_err]
let _x = 1 / (1 - 1);
//~^ WARN const_err
//~^ WARN [unconditional_panic]
println!("{}", 1 / (false as u32));
//~^ WARN attempt to divide by zero [const_err]
//~| WARN const_err
//~^ WARN [unconditional_panic]
//~| WARN panic or abort [const_err]
//~| WARN erroneous constant used [const_err]
let _x = 1 / (false as u32);
//~^ WARN const_err
//~^ WARN [unconditional_panic]
}

View File

@ -1,60 +0,0 @@
warning: this expression will panic at runtime
--> $DIR/promoted_errors.rs:9:14
|
LL | let _x = 0u32 - 1;
| ^^^^^^^^ attempt to subtract with overflow
|
note: the lint level is defined here
--> $DIR/promoted_errors.rs:5:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^
warning: attempt to divide by zero
--> $DIR/promoted_errors.rs:11:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors.rs:11:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ dividing by zero
warning: erroneous constant used
--> $DIR/promoted_errors.rs:11:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ referenced constant has errors
warning: attempt to divide by zero
--> $DIR/promoted_errors.rs:15:14
|
LL | let _x = 1 / (1 - 1);
| ^^^^^^^^^^^
warning: attempt to divide by zero
--> $DIR/promoted_errors.rs:17:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors.rs:17:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ dividing by zero
warning: erroneous constant used
--> $DIR/promoted_errors.rs:17:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
warning: attempt to divide by zero
--> $DIR/promoted_errors.rs:21:14
|
LL | let _x = 1 / (false as u32);
| ^^^^^^^^^^^^^^^^^^

View File

@ -1,24 +0,0 @@
// build-pass
// ignore-pass (emit codegen-time warnings and verify that they are indeed warnings and not errors)
// compile-flags: -C overflow-checks=on -O
#![warn(const_err)]
fn main() {
println!("{}", 0u32 - 1);
//~^ WARN attempt to subtract with overflow
let _x = 0u32 - 1;
//~^ WARN attempt to subtract with overflow
println!("{}", 1 / (1 - 1));
//~^ WARN attempt to divide by zero [const_err]
//~| WARN const_err
//~| WARN erroneous constant used [const_err]
let _x = 1 / (1 - 1);
//~^ WARN const_err
println!("{}", 1 / (false as u32));
//~^ WARN attempt to divide by zero [const_err]
//~| WARN const_err
//~| WARN erroneous constant used [const_err]
let _x = 1 / (false as u32);
//~^ WARN const_err
}

View File

@ -1,66 +0,0 @@
warning: attempt to subtract with overflow
--> $DIR/promoted_errors2.rs:8:20
|
LL | println!("{}", 0u32 - 1);
| ^^^^^^^^
|
note: the lint level is defined here
--> $DIR/promoted_errors2.rs:5:9
|
LL | #![warn(const_err)]
| ^^^^^^^^^
warning: attempt to subtract with overflow
--> $DIR/promoted_errors2.rs:10:14
|
LL | let _x = 0u32 - 1;
| ^^^^^^^^
warning: attempt to divide by zero
--> $DIR/promoted_errors2.rs:12:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors2.rs:12:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ dividing by zero
warning: erroneous constant used
--> $DIR/promoted_errors2.rs:12:20
|
LL | println!("{}", 1 / (1 - 1));
| ^^^^^^^^^^^ referenced constant has errors
warning: attempt to divide by zero
--> $DIR/promoted_errors2.rs:16:14
|
LL | let _x = 1 / (1 - 1);
| ^^^^^^^^^^^
warning: attempt to divide by zero
--> $DIR/promoted_errors2.rs:18:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^
warning: reaching this expression at runtime will panic or abort
--> $DIR/promoted_errors2.rs:18:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ dividing by zero
warning: erroneous constant used
--> $DIR/promoted_errors2.rs:18:20
|
LL | println!("{}", 1 / (false as u32));
| ^^^^^^^^^^^^^^^^^^ referenced constant has errors
warning: attempt to divide by zero
--> $DIR/promoted_errors2.rs:22:14
|
LL | let _x = 1 / (false as u32);
| ^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,5 @@
// build-fail
fn main() {
[0; 3][3u64 as usize]; //~ ERROR the len is 3 but the index is 3
[0; 3][3u64 as usize]; //~ ERROR this operation will panic at runtime
}

View File

@ -1,10 +1,10 @@
error: index out of bounds: the len is 3 but the index is 3
error: this operation will panic at runtime
--> $DIR/const-prop-ice.rs:4:5
|
LL | [0; 3][3u64 as usize];
| ^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 3 but the index is 3
|
= note: `#[deny(const_err)]` on by default
= note: `#[deny(unconditional_panic)]` on by default
error: aborting due to previous error

View File

@ -3,5 +3,5 @@
fn main() {
enum Enum { One=1 }
let xs=[0;1 as usize];
println!("{}", xs[Enum::One as usize]); //~ ERROR the len is 1 but the index is 1
println!("{}", xs[Enum::One as usize]); //~ ERROR this operation will panic at runtime
}

View File

@ -1,10 +1,10 @@
error: index out of bounds: the len is 1 but the index is 1
error: this operation will panic at runtime
--> $DIR/const-prop-ice2.rs:6:20
|
LL | println!("{}", xs[Enum::One as usize]);
| ^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
= note: `#[deny(const_err)]` on by default
= note: `#[deny(unconditional_panic)]` on by default
error: aborting due to previous error

View File

@ -1,6 +0,0 @@
// compile-flags: -C overflow-checks=on -O
// run-pass
fn main() {
let _ = -(-0.0);
}

View File

@ -1,3 +1,8 @@
// revisions: noopt opt opt_with_overflow_checks
//[noopt]compile-flags: -C opt-level=0
//[opt]compile-flags: -O
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
// run-pass
fn main() {

View File

@ -0,0 +1,30 @@
error: this arithmetic operation will overflow
--> $DIR/issue-69020.rs:21:22
|
LL | const NEG: i32 = -i32::MIN + T::NEG;
| ^^^^^^^^^ attempt to negate with overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: this arithmetic operation will overflow
--> $DIR/issue-69020.rs:23:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| ^^^^^^^^^^^^ attempt to add with overflow
error: this operation will panic at runtime
--> $DIR/issue-69020.rs:25:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| ^^^^^ attempt to divide by zero
|
= note: `#[deny(unconditional_panic)]` on by default
error: this operation will panic at runtime
--> $DIR/issue-69020.rs:27:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| ^^^^^^ index out of bounds: the len is 1 but the index is 1
error: aborting due to 4 previous errors

View File

@ -0,0 +1,30 @@
error: this arithmetic operation will overflow
--> $DIR/issue-69020.rs:21:22
|
LL | const NEG: i32 = -i32::MIN + T::NEG;
| ^^^^^^^^^ attempt to negate with overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: this arithmetic operation will overflow
--> $DIR/issue-69020.rs:23:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| ^^^^^^^^^^^^ attempt to add with overflow
error: this operation will panic at runtime
--> $DIR/issue-69020.rs:25:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| ^^^^^ attempt to divide by zero
|
= note: `#[deny(unconditional_panic)]` on by default
error: this operation will panic at runtime
--> $DIR/issue-69020.rs:27:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| ^^^^^^ index out of bounds: the len is 1 but the index is 1
error: aborting due to 4 previous errors

View File

@ -0,0 +1,30 @@
error: this arithmetic operation will overflow
--> $DIR/issue-69020.rs:21:22
|
LL | const NEG: i32 = -i32::MIN + T::NEG;
| ^^^^^^^^^ attempt to negate with overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: this arithmetic operation will overflow
--> $DIR/issue-69020.rs:23:22
|
LL | const ADD: i32 = (i32::MAX+1) + T::ADD;
| ^^^^^^^^^^^^ attempt to add with overflow
error: this operation will panic at runtime
--> $DIR/issue-69020.rs:25:22
|
LL | const DIV: i32 = (1/0) + T::DIV;
| ^^^^^ attempt to divide by zero
|
= note: `#[deny(unconditional_panic)]` on by default
error: this operation will panic at runtime
--> $DIR/issue-69020.rs:27:22
|
LL | const OOB: i32 = [1][1] + T::OOB;
| ^^^^^^ index out of bounds: the len is 1 but the index is 1
error: aborting due to 4 previous errors

View File

@ -0,0 +1,29 @@
// revisions: noopt opt opt_with_overflow_checks
//[noopt]compile-flags: -C opt-level=0
//[opt]compile-flags: -O
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
#![crate_type="lib"]
use std::i32;
pub trait Foo {
const NEG: i32;
const ADD: i32;
const DIV: i32;
const OOB: i32;
}
// These constants cannot be evaluated already (they depend on `T::N`), so
// they can just be linted like normal run-time code. But codegen works
// a bit different in const context, so this test makes sure that we still catch overflow.
impl<T: Foo> Foo for Vec<T> {
const NEG: i32 = -i32::MIN + T::NEG;
//~^ ERROR arithmetic operation will overflow
const ADD: i32 = (i32::MAX+1) + T::ADD;
//~^ ERROR arithmetic operation will overflow
const DIV: i32 = (1/0) + T::DIV;
//~^ ERROR operation will panic
const OOB: i32 = [1][1] + T::OOB;
//~^ ERROR operation will panic
}

View File

@ -1,14 +1,18 @@
error[E0057]: this function takes 1 parameter but 0 parameters were supplied
error[E0057]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/E0057.rs:3:13
|
LL | let a = f();
| ^^^ expected 1 parameter
| ^-- supplied 0 arguments
| |
| expected 1 argument
error[E0057]: this function takes 1 parameter but 2 parameters were supplied
error[E0057]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/E0057.rs:5:13
|
LL | let c = f(2, 3);
| ^^^^^^^ expected 1 parameter
| ^ - - supplied 2 arguments
| |
| expected 1 argument
error: aborting due to 2 previous errors

View File

@ -5,5 +5,5 @@ extern "C" {
fn main() {
unsafe { printf(); }
//~^ ERROR E0060
//~| expected at least 1 parameter
//~| expected at least 1 argument
}

View File

@ -1,11 +1,13 @@
error[E0060]: this function takes at least 1 parameter but 0 parameters were supplied
error[E0060]: this function takes at least 1 argument but 0 arguments were supplied
--> $DIR/E0060.rs:6:14
|
LL | fn printf(_: *const u8, ...) -> u32;
| ------------------------------------ defined here
...
LL | unsafe { printf(); }
| ^^^^^^^^ expected at least 1 parameter
| ^^^^^^-- supplied 0 arguments
| |
| expected at least 1 argument
error: aborting due to previous error

View File

@ -5,9 +5,9 @@ fn f2(a: u16) {}
fn main() {
f(0);
//~^ ERROR E0061
//~| expected 2 parameters
//~| expected 2 arguments
f2();
//~^ ERROR E0061
//~| expected 1 parameter
//~| expected 1 argument
}

View File

@ -1,20 +1,24 @@
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/E0061.rs:6:5
|
LL | fn f(a: u16, b: &str) {}
| --------------------- defined here
...
LL | f(0);
| ^^^^ expected 2 parameters
| ^ - supplied 1 argument
| |
| expected 2 arguments
error[E0061]: this function takes 1 parameter but 0 parameters were supplied
error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/E0061.rs:10:5
|
LL | fn f2(a: u16) {}
| ------------- defined here
...
LL | f2();
| ^^^^ expected 1 parameter
| ^^-- supplied 0 arguments
| |
| expected 1 argument
error: aborting due to 2 previous errors

View File

@ -2,7 +2,7 @@ error[E0310]: the parameter type `U` may not live long enough
--> $DIR/feature-gate-infer_static_outlives_requirements.rs:5:5
|
LL | struct Foo<U> {
| - help: consider adding an explicit lifetime bound `U: 'static`...
| - help: consider adding an explicit lifetime bound...: `U: 'static`
LL | bar: Bar<U>
| ^^^^^^^^^^^
|

View File

@ -9,5 +9,5 @@ where
{}
fn main() {
f(&[f()]); //~ ERROR this function takes 1 parameter
f(&[f()]); //~ ERROR this function takes 1 argument
}

View File

@ -1,4 +1,4 @@
error[E0061]: this function takes 1 parameter but 0 parameters were supplied
error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/issue-58451.rs:12:9
|
LL | / fn f<I>(i: I)
@ -9,7 +9,9 @@ LL | | {}
| |__- defined here
...
LL | f(&[f()]);
| ^^^ expected 1 parameter
| ^-- supplied 0 arguments
| |
| expected 1 argument
error: aborting due to previous error

View File

@ -4,7 +4,7 @@
// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
#![allow(exceeding_bitshifts)]
#![allow(arithmetic_overflow)]
fn main() {
let _fat: [u8; (1<<31)+(1<<15)] = //~ ERROR too big for the current architecture

View File

@ -4,7 +4,7 @@
// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
#![allow(exceeding_bitshifts)]
#![allow(arithmetic_overflow)]
fn main() {
let _fat: [u8; (1<<61)+(1<<31)] = //~ ERROR too big for the current architecture

View File

@ -67,7 +67,7 @@ error[E0310]: the parameter type `T` may not live long enough
LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static {
| -- ^^^^^^^^^^^^^^^^^^^^
| |
| help: consider adding an explicit lifetime bound `T: 'static`...
| help: consider adding an explicit lifetime bound...: `T: 'static +`
|
note: ...so that the type `T` will meet its required lifetime bounds
--> $DIR/must_outlive_least_region_or_bound.rs:22:51

View File

@ -4,7 +4,7 @@ error[E0310]: the parameter type `T` may not live long enough
LL | fn foo<T>(x: T) -> impl Any + 'static {
| - ^^^^^^^^^^^^^^^^^^
| |
| help: consider adding an explicit lifetime bound `T: 'static`...
| help: consider adding an explicit lifetime bound...: `T: 'static`
|
note: ...so that the type `T` will meet its required lifetime bounds
--> $DIR/type_parameters_captured.rs:7:20

View File

@ -1,8 +1,10 @@
error[E0057]: this function takes 0 parameters but 1 parameter was supplied
error[E0057]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/issue-16939.rs:5:9
|
LL | |t| f(t);
| ^^^^ expected 0 parameters
| ^ - supplied 1 argument
| |
| expected 0 arguments
error: aborting due to previous error

View File

@ -1,11 +1,13 @@
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/issue-18819.rs:16:5
|
LL | fn print_x(_: &dyn Foo<Item=bool>, extra: &str) {
| ----------------------------------------------- defined here
...
LL | print_x(X);
| ^^^^^^^^^^ expected 2 parameters
| ^^^^^^^ - supplied 1 argument
| |
| expected 2 arguments
error: aborting due to previous error

View File

@ -1,13 +1,13 @@
macro_rules! some_macro {
($other: expr) => ({
$other(None)
//~^ this function takes 0 parameters but 1 parameter was supplied
$other(None) //~ NOTE supplied 1 argument
})
}
fn some_function() {}
fn some_function() {} //~ NOTE defined here
fn main() {
some_macro!(some_function);
//~^ in this expansion of some_macro!
//~^ ERROR this function takes 0 arguments but 1 argument was supplied
//~| NOTE expected 0 arguments
}

View File

@ -1,16 +1,14 @@
error[E0061]: this function takes 0 parameters but 1 parameter was supplied
--> $DIR/issue-26094.rs:3:9
error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/issue-26094.rs:10:17
|
LL | $other(None)
| ^^^^^^^^^^^^ expected 0 parameters
| ---- supplied 1 argument
...
LL | fn some_function() {}
| ------------------ defined here
...
LL | some_macro!(some_function);
| --------------------------- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
| ^^^^^^^^^^^^^ expected 0 arguments
error: aborting due to previous error

View File

@ -2,5 +2,5 @@ fn main() {
let needlesArr: Vec<char> = vec!['a', 'f'];
needlesArr.iter().fold(|x, y| {
});
//~^^ ERROR this function takes 2 parameters but 1 parameter was supplied
//~^^ ERROR this function takes 2 arguments but 1 argument was supplied
}

View File

@ -1,8 +1,12 @@
error[E0061]: this function takes 2 parameters but 1 parameter was supplied
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> $DIR/issue-3044.rs:3:23
|
LL | needlesArr.iter().fold(|x, y| {
| ^^^^ expected 2 parameters
LL | needlesArr.iter().fold(|x, y| {
| _______________________^^^^_-
| | |
| | expected 2 arguments
LL | | });
| |_____- supplied 1 argument
error: aborting due to previous error

View File

@ -3,4 +3,4 @@
fn foo(a: usize) {}
//~^ defined here
fn main() { foo(5, 6) }
//~^ ERROR this function takes 1 parameter but 2 parameters were supplied
//~^ ERROR this function takes 1 argument but 2 arguments were supplied

View File

@ -1,11 +1,13 @@
error[E0061]: this function takes 1 parameter but 2 parameters were supplied
error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/issue-4935.rs:5:13
|
LL | fn foo(a: usize) {}
| ---------------- defined here
LL |
LL | fn main() { foo(5, 6) }
| ^^^^^^^^^ expected 1 parameter
| ^^^ - - supplied 2 arguments
| |
| expected 1 argument
error: aborting due to previous error

View File

@ -2,6 +2,6 @@
fn main() {
[1][0u64 as usize];
[1][1.5 as usize]; //~ ERROR index out of bounds
[1][1u64 as usize]; //~ ERROR index out of bounds
[1][1.5 as usize]; //~ ERROR operation will panic
[1][1u64 as usize]; //~ ERROR operation will panic
}

View File

@ -1,16 +1,16 @@
error: index out of bounds: the len is 1 but the index is 1
error: this operation will panic at runtime
--> $DIR/issue-54348.rs:5:5
|
LL | [1][1.5 as usize];
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1
|
= note: `#[deny(const_err)]` on by default
= note: `#[deny(unconditional_panic)]` on by default
error: index out of bounds: the len is 1 but the index is 1
error: this operation will panic at runtime
--> $DIR/issue-54348.rs:6:5
|
LL | [1][1u64 as usize];
| ^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^ index out of bounds: the len is 1 but the index is 1
error: aborting due to 2 previous errors

View File

@ -0,0 +1,150 @@
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:14:36
|
LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ attempt to divide with overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:16:36
|
LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:18:36
|
LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:20:36
|
LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:22:36
|
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:24:36
|
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^ attempt to divide with overflow
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:26:36
|
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
| ^^^^^^^^^^ attempt to divide by zero
|
= note: `#[deny(unconditional_panic)]` on by default
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:28:36
|
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
| ^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:30:36
|
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
| ^^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:32:36
|
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
| ^^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:34:36
|
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
| ^^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:36:36
|
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
| ^^^^^^^^^ attempt to divide by zero
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:38:36
|
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:40:36
|
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:42:36
|
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:44:36
|
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:46:36
|
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:48:36
|
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:50:36
|
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
| ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:52:36
|
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
| ^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:54:36
|
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:56:36
|
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:58:36
|
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:60:36
|
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
| ^^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: aborting due to 24 previous errors

View File

@ -0,0 +1,150 @@
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:14:36
|
LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ attempt to divide with overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:16:36
|
LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:18:36
|
LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:20:36
|
LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:22:36
|
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:24:36
|
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^ attempt to divide with overflow
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:26:36
|
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
| ^^^^^^^^^^ attempt to divide by zero
|
= note: `#[deny(unconditional_panic)]` on by default
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:28:36
|
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
| ^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:30:36
|
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
| ^^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:32:36
|
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
| ^^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:34:36
|
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
| ^^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:36:36
|
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
| ^^^^^^^^^ attempt to divide by zero
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:38:36
|
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:40:36
|
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:42:36
|
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:44:36
|
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:46:36
|
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:48:36
|
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:50:36
|
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
| ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:52:36
|
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
| ^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:54:36
|
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:56:36
|
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:58:36
|
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:60:36
|
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
| ^^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: aborting due to 24 previous errors

View File

@ -0,0 +1,150 @@
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:14:36
|
LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ attempt to divide with overflow
|
= note: `#[deny(arithmetic_overflow)]` on by default
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:16:36
|
LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:18:36
|
LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:20:36
|
LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:22:36
|
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:24:36
|
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^ attempt to divide with overflow
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:26:36
|
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
| ^^^^^^^^^^ attempt to divide by zero
|
= note: `#[deny(unconditional_panic)]` on by default
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:28:36
|
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
| ^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:30:36
|
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
| ^^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:32:36
|
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
| ^^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:34:36
|
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
| ^^^^^^^^ attempt to divide by zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:36:36
|
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
| ^^^^^^^^^ attempt to divide by zero
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:38:36
|
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:40:36
|
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:42:36
|
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:44:36
|
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:46:36
|
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this arithmetic operation will overflow
--> $DIR/issue-8460-const.rs:48:36
|
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:50:36
|
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
| ^^^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:52:36
|
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
| ^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:54:36
|
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:56:36
|
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:58:36
|
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
| ^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: this operation will panic at runtime
--> $DIR/issue-8460-const.rs:60:36
|
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
| ^^^^^^^^^ attempt to calculate the remainder with a divisor of zero
error: aborting due to 24 previous errors

View File

@ -1,5 +1,9 @@
// revisions: noopt opt opt_with_overflow_checks
//[noopt]compile-flags: -C opt-level=0
//[opt]compile-flags: -O
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
// build-fail
// compile-flags: -O
#![deny(const_err)]
@ -8,63 +12,51 @@ use std::thread;
fn main() {
assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
//~| ERROR this expression will panic at runtime
//~^ ERROR arithmetic operation will overflow
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
//~^ ERROR operation will panic
assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
//~^ ERROR operation will panic
}

View File

@ -1,224 +0,0 @@
error: attempt to divide with overflow
--> $DIR/issue-8460-const.rs:10:36
|
LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/issue-8460-const.rs:4:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:10:36
|
LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ attempt to divide with overflow
error: attempt to divide with overflow
--> $DIR/issue-8460-const.rs:13:36
|
LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:13:36
|
LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^ attempt to divide with overflow
error: attempt to divide with overflow
--> $DIR/issue-8460-const.rs:16:36
|
LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:16:36
|
LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: attempt to divide with overflow
--> $DIR/issue-8460-const.rs:19:36
|
LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:19:36
|
LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: attempt to divide with overflow
--> $DIR/issue-8460-const.rs:22:36
|
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:22:36
|
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to divide with overflow
error: attempt to divide with overflow
--> $DIR/issue-8460-const.rs:25:36
|
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:25:36
|
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^ attempt to divide with overflow
error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:28:36
|
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
| ^^^^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:30:36
|
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
| ^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:32:36
|
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
| ^^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:34:36
|
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
| ^^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:36:36
|
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
| ^^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const.rs:38:36
|
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
| ^^^^^^^^^
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:40:36
|
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:40:36
|
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:43:36
|
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:43:36
|
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:46:36
|
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:46:36
|
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:49:36
|
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:49:36
|
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:52:36
|
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:52:36
|
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const.rs:55:36
|
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^
error: this expression will panic at runtime
--> $DIR/issue-8460-const.rs:55:36
|
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^ attempt to calculate the remainder with overflow
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:58:36
|
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
| ^^^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:60:36
|
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
| ^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:62:36
|
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:64:36
|
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:66:36
|
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const.rs:68:36
|
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
| ^^^^^^^^^
error: aborting due to 36 previous errors

View File

@ -1,58 +0,0 @@
// build-fail
// compile-flags: -C overflow-checks=on -O
#![deny(const_err)]
use std::{isize, i8, i16, i32, i64, i128};
use std::thread;
fn main() {
assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
//~^ ERROR attempt to divide with overflow
assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
//~^ ERROR attempt to divide by zero
assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with overflow
assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
//~^ ERROR attempt to calculate the remainder with a divisor of zero
}

View File

@ -1,152 +0,0 @@
error: attempt to divide with overflow
--> $DIR/issue-8460-const2.rs:10:36
|
LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/issue-8460-const2.rs:4:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
error: attempt to divide with overflow
--> $DIR/issue-8460-const2.rs:12:36
|
LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^
error: attempt to divide with overflow
--> $DIR/issue-8460-const2.rs:14:36
|
LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: attempt to divide with overflow
--> $DIR/issue-8460-const2.rs:16:36
|
LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: attempt to divide with overflow
--> $DIR/issue-8460-const2.rs:18:36
|
LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: attempt to divide with overflow
--> $DIR/issue-8460-const2.rs:20:36
|
LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err());
| ^^^^^^^^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:22:36
|
LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err());
| ^^^^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:24:36
|
LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err());
| ^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:26:36
|
LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err());
| ^^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:28:36
|
LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err());
| ^^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:30:36
|
LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err());
| ^^^^^^^^
error: attempt to divide by zero
--> $DIR/issue-8460-const2.rs:32:36
|
LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err());
| ^^^^^^^^^
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:34:36
|
LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^^
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:36:36
|
LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:38:36
|
LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:40:36
|
LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:42:36
|
LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^
error: attempt to calculate the remainder with overflow
--> $DIR/issue-8460-const2.rs:44:36
|
LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err());
| ^^^^^^^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:46:36
|
LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err());
| ^^^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:48:36
|
LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err());
| ^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:50:36
|
LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:52:36
|
LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:54:36
|
LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err());
| ^^^^^^^^
error: attempt to calculate the remainder with a divisor of zero
--> $DIR/issue-8460-const2.rs:56:36
|
LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err());
| ^^^^^^^^^
error: aborting due to 24 previous errors

View File

@ -2,7 +2,7 @@ error[E0310]: the parameter type `T` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:19:5
|
LL | struct Foo<T> {
| - help: consider adding an explicit lifetime bound `T: 'static`...
| - help: consider adding an explicit lifetime bound...: `T: 'static`
LL | foo: &'static T
| ^^^^^^^^^^^^^^^
|
@ -16,7 +16,7 @@ error[E0309]: the parameter type `K` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:24:19
|
LL | trait X<K>: Sized {
| - help: consider adding an explicit lifetime bound `K: 'a`...
| - help: consider adding an explicit lifetime bound...: `K: 'a`
LL | fn foo<'a, L: X<&'a Nested<K>>>();
| ^^^^^^^^^^^^^^^^
|
@ -45,7 +45,7 @@ error[E0309]: the parameter type `L` may not live long enough
LL | fn baz<'a, L, M: X<&'a Nested<L>>>() {
| - ^^^^^^^^^^^^^^^^
| |
| help: consider adding an explicit lifetime bound `L: 'a`...
| help: consider adding an explicit lifetime bound...: `L: 'a`
|
note: ...so that the reference type `&'a Nested<L>` does not outlive the data it points at
--> $DIR/lifetime-doesnt-live-long-enough.rs:32:22
@ -57,7 +57,7 @@ error[E0309]: the parameter type `K` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:41:33
|
LL | impl<K> Nested<K> {
| - help: consider adding an explicit lifetime bound `K: 'a`...
| - help: consider adding an explicit lifetime bound...: `K: 'a`
LL | fn generic_in_parent<'a, L: X<&'a Nested<K>>>() {
| ^^^^^^^^^^^^^^^^
|
@ -71,7 +71,7 @@ error[E0309]: the parameter type `M` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:36
|
LL | fn generic_in_child<'a, 'b, L: X<&'a Nested<M>>, M: 'b>() {
| ^^^^^^^^^^^^^^^^ -- help: consider adding an explicit lifetime bound `M: 'a`...
| ^^^^^^^^^^^^^^^^ -- help: consider adding an explicit lifetime bound...: `M: 'a +`
|
note: ...so that the reference type `&'a Nested<M>` does not outlive the data it points at
--> $DIR/lifetime-doesnt-live-long-enough.rs:44:36

View File

@ -0,0 +1,146 @@
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
LL | let _ = x << 42;
| ^^^^^^^ attempt to shift left with overflow
|
note: the lint level is defined here
--> $DIR/lint-exceeding-bitshifts.rs:9:9
|
LL | #![deny(arithmetic_overflow, const_err)]
| ^^^^^^^^^^^^^^^^^^^
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:27:15
|
LL | let n = 1u8 << 8;
| ^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:29:15
|
LL | let n = 1u16 << 16;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:31:15
|
LL | let n = 1u32 << 32;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:33:15
|
LL | let n = 1u64 << 64;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:35:15
|
LL | let n = 1i8 << 8;
| ^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:37:15
|
LL | let n = 1i16 << 16;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:39:15
|
LL | let n = 1i32 << 32;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:41:15
|
LL | let n = 1i64 << 64;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:44:15
|
LL | let n = 1u8 >> 8;
| ^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:46:15
|
LL | let n = 1u16 >> 16;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:48:15
|
LL | let n = 1u32 >> 32;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:50:15
|
LL | let n = 1u64 >> 64;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:52:15
|
LL | let n = 1i8 >> 8;
| ^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:54:15
|
LL | let n = 1i16 >> 16;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:56:15
|
LL | let n = 1i32 >> 32;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:58:15
|
LL | let n = 1i64 >> 64;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:62:15
|
LL | let n = n << 8;
| ^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:64:15
|
LL | let n = 1u8 << -8;
| ^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:69:15
|
LL | let n = 1u8 << (4+4);
| ^^^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:71:15
|
LL | let n = 1i64 >> [64][0];
| ^^^^^^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:77:15
|
LL | let n = 1_isize << BITS;
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:78:15
|
LL | let n = 1_usize << BITS;
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
error: aborting due to 23 previous errors

View File

@ -0,0 +1,146 @@
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
LL | let _ = x << 42;
| ^^^^^^^ attempt to shift left with overflow
|
note: the lint level is defined here
--> $DIR/lint-exceeding-bitshifts.rs:9:9
|
LL | #![deny(arithmetic_overflow, const_err)]
| ^^^^^^^^^^^^^^^^^^^
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:27:15
|
LL | let n = 1u8 << 8;
| ^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:29:15
|
LL | let n = 1u16 << 16;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:31:15
|
LL | let n = 1u32 << 32;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:33:15
|
LL | let n = 1u64 << 64;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:35:15
|
LL | let n = 1i8 << 8;
| ^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:37:15
|
LL | let n = 1i16 << 16;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:39:15
|
LL | let n = 1i32 << 32;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:41:15
|
LL | let n = 1i64 << 64;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:44:15
|
LL | let n = 1u8 >> 8;
| ^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:46:15
|
LL | let n = 1u16 >> 16;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:48:15
|
LL | let n = 1u32 >> 32;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:50:15
|
LL | let n = 1u64 >> 64;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:52:15
|
LL | let n = 1i8 >> 8;
| ^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:54:15
|
LL | let n = 1i16 >> 16;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:56:15
|
LL | let n = 1i32 >> 32;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:58:15
|
LL | let n = 1i64 >> 64;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:62:15
|
LL | let n = n << 8;
| ^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:64:15
|
LL | let n = 1u8 << -8;
| ^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:69:15
|
LL | let n = 1u8 << (4+4);
| ^^^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:71:15
|
LL | let n = 1i64 >> [64][0];
| ^^^^^^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:77:15
|
LL | let n = 1_isize << BITS;
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:78:15
|
LL | let n = 1_usize << BITS;
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
error: aborting due to 23 previous errors

View File

@ -0,0 +1,146 @@
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:22:13
|
LL | let _ = x << 42;
| ^^^^^^^ attempt to shift left with overflow
|
note: the lint level is defined here
--> $DIR/lint-exceeding-bitshifts.rs:9:9
|
LL | #![deny(arithmetic_overflow, const_err)]
| ^^^^^^^^^^^^^^^^^^^
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:27:15
|
LL | let n = 1u8 << 8;
| ^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:29:15
|
LL | let n = 1u16 << 16;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:31:15
|
LL | let n = 1u32 << 32;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:33:15
|
LL | let n = 1u64 << 64;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:35:15
|
LL | let n = 1i8 << 8;
| ^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:37:15
|
LL | let n = 1i16 << 16;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:39:15
|
LL | let n = 1i32 << 32;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:41:15
|
LL | let n = 1i64 << 64;
| ^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:44:15
|
LL | let n = 1u8 >> 8;
| ^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:46:15
|
LL | let n = 1u16 >> 16;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:48:15
|
LL | let n = 1u32 >> 32;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:50:15
|
LL | let n = 1u64 >> 64;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:52:15
|
LL | let n = 1i8 >> 8;
| ^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:54:15
|
LL | let n = 1i16 >> 16;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:56:15
|
LL | let n = 1i32 >> 32;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:58:15
|
LL | let n = 1i64 >> 64;
| ^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:62:15
|
LL | let n = n << 8;
| ^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:64:15
|
LL | let n = 1u8 << -8;
| ^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:69:15
|
LL | let n = 1u8 << (4+4);
| ^^^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:71:15
|
LL | let n = 1i64 >> [64][0];
| ^^^^^^^^^^^^^^^ attempt to shift right with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:77:15
|
LL | let n = 1_isize << BITS;
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
error: this arithmetic operation will overflow
--> $DIR/lint-exceeding-bitshifts.rs:78:15
|
LL | let n = 1_usize << BITS;
| ^^^^^^^^^^^^^^^ attempt to shift left with overflow
error: aborting due to 23 previous errors

View File

@ -1,50 +1,79 @@
// build-fail
// compile-flags: -O
// revisions: noopt opt opt_with_overflow_checks
//[noopt]compile-flags: -C opt-level=0
//[opt]compile-flags: -O
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O
#![deny(exceeding_bitshifts, const_err)]
// build-fail
#![crate_type="lib"]
#![deny(arithmetic_overflow, const_err)]
#![allow(unused_variables)]
#![allow(dead_code)]
fn main() {
pub trait Foo {
const N: i32;
}
impl<T: Foo> Foo for Vec<T> {
const N: i32 = T::N << 42; // FIXME this should warn
}
pub fn foo(x: i32) {
let _ = x << 42; //~ ERROR: arithmetic operation will overflow
}
pub fn main() {
let n = 1u8 << 7;
let n = 1u8 << 8; //~ ERROR: attempt to shift left with overflow
let n = 1u8 << 8; //~ ERROR: arithmetic operation will overflow
let n = 1u16 << 15;
let n = 1u16 << 16; //~ ERROR: attempt to shift left with overflow
let n = 1u16 << 16; //~ ERROR: arithmetic operation will overflow
let n = 1u32 << 31;
let n = 1u32 << 32; //~ ERROR: attempt to shift left with overflow
let n = 1u32 << 32; //~ ERROR: arithmetic operation will overflow
let n = 1u64 << 63;
let n = 1u64 << 64; //~ ERROR: attempt to shift left with overflow
let n = 1u64 << 64; //~ ERROR: arithmetic operation will overflow
let n = 1i8 << 7;
let n = 1i8 << 8; //~ ERROR: attempt to shift left with overflow
let n = 1i8 << 8; //~ ERROR: arithmetic operation will overflow
let n = 1i16 << 15;
let n = 1i16 << 16; //~ ERROR: attempt to shift left with overflow
let n = 1i16 << 16; //~ ERROR: arithmetic operation will overflow
let n = 1i32 << 31;
let n = 1i32 << 32; //~ ERROR: attempt to shift left with overflow
let n = 1i32 << 32; //~ ERROR: arithmetic operation will overflow
let n = 1i64 << 63;
let n = 1i64 << 64; //~ ERROR: attempt to shift left with overflow
let n = 1i64 << 64; //~ ERROR: arithmetic operation will overflow
let n = 1u8 >> 7;
let n = 1u8 >> 8; //~ ERROR: attempt to shift right with overflow
let n = 1u8 >> 8; //~ ERROR: arithmetic operation will overflow
let n = 1u16 >> 15;
let n = 1u16 >> 16; //~ ERROR: attempt to shift right with overflow
let n = 1u16 >> 16; //~ ERROR: arithmetic operation will overflow
let n = 1u32 >> 31;
let n = 1u32 >> 32; //~ ERROR: attempt to shift right with overflow
let n = 1u32 >> 32; //~ ERROR: arithmetic operation will overflow
let n = 1u64 >> 63;
let n = 1u64 >> 64; //~ ERROR: attempt to shift right with overflow
let n = 1u64 >> 64; //~ ERROR: arithmetic operation will overflow
let n = 1i8 >> 7;
let n = 1i8 >> 8; //~ ERROR: attempt to shift right with overflow
let n = 1i8 >> 8; //~ ERROR: arithmetic operation will overflow
let n = 1i16 >> 15;
let n = 1i16 >> 16; //~ ERROR: attempt to shift right with overflow
let n = 1i16 >> 16; //~ ERROR: arithmetic operation will overflow
let n = 1i32 >> 31;
let n = 1i32 >> 32; //~ ERROR: attempt to shift right with overflow
let n = 1i32 >> 32; //~ ERROR: arithmetic operation will overflow
let n = 1i64 >> 63;
let n = 1i64 >> 64; //~ ERROR: attempt to shift right with overflow
let n = 1i64 >> 64; //~ ERROR: arithmetic operation will overflow
let n = 1u8;
let n = n << 7;
let n = n << 8; //~ ERROR: attempt to shift left with overflow
let n = n << 8; //~ ERROR: arithmetic operation will overflow
let n = 1u8 << -8; //~ ERROR: attempt to shift left with overflow
let n = 1u8 << -8; //~ ERROR: arithmetic operation will overflow
let n = 1i8<<(1isize+-1);
let n = 1u8 << (4+3);
let n = 1u8 << (4+4); //~ ERROR: arithmetic operation will overflow
let n = 1i64 >> [63][0];
let n = 1i64 >> [64][0]; //~ ERROR: arithmetic operation will overflow
#[cfg(target_pointer_width = "32")]
const BITS: usize = 32;
#[cfg(target_pointer_width = "64")]
const BITS: usize = 64;
let n = 1_isize << BITS; //~ ERROR: arithmetic operation will overflow
let n = 1_usize << BITS; //~ ERROR: arithmetic operation will overflow
}

View File

@ -1,116 +0,0 @@
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:10:15
|
LL | let n = 1u8 << 8;
| ^^^^^^^^
|
note: the lint level is defined here
--> $DIR/lint-exceeding-bitshifts.rs:4:9
|
LL | #![deny(exceeding_bitshifts, const_err)]
| ^^^^^^^^^^^^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:12:15
|
LL | let n = 1u16 << 16;
| ^^^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:14:15
|
LL | let n = 1u32 << 32;
| ^^^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:16:15
|
LL | let n = 1u64 << 64;
| ^^^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:18:15
|
LL | let n = 1i8 << 8;
| ^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:20:15
|
LL | let n = 1i16 << 16;
| ^^^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:22:15
|
LL | let n = 1i32 << 32;
| ^^^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:24:15
|
LL | let n = 1i64 << 64;
| ^^^^^^^^^^
error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts.rs:27:15
|
LL | let n = 1u8 >> 8;
| ^^^^^^^^
error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts.rs:29:15
|
LL | let n = 1u16 >> 16;
| ^^^^^^^^^^
error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts.rs:31:15
|
LL | let n = 1u32 >> 32;
| ^^^^^^^^^^
error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts.rs:33:15
|
LL | let n = 1u64 >> 64;
| ^^^^^^^^^^
error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts.rs:35:15
|
LL | let n = 1i8 >> 8;
| ^^^^^^^^
error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts.rs:37:15
|
LL | let n = 1i16 >> 16;
| ^^^^^^^^^^
error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts.rs:39:15
|
LL | let n = 1i32 >> 32;
| ^^^^^^^^^^
error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts.rs:41:15
|
LL | let n = 1i64 >> 64;
| ^^^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:45:15
|
LL | let n = n << 8;
| ^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts.rs:47:15
|
LL | let n = 1u8 << -8;
| ^^^^^^^^^
error: aborting due to 18 previous errors

View File

@ -1,20 +0,0 @@
// build-fail
// compile-flags: -O
#![deny(exceeding_bitshifts, const_err)]
#![allow(unused_variables)]
#![allow(dead_code)]
fn main() {
let n = 1u8 << (4+3);
let n = 1u8 << (4+4); //~ ERROR: attempt to shift left with overflow
let n = 1i64 >> [63][0];
let n = 1i64 >> [64][0]; //~ ERROR: attempt to shift right with overflow
#[cfg(target_pointer_width = "32")]
const BITS: usize = 32;
#[cfg(target_pointer_width = "64")]
const BITS: usize = 64;
let n = 1_isize << BITS; //~ ERROR: attempt to shift left with overflow
let n = 1_usize << BITS; //~ ERROR: attempt to shift left with overflow
}

View File

@ -1,32 +0,0 @@
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts2.rs:10:15
|
LL | let n = 1u8 << (4+4);
| ^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/lint-exceeding-bitshifts2.rs:4:9
|
LL | #![deny(exceeding_bitshifts, const_err)]
| ^^^^^^^^^^^^^^^^^^^
error: attempt to shift right with overflow
--> $DIR/lint-exceeding-bitshifts2.rs:12:15
|
LL | let n = 1i64 >> [64][0];
| ^^^^^^^^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts2.rs:18:15
|
LL | let n = 1_isize << BITS;
| ^^^^^^^^^^^^^^^
error: attempt to shift left with overflow
--> $DIR/lint-exceeding-bitshifts2.rs:19:15
|
LL | let n = 1_usize << BITS;
| ^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors

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