diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 8e76e47cfefca..c6b04431fab10 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -623,7 +623,7 @@ pub fn create_compressed_metadata_file_for_xcoff( /// that contains a custom section of the name `section_name` with contents /// `data`. /// -/// NB: the `object` crate does not yet have support for writing the the wasm +/// NB: the `object` crate does not yet have support for writing the wasm /// object file format. The format is simple enough that for now an extra crate /// from crates.io (such as `wasm-encoder`). The file format is: /// diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 9012b731a1323..93c183a65ef3e 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -518,7 +518,7 @@ declare_features! ( (unstable, marker_trait_attr, "1.30.0", Some(29864)), /// Allows exhaustive pattern matching on types that contain uninhabited types in cases that are /// unambiguously sound. - (incomplete, min_exhaustive_patterns, "1.77.0", Some(119612)), + (unstable, min_exhaustive_patterns, "1.77.0", Some(119612)), /// A minimal, sound subset of specialization intended to be used by the /// standard library until the soundness issues with specialization /// are fixed. diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index fcb15925f6a7b..78e7c636a3e74 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3004,6 +3004,11 @@ impl<'hir> Item<'hir> { matches!(self.kind, ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..)) } + /// Check if this is an [`ItemKind::Struct`] or [`ItemKind::Union`]. + pub fn is_struct_or_union(&self) -> bool { + matches!(self.kind, ItemKind::Struct(..) | ItemKind::Union(..)) + } + expect_methods_self_kind! { expect_extern_crate, Option, ItemKind::ExternCrate(s), *s; diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 642009dfa48a8..e9c9ec6ba53f8 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -1025,7 +1025,15 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AdtDef<'_> { let is_anonymous = item.ident.name == kw::Empty; let repr = if is_anonymous { - tcx.adt_def(tcx.local_parent(def_id)).repr() + let parent = tcx.local_parent(def_id); + if let Node::Item(item) = tcx.hir_node_by_def_id(parent) + && item.is_struct_or_union() + { + tcx.adt_def(parent).repr() + } else { + tcx.dcx().span_delayed_bug(item.span, "anonymous field inside non struct/union"); + ty::ReprOptions::default() + } } else { tcx.repr_options_of_def(def_id) }; diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 9c0846e9fb199..c3e4a03ad1677 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -24,6 +24,8 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] +#![cfg_attr(bootstrap, feature(exhaustive_patterns))] +#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))] #![feature(rustdoc_internals)] #![feature(allocator_api)] #![feature(array_windows)] @@ -32,7 +34,6 @@ #![feature(core_intrinsics)] #![feature(const_type_name)] #![feature(discriminant_kind)] -#![feature(exhaustive_patterns)] #![feature(coroutines)] #![feature(generic_nonzero)] #![feature(if_let_guard)] diff --git a/compiler/rustc_middle/src/traits/select.rs b/compiler/rustc_middle/src/traits/select.rs index e3050007c7b3c..8e9751f45294c 100644 --- a/compiler/rustc_middle/src/traits/select.rs +++ b/compiler/rustc_middle/src/traits/select.rs @@ -139,7 +139,7 @@ pub enum SelectionCandidate<'tcx> { /// generated for an `async ||` expression. AsyncClosureCandidate, - /// Implementation of the the `AsyncFnKindHelper` helper trait, which + /// Implementation of the `AsyncFnKindHelper` helper trait, which /// is used internally to delay computation for async closures until after /// upvar analysis is performed in HIR typeck. AsyncFnKindHelperCandidate, diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 98fb1d8e1c940..4260a6f0c6f79 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -90,23 +90,23 @@ pub(super) fn generate_coverage_spans( struct CurrCovspan { span: Span, bcb: BasicCoverageBlock, - is_closure: bool, + is_hole: bool, } impl CurrCovspan { - fn new(span: Span, bcb: BasicCoverageBlock, is_closure: bool) -> Self { - Self { span, bcb, is_closure } + fn new(span: Span, bcb: BasicCoverageBlock, is_hole: bool) -> Self { + Self { span, bcb, is_hole } } fn into_prev(self) -> PrevCovspan { - let Self { span, bcb, is_closure } = self; - PrevCovspan { span, bcb, merged_spans: vec![span], is_closure } + let Self { span, bcb, is_hole } = self; + PrevCovspan { span, bcb, merged_spans: vec![span], is_hole } } fn into_refined(self) -> RefinedCovspan { - // This is only called in cases where `curr` is a closure span that has + // This is only called in cases where `curr` is a hole span that has // been carved out of `prev`. - debug_assert!(self.is_closure); + debug_assert!(self.is_hole); self.into_prev().into_refined() } } @@ -118,12 +118,12 @@ struct PrevCovspan { /// List of all the original spans from MIR that have been merged into this /// span. Mainly used to precisely skip over gaps when truncating a span. merged_spans: Vec, - is_closure: bool, + is_hole: bool, } impl PrevCovspan { fn is_mergeable(&self, other: &CurrCovspan) -> bool { - self.bcb == other.bcb && !self.is_closure && !other.is_closure + self.bcb == other.bcb && !self.is_hole && !other.is_hole } fn merge_from(&mut self, other: &CurrCovspan) { @@ -142,8 +142,8 @@ impl PrevCovspan { } fn refined_copy(&self) -> RefinedCovspan { - let &Self { span, bcb, merged_spans: _, is_closure } = self; - RefinedCovspan { span, bcb, is_closure } + let &Self { span, bcb, merged_spans: _, is_hole } = self; + RefinedCovspan { span, bcb, is_hole } } fn into_refined(self) -> RefinedCovspan { @@ -156,12 +156,12 @@ impl PrevCovspan { struct RefinedCovspan { span: Span, bcb: BasicCoverageBlock, - is_closure: bool, + is_hole: bool, } impl RefinedCovspan { fn is_mergeable(&self, other: &Self) -> bool { - self.bcb == other.bcb && !self.is_closure && !other.is_closure + self.bcb == other.bcb && !self.is_hole && !other.is_hole } fn merge_from(&mut self, other: &Self) { @@ -176,16 +176,16 @@ impl RefinedCovspan { /// * Remove duplicate source code coverage regions /// * Merge spans that represent continuous (both in source code and control flow), non-branching /// execution -/// * Carve out (leave uncovered) any span that will be counted by another MIR (notably, closures) +/// * Carve out (leave uncovered) any "hole" spans that need to be left blank +/// (e.g. closures that will be counted by their own MIR body) struct SpansRefiner { /// The initial set of coverage spans, sorted by `Span` (`lo` and `hi`) and by relative /// dominance between the `BasicCoverageBlock`s of equal `Span`s. sorted_spans_iter: std::vec::IntoIter, - /// The current coverage span to compare to its `prev`, to possibly merge, discard, force the - /// discard of the `prev` (and or `pending_dups`), or keep both (with `prev` moved to - /// `pending_dups`). If `curr` is not discarded or merged, it becomes `prev` for the next - /// iteration. + /// The current coverage span to compare to its `prev`, to possibly merge, discard, + /// or cause `prev` to be modified or discarded. + /// If `curr` is not discarded or merged, it becomes `prev` for the next iteration. some_curr: Option, /// The coverage span from a prior iteration; typically assigned from that iteration's `curr`. @@ -229,7 +229,7 @@ impl SpansRefiner { let curr = self.curr(); if prev.is_mergeable(curr) { - debug!(" same bcb (and neither is a closure), merge with prev={prev:?}"); + debug!(?prev, "curr will be merged into prev"); let curr = self.take_curr(); self.prev_mut().merge_from(&curr); } else if prev.span.hi() <= curr.span.lo() { @@ -238,15 +238,13 @@ impl SpansRefiner { ); let prev = self.take_prev().into_refined(); self.refined_spans.push(prev); - } else if prev.is_closure { + } else if prev.is_hole { // drop any equal or overlapping span (`curr`) and keep `prev` to test again in the // next iter - debug!( - " curr overlaps a closure (prev). Drop curr and keep prev for next iter. prev={prev:?}", - ); + debug!(?prev, "prev (a hole) overlaps curr, so discarding curr"); self.take_curr(); // Discards curr. - } else if curr.is_closure { - self.carve_out_span_for_closure(); + } else if curr.is_hole { + self.carve_out_span_for_hole(); } else { self.cutoff_prev_at_overlapping_curr(); } @@ -270,10 +268,9 @@ impl SpansRefiner { } }); - // Remove spans derived from closures, originally added to ensure the coverage - // regions for the current function leave room for the closure's own coverage regions - // (injected separately, from the closure's own MIR). - self.refined_spans.retain(|covspan| !covspan.is_closure); + // Discard hole spans, since their purpose was to carve out chunks from + // other spans, but we don't want the holes themselves in the final mappings. + self.refined_spans.retain(|covspan| !covspan.is_hole); self.refined_spans } @@ -316,48 +313,43 @@ impl SpansRefiner { { // Skip curr because prev has already advanced beyond the end of curr. // This can only happen if a prior iteration updated `prev` to skip past - // a region of code, such as skipping past a closure. - debug!( - " prev.span starts after curr.span, so curr will be dropped (skipping past \ - closure?); prev={prev:?}", - ); + // a region of code, such as skipping past a hole. + debug!(?prev, "prev.span starts after curr.span, so curr will be dropped"); } else { - self.some_curr = Some(CurrCovspan::new(curr.span, curr.bcb, curr.is_closure)); + self.some_curr = Some(CurrCovspan::new(curr.span, curr.bcb, curr.is_hole)); return true; } } false } - /// If `prev`s span extends left of the closure (`curr`), carve out the closure's span from - /// `prev`'s span. (The closure's coverage counters will be injected when processing the - /// closure's own MIR.) Add the portion of the span to the left of the closure; and if the span - /// extends to the right of the closure, update `prev` to that portion of the span. For any - /// `pending_dups`, repeat the same process. - fn carve_out_span_for_closure(&mut self) { + /// If `prev`s span extends left of the hole (`curr`), carve out the hole's span from + /// `prev`'s span. Add the portion of the span to the left of the hole; and if the span + /// extends to the right of the hole, update `prev` to that portion of the span. + fn carve_out_span_for_hole(&mut self) { let prev = self.prev(); let curr = self.curr(); let left_cutoff = curr.span.lo(); let right_cutoff = curr.span.hi(); - let has_pre_closure_span = prev.span.lo() < right_cutoff; - let has_post_closure_span = prev.span.hi() > right_cutoff; - - if has_pre_closure_span { - let mut pre_closure = self.prev().refined_copy(); - pre_closure.span = pre_closure.span.with_hi(left_cutoff); - debug!(" prev overlaps a closure. Adding span for pre_closure={:?}", pre_closure); - self.refined_spans.push(pre_closure); + let has_pre_hole_span = prev.span.lo() < right_cutoff; + let has_post_hole_span = prev.span.hi() > right_cutoff; + + if has_pre_hole_span { + let mut pre_hole = prev.refined_copy(); + pre_hole.span = pre_hole.span.with_hi(left_cutoff); + debug!(?pre_hole, "prev overlaps a hole; adding pre-hole span"); + self.refined_spans.push(pre_hole); } - if has_post_closure_span { - // Mutate `prev.span` to start after the closure (and discard curr). + if has_post_hole_span { + // Mutate `prev.span` to start after the hole (and discard curr). self.prev_mut().span = self.prev().span.with_lo(right_cutoff); - debug!(" Mutated prev.span to start after the closure. prev={:?}", self.prev()); + debug!(prev=?self.prev(), "mutated prev to start after the hole"); // Prevent this curr from becoming prev. - let closure_covspan = self.take_curr().into_refined(); - self.refined_spans.push(closure_covspan); // since self.prev() was already updated + let hole_covspan = self.take_curr().into_refined(); + self.refined_spans.push(hole_covspan); // since self.prev() was already updated } } diff --git a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs index b91ab811918a7..099a354f45dd1 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans/from_mir.rs @@ -52,14 +52,14 @@ pub(super) fn mir_to_initial_sorted_coverage_spans( // - Span A extends further left, or // - Both have the same start and span A extends further right .then_with(|| Ord::cmp(&a.span.hi(), &b.span.hi()).reverse()) - // If two spans have the same lo & hi, put closure spans first, - // as they take precedence over non-closure spans. - .then_with(|| Ord::cmp(&a.is_closure, &b.is_closure).reverse()) + // If two spans have the same lo & hi, put hole spans first, + // as they take precedence over non-hole spans. + .then_with(|| Ord::cmp(&a.is_hole, &b.is_hole).reverse()) // After deduplication, we want to keep only the most-dominated BCB. .then_with(|| basic_coverage_blocks.cmp_in_dominator_order(a.bcb, b.bcb).reverse()) }); - // Among covspans with the same span, keep only one. Closure spans take + // Among covspans with the same span, keep only one. Hole spans take // precedence, otherwise keep the one with the most-dominated BCB. // (Ideally we should try to preserve _all_ non-dominating BCBs, but that // requires a lot more complexity in the span refiner, for little benefit.) @@ -78,8 +78,8 @@ pub(super) fn mir_to_initial_sorted_coverage_spans( fn remove_unwanted_macro_spans(initial_spans: &mut Vec) { let mut seen_macro_spans = FxHashSet::default(); initial_spans.retain(|covspan| { - // Ignore (retain) closure spans and non-macro-expansion spans. - if covspan.is_closure || covspan.visible_macro.is_none() { + // Ignore (retain) hole spans and non-macro-expansion spans. + if covspan.is_hole || covspan.visible_macro.is_none() { return true; } @@ -96,7 +96,7 @@ fn split_visible_macro_spans(initial_spans: &mut Vec) { let mut extra_spans = vec![]; initial_spans.retain(|covspan| { - if covspan.is_closure { + if covspan.is_hole { return true; } @@ -112,7 +112,7 @@ fn split_visible_macro_spans(initial_spans: &mut Vec) { return true; } - assert!(!covspan.is_closure); + assert!(!covspan.is_hole); extra_spans.push(SpanFromMir::new(before, covspan.visible_macro, covspan.bcb, false)); extra_spans.push(SpanFromMir::new(after, covspan.visible_macro, covspan.bcb, false)); false // Discard the original covspan that we just split. @@ -148,6 +148,8 @@ fn bcb_to_initial_coverage_spans<'a, 'tcx>( let expn_span = filtered_statement_span(statement)?; let (span, visible_macro) = unexpand(expn_span)?; + // A statement that looks like the assignment of a closure expression + // is treated as a "hole" span, to be carved out of other spans. Some(SpanFromMir::new(span, visible_macro, bcb, is_closure_like(statement))) }); @@ -336,7 +338,10 @@ pub(super) struct SpanFromMir { pub(super) span: Span, visible_macro: Option, pub(super) bcb: BasicCoverageBlock, - pub(super) is_closure: bool, + /// If true, this covspan represents a "hole" that should be carved out + /// from other spans, e.g. because it represents a closure expression that + /// will be instrumented separately as its own function. + pub(super) is_hole: bool, } impl SpanFromMir { @@ -348,8 +353,8 @@ impl SpanFromMir { span: Span, visible_macro: Option, bcb: BasicCoverageBlock, - is_closure: bool, + is_hole: bool, ) -> Self { - Self { span, visible_macro, bcb, is_closure } + Self { span, visible_macro, bcb, is_hole } } } diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs index 04c5e60aa6ba1..8019d2b80cde0 100644 --- a/compiler/rustc_target/src/lib.rs +++ b/compiler/rustc_target/src/lib.rs @@ -9,9 +9,10 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] +#![cfg_attr(bootstrap, feature(exhaustive_patterns))] +#![cfg_attr(not(bootstrap), feature(min_exhaustive_patterns))] #![feature(rustdoc_internals)] #![feature(assert_matches)] -#![feature(exhaustive_patterns)] #![feature(iter_intersperse)] #![feature(let_chains)] #![cfg_attr(bootstrap, feature(min_specialization))] diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 80be4ee57c5c0..271ea88fff652 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -2916,7 +2916,7 @@ impl<'a, K, V> Cursor<'a, K, V> { } } - /// Returns a reference to the the key and value of the next element without + /// Returns a reference to the key and value of the next element without /// moving the cursor. /// /// If the cursor is at the end of the map then `None` is returned @@ -2925,7 +2925,7 @@ impl<'a, K, V> Cursor<'a, K, V> { self.clone().next() } - /// Returns a reference to the the key and value of the previous element + /// Returns a reference to the key and value of the previous element /// without moving the cursor. /// /// If the cursor is at the start of the map then `None` is returned. @@ -2958,7 +2958,7 @@ impl<'a, K, V, A> CursorMut<'a, K, V, A> { Some((&*k, v)) } - /// Returns a reference to the the key and value of the next element without + /// Returns a reference to the key and value of the next element without /// moving the cursor. /// /// If the cursor is at the end of the map then `None` is returned @@ -2968,7 +2968,7 @@ impl<'a, K, V, A> CursorMut<'a, K, V, A> { Some((&*k, v)) } - /// Returns a reference to the the key and value of the previous element + /// Returns a reference to the key and value of the previous element /// without moving the cursor. /// /// If the cursor is at the start of the map then `None` is returned. @@ -3056,7 +3056,7 @@ impl<'a, K, V, A> CursorMutKey<'a, K, V, A> { } } - /// Returns a reference to the the key and value of the next element without + /// Returns a reference to the key and value of the next element without /// moving the cursor. /// /// If the cursor is at the end of the map then `None` is returned @@ -3068,7 +3068,7 @@ impl<'a, K, V, A> CursorMutKey<'a, K, V, A> { Some(kv) } - /// Returns a reference to the the key and value of the previous element + /// Returns a reference to the key and value of the previous element /// without moving the cursor. /// /// If the cursor is at the start of the map then `None` is returned. diff --git a/library/std/src/sys/pal/unix/time.rs b/library/std/src/sys/pal/unix/time.rs index f62eb828ee5d4..251a37d54dd88 100644 --- a/library/std/src/sys/pal/unix/time.rs +++ b/library/std/src/sys/pal/unix/time.rs @@ -10,7 +10,7 @@ pub const TIMESPEC_MAX: libc::timespec = // This additional constant is only used when calling // `libc::pthread_cond_timedwait`. #[cfg(target_os = "nto")] -pub(super) const TIMESPEC_MAX_CAPPED: libc::timespec = libc::timespec { +pub(in crate::sys) const TIMESPEC_MAX_CAPPED: libc::timespec = libc::timespec { tv_sec: (u64::MAX / NSEC_PER_SEC) as i64, tv_nsec: (u64::MAX % NSEC_PER_SEC) as i64, }; @@ -204,7 +204,7 @@ impl Timespec { // On QNX Neutrino, the maximum timespec for e.g. pthread_cond_timedwait // is 2^64 nanoseconds #[cfg(target_os = "nto")] - pub(super) fn to_timespec_capped(&self) -> Option { + pub(in crate::sys) fn to_timespec_capped(&self) -> Option { // Check if timeout in nanoseconds would fit into an u64 if (self.tv_nsec.0 as u64) .checked_add((self.tv_sec as u64).checked_mul(NSEC_PER_SEC)?) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 66592fe7e1010..834025c81887e 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2399,7 +2399,7 @@ impl Config { .last_modified_commit(&["src/llvm-project"], "download-ci-llvm", true) .is_none() { - // there are some untracked changes in the the given paths. + // there are some untracked changes in the given paths. false } else { llvm::is_ci_llvm_available(self, asserts) diff --git a/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md b/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md index f7a749744e0fe..56c14b1638a6f 100644 --- a/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md +++ b/src/doc/rustdoc/src/write-documentation/linking-to-items-by-name.md @@ -167,5 +167,5 @@ render differently in this case: [f]: g ``` -`1.` and `2.` will will be displayed as is in the rendered documentation (ie, `[a]` and `[b][c]`) +`1.` and `2.` will be displayed as is in the rendered documentation (ie, `[a]` and `[b][c]`) whereas `3.` and `4.` will be replaced by a link targetting `e` for `[d](e)` and `g` for `[f]`. diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.min_exhaustive_patterns.stderr b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.min_exhaustive_patterns.stderr deleted file mode 100644 index b54341f82c794..0000000000000 --- a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.min_exhaustive_patterns.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/multivariant.rs:7:46 - | -LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs index 9b3f6d046b4c0..52ed008137fce 100644 --- a/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs +++ b/tests/ui/closures/2229_closure_analysis/run_pass/multivariant.rs @@ -5,7 +5,6 @@ //@ run-pass #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![feature(never_type)] pub fn main() { diff --git a/tests/ui/lint/lint-overflowing-ops.noopt.stderr b/tests/ui/lint/lint-overflowing-ops.noopt.stderr index 265868ccc6108..f89ee8569c66f 100644 --- a/tests/ui/lint/lint-overflowing-ops.noopt.stderr +++ b/tests/ui/lint/lint-overflowing-ops.noopt.stderr @@ -13,81 +13,81 @@ LL | #![deny(arithmetic_overflow)] error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:226:15 | -LL | let _n = &(-i8::MIN); - | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:223:15 - | -LL | let _n = &(usize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:220:15 - | LL | let _n = &(isize::MAX * 5); | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:217:15 + --> $DIR/lint-overflowing-ops.rs:223:15 | LL | let _n = &(i128::MAX * 5); | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:214:15 + --> $DIR/lint-overflowing-ops.rs:220:15 | LL | let _n = &(i64::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:211:15 + --> $DIR/lint-overflowing-ops.rs:217:15 | LL | let _n = &(i32::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:208:15 + --> $DIR/lint-overflowing-ops.rs:214:15 | LL | let _n = &(i16::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:205:15 + --> $DIR/lint-overflowing-ops.rs:211:15 | LL | let _n = &(i8::MAX * i8::MAX); | ^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:202:15 + --> $DIR/lint-overflowing-ops.rs:208:15 + | +LL | let _n = &(usize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:205:15 | LL | let _n = &(u128::MAX * 5); | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:199:15 + --> $DIR/lint-overflowing-ops.rs:202:15 | LL | let _n = &(u64::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:196:15 + --> $DIR/lint-overflowing-ops.rs:199:15 | LL | let _n = &(u32::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:193:15 + --> $DIR/lint-overflowing-ops.rs:196:15 | LL | let _n = &(u16::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:190:15 + --> $DIR/lint-overflowing-ops.rs:193:15 | LL | let _n = &(u8::MAX * 5); | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:188:15 + | +LL | let _n = &(-i8::MIN); + | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:185:15 | @@ -701,83 +701,83 @@ LL | let _n = 1usize - 5; | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:189:14 + --> $DIR/lint-overflowing-ops.rs:187:14 + | +LL | let _n = -i8::MIN; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:192:14 | LL | let _n = u8::MAX * 5; | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:192:14 + --> $DIR/lint-overflowing-ops.rs:195:14 | LL | let _n = u16::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:195:14 + --> $DIR/lint-overflowing-ops.rs:198:14 | LL | let _n = u32::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:198:14 + --> $DIR/lint-overflowing-ops.rs:201:14 | LL | let _n = u64::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:201:14 + --> $DIR/lint-overflowing-ops.rs:204:14 | LL | let _n = u128::MAX * 5; | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:204:14 + --> $DIR/lint-overflowing-ops.rs:207:14 + | +LL | let _n = usize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:210:14 | LL | let _n = i8::MAX * i8::MAX; | ^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:207:14 + --> $DIR/lint-overflowing-ops.rs:213:14 | LL | let _n = i16::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:210:14 + --> $DIR/lint-overflowing-ops.rs:216:14 | LL | let _n = i32::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:213:14 + --> $DIR/lint-overflowing-ops.rs:219:14 | LL | let _n = i64::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:216:14 + --> $DIR/lint-overflowing-ops.rs:222:14 | LL | let _n = i128::MAX * 5; | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:219:14 + --> $DIR/lint-overflowing-ops.rs:225:14 | LL | let _n = isize::MAX * 5; | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:222:14 - | -LL | let _n = usize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:225:14 - | -LL | let _n = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:230:14 | @@ -843,386 +843,531 @@ LL | let _n = &(1u128 / 0); error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:245:14 | +LL | let _n = 1usize / 0; + | ^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:246:15 + | +LL | let _n = &(1usize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:248:14 + | LL | let _n = 1i8 / 0; | ^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:246:15 + --> $DIR/lint-overflowing-ops.rs:249:15 | LL | let _n = &(1i8 / 0); | ^^^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:248:14 + --> $DIR/lint-overflowing-ops.rs:250:14 + | +LL | let _n = i8::MIN / -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:251:14 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:254:14 | LL | let _n = 1i16 / 0; | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:249:15 + --> $DIR/lint-overflowing-ops.rs:255:15 | LL | let _n = &(1i16 / 0); | ^^^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:251:14 + --> $DIR/lint-overflowing-ops.rs:256:14 + | +LL | let _n = i16::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:260:14 | LL | let _n = 1i32 / 0; | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:252:15 + --> $DIR/lint-overflowing-ops.rs:261:15 | LL | let _n = &(1i32 / 0); | ^^^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:254:14 + --> $DIR/lint-overflowing-ops.rs:262:14 + | +LL | let _n = i32::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:266:14 | LL | let _n = 1i64 / 0; | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:255:15 + --> $DIR/lint-overflowing-ops.rs:267:15 | LL | let _n = &(1i64 / 0); | ^^^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:257:14 + --> $DIR/lint-overflowing-ops.rs:268:14 + | +LL | let _n = i64::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:272:14 | LL | let _n = 1i128 / 0; | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:258:15 + --> $DIR/lint-overflowing-ops.rs:273:15 | LL | let _n = &(1i128 / 0); | ^^^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:260:14 + --> $DIR/lint-overflowing-ops.rs:274:14 + | +LL | let _n = i128::MIN / -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:278:14 | LL | let _n = 1isize / 0; | ^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:261:15 + --> $DIR/lint-overflowing-ops.rs:279:15 | LL | let _n = &(1isize / 0); | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:263:14 + --> $DIR/lint-overflowing-ops.rs:280:14 | -LL | let _n = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = isize::MIN / -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:264:15 + --> $DIR/lint-overflowing-ops.rs:281:15 | -LL | let _n = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:281:15 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:268:14 + --> $DIR/lint-overflowing-ops.rs:286:14 | LL | let _n = 1u8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:269:15 + --> $DIR/lint-overflowing-ops.rs:287:15 | LL | let _n = &(1u8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:271:14 + --> $DIR/lint-overflowing-ops.rs:289:14 | LL | let _n = 1u16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:272:15 + --> $DIR/lint-overflowing-ops.rs:290:15 | LL | let _n = &(1u16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:274:14 + --> $DIR/lint-overflowing-ops.rs:292:14 | LL | let _n = 1u32 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:275:15 + --> $DIR/lint-overflowing-ops.rs:293:15 | LL | let _n = &(1u32 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:277:14 + --> $DIR/lint-overflowing-ops.rs:295:14 | LL | let _n = 1u64 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:278:15 + --> $DIR/lint-overflowing-ops.rs:296:15 | LL | let _n = &(1u64 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:280:14 + --> $DIR/lint-overflowing-ops.rs:298:14 | LL | let _n = 1u128 % 0; | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:281:15 + --> $DIR/lint-overflowing-ops.rs:299:15 | LL | let _n = &(1u128 % 0); | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:283:14 + --> $DIR/lint-overflowing-ops.rs:301:14 | -LL | let _n = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = 1usize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:284:15 + --> $DIR/lint-overflowing-ops.rs:302:15 | -LL | let _n = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = &(1usize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:286:14 + --> $DIR/lint-overflowing-ops.rs:304:14 | -LL | let _n = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = 1i8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:287:15 + --> $DIR/lint-overflowing-ops.rs:305:15 | -LL | let _n = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = &(1i8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:289:14 + --> $DIR/lint-overflowing-ops.rs:306:14 | -LL | let _n = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = i8::MIN % -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:290:15 + --> $DIR/lint-overflowing-ops.rs:307:15 | -LL | let _n = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:292:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:307:15 | -LL | let _n = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:293:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:307:14 | -LL | let _n = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:295:14 + --> $DIR/lint-overflowing-ops.rs:310:14 | -LL | let _n = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = 1i16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:296:15 + --> $DIR/lint-overflowing-ops.rs:311:15 | -LL | let _n = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = &(1i16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:298:14 + --> $DIR/lint-overflowing-ops.rs:312:14 | -LL | let _n = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = i16::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:299:15 + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:301:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:302:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:313:14 | -LL | let _n = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:306:14 + --> $DIR/lint-overflowing-ops.rs:316:14 | -LL | let _n = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +LL | let _n = 1i32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:307:15 + --> $DIR/lint-overflowing-ops.rs:317:15 | -LL | let _n = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +LL | let _n = &(1i32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:311:36 + --> $DIR/lint-overflowing-ops.rs:318:14 | -LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow +LL | let _n = i32::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:313:36 + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:315:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:317:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:319:14 | -LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:319:36 + --> $DIR/lint-overflowing-ops.rs:322:14 | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow +LL | let _n = 1i64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:321:36 + --> $DIR/lint-overflowing-ops.rs:323:15 | -LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow +LL | let _n = &(1i64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:323:36 + --> $DIR/lint-overflowing-ops.rs:324:14 | -LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to divide `1_isize` by zero +LL | let _n = i64::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:325:36 + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - | ^^^^^^^ attempt to divide `1_i8` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:327:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i16` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:329:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:325:14 | -LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i32` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:331:36 + --> $DIR/lint-overflowing-ops.rs:328:14 | -LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i64` by zero +LL | let _n = 1i128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:333:36 + --> $DIR/lint-overflowing-ops.rs:329:15 | -LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - | ^^^^^^^^^ attempt to divide `1_i128` by zero +LL | let _n = &(1i128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:335:36 + --> $DIR/lint-overflowing-ops.rs:330:14 | -LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow +LL | let _n = i128::MIN % -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:337:36 + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:339:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:341:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:331:14 | -LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:343:36 + --> $DIR/lint-overflowing-ops.rs:334:14 | -LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow +LL | let _n = 1isize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:345:36 + --> $DIR/lint-overflowing-ops.rs:335:15 | -LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow +LL | let _n = &(1isize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:347:36 + --> $DIR/lint-overflowing-ops.rs:336:14 | -LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = isize::MIN % -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:349:36 + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:351:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:353:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:337:14 | -LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:355:36 + --> $DIR/lint-overflowing-ops.rs:341:14 | -LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = [1, 2, 3][4]; + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:357:36 + --> $DIR/lint-overflowing-ops.rs:342:15 | -LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -error: aborting due to 203 previous errors +error: aborting due to 215 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/lint/lint-overflowing-ops.opt.stderr b/tests/ui/lint/lint-overflowing-ops.opt.stderr index 265868ccc6108..7ac5c4e0d76ff 100644 --- a/tests/ui/lint/lint-overflowing-ops.opt.stderr +++ b/tests/ui/lint/lint-overflowing-ops.opt.stderr @@ -13,81 +13,81 @@ LL | #![deny(arithmetic_overflow)] error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:226:15 | -LL | let _n = &(-i8::MIN); - | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:223:15 - | -LL | let _n = &(usize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:220:15 - | LL | let _n = &(isize::MAX * 5); | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:217:15 + --> $DIR/lint-overflowing-ops.rs:223:15 | LL | let _n = &(i128::MAX * 5); | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:214:15 + --> $DIR/lint-overflowing-ops.rs:220:15 | LL | let _n = &(i64::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:211:15 + --> $DIR/lint-overflowing-ops.rs:217:15 | LL | let _n = &(i32::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:208:15 + --> $DIR/lint-overflowing-ops.rs:214:15 | LL | let _n = &(i16::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:205:15 + --> $DIR/lint-overflowing-ops.rs:211:15 | LL | let _n = &(i8::MAX * i8::MAX); | ^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:202:15 + --> $DIR/lint-overflowing-ops.rs:208:15 + | +LL | let _n = &(usize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:205:15 | LL | let _n = &(u128::MAX * 5); | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:199:15 + --> $DIR/lint-overflowing-ops.rs:202:15 | LL | let _n = &(u64::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:196:15 + --> $DIR/lint-overflowing-ops.rs:199:15 | LL | let _n = &(u32::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:193:15 + --> $DIR/lint-overflowing-ops.rs:196:15 | LL | let _n = &(u16::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:190:15 + --> $DIR/lint-overflowing-ops.rs:193:15 | LL | let _n = &(u8::MAX * 5); | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:188:15 + | +LL | let _n = &(-i8::MIN); + | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:185:15 | @@ -701,83 +701,83 @@ LL | let _n = 1usize - 5; | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:189:14 + --> $DIR/lint-overflowing-ops.rs:187:14 + | +LL | let _n = -i8::MIN; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:192:14 | LL | let _n = u8::MAX * 5; | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:192:14 + --> $DIR/lint-overflowing-ops.rs:195:14 | LL | let _n = u16::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:195:14 + --> $DIR/lint-overflowing-ops.rs:198:14 | LL | let _n = u32::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:198:14 + --> $DIR/lint-overflowing-ops.rs:201:14 | LL | let _n = u64::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:201:14 + --> $DIR/lint-overflowing-ops.rs:204:14 | LL | let _n = u128::MAX * 5; | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:204:14 + --> $DIR/lint-overflowing-ops.rs:207:14 + | +LL | let _n = usize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:210:14 | LL | let _n = i8::MAX * i8::MAX; | ^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:207:14 + --> $DIR/lint-overflowing-ops.rs:213:14 | LL | let _n = i16::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:210:14 + --> $DIR/lint-overflowing-ops.rs:216:14 | LL | let _n = i32::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:213:14 + --> $DIR/lint-overflowing-ops.rs:219:14 | LL | let _n = i64::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:216:14 + --> $DIR/lint-overflowing-ops.rs:222:14 | LL | let _n = i128::MAX * 5; | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:219:14 + --> $DIR/lint-overflowing-ops.rs:225:14 | LL | let _n = isize::MAX * 5; | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:222:14 - | -LL | let _n = usize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:225:14 - | -LL | let _n = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:230:14 | @@ -843,386 +843,627 @@ LL | let _n = &(1u128 / 0); error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:245:14 | +LL | let _n = 1usize / 0; + | ^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:246:15 + | +LL | let _n = &(1usize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:248:14 + | LL | let _n = 1i8 / 0; | ^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:246:15 + --> $DIR/lint-overflowing-ops.rs:249:15 | LL | let _n = &(1i8 / 0); | ^^^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:248:14 + --> $DIR/lint-overflowing-ops.rs:250:14 + | +LL | let _n = i8::MIN / -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:251:14 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:251:14 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:254:14 | LL | let _n = 1i16 / 0; | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:249:15 + --> $DIR/lint-overflowing-ops.rs:255:15 | LL | let _n = &(1i16 / 0); | ^^^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:251:14 + --> $DIR/lint-overflowing-ops.rs:256:14 + | +LL | let _n = i16::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:260:14 | LL | let _n = 1i32 / 0; | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:252:15 + --> $DIR/lint-overflowing-ops.rs:261:15 | LL | let _n = &(1i32 / 0); | ^^^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:254:14 + --> $DIR/lint-overflowing-ops.rs:262:14 + | +LL | let _n = i32::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:266:14 | LL | let _n = 1i64 / 0; | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:255:15 + --> $DIR/lint-overflowing-ops.rs:267:15 | LL | let _n = &(1i64 / 0); | ^^^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:257:14 + --> $DIR/lint-overflowing-ops.rs:268:14 + | +LL | let _n = i64::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:272:14 | LL | let _n = 1i128 / 0; | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:258:15 + --> $DIR/lint-overflowing-ops.rs:273:15 | LL | let _n = &(1i128 / 0); | ^^^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:260:14 + --> $DIR/lint-overflowing-ops.rs:274:14 + | +LL | let _n = i128::MIN / -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:278:14 | LL | let _n = 1isize / 0; | ^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:261:15 + --> $DIR/lint-overflowing-ops.rs:279:15 | LL | let _n = &(1isize / 0); | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:263:14 + --> $DIR/lint-overflowing-ops.rs:280:14 | -LL | let _n = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = isize::MIN / -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:264:15 + --> $DIR/lint-overflowing-ops.rs:281:15 | -LL | let _n = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:281:15 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:268:14 + --> $DIR/lint-overflowing-ops.rs:286:14 | LL | let _n = 1u8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:269:15 + --> $DIR/lint-overflowing-ops.rs:287:15 | LL | let _n = &(1u8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:271:14 + --> $DIR/lint-overflowing-ops.rs:289:14 | LL | let _n = 1u16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:272:15 + --> $DIR/lint-overflowing-ops.rs:290:15 | LL | let _n = &(1u16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:274:14 + --> $DIR/lint-overflowing-ops.rs:292:14 | LL | let _n = 1u32 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:275:15 + --> $DIR/lint-overflowing-ops.rs:293:15 | LL | let _n = &(1u32 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:277:14 + --> $DIR/lint-overflowing-ops.rs:295:14 | LL | let _n = 1u64 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:278:15 + --> $DIR/lint-overflowing-ops.rs:296:15 | LL | let _n = &(1u64 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:280:14 + --> $DIR/lint-overflowing-ops.rs:298:14 | LL | let _n = 1u128 % 0; | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:281:15 + --> $DIR/lint-overflowing-ops.rs:299:15 | LL | let _n = &(1u128 % 0); | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:283:14 + --> $DIR/lint-overflowing-ops.rs:301:14 + | +LL | let _n = 1usize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:302:15 + | +LL | let _n = &(1usize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:304:14 | LL | let _n = 1i8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:284:15 + --> $DIR/lint-overflowing-ops.rs:305:15 | LL | let _n = &(1i8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:286:14 + --> $DIR/lint-overflowing-ops.rs:306:14 + | +LL | let _n = i8::MIN % -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:307:15 + | +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:307:15 + | +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:307:14 + | +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:307:14 + | +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:310:14 | LL | let _n = 1i16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:287:15 + --> $DIR/lint-overflowing-ops.rs:311:15 | LL | let _n = &(1i16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:289:14 + --> $DIR/lint-overflowing-ops.rs:312:14 | -LL | let _n = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = i16::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:290:15 + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:292:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:293:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:313:14 | -LL | let _n = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:295:14 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:313:14 | -LL | let _n = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero - -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:296:15 +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^^ | -LL | let _n = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:298:14 + --> $DIR/lint-overflowing-ops.rs:316:14 | -LL | let _n = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = 1i32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:299:15 + --> $DIR/lint-overflowing-ops.rs:317:15 | -LL | let _n = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = &(1i32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:301:14 + --> $DIR/lint-overflowing-ops.rs:318:14 | -LL | let _n = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = i32::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:302:15 + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | let _n = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:306:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | let _n = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:307:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:319:14 | -LL | let _n = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:311:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:319:14 + | +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^^ | -LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:313:36 + --> $DIR/lint-overflowing-ops.rs:322:14 | -LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow +LL | let _n = 1i64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:315:36 + --> $DIR/lint-overflowing-ops.rs:323:15 | -LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow +LL | let _n = &(1i64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:317:36 + --> $DIR/lint-overflowing-ops.rs:324:14 | -LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow +LL | let _n = i64::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:319:36 + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:321:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:323:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:325:14 | -LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to divide `1_isize` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:325:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:325:14 + | +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^^ | -LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - | ^^^^^^^ attempt to divide `1_i8` by zero + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:327:36 + --> $DIR/lint-overflowing-ops.rs:328:14 | -LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i16` by zero +LL | let _n = 1i128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:329:36 + --> $DIR/lint-overflowing-ops.rs:329:15 | -LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i32` by zero +LL | let _n = &(1i128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:331:36 + --> $DIR/lint-overflowing-ops.rs:330:14 | -LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i64` by zero +LL | let _n = i128::MIN % -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:333:36 + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - | ^^^^^^^^^ attempt to divide `1_i128` by zero +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:335:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:337:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:331:14 | -LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:339:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:331:14 + | +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^^ | -LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:341:36 + --> $DIR/lint-overflowing-ops.rs:334:14 | -LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow +LL | let _n = 1isize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:343:36 + --> $DIR/lint-overflowing-ops.rs:335:15 | -LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow +LL | let _n = &(1isize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:345:36 + --> $DIR/lint-overflowing-ops.rs:336:14 | -LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow +LL | let _n = isize::MIN % -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:347:36 + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:349:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:351:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:337:14 | -LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^^ -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:353:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:337:14 | -LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:355:36 + --> $DIR/lint-overflowing-ops.rs:341:14 | -LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = [1, 2, 3][4]; + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:357:36 + --> $DIR/lint-overflowing-ops.rs:342:15 | -LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -error: aborting due to 203 previous errors +error: aborting due to 215 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr b/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr index 265868ccc6108..f89ee8569c66f 100644 --- a/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr +++ b/tests/ui/lint/lint-overflowing-ops.opt_with_overflow_checks.stderr @@ -13,81 +13,81 @@ LL | #![deny(arithmetic_overflow)] error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:226:15 | -LL | let _n = &(-i8::MIN); - | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:223:15 - | -LL | let _n = &(usize::MAX * 5); - | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:220:15 - | LL | let _n = &(isize::MAX * 5); | ^^^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:217:15 + --> $DIR/lint-overflowing-ops.rs:223:15 | LL | let _n = &(i128::MAX * 5); | ^^^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:214:15 + --> $DIR/lint-overflowing-ops.rs:220:15 | LL | let _n = &(i64::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:211:15 + --> $DIR/lint-overflowing-ops.rs:217:15 | LL | let _n = &(i32::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:208:15 + --> $DIR/lint-overflowing-ops.rs:214:15 | LL | let _n = &(i16::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:205:15 + --> $DIR/lint-overflowing-ops.rs:211:15 | LL | let _n = &(i8::MAX * i8::MAX); | ^^^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:202:15 + --> $DIR/lint-overflowing-ops.rs:208:15 + | +LL | let _n = &(usize::MAX * 5); + | ^^^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:205:15 | LL | let _n = &(u128::MAX * 5); | ^^^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:199:15 + --> $DIR/lint-overflowing-ops.rs:202:15 | LL | let _n = &(u64::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:196:15 + --> $DIR/lint-overflowing-ops.rs:199:15 | LL | let _n = &(u32::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:193:15 + --> $DIR/lint-overflowing-ops.rs:196:15 | LL | let _n = &(u16::MAX * 5); | ^^^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:190:15 + --> $DIR/lint-overflowing-ops.rs:193:15 | LL | let _n = &(u8::MAX * 5); | ^^^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:188:15 + | +LL | let _n = &(-i8::MIN); + | ^^^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + error: this arithmetic operation will overflow --> $DIR/lint-overflowing-ops.rs:185:15 | @@ -701,83 +701,83 @@ LL | let _n = 1usize - 5; | ^^^^^^^^^^ attempt to compute `1_usize - 5_usize`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:189:14 + --> $DIR/lint-overflowing-ops.rs:187:14 + | +LL | let _n = -i8::MIN; + | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:192:14 | LL | let _n = u8::MAX * 5; | ^^^^^^^^^^^ attempt to compute `u8::MAX * 5_u8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:192:14 + --> $DIR/lint-overflowing-ops.rs:195:14 | LL | let _n = u16::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 5_u16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:195:14 + --> $DIR/lint-overflowing-ops.rs:198:14 | LL | let _n = u32::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 5_u32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:198:14 + --> $DIR/lint-overflowing-ops.rs:201:14 | LL | let _n = u64::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 5_u64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:201:14 + --> $DIR/lint-overflowing-ops.rs:204:14 | LL | let _n = u128::MAX * 5; | ^^^^^^^^^^^^^ attempt to compute `u128::MAX * 5_u128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:204:14 + --> $DIR/lint-overflowing-ops.rs:207:14 + | +LL | let _n = usize::MAX * 5; + | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow + +error: this arithmetic operation will overflow + --> $DIR/lint-overflowing-ops.rs:210:14 | LL | let _n = i8::MAX * i8::MAX; | ^^^^^^^^^^^^^^^^^ attempt to compute `i8::MAX * i8::MAX`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:207:14 + --> $DIR/lint-overflowing-ops.rs:213:14 | LL | let _n = i16::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `i16::MAX * 5_i16`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:210:14 + --> $DIR/lint-overflowing-ops.rs:216:14 | LL | let _n = i32::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `i32::MAX * 5_i32`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:213:14 + --> $DIR/lint-overflowing-ops.rs:219:14 | LL | let _n = i64::MAX * 5; | ^^^^^^^^^^^^ attempt to compute `i64::MAX * 5_i64`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:216:14 + --> $DIR/lint-overflowing-ops.rs:222:14 | LL | let _n = i128::MAX * 5; | ^^^^^^^^^^^^^ attempt to compute `i128::MAX * 5_i128`, which would overflow error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:219:14 + --> $DIR/lint-overflowing-ops.rs:225:14 | LL | let _n = isize::MAX * 5; | ^^^^^^^^^^^^^^ attempt to compute `isize::MAX * 5_isize`, which would overflow -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:222:14 - | -LL | let _n = usize::MAX * 5; - | ^^^^^^^^^^^^^^ attempt to compute `usize::MAX * 5_usize`, which would overflow - -error: this arithmetic operation will overflow - --> $DIR/lint-overflowing-ops.rs:225:14 - | -LL | let _n = -i8::MIN; - | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow - error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:230:14 | @@ -843,386 +843,531 @@ LL | let _n = &(1u128 / 0); error: this operation will panic at runtime --> $DIR/lint-overflowing-ops.rs:245:14 | +LL | let _n = 1usize / 0; + | ^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:246:15 + | +LL | let _n = &(1usize / 0); + | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:248:14 + | LL | let _n = 1i8 / 0; | ^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:246:15 + --> $DIR/lint-overflowing-ops.rs:249:15 | LL | let _n = &(1i8 / 0); | ^^^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:248:14 + --> $DIR/lint-overflowing-ops.rs:250:14 + | +LL | let _n = i8::MIN / -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:251:15 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:251:14 + | +LL | let _n = &(i8::MIN / -1); + | ^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:254:14 | LL | let _n = 1i16 / 0; | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:249:15 + --> $DIR/lint-overflowing-ops.rs:255:15 | LL | let _n = &(1i16 / 0); | ^^^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:251:14 + --> $DIR/lint-overflowing-ops.rs:256:14 + | +LL | let _n = i16::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:257:15 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:257:14 + | +LL | let _n = &(i16::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:260:14 | LL | let _n = 1i32 / 0; | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:252:15 + --> $DIR/lint-overflowing-ops.rs:261:15 | LL | let _n = &(1i32 / 0); | ^^^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:254:14 + --> $DIR/lint-overflowing-ops.rs:262:14 + | +LL | let _n = i32::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:263:15 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:263:14 + | +LL | let _n = &(i32::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:266:14 | LL | let _n = 1i64 / 0; | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:255:15 + --> $DIR/lint-overflowing-ops.rs:267:15 | LL | let _n = &(1i64 / 0); | ^^^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:257:14 + --> $DIR/lint-overflowing-ops.rs:268:14 + | +LL | let _n = i64::MIN / -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:269:15 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:269:14 + | +LL | let _n = &(i64::MIN / -1); + | ^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:272:14 | LL | let _n = 1i128 / 0; | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:258:15 + --> $DIR/lint-overflowing-ops.rs:273:15 | LL | let _n = &(1i128 / 0); | ^^^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:260:14 + --> $DIR/lint-overflowing-ops.rs:274:14 + | +LL | let _n = i128::MIN / -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:275:15 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:275:14 + | +LL | let _n = &(i128::MIN / -1); + | ^^^^^^^^^^^^^^^^^ + +error: this operation will panic at runtime + --> $DIR/lint-overflowing-ops.rs:278:14 | LL | let _n = 1isize / 0; | ^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:261:15 + --> $DIR/lint-overflowing-ops.rs:279:15 | LL | let _n = &(1isize / 0); | ^^^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:263:14 + --> $DIR/lint-overflowing-ops.rs:280:14 | -LL | let _n = 1usize / 0; - | ^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = isize::MIN / -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:264:15 + --> $DIR/lint-overflowing-ops.rs:281:15 | -LL | let _n = &(1usize / 0); - | ^^^^^^^^^^^^ attempt to divide `1_usize` by zero +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow + +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:281:15 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:281:14 + | +LL | let _n = &(isize::MIN / -1); + | ^^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:268:14 + --> $DIR/lint-overflowing-ops.rs:286:14 | LL | let _n = 1u8 % 0; | ^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:269:15 + --> $DIR/lint-overflowing-ops.rs:287:15 | LL | let _n = &(1u8 % 0); | ^^^^^^^^^ attempt to calculate the remainder of `1_u8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:271:14 + --> $DIR/lint-overflowing-ops.rs:289:14 | LL | let _n = 1u16 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:272:15 + --> $DIR/lint-overflowing-ops.rs:290:15 | LL | let _n = &(1u16 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:274:14 + --> $DIR/lint-overflowing-ops.rs:292:14 | LL | let _n = 1u32 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:275:15 + --> $DIR/lint-overflowing-ops.rs:293:15 | LL | let _n = &(1u32 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:277:14 + --> $DIR/lint-overflowing-ops.rs:295:14 | LL | let _n = 1u64 % 0; | ^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:278:15 + --> $DIR/lint-overflowing-ops.rs:296:15 | LL | let _n = &(1u64 % 0); | ^^^^^^^^^^ attempt to calculate the remainder of `1_u64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:280:14 + --> $DIR/lint-overflowing-ops.rs:298:14 | LL | let _n = 1u128 % 0; | ^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:281:15 + --> $DIR/lint-overflowing-ops.rs:299:15 | LL | let _n = &(1u128 % 0); | ^^^^^^^^^^^ attempt to calculate the remainder of `1_u128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:283:14 + --> $DIR/lint-overflowing-ops.rs:301:14 | -LL | let _n = 1i8 % 0; - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = 1usize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:284:15 + --> $DIR/lint-overflowing-ops.rs:302:15 | -LL | let _n = &(1i8 % 0); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = &(1usize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:286:14 + --> $DIR/lint-overflowing-ops.rs:304:14 | -LL | let _n = 1i16 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = 1i8 % 0; + | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:287:15 + --> $DIR/lint-overflowing-ops.rs:305:15 | -LL | let _n = &(1i16 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = &(1i8 % 0); + | ^^^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:289:14 + --> $DIR/lint-overflowing-ops.rs:306:14 | -LL | let _n = 1i32 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = i8::MIN % -1; + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:290:15 + --> $DIR/lint-overflowing-ops.rs:307:15 | -LL | let _n = &(1i32 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:292:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:307:15 | -LL | let _n = 1i64 % 0; - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:293:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:307:14 | -LL | let _n = &(1i64 % 0); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = &(i8::MIN % -1); + | ^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:295:14 + --> $DIR/lint-overflowing-ops.rs:310:14 | -LL | let _n = 1i128 % 0; - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = 1i16 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:296:15 + --> $DIR/lint-overflowing-ops.rs:311:15 | -LL | let _n = &(1i128 % 0); - | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = &(1i16 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:298:14 + --> $DIR/lint-overflowing-ops.rs:312:14 | -LL | let _n = 1isize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = i16::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:299:15 + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = &(1isize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:301:14 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:313:15 | -LL | let _n = 1usize % 0; - | ^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:302:15 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:313:14 | -LL | let _n = &(1usize % 0); - | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_usize` with a divisor of zero +LL | let _n = &(i16::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:306:14 + --> $DIR/lint-overflowing-ops.rs:316:14 | -LL | let _n = [1, 2, 3][4]; - | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +LL | let _n = 1i32 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:307:15 + --> $DIR/lint-overflowing-ops.rs:317:15 | -LL | let _n = &([1, 2, 3][4]); - | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 +LL | let _n = &(1i32 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:311:36 + --> $DIR/lint-overflowing-ops.rs:318:14 | -LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow +LL | let _n = i32::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:313:36 + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:315:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:319:15 | -LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:317:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:319:14 | -LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow +LL | let _n = &(i32::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:319:36 + --> $DIR/lint-overflowing-ops.rs:322:14 | -LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow +LL | let _n = 1i64 % 0; + | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:321:36 + --> $DIR/lint-overflowing-ops.rs:323:15 | -LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow +LL | let _n = &(1i64 % 0); + | ^^^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:323:36 + --> $DIR/lint-overflowing-ops.rs:324:14 | -LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to divide `1_isize` by zero +LL | let _n = i64::MIN % -1; + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:325:36 + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - | ^^^^^^^ attempt to divide `1_i8` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:327:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:325:15 | -LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i16` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:329:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:325:14 | -LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i32` by zero +LL | let _n = &(i64::MIN % -1); + | ^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:331:36 + --> $DIR/lint-overflowing-ops.rs:328:14 | -LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - | ^^^^^^^^ attempt to divide `1_i64` by zero +LL | let _n = 1i128 % 0; + | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:333:36 + --> $DIR/lint-overflowing-ops.rs:329:15 | -LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - | ^^^^^^^^^ attempt to divide `1_i128` by zero +LL | let _n = &(1i128 % 0); + | ^^^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:335:36 + --> $DIR/lint-overflowing-ops.rs:330:14 | -LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow +LL | let _n = i128::MIN % -1; + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:337:36 + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:339:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:331:15 | -LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:341:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:331:14 | -LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow +LL | let _n = &(i128::MIN % -1); + | ^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:343:36 + --> $DIR/lint-overflowing-ops.rs:334:14 | -LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow +LL | let _n = 1isize % 0; + | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:345:36 + --> $DIR/lint-overflowing-ops.rs:335:15 | -LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow +LL | let _n = &(1isize % 0); + | ^^^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:347:36 + --> $DIR/lint-overflowing-ops.rs:336:14 | -LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero +LL | let _n = isize::MIN % -1; + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:349:36 + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:351:36 +error[E0080]: evaluation of constant value failed + --> $DIR/lint-overflowing-ops.rs:337:15 | -LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) -error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:353:36 +note: erroneous constant encountered + --> $DIR/lint-overflowing-ops.rs:337:14 | -LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero +LL | let _n = &(isize::MIN % -1); + | ^^^^^^^^^^^^^^^^^^ error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:355:36 + --> $DIR/lint-overflowing-ops.rs:341:14 | -LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero +LL | let _n = [1, 2, 3][4]; + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 error: this operation will panic at runtime - --> $DIR/lint-overflowing-ops.rs:357:36 + --> $DIR/lint-overflowing-ops.rs:342:15 | -LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero +LL | let _n = &([1, 2, 3][4]); + | ^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 -error: aborting due to 203 previous errors +error: aborting due to 215 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/lint/lint-overflowing-ops.rs b/tests/ui/lint/lint-overflowing-ops.rs index 5305677d166c1..4ef99f6c5fa18 100644 --- a/tests/ui/lint/lint-overflowing-ops.rs +++ b/tests/ui/lint/lint-overflowing-ops.rs @@ -184,6 +184,9 @@ fn main() { let _n = 1usize - 5; //~ ERROR: arithmetic operation will overflow let _n = &(1usize - 5); //~ ERROR: arithmetic operation will overflow + let _n = -i8::MIN; //~ ERROR this arithmetic operation will overflow + let _n = &(-i8::MIN); //~ ERROR this arithmetic operation will overflow + // Multiplication let _n = u8::MAX * 5; //~ ERROR: arithmetic operation will overflow @@ -201,6 +204,9 @@ fn main() { let _n = u128::MAX * 5; //~ ERROR: arithmetic operation will overflow let _n = &(u128::MAX * 5); //~ ERROR: arithmetic operation will overflow + let _n = usize::MAX * 5; //~ ERROR: arithmetic operation will overflow + let _n = &(usize::MAX * 5); //~ ERROR: arithmetic operation will overflow + let _n = i8::MAX * i8::MAX; //~ ERROR: arithmetic operation will overflow let _n = &(i8::MAX * i8::MAX); //~ ERROR: arithmetic operation will overflow @@ -219,12 +225,6 @@ fn main() { let _n = isize::MAX * 5; //~ ERROR: arithmetic operation will overflow let _n = &(isize::MAX * 5); //~ ERROR: arithmetic operation will overflow - let _n = usize::MAX * 5; //~ ERROR: arithmetic operation will overflow - let _n = &(usize::MAX * 5); //~ ERROR: arithmetic operation will overflow - - let _n = -i8::MIN; //~ ERROR this arithmetic operation will overflow - let _n = &(-i8::MIN); //~ ERROR this arithmetic operation will overflow - // Division let _n = 1u8 / 0; //~ ERROR: this operation will panic at runtime @@ -242,26 +242,44 @@ fn main() { let _n = 1u128 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1u128 / 0); //~ ERROR: this operation will panic at runtime + let _n = 1usize / 0; //~ ERROR: this operation will panic at runtime + let _n = &(1usize / 0); //~ ERROR: this operation will panic at runtime + let _n = 1i8 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i8 / 0); //~ ERROR: this operation will panic at runtime + let _n = i8::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i8::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i16 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i16 / 0); //~ ERROR: this operation will panic at runtime + let _n = i16::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i16::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i32 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i32 / 0); //~ ERROR: this operation will panic at runtime + let _n = i32::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i32::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i64 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i64 / 0); //~ ERROR: this operation will panic at runtime + let _n = i64::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i64::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i128 / 0; //~ ERROR: this operation will panic at runtime let _n = &(1i128 / 0); //~ ERROR: this operation will panic at runtime + let _n = i128::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(i128::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1isize / 0; //~ ERROR: this operation will panic at runtime let _n = &(1isize / 0); //~ ERROR: this operation will panic at runtime - - let _n = 1usize / 0; //~ ERROR: this operation will panic at runtime - let _n = &(1usize / 0); //~ ERROR: this operation will panic at runtime + let _n = isize::MIN / -1; //~ ERROR: this operation will panic at runtime + let _n = &(isize::MIN / -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed // Modulus @@ -280,80 +298,46 @@ fn main() { let _n = 1u128 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1u128 % 0); //~ ERROR: this operation will panic at runtime + let _n = 1usize % 0; //~ ERROR: this operation will panic at runtime + let _n = &(1usize % 0); //~ ERROR: this operation will panic at runtime + let _n = 1i8 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i8 % 0); //~ ERROR: this operation will panic at runtime + let _n = i8::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i8::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i16 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i16 % 0); //~ ERROR: this operation will panic at runtime + let _n = i16::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i16::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i32 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i32 % 0); //~ ERROR: this operation will panic at runtime + let _n = i32::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i32::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i64 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i64 % 0); //~ ERROR: this operation will panic at runtime + let _n = i64::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i64::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1i128 % 0; //~ ERROR: this operation will panic at runtime let _n = &(1i128 % 0); //~ ERROR: this operation will panic at runtime + let _n = i128::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(i128::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed let _n = 1isize % 0; //~ ERROR: this operation will panic at runtime let _n = &(1isize % 0); //~ ERROR: this operation will panic at runtime - - let _n = 1usize % 0; //~ ERROR: this operation will panic at runtime - let _n = &(1usize % 0); //~ ERROR: this operation will panic at runtime - + let _n = isize::MIN % -1; //~ ERROR: this operation will panic at runtime + let _n = &(isize::MIN % -1); //~ ERROR: this operation will panic at runtime + //~^ERROR: evaluation of constant value failed // Out of bounds access let _n = [1, 2, 3][4]; //~ ERROR: this operation will panic at runtime let _n = &([1, 2, 3][4]); //~ ERROR: this operation will panic at runtime - - - // issue-8460-const - assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); - //~^ ERROR operation will panic - assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); - //~^ ERROR operation will panic } diff --git a/tests/ui/pattern/usefulness/always-inhabited-union-ref.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/always-inhabited-union-ref.exhaustive_patterns.stderr index 553daff2d969d..d6304a0b997d3 100644 --- a/tests/ui/pattern/usefulness/always-inhabited-union-ref.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/always-inhabited-union-ref.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/always-inhabited-union-ref.rs:26:11 + --> $DIR/always-inhabited-union-ref.rs:25:11 | LL | match uninhab_ref() { | ^^^^^^^^^^^^^ @@ -14,13 +14,13 @@ LL + } | error[E0004]: non-exhaustive patterns: type `Foo` is non-empty - --> $DIR/always-inhabited-union-ref.rs:30:11 + --> $DIR/always-inhabited-union-ref.rs:29:11 | LL | match uninhab_union() { | ^^^^^^^^^^^^^^^ | note: `Foo` defined here - --> $DIR/always-inhabited-union-ref.rs:13:11 + --> $DIR/always-inhabited-union-ref.rs:12:11 | LL | pub union Foo { | ^^^ diff --git a/tests/ui/pattern/usefulness/always-inhabited-union-ref.min_exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/always-inhabited-union-ref.min_exhaustive_patterns.stderr index a1d8002c64895..d6304a0b997d3 100644 --- a/tests/ui/pattern/usefulness/always-inhabited-union-ref.min_exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/always-inhabited-union-ref.min_exhaustive_patterns.stderr @@ -1,14 +1,5 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/always-inhabited-union-ref.rs:7:46 - | -LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/always-inhabited-union-ref.rs:26:11 + --> $DIR/always-inhabited-union-ref.rs:25:11 | LL | match uninhab_ref() { | ^^^^^^^^^^^^^ @@ -23,13 +14,13 @@ LL + } | error[E0004]: non-exhaustive patterns: type `Foo` is non-empty - --> $DIR/always-inhabited-union-ref.rs:30:11 + --> $DIR/always-inhabited-union-ref.rs:29:11 | LL | match uninhab_union() { | ^^^^^^^^^^^^^^^ | note: `Foo` defined here - --> $DIR/always-inhabited-union-ref.rs:13:11 + --> $DIR/always-inhabited-union-ref.rs:12:11 | LL | pub union Foo { | ^^^ @@ -41,6 +32,6 @@ LL + _ => todo!(), LL + } | -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/always-inhabited-union-ref.rs b/tests/ui/pattern/usefulness/always-inhabited-union-ref.rs index c951cb567fcb7..5088098d0ae3a 100644 --- a/tests/ui/pattern/usefulness/always-inhabited-union-ref.rs +++ b/tests/ui/pattern/usefulness/always-inhabited-union-ref.rs @@ -5,7 +5,6 @@ #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![feature(never_type)] #![allow(dead_code)] #![allow(unreachable_code)] diff --git a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr index 0c55164a780b5..98c66c9dd0711 100644 --- a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr @@ -1,23 +1,23 @@ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:49:9 | LL | _ => {} | ^ | note: the lint level is defined here - --> $DIR/empty-types.rs:16:9 + --> $DIR/empty-types.rs:15:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:53:9 + --> $DIR/empty-types.rs:52:9 | LL | _x => {} | ^^ error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:57:11 + --> $DIR/empty-types.rs:56:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -32,31 +32,31 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:72:9 + --> $DIR/empty-types.rs:71:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:79:9 + --> $DIR/empty-types.rs:78:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:82:9 + --> $DIR/empty-types.rs:81:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:86:9 + --> $DIR/empty-types.rs:85:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:90:11 + --> $DIR/empty-types.rs:89:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -75,19 +75,19 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:98:9 + --> $DIR/empty-types.rs:97:9 | LL | Err(_) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:103:9 + --> $DIR/empty-types.rs:102:9 | LL | Err(_) => {} | ^^^^^^ error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:100:11 + --> $DIR/empty-types.rs:99:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -105,7 +105,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:107:9 + --> $DIR/empty-types.rs:106:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -119,121 +119,121 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:118:9 + --> $DIR/empty-types.rs:117:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:122:9 + --> $DIR/empty-types.rs:121:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:125:9 + --> $DIR/empty-types.rs:124:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:126:9 + --> $DIR/empty-types.rs:125:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:129:9 + --> $DIR/empty-types.rs:128:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:130:9 + --> $DIR/empty-types.rs:129:9 | LL | Err(_) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:139:13 + --> $DIR/empty-types.rs:138:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:142:13 + --> $DIR/empty-types.rs:141:13 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:151:13 + --> $DIR/empty-types.rs:150:13 | LL | Some(_) => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:155:13 + --> $DIR/empty-types.rs:154:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:206:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:211:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:217:13 + --> $DIR/empty-types.rs:216:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:222:13 + --> $DIR/empty-types.rs:221:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:228:13 + --> $DIR/empty-types.rs:227:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:287:9 + --> $DIR/empty-types.rs:286:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:290:9 + --> $DIR/empty-types.rs:289:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:293:9 + --> $DIR/empty-types.rs:292:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:294:9 + --> $DIR/empty-types.rs:293:9 | LL | Err(_) => {} | ^^^^^^ error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:326:11 + --> $DIR/empty-types.rs:325:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -247,7 +247,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/empty-types.rs:337:11 + --> $DIR/empty-types.rs:336:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[]` not covered @@ -260,7 +260,7 @@ LL + &[] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:349:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[]` not covered @@ -274,7 +274,7 @@ LL + &[] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:356:11 + --> $DIR/empty-types.rs:355:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -288,25 +288,25 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:366:9 + --> $DIR/empty-types.rs:365:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:369:9 + --> $DIR/empty-types.rs:368:9 | LL | [_, _, _] => {} | ^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:372:9 + --> $DIR/empty-types.rs:371:9 | LL | [_, ..] => {} | ^^^^^^^ error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:385:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -320,13 +320,13 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:392:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:394:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -340,49 +340,49 @@ LL + [] => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:414:9 + --> $DIR/empty-types.rs:413:9 | LL | Some(_) => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:419:9 + --> $DIR/empty-types.rs:418:9 | LL | Some(_a) => {} | ^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:424:9 + --> $DIR/empty-types.rs:423:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:429:9 + --> $DIR/empty-types.rs:428:9 | LL | _a => {} | ^^ error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:600:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:603:9 | LL | _x => {} | ^^ error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:606:9 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:609:9 | LL | _x if false => {} | ^^ diff --git a/tests/ui/pattern/usefulness/empty-types.min_exh_pats.stderr b/tests/ui/pattern/usefulness/empty-types.min_exh_pats.stderr index ed5d125e68404..d5121e7043c73 100644 --- a/tests/ui/pattern/usefulness/empty-types.min_exh_pats.stderr +++ b/tests/ui/pattern/usefulness/empty-types.min_exh_pats.stderr @@ -1,32 +1,23 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/empty-types.rs:13:35 - | -LL | #![cfg_attr(min_exh_pats, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:49:9 | LL | _ => {} | ^ | note: the lint level is defined here - --> $DIR/empty-types.rs:16:9 + --> $DIR/empty-types.rs:15:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:53:9 + --> $DIR/empty-types.rs:52:9 | LL | _x => {} | ^^ error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:57:11 + --> $DIR/empty-types.rs:56:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -41,31 +32,31 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:72:9 + --> $DIR/empty-types.rs:71:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:79:9 + --> $DIR/empty-types.rs:78:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:82:9 + --> $DIR/empty-types.rs:81:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:86:9 + --> $DIR/empty-types.rs:85:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:90:11 + --> $DIR/empty-types.rs:89:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -84,19 +75,19 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:98:9 + --> $DIR/empty-types.rs:97:9 | LL | Err(_) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:103:9 + --> $DIR/empty-types.rs:102:9 | LL | Err(_) => {} | ^^^^^^ error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:100:11 + --> $DIR/empty-types.rs:99:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -114,7 +105,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:107:9 + --> $DIR/empty-types.rs:106:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -128,7 +119,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:111:9 + --> $DIR/empty-types.rs:110:9 | LL | let Ok(_x) = &res_u32_never; | ^^^^^^ pattern `&Err(_)` not covered @@ -142,67 +133,67 @@ LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:118:9 + --> $DIR/empty-types.rs:117:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:122:9 + --> $DIR/empty-types.rs:121:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:125:9 + --> $DIR/empty-types.rs:124:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:126:9 + --> $DIR/empty-types.rs:125:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:129:9 + --> $DIR/empty-types.rs:128:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:130:9 + --> $DIR/empty-types.rs:129:9 | LL | Err(_) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:139:13 + --> $DIR/empty-types.rs:138:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:142:13 + --> $DIR/empty-types.rs:141:13 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:151:13 + --> $DIR/empty-types.rs:150:13 | LL | Some(_) => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:155:13 + --> $DIR/empty-types.rs:154:13 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:164:15 + --> $DIR/empty-types.rs:163:15 | LL | match *ref_opt_void { | ^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -220,61 +211,61 @@ LL + Some(_) => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:206:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:211:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:217:13 + --> $DIR/empty-types.rs:216:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:222:13 + --> $DIR/empty-types.rs:221:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:228:13 + --> $DIR/empty-types.rs:227:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:287:9 + --> $DIR/empty-types.rs:286:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:290:9 + --> $DIR/empty-types.rs:289:9 | LL | (_, _) => {} | ^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:293:9 + --> $DIR/empty-types.rs:292:9 | LL | Ok(_) => {} | ^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:294:9 + --> $DIR/empty-types.rs:293:9 | LL | Err(_) => {} | ^^^^^^ error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:315:11 + --> $DIR/empty-types.rs:314:11 | LL | match *x {} | ^^ @@ -288,7 +279,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:317:11 + --> $DIR/empty-types.rs:316:11 | LL | match *x {} | ^^ @@ -302,7 +293,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:319:11 + --> $DIR/empty-types.rs:318:11 | LL | match *x {} | ^^ patterns `Ok(_)` and `Err(_)` not covered @@ -324,7 +315,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:321:11 + --> $DIR/empty-types.rs:320:11 | LL | match *x {} | ^^ @@ -338,7 +329,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:326:11 + --> $DIR/empty-types.rs:325:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -352,7 +343,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered - --> $DIR/empty-types.rs:328:11 + --> $DIR/empty-types.rs:327:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[_, ..]` not covered @@ -365,7 +356,7 @@ LL + &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: `&[]`, `&[_]` and `&[_, _]` not covered - --> $DIR/empty-types.rs:337:11 + --> $DIR/empty-types.rs:336:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _]` not covered @@ -378,7 +369,7 @@ LL + &[] | &[_] | &[_, _] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:349:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]` and `&[_, ..]` not covered @@ -392,7 +383,7 @@ LL + &[] | &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:356:11 + --> $DIR/empty-types.rs:355:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -406,25 +397,25 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:366:9 + --> $DIR/empty-types.rs:365:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:369:9 + --> $DIR/empty-types.rs:368:9 | LL | [_, _, _] => {} | ^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:372:9 + --> $DIR/empty-types.rs:371:9 | LL | [_, ..] => {} | ^^^^^^^ error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:385:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -438,13 +429,13 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:392:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:394:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -458,31 +449,31 @@ LL + [] => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:414:9 + --> $DIR/empty-types.rs:413:9 | LL | Some(_) => {} | ^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:419:9 + --> $DIR/empty-types.rs:418:9 | LL | Some(_a) => {} | ^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:424:9 + --> $DIR/empty-types.rs:423:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:429:9 + --> $DIR/empty-types.rs:428:9 | LL | _a => {} | ^^ error[E0004]: non-exhaustive patterns: `&Some(_)` not covered - --> $DIR/empty-types.rs:449:11 + --> $DIR/empty-types.rs:448:11 | LL | match ref_opt_never { | ^^^^^^^^^^^^^ pattern `&Some(_)` not covered @@ -500,7 +491,7 @@ LL + &Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:490:11 + --> $DIR/empty-types.rs:489:11 | LL | match *ref_opt_never { | ^^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -518,7 +509,7 @@ LL + Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:538:11 + --> $DIR/empty-types.rs:537:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -536,7 +527,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:549:11 + --> $DIR/empty-types.rs:548:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -554,7 +545,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:568:11 + --> $DIR/empty-types.rs:567:11 | LL | match *ref_tuple_half_never {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -568,31 +559,31 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:600:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:603:9 | LL | _x => {} | ^^ error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:606:9 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:609:9 | LL | _x if false => {} | ^^ error[E0004]: non-exhaustive patterns: `&_` not covered - --> $DIR/empty-types.rs:635:11 + --> $DIR/empty-types.rs:634:11 | LL | match ref_never { | ^^^^^^^^^ pattern `&_` not covered @@ -607,7 +598,7 @@ LL + &_ => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:663:11 + --> $DIR/empty-types.rs:662:11 | LL | match *x { | ^^ pattern `Some(_)` not covered @@ -624,7 +615,7 @@ LL ~ None => {}, LL + Some(_) => todo!() | -error: aborting due to 63 previous errors; 1 warning emitted +error: aborting due to 63 previous errors Some errors have detailed explanations: E0004, E0005. For more information about an error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr index 2fdb51677dac5..dc01ac4ddcea2 100644 --- a/tests/ui/pattern/usefulness/empty-types.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr @@ -1,23 +1,23 @@ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:49:9 | LL | _ => {} | ^ | note: the lint level is defined here - --> $DIR/empty-types.rs:16:9 + --> $DIR/empty-types.rs:15:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:53:9 + --> $DIR/empty-types.rs:52:9 | LL | _x => {} | ^^ error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:57:11 + --> $DIR/empty-types.rs:56:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -32,7 +32,7 @@ LL + } | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:69:11 + --> $DIR/empty-types.rs:68:11 | LL | match tuple_half_never {} | ^^^^^^^^^^^^^^^^ @@ -46,7 +46,7 @@ LL + } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:76:11 + --> $DIR/empty-types.rs:75:11 | LL | match tuple_never {} | ^^^^^^^^^^^ @@ -60,13 +60,13 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:86:9 + --> $DIR/empty-types.rs:85:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:90:11 + --> $DIR/empty-types.rs:89:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ patterns `Ok(_)` and `Err(_)` not covered @@ -88,7 +88,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:92:11 + --> $DIR/empty-types.rs:91:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -106,7 +106,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:100:11 + --> $DIR/empty-types.rs:99:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -124,7 +124,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:105:9 + --> $DIR/empty-types.rs:104:9 | LL | let Ok(_x) = res_u32_never; | ^^^^^^ pattern `Err(_)` not covered @@ -138,7 +138,7 @@ LL | let Ok(_x) = res_u32_never else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:107:9 + --> $DIR/empty-types.rs:106:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -152,7 +152,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:111:9 + --> $DIR/empty-types.rs:110:9 | LL | let Ok(_x) = &res_u32_never; | ^^^^^^ pattern `&Err(_)` not covered @@ -166,7 +166,7 @@ LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:115:11 + --> $DIR/empty-types.rs:114:11 | LL | match result_never {} | ^^^^^^^^^^^^ patterns `Ok(_)` and `Err(_)` not covered @@ -188,7 +188,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:120:11 + --> $DIR/empty-types.rs:119:11 | LL | match result_never { | ^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -205,19 +205,19 @@ LL | Ok(_) => {}, Err(_) => todo!() | +++++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:139:13 + --> $DIR/empty-types.rs:138:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:142:13 + --> $DIR/empty-types.rs:141:13 | LL | _ if false => {} | ^ error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:145:15 + --> $DIR/empty-types.rs:144:15 | LL | match opt_void { | ^^^^^^^^ pattern `Some(_)` not covered @@ -235,7 +235,7 @@ LL + Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:164:15 + --> $DIR/empty-types.rs:163:15 | LL | match *ref_opt_void { | ^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -253,43 +253,43 @@ LL + Some(_) => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:206:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:211:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:217:13 + --> $DIR/empty-types.rs:216:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:222:13 + --> $DIR/empty-types.rs:221:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:228:13 + --> $DIR/empty-types.rs:227:13 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:287:9 + --> $DIR/empty-types.rs:286:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:315:11 + --> $DIR/empty-types.rs:314:11 | LL | match *x {} | ^^ @@ -303,7 +303,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:317:11 + --> $DIR/empty-types.rs:316:11 | LL | match *x {} | ^^ @@ -317,7 +317,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:319:11 + --> $DIR/empty-types.rs:318:11 | LL | match *x {} | ^^ patterns `Ok(_)` and `Err(_)` not covered @@ -339,7 +339,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:321:11 + --> $DIR/empty-types.rs:320:11 | LL | match *x {} | ^^ @@ -353,7 +353,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:326:11 + --> $DIR/empty-types.rs:325:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -367,7 +367,7 @@ LL + } | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered - --> $DIR/empty-types.rs:328:11 + --> $DIR/empty-types.rs:327:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[_, ..]` not covered @@ -380,7 +380,7 @@ LL + &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: `&[]`, `&[_]` and `&[_, _]` not covered - --> $DIR/empty-types.rs:337:11 + --> $DIR/empty-types.rs:336:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _]` not covered @@ -393,7 +393,7 @@ LL + &[] | &[_] | &[_, _] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:349:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]` and `&[_, ..]` not covered @@ -407,7 +407,7 @@ LL + &[] | &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:356:11 + --> $DIR/empty-types.rs:355:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -421,7 +421,7 @@ LL + } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:363:11 + --> $DIR/empty-types.rs:362:11 | LL | match array_3_never {} | ^^^^^^^^^^^^^ @@ -435,7 +435,7 @@ LL + } | error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:385:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -449,13 +449,13 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:392:9 | LL | _ => {} | ^ error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:394:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -469,7 +469,7 @@ LL + [] => todo!() | error[E0004]: non-exhaustive patterns: `&Some(_)` not covered - --> $DIR/empty-types.rs:449:11 + --> $DIR/empty-types.rs:448:11 | LL | match ref_opt_never { | ^^^^^^^^^^^^^ pattern `&Some(_)` not covered @@ -487,7 +487,7 @@ LL + &Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:490:11 + --> $DIR/empty-types.rs:489:11 | LL | match *ref_opt_never { | ^^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -505,7 +505,7 @@ LL + Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:538:11 + --> $DIR/empty-types.rs:537:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -523,7 +523,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:549:11 + --> $DIR/empty-types.rs:548:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -541,7 +541,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:568:11 + --> $DIR/empty-types.rs:567:11 | LL | match *ref_tuple_half_never {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -555,31 +555,31 @@ LL + } | error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:600:9 | LL | _ => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:603:9 | LL | _x => {} | ^^ error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:606:9 | LL | _ if false => {} | ^ error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:609:9 | LL | _x if false => {} | ^^ error[E0004]: non-exhaustive patterns: `&_` not covered - --> $DIR/empty-types.rs:635:11 + --> $DIR/empty-types.rs:634:11 | LL | match ref_never { | ^^^^^^^^^ pattern `&_` not covered @@ -594,7 +594,7 @@ LL + &_ => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:663:11 + --> $DIR/empty-types.rs:662:11 | LL | match *x { | ^^ pattern `Some(_)` not covered diff --git a/tests/ui/pattern/usefulness/empty-types.rs b/tests/ui/pattern/usefulness/empty-types.rs index 170a663e754b2..06651613010d1 100644 --- a/tests/ui/pattern/usefulness/empty-types.rs +++ b/tests/ui/pattern/usefulness/empty-types.rs @@ -11,7 +11,6 @@ #![feature(never_type_fallback)] #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exh_pats, feature(min_exhaustive_patterns))] -//[min_exh_pats]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![allow(dead_code, unreachable_code)] #![deny(unreachable_patterns)] diff --git a/tests/ui/pattern/usefulness/impl-trait.rs b/tests/ui/pattern/usefulness/impl-trait.rs index ceb97315e9dde..1fec9a2633eec 100644 --- a/tests/ui/pattern/usefulness/impl-trait.rs +++ b/tests/ui/pattern/usefulness/impl-trait.rs @@ -1,5 +1,5 @@ #![feature(never_type)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(type_alias_impl_trait)] #![feature(non_exhaustive_omitted_patterns_lint)] #![deny(unreachable_patterns)] diff --git a/tests/ui/pattern/usefulness/match-privately-empty.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/match-privately-empty.exhaustive_patterns.stderr index 708a1511244c2..261a4b3353f23 100644 --- a/tests/ui/pattern/usefulness/match-privately-empty.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/match-privately-empty.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered - --> $DIR/match-privately-empty.rs:16:11 + --> $DIR/match-privately-empty.rs:15:11 | LL | match private::DATA { | ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered diff --git a/tests/ui/pattern/usefulness/match-privately-empty.min_exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/match-privately-empty.min_exhaustive_patterns.stderr index a6ce02c0c3c6a..261a4b3353f23 100644 --- a/tests/ui/pattern/usefulness/match-privately-empty.min_exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/match-privately-empty.min_exhaustive_patterns.stderr @@ -1,14 +1,5 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/match-privately-empty.rs:3:46 - | -LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered - --> $DIR/match-privately-empty.rs:16:11 + --> $DIR/match-privately-empty.rs:15:11 | LL | match private::DATA { | ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered @@ -25,6 +16,6 @@ LL ~ Some(private::Private { misc: false, .. }) => {}, LL + Some(Private { misc: true, .. }) => todo!() | -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/match-privately-empty.rs b/tests/ui/pattern/usefulness/match-privately-empty.rs index 95b18e774fbdc..7e1d0dc48f2c2 100644 --- a/tests/ui/pattern/usefulness/match-privately-empty.rs +++ b/tests/ui/pattern/usefulness/match-privately-empty.rs @@ -1,7 +1,6 @@ //@ revisions: min_exhaustive_patterns exhaustive_patterns #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![feature(never_type)] mod private { diff --git a/tests/ui/pattern/usefulness/slice_of_empty.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/slice_of_empty.exhaustive_patterns.stderr index 9770f680b2da8..e5e581447e66c 100644 --- a/tests/ui/pattern/usefulness/slice_of_empty.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/slice_of_empty.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/slice_of_empty.rs:22:11 + --> $DIR/slice_of_empty.rs:21:11 | LL | match nevers { | ^^^^^^ pattern `&[]` not covered diff --git a/tests/ui/pattern/usefulness/slice_of_empty.min_exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/slice_of_empty.min_exhaustive_patterns.stderr index 3b9e71f50d5ff..a1239466c9c2c 100644 --- a/tests/ui/pattern/usefulness/slice_of_empty.min_exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/slice_of_empty.min_exhaustive_patterns.stderr @@ -1,14 +1,5 @@ -warning: the feature `min_exhaustive_patterns` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/slice_of_empty.rs:3:46 - | -LL | #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #119612 for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered - --> $DIR/slice_of_empty.rs:11:11 + --> $DIR/slice_of_empty.rs:10:11 | LL | match nevers { | ^^^^^^ pattern `&[_, ..]` not covered @@ -21,7 +12,7 @@ LL ~ &[_, ..] => todo!(), | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered - --> $DIR/slice_of_empty.rs:22:11 + --> $DIR/slice_of_empty.rs:21:11 | LL | match nevers { | ^^^^^^ patterns `&[]` and `&[_, _, ..]` not covered @@ -33,6 +24,6 @@ LL ~ &[_] => (), LL ~ &[] | &[_, _, ..] => todo!(), | -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/pattern/usefulness/slice_of_empty.rs b/tests/ui/pattern/usefulness/slice_of_empty.rs index 589c7767ad246..785fccaabf7eb 100644 --- a/tests/ui/pattern/usefulness/slice_of_empty.rs +++ b/tests/ui/pattern/usefulness/slice_of_empty.rs @@ -1,7 +1,6 @@ //@ revisions: min_exhaustive_patterns exhaustive_patterns #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -//[min_exhaustive_patterns]~^ WARN the feature `min_exhaustive_patterns` is incomplete #![feature(never_type)] #![deny(unreachable_patterns)] diff --git a/tests/ui/pattern/usefulness/uninhabited.rs b/tests/ui/pattern/usefulness/uninhabited.rs index ff7aeb263e4d2..72e602ee8d2d7 100644 --- a/tests/ui/pattern/usefulness/uninhabited.rs +++ b/tests/ui/pattern/usefulness/uninhabited.rs @@ -5,7 +5,7 @@ // `Ty::is_inhabited_from` function. #![feature(never_type)] #![feature(never_type_fallback)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![deny(unreachable_patterns)] macro_rules! assert_empty { diff --git a/tests/ui/reachable/unreachable-loop-patterns.rs b/tests/ui/reachable/unreachable-loop-patterns.rs index e9cef5f47d4aa..4294a18ba440f 100644 --- a/tests/ui/reachable/unreachable-loop-patterns.rs +++ b/tests/ui/reachable/unreachable-loop-patterns.rs @@ -1,5 +1,5 @@ #![feature(never_type, never_type_fallback)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![allow(unreachable_code)] #![deny(unreachable_patterns)] diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs index b4c26ed910a5c..c40a2676e84ce 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs @@ -1,6 +1,6 @@ //@ aux-build:uninhabited.rs #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs index 246443f029faf..efaec0ebdbe3b 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs @@ -1,7 +1,7 @@ //@ check-pass #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] #[non_exhaustive] diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs index 22cffc537bd5c..69b15fca0b721 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs @@ -1,6 +1,6 @@ //@ aux-build:uninhabited.rs #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs index ac346bc83614b..bbc5d03d6126c 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs @@ -1,7 +1,7 @@ //@ check-pass #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] #[non_exhaustive] diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs index 21aa562365af8..0007614988cda 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.rs @@ -1,7 +1,7 @@ //@ aux-build:uninhabited.rs //@ build-pass (FIXME(62277): could be check-pass?) #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] extern crate uninhabited; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs index ffc496a975ecf..898be87cccab1 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs @@ -1,5 +1,5 @@ #![deny(unreachable_patterns)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![feature(never_type)] #[non_exhaustive] diff --git a/tests/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs b/tests/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs index e392d74ea0ff9..3130fb3fe9e67 100644 --- a/tests/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs +++ b/tests/ui/uninhabited/exhaustive-wo-nevertype-issue-51221.rs @@ -1,6 +1,6 @@ //@ check-pass -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] enum Void {} fn main() { diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr b/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr index c9131a8372ab1..bc1a9fa41915a 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr +++ b/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/uninhabited-irrefutable.rs:32:9 + --> $DIR/uninhabited-irrefutable.rs:31:9 | LL | let Foo::D(_y, _z) = x; | ^^^^^^^^^^^^^^ pattern `Foo::A(_)` not covered @@ -7,7 +7,7 @@ LL | let Foo::D(_y, _z) = x; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Foo` defined here - --> $DIR/uninhabited-irrefutable.rs:21:6 + --> $DIR/uninhabited-irrefutable.rs:20:6 | LL | enum Foo { | ^^^ diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.min_exhaustive_patterns.stderr b/tests/ui/uninhabited/uninhabited-irrefutable.min_exhaustive_patterns.stderr index c9131a8372ab1..bc1a9fa41915a 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.min_exhaustive_patterns.stderr +++ b/tests/ui/uninhabited/uninhabited-irrefutable.min_exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding - --> $DIR/uninhabited-irrefutable.rs:32:9 + --> $DIR/uninhabited-irrefutable.rs:31:9 | LL | let Foo::D(_y, _z) = x; | ^^^^^^^^^^^^^^ pattern `Foo::A(_)` not covered @@ -7,7 +7,7 @@ LL | let Foo::D(_y, _z) = x; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Foo` defined here - --> $DIR/uninhabited-irrefutable.rs:21:6 + --> $DIR/uninhabited-irrefutable.rs:20:6 | LL | enum Foo { | ^^^ diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.rs b/tests/ui/uninhabited/uninhabited-irrefutable.rs index 67622a842a5c3..c1f4e5f8e27f1 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.rs +++ b/tests/ui/uninhabited/uninhabited-irrefutable.rs @@ -1,7 +1,6 @@ //@ revisions: min_exhaustive_patterns exhaustive_patterns #![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))] #![cfg_attr(min_exhaustive_patterns, feature(min_exhaustive_patterns))] -#![cfg_attr(min_exhaustive_patterns, allow(incomplete_features))] #![feature(never_type)] mod foo { diff --git a/tests/ui/uninhabited/uninhabited-patterns.rs b/tests/ui/uninhabited/uninhabited-patterns.rs index 4e90691e5c809..ae12c0fc4af68 100644 --- a/tests/ui/uninhabited/uninhabited-patterns.rs +++ b/tests/ui/uninhabited/uninhabited-patterns.rs @@ -1,6 +1,6 @@ #![feature(box_patterns)] #![feature(never_type)] -#![feature(exhaustive_patterns)] +#![feature(min_exhaustive_patterns)] #![deny(unreachable_patterns)] mod foo { diff --git a/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.rs b/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.rs new file mode 100644 index 0000000000000..00f9bfd5cdff9 --- /dev/null +++ b/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.rs @@ -0,0 +1,11 @@ +#![crate_type = "lib"] +#![feature(unnamed_fields)] +#![allow(unused, incomplete_features)] + +enum K { + M { + _ : struct { field: u8 }, + //~^ error: unnamed fields are not allowed outside of structs or unions + //~| error: anonymous structs are not allowed outside of unnamed struct or union fields + } +} diff --git a/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.stderr b/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.stderr new file mode 100644 index 0000000000000..43843141e2e7a --- /dev/null +++ b/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.stderr @@ -0,0 +1,16 @@ +error: unnamed fields are not allowed outside of structs or unions + --> $DIR/anon-struct-in-enum-issue-121446.rs:7:9 + | +LL | _ : struct { field: u8 }, + | -^^^^^^^^^^^^^^^^^^^^^^^ + | | + | unnamed field declared here + +error: anonymous structs are not allowed outside of unnamed struct or union fields + --> $DIR/anon-struct-in-enum-issue-121446.rs:7:13 + | +LL | _ : struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here + +error: aborting due to 2 previous errors +