diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index a0c9263673d74..6ee22834a460e 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -808,7 +808,21 @@ impl LinkedList { #[stable(feature = "rust1", since = "1.0.0")] unsafe impl<#[may_dangle] T> Drop for LinkedList { fn drop(&mut self) { - while let Some(_) = self.pop_front_node() {} + struct DropGuard<'a, T>(&'a mut LinkedList); + + impl<'a, T> Drop for DropGuard<'a, T> { + fn drop(&mut self) { + // Continue the same loop we do below. This only runs when a destructor has + // panicked. If another one panics this will abort. + while let Some(_) = self.0.pop_front_node() {} + } + } + + while let Some(node) = self.pop_front_node() { + let guard = DropGuard(self); + drop(node); + mem::forget(guard); + } } } diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 7795083e0580c..5ec69f73740c3 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -144,11 +144,23 @@ impl Clone for VecDeque { #[stable(feature = "rust1", since = "1.0.0")] unsafe impl<#[may_dangle] T> Drop for VecDeque { fn drop(&mut self) { + /// Runs the destructor for all items in the slice when it gets dropped (normally or + /// during unwinding). + struct Dropper<'a, T>(&'a mut [T]); + + impl<'a, T> Drop for Dropper<'a, T> { + fn drop(&mut self) { + unsafe { + ptr::drop_in_place(self.0); + } + } + } + let (front, back) = self.as_mut_slices(); unsafe { + let _back_dropper = Dropper(back); // use drop for [T] ptr::drop_in_place(front); - ptr::drop_in_place(back); } // RawVec handles deallocation } diff --git a/src/liballoc/tests/linked_list.rs b/src/liballoc/tests/linked_list.rs index daa49c48c6a92..54a77d643cbe3 100644 --- a/src/liballoc/tests/linked_list.rs +++ b/src/liballoc/tests/linked_list.rs @@ -1,4 +1,5 @@ use std::collections::LinkedList; +use std::panic::catch_unwind; #[test] fn test_basic() { @@ -529,3 +530,109 @@ fn drain_filter_complex() { assert_eq!(list.into_iter().collect::>(), vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19]); } } + + +#[test] +fn test_drop() { + static mut DROPS: i32 = 0; + struct Elem; + impl Drop for Elem { + fn drop(&mut self) { + unsafe { + DROPS += 1; + } + } + } + + let mut ring = LinkedList::new(); + ring.push_back(Elem); + ring.push_front(Elem); + ring.push_back(Elem); + ring.push_front(Elem); + drop(ring); + + assert_eq!(unsafe { DROPS }, 4); +} + +#[test] +fn test_drop_with_pop() { + static mut DROPS: i32 = 0; + struct Elem; + impl Drop for Elem { + fn drop(&mut self) { + unsafe { + DROPS += 1; + } + } + } + + let mut ring = LinkedList::new(); + ring.push_back(Elem); + ring.push_front(Elem); + ring.push_back(Elem); + ring.push_front(Elem); + + drop(ring.pop_back()); + drop(ring.pop_front()); + assert_eq!(unsafe { DROPS }, 2); + + drop(ring); + assert_eq!(unsafe { DROPS }, 4); +} + +#[test] +fn test_drop_clear() { + static mut DROPS: i32 = 0; + struct Elem; + impl Drop for Elem { + fn drop(&mut self) { + unsafe { + DROPS += 1; + } + } + } + + let mut ring = LinkedList::new(); + ring.push_back(Elem); + ring.push_front(Elem); + ring.push_back(Elem); + ring.push_front(Elem); + ring.clear(); + assert_eq!(unsafe { DROPS }, 4); + + drop(ring); + assert_eq!(unsafe { DROPS }, 4); +} + +#[test] +fn test_drop_panic() { + static mut DROPS: i32 = 0; + + struct D(bool); + + impl Drop for D { + fn drop(&mut self) { + unsafe { + DROPS += 1; + } + + if self.0 { + panic!("panic in `drop`"); + } + } + } + + let mut q = LinkedList::new(); + q.push_back(D(false)); + q.push_back(D(false)); + q.push_back(D(false)); + q.push_back(D(false)); + q.push_back(D(false)); + q.push_front(D(false)); + q.push_front(D(false)); + q.push_front(D(true)); + + catch_unwind(move || drop(q)).ok(); + + assert_eq!(unsafe { DROPS }, 8); +} diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index ebcc832017172..1ab3694a3ca61 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -2,6 +2,7 @@ use std::collections::TryReserveError::*; use std::collections::{vec_deque::Drain, VecDeque}; use std::fmt::Debug; use std::mem::size_of; +use std::panic::catch_unwind; use std::{isize, usize}; use crate::hash; @@ -709,6 +710,39 @@ fn test_drop_clear() { assert_eq!(unsafe { DROPS }, 4); } +#[test] +fn test_drop_panic() { + static mut DROPS: i32 = 0; + + struct D(bool); + + impl Drop for D { + fn drop(&mut self) { + unsafe { + DROPS += 1; + } + + if self.0 { + panic!("panic in `drop`"); + } + } + } + + let mut q = VecDeque::new(); + q.push_back(D(false)); + q.push_back(D(false)); + q.push_back(D(false)); + q.push_back(D(false)); + q.push_back(D(false)); + q.push_front(D(false)); + q.push_front(D(false)); + q.push_front(D(true)); + + catch_unwind(move || drop(q)).ok(); + + assert_eq!(unsafe { DROPS }, 8); +} + #[test] fn test_reserve_grow() { // test growth path A diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 6e7a46ba62aab..18f808638deac 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -195,7 +195,7 @@ mod impls { bool char } - #[stable(feature = "never_type", since = "1.41.0")] + #[unstable(feature = "never_type", issue = "35121")] impl Clone for ! { #[inline] fn clone(&self) -> Self { diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index fd4be02e20f4b..4aa52a7a390e3 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -1141,24 +1141,24 @@ mod impls { ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } - #[stable(feature = "never_type", since = "1.41.0")] + #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { fn eq(&self, _: &!) -> bool { *self } } - #[stable(feature = "never_type", since = "1.41.0")] + #[unstable(feature = "never_type", issue = "35121")] impl Eq for ! {} - #[stable(feature = "never_type", since = "1.41.0")] + #[unstable(feature = "never_type", issue = "35121")] impl PartialOrd for ! { fn partial_cmp(&self, _: &!) -> Option { *self } } - #[stable(feature = "never_type", since = "1.41.0")] + #[unstable(feature = "never_type", issue = "35121")] impl Ord for ! { fn cmp(&self, _: &!) -> Ordering { *self diff --git a/src/libcore/convert/mod.rs b/src/libcore/convert/mod.rs index 5414d9ac2344a..3329c8010e1c2 100644 --- a/src/libcore/convert/mod.rs +++ b/src/libcore/convert/mod.rs @@ -40,6 +40,8 @@ #![stable(feature = "rust1", since = "1.0.0")] +use crate::fmt; + mod num; #[unstable(feature = "convert_float_to_int", issue = "67057")] @@ -429,7 +431,9 @@ pub trait TryInto: Sized { /// - `TryFrom for U` implies [`TryInto`]` for T` /// - [`try_from`] is reflexive, which means that `TryFrom for T` /// is implemented and cannot fail -- the associated `Error` type for -/// calling `T::try_from()` on a value of type `T` is [`!`]. +/// calling `T::try_from()` on a value of type `T` is [`Infallible`]. +/// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be +/// equivalent. /// /// `TryFrom` can be implemented as follows: /// @@ -478,6 +482,7 @@ pub trait TryInto: Sized { /// [`TryInto`]: trait.TryInto.html /// [`i32::MAX`]: ../../std/i32/constant.MAX.html /// [`!`]: ../../std/primitive.never.html +/// [`Infallible`]: enum.Infallible.html #[stable(feature = "try_from", since = "1.34.0")] pub trait TryFrom: Sized { /// The type returned in the event of a conversion error. @@ -633,9 +638,9 @@ impl AsRef for str { // THE NO-ERROR ERROR TYPE //////////////////////////////////////////////////////////////////////////////// -/// A type alias for [the `!` “never” type][never]. +/// The error type for errors that can never happen. /// -/// `Infallible` represents types of errors that can never happen since `!` has no valid values. +/// Since this enum has no variant, a value of this type can never actually exist. /// This can be useful for generic APIs that use [`Result`] and parameterize the error type, /// to indicate that the result is always [`Ok`]. /// @@ -652,10 +657,33 @@ impl AsRef for str { /// } /// ``` /// -/// # Eventual deprecation +/// # Future compatibility +/// +/// This enum has the same role as [the `!` “never” type][never], +/// which is unstable in this version of Rust. +/// When `!` is stabilized, we plan to make `Infallible` a type alias to it: +/// +/// ```ignore (illustrates future std change) +/// pub type Infallible = !; +/// ``` +/// +/// … and eventually deprecate `Infallible`. +/// +/// +/// However there is one case where `!` syntax can be used +/// before `!` is stabilized as a full-fleged type: in the position of a function’s return type. +/// Specifically, it is possible implementations for two different function pointer types: +/// +/// ``` +/// trait MyTrait {} +/// impl MyTrait for fn() -> ! {} +/// impl MyTrait for fn() -> std::convert::Infallible {} +/// ``` /// -/// Previously, `Infallible` was defined as `enum Infallible {}`. -/// Now that it is merely a type alias to `!`, we will eventually deprecate `Infallible`. +/// With `Infallible` being an enum, this code is valid. +/// However when `Infallible` becomes an alias for the never type, +/// the two `impl`s will start to overlap +/// and therefore will be disallowed by the language’s trait coherence rules. /// /// [`Ok`]: ../result/enum.Result.html#variant.Ok /// [`Result`]: ../result/enum.Result.html @@ -663,4 +691,57 @@ impl AsRef for str { /// [`Into`]: trait.Into.html /// [never]: ../../std/primitive.never.html #[stable(feature = "convert_infallible", since = "1.34.0")] -pub type Infallible = !; +#[derive(Copy)] +pub enum Infallible {} + +#[stable(feature = "convert_infallible", since = "1.34.0")] +impl Clone for Infallible { + fn clone(&self) -> Infallible { + match *self {} + } +} + +#[stable(feature = "convert_infallible", since = "1.34.0")] +impl fmt::Debug for Infallible { + fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self {} + } +} + +#[stable(feature = "convert_infallible", since = "1.34.0")] +impl fmt::Display for Infallible { + fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self {} + } +} + +#[stable(feature = "convert_infallible", since = "1.34.0")] +impl PartialEq for Infallible { + fn eq(&self, _: &Infallible) -> bool { + match *self {} + } +} + +#[stable(feature = "convert_infallible", since = "1.34.0")] +impl Eq for Infallible {} + +#[stable(feature = "convert_infallible", since = "1.34.0")] +impl PartialOrd for Infallible { + fn partial_cmp(&self, _other: &Self) -> Option { + match *self {} + } +} + +#[stable(feature = "convert_infallible", since = "1.34.0")] +impl Ord for Infallible { + fn cmp(&self, _other: &Self) -> crate::cmp::Ordering { + match *self {} + } +} + +#[stable(feature = "convert_infallible", since = "1.34.0")] +impl From for Infallible { + fn from(x: !) -> Self { + x + } +} diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index e2f49ee25a756..223f91d909b34 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -1940,14 +1940,14 @@ macro_rules! fmt_refs { fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp } -#[stable(feature = "never_type", since = "1.41.0")] +#[unstable(feature = "never_type", issue = "35121")] impl Debug for ! { fn fmt(&self, _: &mut Formatter<'_>) -> Result { *self } } -#[stable(feature = "never_type", since = "1.41.0")] +#[unstable(feature = "never_type", issue = "35121")] impl Display for ! { fn fmt(&self, _: &mut Formatter<'_>) -> Result { *self diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 8a514f1e78e80..8412e79aa333d 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -87,7 +87,7 @@ #![feature(iter_once_with)] #![feature(lang_items)] #![feature(link_llvm_intrinsics)] -#![cfg_attr(bootstrap, feature(never_type))] +#![feature(never_type)] #![feature(nll)] #![feature(exhaustive_patterns)] #![feature(no_core)] diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 288017b7ca53e..2db55508ad546 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -776,7 +776,7 @@ mod copy_impls { bool char } - #[stable(feature = "never_type", since = "1.41.0")] + #[unstable(feature = "never_type", issue = "35121")] impl Copy for ! {} #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index d1f518d52dd72..00447a7d532f1 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -4,6 +4,7 @@ #![stable(feature = "rust1", since = "1.0.0")] +use crate::convert::Infallible; use crate::fmt; use crate::intrinsics; use crate::mem; @@ -4724,8 +4725,18 @@ impl fmt::Display for TryFromIntError { } #[stable(feature = "try_from", since = "1.34.0")] +impl From for TryFromIntError { + fn from(x: Infallible) -> TryFromIntError { + match x {} + } +} + +#[unstable(feature = "never_type", issue = "35121")] impl From for TryFromIntError { fn from(never: !) -> TryFromIntError { + // Match rather than coerce to make sure that code like + // `From for TryFromIntError` above will keep working + // when `Infallible` becomes an alias to `!`. match never {} } } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 24b87ffc80c2a..641e6a4f61489 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -37,7 +37,7 @@ #![feature(core_intrinsics)] #![feature(drain_filter)] #![cfg_attr(windows, feature(libc))] -#![cfg_attr(bootstrap, feature(never_type))] +#![feature(never_type)] #![feature(exhaustive_patterns)] #![feature(overlapping_marker_traits)] #![feature(extern_types)] diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index f2739a3b30c92..fb2099e71a31a 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -8,7 +8,7 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(core_intrinsics)] -#![cfg_attr(bootstrap, feature(never_type))] +#![feature(never_type)] #![feature(nll)] #![feature(in_band_lifetimes)] diff --git a/src/librustc_error_codes/error_codes/E0725.md b/src/librustc_error_codes/error_codes/E0725.md index b96a5e694dfc0..9bd321e5f82d6 100644 --- a/src/librustc_error_codes/error_codes/E0725.md +++ b/src/librustc_error_codes/error_codes/E0725.md @@ -4,8 +4,8 @@ command line flags. Erroneous code example: ```ignore (can't specify compiler flags from doctests) -#![feature(specialization)] // error: the feature `specialization` is not in - // the list of allowed features +#![feature(never_type)] // error: the feature `never_type` is not in + // the list of allowed features ``` Delete the offending feature attribute, or add it to the list of allowed diff --git a/src/librustc_feature/accepted.rs b/src/librustc_feature/accepted.rs index fec5a7f1a4501..3f294dc02ed6f 100644 --- a/src/librustc_feature/accepted.rs +++ b/src/librustc_feature/accepted.rs @@ -253,8 +253,6 @@ declare_features! ( (accepted, const_constructor, "1.40.0", Some(61456), None), /// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests. (accepted, cfg_doctest, "1.40.0", Some(62210), None), - /// Allows the `!` type. Does not imply 'exhaustive_patterns' any more. - (accepted, never_type, "1.41.0", Some(35121), None), /// Allows relaxing the coherence rules such that /// `impl ForeignTrait for ForeignType` is permitted. (accepted, re_rebalance_coherence, "1.41.0", Some(55437), None), diff --git a/src/librustc_feature/active.rs b/src/librustc_feature/active.rs index 363621b3ca436..c0dfed99d3bfc 100644 --- a/src/librustc_feature/active.rs +++ b/src/librustc_feature/active.rs @@ -307,6 +307,9 @@ declare_features! ( /// Allows `X..Y` patterns. (active, exclusive_range_pattern, "1.11.0", Some(37854), None), + /// Allows the `!` type. Does not imply 'exhaustive_patterns' (below) any more. + (active, never_type, "1.13.0", Some(35121), None), + /// Allows exhaustive pattern matching on types that contain uninhabited types. (active, exhaustive_patterns, "1.13.0", Some(51085), None), diff --git a/src/librustc_mir/borrow_check/diagnostics/move_errors.rs b/src/librustc_mir/borrow_check/diagnostics/move_errors.rs index 938836db9ae4b..cc634101f0adf 100644 --- a/src/librustc_mir/borrow_check/diagnostics/move_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/move_errors.rs @@ -223,18 +223,24 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { fn report(&mut self, error: GroupedMoveError<'tcx>) { let (mut err, err_span) = { - let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind<'_>) = + let (span, use_spans, original_path, kind,): + ( + Span, + Option, + &Place<'tcx>, + &IllegalMoveOriginKind<'_>, + ) = match error { GroupedMoveError::MovesFromPlace { span, ref original_path, ref kind, .. } | GroupedMoveError::MovesFromValue { span, ref original_path, ref kind, .. } => { - (span, original_path, kind) + (span, None, original_path, kind) } GroupedMoveError::OtherIllegalMove { use_spans, ref original_path, ref kind } => { - (use_spans.args_or_use(), original_path, kind) + (use_spans.args_or_use(), Some(use_spans), original_path, kind) }, }; debug!("report: original_path={:?} span={:?}, kind={:?} \ @@ -250,6 +256,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { original_path, target_place, span, + use_spans, ) } IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } => { @@ -296,6 +303,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { move_place: &Place<'tcx>, deref_target_place: &Place<'tcx>, span: Span, + use_spans: Option, ) -> DiagnosticBuilder<'a> { // Inspect the type of the content behind the // borrow to provide feedback about why this @@ -416,7 +424,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) { let is_option = move_ty.starts_with("std::option::Option"); let is_result = move_ty.starts_with("std::result::Result"); - if is_option || is_result { + if (is_option || is_result) && use_spans.map_or(true, |v| !v.for_closure()) { err.span_suggestion( span, &format!("consider borrowing the `{}`'s content", if is_option { diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 42b72b64f8a30..f6b3c5b8e5e82 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -18,7 +18,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![feature(drain_filter)] #![feature(exhaustive_patterns)] #![feature(iter_order_by)] -#![cfg_attr(bootstrap, feature(never_type))] +#![feature(never_type)] #![feature(specialization)] #![feature(try_trait)] #![feature(unicode_internals)] diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs index cf2e1306dc44b..1c95155e7ff1c 100644 --- a/src/librustc_mir/transform/qualify_min_const_fn.rs +++ b/src/librustc_mir/transform/qualify_min_const_fn.rs @@ -80,7 +80,7 @@ fn check_ty(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span, fn_def_id: DefId) -> Mc for ty in ty.walk() { match ty.kind { ty::Ref(_, _, hir::Mutability::Mutable) => { - if !tcx.features().const_mut_refs { + if !feature_allowed(tcx, fn_def_id, sym::const_mut_refs) { return Err(( span, "mutable references in const fn are unstable".into(), @@ -220,7 +220,7 @@ fn check_statement( } | StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) - if !tcx.features().const_if_match + if !feature_allowed(tcx, def_id, sym::const_if_match) => { Err((span, "loops and conditional expressions are not stable in const fn".into())) } @@ -272,7 +272,7 @@ fn check_place( while let &[ref proj_base @ .., elem] = cursor { cursor = proj_base; match elem { - ProjectionElem::Downcast(..) if !tcx.features().const_if_match + ProjectionElem::Downcast(..) if !feature_allowed(tcx, def_id, sym::const_if_match) => return Err((span, "`match` or `if let` in `const fn` is unstable".into())), ProjectionElem::Downcast(_symbol, _variant_index) => {} @@ -329,7 +329,7 @@ fn check_terminator( | TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. } - if !tcx.features().const_if_match + if !feature_allowed(tcx, def_id, sym::const_if_match) => Err(( span, "loops and conditional expressions are not stable in const fn".into(), @@ -341,7 +341,7 @@ fn check_terminator( } // FIXME(ecstaticmorse): We probably want to allow `Unreachable` unconditionally. - TerminatorKind::Unreachable if tcx.features().const_if_match => Ok(()), + TerminatorKind::Unreachable if feature_allowed(tcx, def_id, sym::const_if_match) => Ok(()), | TerminatorKind::Abort | TerminatorKind::Unreachable => { Err((span, "const fn with unreachable code is not stable".into())) diff --git a/src/librustc_target/spec/i686_unknown_dragonfly.rs b/src/librustc_target/spec/i686_unknown_dragonfly.rs deleted file mode 100644 index 20315e7145c73..0000000000000 --- a/src/librustc_target/spec/i686_unknown_dragonfly.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::spec::{LinkerFlavor, Target, TargetResult}; - -pub fn target() -> TargetResult { - let mut base = super::dragonfly_base::opts(); - base.cpu = "pentium4".to_string(); - base.max_atomic_width = Some(64); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string()); - base.stack_probes = true; - - Ok(Target { - llvm_target: "i686-unknown-dragonfly".to_string(), - target_endian: "little".to_string(), - target_pointer_width: "32".to_string(), - target_c_int_width: "32".to_string(), - data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(), - arch: "x86".to_string(), - target_os: "dragonfly".to_string(), - target_env: String::new(), - target_vendor: "unknown".to_string(), - linker_flavor: LinkerFlavor::Gcc, - options: base, - }) -} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index 693cf75e8fd64..34b321d38f0f6 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -398,7 +398,6 @@ supported_targets! { ("powerpc64-unknown-freebsd", powerpc64_unknown_freebsd), ("x86_64-unknown-freebsd", x86_64_unknown_freebsd), - ("i686-unknown-dragonfly", i686_unknown_dragonfly), ("x86_64-unknown-dragonfly", x86_64_unknown_dragonfly), ("aarch64-unknown-openbsd", aarch64_unknown_openbsd), diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 6a6294b6f8798..c6c9703e92c92 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -67,7 +67,7 @@ This API is completely unstable and subject to change. #![feature(in_band_lifetimes)] #![feature(nll)] #![feature(slice_patterns)] -#![cfg_attr(bootstrap, feature(never_type))] +#![feature(never_type)] #![recursion_limit="256"] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index a4be3dee938ed..8fed351c7a394 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -14,7 +14,7 @@ #![feature(crate_visibility_modifier)] #![feature(const_fn)] #![feature(drain_filter)] -#![cfg_attr(bootstrap, feature(never_type))] +#![feature(never_type)] #![feature(unicode_internals)] #![recursion_limit="256"] diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 13d83337f5f6f..e45d56c320cd8 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -11,7 +11,7 @@ Core encoding and decoding interfaces. #![feature(box_syntax)] #![feature(core_intrinsics)] #![feature(specialization)] -#![cfg_attr(bootstrap, feature(never_type))] +#![feature(never_type)] #![feature(nll)] #![feature(associated_type_bounds)] #![cfg_attr(test, feature(test))] diff --git a/src/libstd/error.rs b/src/libstd/error.rs index ec1c444bcf8c8..d4c4cb9c3b997 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -465,7 +465,7 @@ impl<'a> From> for Box { } } -#[stable(feature = "never_type", since = "1.41.0")] +#[unstable(feature = "never_type", issue = "35121")] impl Error for ! { fn description(&self) -> &str { *self } } @@ -551,6 +551,13 @@ impl Error for string::FromUtf16Error { } } +#[stable(feature = "str_parse_error2", since = "1.8.0")] +impl Error for string::ParseError { + fn description(&self) -> &str { + match *self {} + } +} + #[stable(feature = "decode_utf16", since = "1.9.0")] impl Error for char::DecodeUtf16Error { fn description(&self) -> &str { diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 1dbb0c6ec8310..6128c1d46ae3b 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -281,7 +281,7 @@ #![feature(maybe_uninit_ref)] #![feature(maybe_uninit_slice)] #![feature(needs_panic_runtime)] -#![cfg_attr(bootstrap, feature(never_type))] +#![feature(never_type)] #![feature(nll)] #![cfg_attr(bootstrap, feature(on_unimplemented))] #![feature(optin_builtin_traits)] diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index b4495588c9949..a72951c034610 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -71,6 +71,7 @@ mod prim_bool { } /// write: /// /// ``` +/// #![feature(never_type)] /// # fn foo() -> u32 { /// let x: ! = { /// return 123 @@ -200,6 +201,7 @@ mod prim_bool { } /// for example: /// /// ``` +/// #![feature(never_type)] /// # use std::fmt; /// # trait Debug { /// # fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result; @@ -237,7 +239,7 @@ mod prim_bool { } /// [`Default`]: default/trait.Default.html /// [`default()`]: default/trait.Default.html#tymethod.default /// -#[stable(feature = "never_type", since = "1.41.0")] +#[unstable(feature = "never_type", issue = "35121")] mod prim_never { } #[doc(primitive = "char")] diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index 3d2c3b1d4f901..99d89183e5b0d 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -464,11 +464,25 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { ast::TyKind::BareFn(ref bare_fn_ty) => { self.check_extern(bare_fn_ty.ext); } + ast::TyKind::Never => { + gate_feature_post!(&self, never_type, ty.span, + "The `!` type is experimental"); + } _ => {} } visit::walk_ty(self, ty) } + fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) { + if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty { + if let ast::TyKind::Never = output_ty.kind { + // Do nothing. + } else { + self.visit_ty(output_ty) + } + } + } + fn visit_expr(&mut self, e: &'a ast::Expr) { match e.kind { ast::ExprKind::Box(_) => { @@ -499,6 +513,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { visit::walk_expr(self, e) } + fn visit_arm(&mut self, arm: &'a ast::Arm) { + visit::walk_arm(self, arm) + } + fn visit_pat(&mut self, pattern: &'a ast::Pat) { match &pattern.kind { PatKind::Slice(pats) => { diff --git a/src/libsyntax_expand/mbe/macro_parser.rs b/src/libsyntax_expand/mbe/macro_parser.rs index bf7960f90660a..1e2f3f9d1e53e 100644 --- a/src/libsyntax_expand/mbe/macro_parser.rs +++ b/src/libsyntax_expand/mbe/macro_parser.rs @@ -83,7 +83,7 @@ use syntax::print::pprust; use syntax::sess::ParseSess; use syntax::symbol::{kw, sym, Symbol}; use syntax::token::{self, DocComment, Nonterminal, Token}; -use syntax::tokenstream::{DelimSpan, TokenStream}; +use syntax::tokenstream::TokenStream; use errors::{PResult, FatalError}; use smallvec::{smallvec, SmallVec}; @@ -164,11 +164,6 @@ struct MatcherPos<'root, 'tt> { /// The position of the "dot" in this matcher idx: usize, - /// The first span of source that the beginning of this matcher corresponds to. In other - /// words, the token in the source whose span is `sp_open` is matched against the first token of - /// the matcher. - sp_open: Span, - /// For each named metavar in the matcher, we keep track of token trees matched against the /// metavar by the black box parser. In particular, there may be more than one match per /// metavar if we are in a repetition (each repetition matches each of the variables). @@ -307,8 +302,8 @@ fn create_matches(len: usize) -> Box<[Lrc]> { } /// Generates the top-level matcher position in which the "dot" is before the first token of the -/// matcher `ms` and we are going to start matching at the span `open` in the source. -fn initial_matcher_pos<'root, 'tt>(ms: &'tt [TokenTree], open: Span) -> MatcherPos<'root, 'tt> { +/// matcher `ms`. +fn initial_matcher_pos<'root, 'tt>(ms: &'tt [TokenTree]) -> MatcherPos<'root, 'tt> { let match_idx_hi = count_names(ms); let matches = create_matches(match_idx_hi); MatcherPos { @@ -316,8 +311,6 @@ fn initial_matcher_pos<'root, 'tt>(ms: &'tt [TokenTree], open: Span) -> MatcherP top_elts: TtSeq(ms), // "elts" is an abbr. for "elements" // The "dot" is before the first token of the matcher idx: 0, - // We start matching at the span `open` in the source code - sp_open: open, // Initialize `matches` to a bunch of empty `Vec`s -- one for each metavar in `top_elts`. // `match_lo` for `top_elts` is 0 and `match_hi` is `matches.len()`. `match_cur` is 0 since @@ -355,7 +348,7 @@ fn initial_matcher_pos<'root, 'tt>(ms: &'tt [TokenTree], open: Span) -> MatcherP /// token tree it was derived from. #[derive(Debug, Clone)] crate enum NamedMatch { - MatchedSeq(Lrc, DelimSpan), + MatchedSeq(Lrc), MatchedNonterminal(Lrc), } @@ -497,8 +490,7 @@ fn inner_parse_loop<'root, 'tt>( // Add matches from this repetition to the `matches` of `up` for idx in item.match_lo..item.match_hi { let sub = item.matches[idx].clone(); - let span = DelimSpan::from_pair(item.sp_open, token.span); - new_pos.push_match(idx, MatchedSeq(sub, span)); + new_pos.push_match(idx, MatchedSeq(sub)); } // Move the "dot" past the repetition in `up` @@ -552,7 +544,7 @@ fn inner_parse_loop<'root, 'tt>( new_item.match_cur += seq.num_captures; new_item.idx += 1; for idx in item.match_cur..item.match_cur + seq.num_captures { - new_item.push_match(idx, MatchedSeq(Lrc::new(smallvec![]), sp)); + new_item.push_match(idx, MatchedSeq(Lrc::new(smallvec![]))); } cur_items.push(new_item); } @@ -568,7 +560,6 @@ fn inner_parse_loop<'root, 'tt>( match_cur: item.match_cur, match_hi: item.match_cur + seq.num_captures, up: Some(item), - sp_open: sp.open, top_elts: Tt(TokenTree::Sequence(sp, seq)), }))); } @@ -663,7 +654,7 @@ pub(super) fn parse( // // This MatcherPos instance is allocated on the stack. All others -- and // there are frequently *no* others! -- are allocated on the heap. - let mut initial = initial_matcher_pos(ms, parser.token.span); + let mut initial = initial_matcher_pos(ms); let mut cur_items = smallvec![MatcherPosHandle::Ref(&mut initial)]; let mut next_items = Vec::new(); diff --git a/src/libsyntax_expand/mbe/macro_rules.rs b/src/libsyntax_expand/mbe/macro_rules.rs index e3c3655bcf882..2dd15872a9f0a 100644 --- a/src/libsyntax_expand/mbe/macro_rules.rs +++ b/src/libsyntax_expand/mbe/macro_rules.rs @@ -379,7 +379,7 @@ pub fn compile_declarative_macro( // Extract the arguments: let lhses = match argument_map[&lhs_nm] { - MatchedSeq(ref s, _) => s + MatchedSeq(ref s) => s .iter() .map(|m| { if let MatchedNonterminal(ref nt) = *m { @@ -402,7 +402,7 @@ pub fn compile_declarative_macro( }; let rhses = match argument_map[&rhs_nm] { - MatchedSeq(ref s, _) => s + MatchedSeq(ref s) => s .iter() .map(|m| { if let MatchedNonterminal(ref nt) = *m { diff --git a/src/libsyntax_expand/mbe/transcribe.rs b/src/libsyntax_expand/mbe/transcribe.rs index a1157667df1b4..0605f7ff36df7 100644 --- a/src/libsyntax_expand/mbe/transcribe.rs +++ b/src/libsyntax_expand/mbe/transcribe.rs @@ -299,7 +299,7 @@ fn lookup_cur_matched<'a>( for &(idx, _) in repeats { match matched { MatchedNonterminal(_) => break, - MatchedSeq(ref ads, _) => matched = ads.get(idx).unwrap(), + MatchedSeq(ref ads) => matched = ads.get(idx).unwrap(), } } @@ -382,7 +382,7 @@ fn lockstep_iter_size( match lookup_cur_matched(name, interpolations, repeats) { Some(matched) => match matched { MatchedNonterminal(_) => LockstepIterSize::Unconstrained, - MatchedSeq(ref ads, _) => LockstepIterSize::Constraint(ads.len(), name), + MatchedSeq(ref ads) => LockstepIterSize::Constraint(ads.len(), name), }, _ => LockstepIterSize::Unconstrained, } diff --git a/src/test/codegen/enum-debug-niche-2.rs b/src/test/codegen/enum-debug-niche-2.rs index 7e00dc5463f68..0f17976ef4965 100644 --- a/src/test/codegen/enum-debug-niche-2.rs +++ b/src/test/codegen/enum-debug-niche-2.rs @@ -12,6 +12,8 @@ // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i64 4294967295{{[,)].*}} // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i64 0{{[,)].*}} +#![feature(never_type)] + #[derive(Copy, Clone)] pub struct Entity { private: std::num::NonZeroU32, diff --git a/src/test/mir-opt/retain-never-const.rs b/src/test/mir-opt/retain-never-const.rs index 5d59b2f48429d..04394dcdf1334 100644 --- a/src/test/mir-opt/retain-never-const.rs +++ b/src/test/mir-opt/retain-never-const.rs @@ -5,6 +5,7 @@ // compile-flags: --emit mir,link #![feature(const_panic)] +#![feature(never_type)] struct PrintName(T); diff --git a/src/test/mir-opt/uninhabited-enum.rs b/src/test/mir-opt/uninhabited-enum.rs index 409be8587cf0f..904a9c43c1bcc 100644 --- a/src/test/mir-opt/uninhabited-enum.rs +++ b/src/test/mir-opt/uninhabited-enum.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + pub enum Void {} #[no_mangle] diff --git a/src/test/ui/binding/empty-types-in-patterns.rs b/src/test/ui/binding/empty-types-in-patterns.rs index 1864d4bb8205b..4271ffb7b1b4d 100644 --- a/src/test/ui/binding/empty-types-in-patterns.rs +++ b/src/test/ui/binding/empty-types-in-patterns.rs @@ -1,5 +1,5 @@ // run-pass -#![feature(never_type_fallback)] +#![feature(never_type, never_type_fallback)] #![feature(exhaustive_patterns)] #![feature(slice_patterns)] #![allow(unreachable_patterns)] diff --git a/src/test/ui/borrowck/assign-never-type.rs b/src/test/ui/borrowck/assign-never-type.rs index 52b2e70d159a9..4f30ea1467023 100644 --- a/src/test/ui/borrowck/assign-never-type.rs +++ b/src/test/ui/borrowck/assign-never-type.rs @@ -2,6 +2,8 @@ // check-pass +#![feature(never_type)] + pub fn main() { loop { match None { diff --git a/src/test/ui/break-while-condition.rs b/src/test/ui/break-while-condition.rs index 7aa5682b923a6..6064e6ab00235 100644 --- a/src/test/ui/break-while-condition.rs +++ b/src/test/ui/break-while-condition.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + fn main() { // The `if false` expressions are simply to // make sure we don't avoid checking everything diff --git a/src/test/ui/break-while-condition.stderr b/src/test/ui/break-while-condition.stderr index bbc9f21edb06e..6960c4fd86735 100644 --- a/src/test/ui/break-while-condition.stderr +++ b/src/test/ui/break-while-condition.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/break-while-condition.rs:7:20 + --> $DIR/break-while-condition.rs:9:20 | LL | let _: ! = { | ____________________^ @@ -11,7 +11,7 @@ LL | | }; found unit type `()` error[E0308]: mismatched types - --> $DIR/break-while-condition.rs:14:13 + --> $DIR/break-while-condition.rs:16:13 | LL | / while false { LL | | break @@ -22,7 +22,7 @@ LL | | } found unit type `()` error[E0308]: mismatched types - --> $DIR/break-while-condition.rs:22:13 + --> $DIR/break-while-condition.rs:24:13 | LL | / while false { LL | | return diff --git a/src/test/ui/coercion/coerce-issue-49593-box-never.rs b/src/test/ui/coercion/coerce-issue-49593-box-never.rs index 55beb7c252895..0824ce8cd585b 100644 --- a/src/test/ui/coercion/coerce-issue-49593-box-never.rs +++ b/src/test/ui/coercion/coerce-issue-49593-box-never.rs @@ -1,5 +1,5 @@ // check-pass -#![feature(never_type_fallback)] +#![feature(never_type, never_type_fallback)] #![allow(unreachable_code)] use std::error::Error; diff --git a/src/test/ui/coercion/coerce-to-bang-cast.rs b/src/test/ui/coercion/coerce-to-bang-cast.rs index ea1384a1dab55..8ef1948084654 100644 --- a/src/test/ui/coercion/coerce-to-bang-cast.rs +++ b/src/test/ui/coercion/coerce-to-bang-cast.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + fn foo(x: usize, y: !, z: usize) { } fn cast_a() { diff --git a/src/test/ui/coercion/coerce-to-bang-cast.stderr b/src/test/ui/coercion/coerce-to-bang-cast.stderr index 0e17f32511f82..ff30ebc09c63a 100644 --- a/src/test/ui/coercion/coerce-to-bang-cast.stderr +++ b/src/test/ui/coercion/coerce-to-bang-cast.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `i32` as `!` - --> $DIR/coerce-to-bang-cast.rs:4:13 + --> $DIR/coerce-to-bang-cast.rs:6:13 | LL | let y = {return; 22} as !; | ^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | let y = {return; 22} as !; = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait error[E0605]: non-primitive cast: `i32` as `!` - --> $DIR/coerce-to-bang-cast.rs:9:13 + --> $DIR/coerce-to-bang-cast.rs:11:13 | LL | let y = 22 as !; | ^^^^^^^ diff --git a/src/test/ui/coercion/coerce-to-bang.rs b/src/test/ui/coercion/coerce-to-bang.rs index d52f79fbb7a98..1e06934d09f9e 100644 --- a/src/test/ui/coercion/coerce-to-bang.rs +++ b/src/test/ui/coercion/coerce-to-bang.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + fn foo(x: usize, y: !, z: usize) { } fn call_foo_a() { diff --git a/src/test/ui/coercion/coerce-to-bang.stderr b/src/test/ui/coercion/coerce-to-bang.stderr index ca42705973750..390aa7c692d18 100644 --- a/src/test/ui/coercion/coerce-to-bang.stderr +++ b/src/test/ui/coercion/coerce-to-bang.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:4:17 + --> $DIR/coerce-to-bang.rs:6:17 | LL | foo(return, 22, 44); | ^^ expected `!`, found integer @@ -8,7 +8,7 @@ LL | foo(return, 22, 44); found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:16:13 + --> $DIR/coerce-to-bang.rs:18:13 | LL | foo(22, 44, return); | ^^ expected `!`, found integer @@ -17,7 +17,7 @@ LL | foo(22, 44, return); found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:24:12 + --> $DIR/coerce-to-bang.rs:26:12 | LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverge. | ^ expected `!`, found integer @@ -26,7 +26,7 @@ LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverg found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:34:12 + --> $DIR/coerce-to-bang.rs:36:12 | LL | foo(a, b, c); | ^ expected `!`, found integer @@ -35,7 +35,7 @@ LL | foo(a, b, c); found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:43:12 + --> $DIR/coerce-to-bang.rs:45:12 | LL | foo(a, b, c); | ^ expected `!`, found integer @@ -44,7 +44,7 @@ LL | foo(a, b, c); found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:48:21 + --> $DIR/coerce-to-bang.rs:50:21 | LL | let x: [!; 2] = [return, 22]; | ------ ^^^^^^^^^^^^ expected `!`, found integer @@ -55,7 +55,7 @@ LL | let x: [!; 2] = [return, 22]; found array `[{integer}; 2]` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:53:22 + --> $DIR/coerce-to-bang.rs:55:22 | LL | let x: [!; 2] = [22, return]; | ^^ expected `!`, found integer @@ -64,7 +64,7 @@ LL | let x: [!; 2] = [22, return]; found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:58:37 + --> $DIR/coerce-to-bang.rs:60:37 | LL | let x: (usize, !, usize) = (22, 44, 66); | ^^ expected `!`, found integer @@ -73,7 +73,7 @@ LL | let x: (usize, !, usize) = (22, 44, 66); found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:63:41 + --> $DIR/coerce-to-bang.rs:65:41 | LL | let x: (usize, !, usize) = (return, 44, 66); | ^^ expected `!`, found integer @@ -82,7 +82,7 @@ LL | let x: (usize, !, usize) = (return, 44, 66); found type `{integer}` error[E0308]: mismatched types - --> $DIR/coerce-to-bang.rs:74:37 + --> $DIR/coerce-to-bang.rs:76:37 | LL | let x: (usize, !, usize) = (22, 44, return); | ^^ expected `!`, found integer diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs index 516ca4f3f77e0..f6ab0bd7dbed6 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs @@ -1,5 +1,6 @@ // Regression test for #66975 #![warn(const_err)] +#![feature(never_type)] struct PrintName(T); diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index e2bd8d0cc85ea..24830f7344c3b 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -1,5 +1,5 @@ warning: any use of this value will cause an error - --> $DIR/index-out-of-bounds-never-type.rs:7:61 + --> $DIR/index-out-of-bounds-never-type.rs:8:61 | LL | const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; | --------------------------------------------------------^^^^^--- @@ -13,7 +13,7 @@ LL | #![warn(const_err)] | ^^^^^^^^^ error: erroneous constant encountered - --> $DIR/index-out-of-bounds-never-type.rs:12:13 + --> $DIR/index-out-of-bounds-never-type.rs:13:13 | LL | let _ = PrintName::::VOID; | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index b39d9af5546f8..a7cbdb40ef108 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -1,6 +1,7 @@ // Regression test for #66975 #![warn(const_err)] #![feature(const_panic)] +#![feature(never_type)] struct PrintName; diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index c07c8c65a2f20..e15952c20e493 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,10 +1,10 @@ warning: any use of this value will cause an error - --> $DIR/panic-assoc-never-type.rs:8:21 + --> $DIR/panic-assoc-never-type.rs:9:21 | LL | const VOID: ! = panic!(); | ----------------^^^^^^^^- | | - | the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:8:21 + | the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:9:21 | note: lint level defined here --> $DIR/panic-assoc-never-type.rs:2:9 @@ -14,7 +14,7 @@ LL | #![warn(const_err)] = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/panic-assoc-never-type.rs:13:13 + --> $DIR/panic-assoc-never-type.rs:14:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/panic-never-type.rs b/src/test/ui/consts/const-eval/panic-never-type.rs index 42eabbf58470f..b1a7d8ae676a8 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-never-type.rs @@ -1,6 +1,7 @@ // Regression test for #66975 #![warn(const_err)] #![feature(const_panic)] +#![feature(never_type)] const VOID: ! = panic!(); //~^ WARN any use of this value will cause an error diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr index 4fb11a61525f4..9e91fdf451415 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -1,10 +1,10 @@ warning: any use of this value will cause an error - --> $DIR/panic-never-type.rs:5:17 + --> $DIR/panic-never-type.rs:6:17 | LL | const VOID: ! = panic!(); | ----------------^^^^^^^^- | | - | the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:5:17 + | the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:6:17 | note: lint level defined here --> $DIR/panic-never-type.rs:2:9 @@ -14,7 +14,7 @@ LL | #![warn(const_err)] = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/panic-never-type.rs:9:13 + --> $DIR/panic-never-type.rs:10:13 | LL | let _ = VOID; | ^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-mut-refs/const_mut_refs.rs b/src/test/ui/consts/const-mut-refs/const_mut_refs.rs index 99006a20b1bcb..33abfec02a87a 100644 --- a/src/test/ui/consts/const-mut-refs/const_mut_refs.rs +++ b/src/test/ui/consts/const-mut-refs/const_mut_refs.rs @@ -1,6 +1,7 @@ // run-pass #![feature(const_mut_refs)] +#![feature(const_fn)] struct Foo { x: usize diff --git a/src/test/ui/consts/control-flow/basics.rs b/src/test/ui/consts/control-flow/basics.rs index 8bd1929956fd3..b9ff040915863 100644 --- a/src/test/ui/consts/control-flow/basics.rs +++ b/src/test/ui/consts/control-flow/basics.rs @@ -4,6 +4,7 @@ #![feature(const_panic)] #![feature(const_if_match)] +#![feature(const_fn)] const X: u32 = 4; const Y: u32 = 5; diff --git a/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs b/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs index 6bbbdd972a26c..7887fd12e5764 100644 --- a/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs +++ b/src/test/ui/consts/control-flow/exhaustive-c-like-enum-match.rs @@ -3,6 +3,7 @@ // check-pass #![feature(const_if_match)] +#![feature(const_fn)] enum E { A, diff --git a/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr b/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr index 21e3f2af15ad6..95096723b3c95 100644 --- a/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr +++ b/src/test/ui/consts/control-flow/feature-gate-const-if-match.if_match.stderr @@ -1,5 +1,5 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/feature-gate-const-if-match.rs:108:1 + --> $DIR/feature-gate-const-if-match.rs:109:1 | LL | / fn main() { LL | | let _ = [0; { diff --git a/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs b/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs index 00576d50ac66b..e4b65257531fd 100644 --- a/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs +++ b/src/test/ui/consts/control-flow/feature-gate-const-if-match.rs @@ -6,6 +6,7 @@ #![feature(rustc_attrs)] #![cfg_attr(if_match, feature(const_if_match))] +#![feature(const_fn)] const _: i32 = if true { //[stock]~ ERROR `if` is not allowed in a `const` 5 diff --git a/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr b/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr index d3c6a51923ffb..e846ee4ab6a41 100644 --- a/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr +++ b/src/test/ui/consts/control-flow/feature-gate-const-if-match.stock.stderr @@ -1,5 +1,5 @@ error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:10:16 + --> $DIR/feature-gate-const-if-match.rs:11:16 | LL | const _: i32 = if true { | ________________^ @@ -13,7 +13,7 @@ LL | | }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:16:16 + --> $DIR/feature-gate-const-if-match.rs:17:16 | LL | const _: i32 = if let Some(true) = Some(false) { | ________________^ @@ -27,7 +27,7 @@ LL | | }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:22:16 + --> $DIR/feature-gate-const-if-match.rs:23:16 | LL | const _: i32 = match 1 { | ________________^ @@ -41,7 +41,7 @@ LL | | }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `static` - --> $DIR/feature-gate-const-if-match.rs:29:13 + --> $DIR/feature-gate-const-if-match.rs:30:13 | LL | let x = if true { 0 } else { 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ LL | let x = if true { 0 } else { 1 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `static` - --> $DIR/feature-gate-const-if-match.rs:31:13 + --> $DIR/feature-gate-const-if-match.rs:32:13 | LL | let x = match x { 0 => 1, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | let x = match x { 0 => 1, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `static` - --> $DIR/feature-gate-const-if-match.rs:33:5 + --> $DIR/feature-gate-const-if-match.rs:34:5 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ LL | if let Some(x) = Some(x) { x } else { 1 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `static mut` - --> $DIR/feature-gate-const-if-match.rs:38:13 + --> $DIR/feature-gate-const-if-match.rs:39:13 | LL | let x = if true { 0 } else { 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -77,7 +77,7 @@ LL | let x = if true { 0 } else { 1 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `static mut` - --> $DIR/feature-gate-const-if-match.rs:40:13 + --> $DIR/feature-gate-const-if-match.rs:41:13 | LL | let x = match x { 0 => 1, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -86,7 +86,7 @@ LL | let x = match x { 0 => 1, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `static mut` - --> $DIR/feature-gate-const-if-match.rs:42:5 + --> $DIR/feature-gate-const-if-match.rs:43:5 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -95,7 +95,7 @@ LL | if let Some(x) = Some(x) { x } else { 1 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:47:5 + --> $DIR/feature-gate-const-if-match.rs:48:5 | LL | if true { 5 } else { 6 } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ LL | if true { 5 } else { 6 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:51:5 + --> $DIR/feature-gate-const-if-match.rs:52:5 | LL | / if let Some(true) = a { LL | | 0 @@ -117,7 +117,7 @@ LL | | } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:59:5 + --> $DIR/feature-gate-const-if-match.rs:60:5 | LL | / match i { LL | | i if i > 10 => i, @@ -130,7 +130,7 @@ LL | | } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:90:17 + --> $DIR/feature-gate-const-if-match.rs:91:17 | LL | let x = if y { 0 } else { 1 }; | ^^^^^^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL | let x = if y { 0 } else { 1 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:92:17 + --> $DIR/feature-gate-const-if-match.rs:93:17 | LL | let x = match x { 0 => 1, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -148,7 +148,7 @@ LL | let x = match x { 0 => 1, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const fn` - --> $DIR/feature-gate-const-if-match.rs:94:9 + --> $DIR/feature-gate-const-if-match.rs:95:9 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -157,7 +157,7 @@ LL | if let Some(x) = Some(x) { x } else { 1 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:110:17 + --> $DIR/feature-gate-const-if-match.rs:111:17 | LL | let x = if false { 0 } else { 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -166,7 +166,7 @@ LL | let x = if false { 0 } else { 1 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:112:17 + --> $DIR/feature-gate-const-if-match.rs:113:17 | LL | let x = match x { 0 => 1, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -175,7 +175,7 @@ LL | let x = match x { 0 => 1, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:114:9 + --> $DIR/feature-gate-const-if-match.rs:115:9 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -184,7 +184,7 @@ LL | if let Some(x) = Some(x) { x } else { 1 } = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:67:21 + --> $DIR/feature-gate-const-if-match.rs:68:21 | LL | const IF: i32 = if true { 5 } else { 6 }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | const IF: i32 = if true { 5 } else { 6 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:70:25 + --> $DIR/feature-gate-const-if-match.rs:71:25 | LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -202,7 +202,7 @@ LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:73:24 + --> $DIR/feature-gate-const-if-match.rs:74:24 | LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -211,7 +211,7 @@ LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:78:21 + --> $DIR/feature-gate-const-if-match.rs:79:21 | LL | const IF: i32 = if true { 5 } else { 6 }; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -220,7 +220,7 @@ LL | const IF: i32 = if true { 5 } else { 6 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `if` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:81:25 + --> $DIR/feature-gate-const-if-match.rs:82:25 | LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -229,7 +229,7 @@ LL | const IF_LET: i32 = if let Some(true) = None { 5 } else { 6 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0658]: `match` is not allowed in a `const` - --> $DIR/feature-gate-const-if-match.rs:84:24 + --> $DIR/feature-gate-const-if-match.rs:85:24 | LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -238,7 +238,7 @@ LL | const MATCH: i32 = match 0 { 1 => 2, _ => 0 }; = help: add `#![feature(const_if_match)]` to the crate attributes to enable error[E0019]: constant contains unimplemented expression type - --> $DIR/feature-gate-const-if-match.rs:114:21 + --> $DIR/feature-gate-const-if-match.rs:115:21 | LL | if let Some(x) = Some(x) { x } else { 1 } | ^ diff --git a/src/test/ui/consts/control-flow/short-circuit-let.rs b/src/test/ui/consts/control-flow/short-circuit-let.rs index 8cee2a54f56d3..4b20a2124c356 100644 --- a/src/test/ui/consts/control-flow/short-circuit-let.rs +++ b/src/test/ui/consts/control-flow/short-circuit-let.rs @@ -4,6 +4,7 @@ #![feature(const_if_match)] #![feature(const_panic)] +#![feature(const_fn)] const X: i32 = { let mut x = 0; diff --git a/src/test/ui/consts/control-flow/single_variant_match_ice.rs b/src/test/ui/consts/control-flow/single_variant_match_ice.rs index 823605ff034f1..bb0fce66c4d89 100644 --- a/src/test/ui/consts/control-flow/single_variant_match_ice.rs +++ b/src/test/ui/consts/control-flow/single_variant_match_ice.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(const_if_match)] +#![feature(const_if_match, const_fn)] enum Foo { Prob, diff --git a/src/test/ui/consts/validate_never_arrays.rs b/src/test/ui/consts/validate_never_arrays.rs index 1270dc4ee30e6..9610b7b22f161 100644 --- a/src/test/ui/consts/validate_never_arrays.rs +++ b/src/test/ui/consts/validate_never_arrays.rs @@ -1,4 +1,4 @@ -#![feature(const_raw_ptr_deref)] +#![feature(const_raw_ptr_deref, never_type)] const FOO: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior diff --git a/src/test/ui/empty/empty-never-array.rs b/src/test/ui/empty/empty-never-array.rs index 38702f8d28f90..f0ecea42f39c8 100644 --- a/src/test/ui/empty/empty-never-array.rs +++ b/src/test/ui/empty/empty-never-array.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + enum Helper { T(T, [!; 0]), #[allow(dead_code)] diff --git a/src/test/ui/empty/empty-never-array.stderr b/src/test/ui/empty/empty-never-array.stderr index defcd256f7d98..d865b59f0b945 100644 --- a/src/test/ui/empty/empty-never-array.stderr +++ b/src/test/ui/empty/empty-never-array.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding: `T(_, _)` not covered - --> $DIR/empty-never-array.rs:8:9 + --> $DIR/empty-never-array.rs:10:9 | LL | / enum Helper { LL | | T(T, [!; 0]), @@ -20,7 +20,7 @@ LL | if let Helper::U(u) = Helper::T(t, []) { /* */ } | error[E0381]: use of possibly-uninitialized variable: `u` - --> $DIR/empty-never-array.rs:10:5 + --> $DIR/empty-never-array.rs:12:5 | LL | u | ^ use of possibly-uninitialized `u` diff --git a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.rs b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.rs index c27089d2a0590..f0cc9ea70550e 100644 --- a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.rs +++ b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + fn foo() -> Result { Ok(123) } diff --git a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr index e599a9ee150f4..08c36cece4cf9 100644 --- a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr +++ b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding: `Err(_)` not covered - --> $DIR/feature-gate-exhaustive-patterns.rs:6:9 + --> $DIR/feature-gate-exhaustive-patterns.rs:8:9 | LL | let Ok(_x) = foo(); | ^^^^^^ pattern `Err(_)` not covered diff --git a/src/test/ui/feature-gates/feature-gate-never_type.rs b/src/test/ui/feature-gates/feature-gate-never_type.rs new file mode 100644 index 0000000000000..be8c27dbb1b02 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-never_type.rs @@ -0,0 +1,17 @@ +// Test that ! errors when used in illegal positions with feature(never_type) disabled + +trait Foo { + type Wub; +} + +type Ma = (u32, !, i32); //~ ERROR type is experimental +type Meeshka = Vec; //~ ERROR type is experimental +type Mow = &'static fn(!) -> !; //~ ERROR type is experimental +type Skwoz = &'static mut !; //~ ERROR type is experimental + +impl Foo for Meeshka { + type Wub = !; //~ ERROR type is experimental +} + +fn main() { +} diff --git a/src/test/ui/feature-gates/feature-gate-never_type.stderr b/src/test/ui/feature-gates/feature-gate-never_type.stderr new file mode 100644 index 0000000000000..d86ab99b82bd5 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-never_type.stderr @@ -0,0 +1,48 @@ +error[E0658]: The `!` type is experimental + --> $DIR/feature-gate-never_type.rs:7:17 + | +LL | type Ma = (u32, !, i32); + | ^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/35121 + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error[E0658]: The `!` type is experimental + --> $DIR/feature-gate-never_type.rs:8:20 + | +LL | type Meeshka = Vec; + | ^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/35121 + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error[E0658]: The `!` type is experimental + --> $DIR/feature-gate-never_type.rs:9:24 + | +LL | type Mow = &'static fn(!) -> !; + | ^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/35121 + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error[E0658]: The `!` type is experimental + --> $DIR/feature-gate-never_type.rs:10:27 + | +LL | type Skwoz = &'static mut !; + | ^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/35121 + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error[E0658]: The `!` type is experimental + --> $DIR/feature-gate-never_type.rs:13:16 + | +LL | type Wub = !; + | ^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/35121 + = help: add `#![feature(never_type)]` to the crate attributes to enable + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/for-loop-while/loop-break-value.rs b/src/test/ui/for-loop-while/loop-break-value.rs index 29848bb0cedaa..d7209fc4de867 100644 --- a/src/test/ui/for-loop-while/loop-break-value.rs +++ b/src/test/ui/for-loop-while/loop-break-value.rs @@ -1,6 +1,7 @@ // run-pass #![allow(unreachable_code)] +#![feature(never_type)] #[allow(unused)] fn never_returns() { diff --git a/src/test/ui/lint/must_use-unit.rs b/src/test/ui/lint/must_use-unit.rs index 8f59bab26d3ef..4dd4798abb7ce 100644 --- a/src/test/ui/lint/must_use-unit.rs +++ b/src/test/ui/lint/must_use-unit.rs @@ -1,3 +1,4 @@ +#![feature(never_type)] #![deny(unused_must_use)] #[must_use] diff --git a/src/test/ui/lint/must_use-unit.stderr b/src/test/ui/lint/must_use-unit.stderr index a6d0259a081af..0a9939b2015b7 100644 --- a/src/test/ui/lint/must_use-unit.stderr +++ b/src/test/ui/lint/must_use-unit.stderr @@ -1,17 +1,17 @@ error: unused return value of `foo` that must be used - --> $DIR/must_use-unit.rs:12:5 + --> $DIR/must_use-unit.rs:13:5 | LL | foo(); | ^^^^^^ | note: lint level defined here - --> $DIR/must_use-unit.rs:1:9 + --> $DIR/must_use-unit.rs:2:9 | LL | #![deny(unused_must_use)] | ^^^^^^^^^^^^^^^ error: unused return value of `bar` that must be used - --> $DIR/must_use-unit.rs:14:5 + --> $DIR/must_use-unit.rs:15:5 | LL | bar(); | ^^^^^^ diff --git a/src/test/ui/lint/uninitialized-zeroed.rs b/src/test/ui/lint/uninitialized-zeroed.rs index ed2369fd650b0..473be434a7524 100644 --- a/src/test/ui/lint/uninitialized-zeroed.rs +++ b/src/test/ui/lint/uninitialized-zeroed.rs @@ -2,7 +2,7 @@ // This test checks that calling `mem::{uninitialized,zeroed}` with certain types results // in a lint. -#![feature(rustc_attrs)] +#![feature(never_type, rustc_attrs)] #![allow(deprecated)] #![deny(invalid_value)] diff --git a/src/test/ui/loops/loop-break-value.rs b/src/test/ui/loops/loop-break-value.rs index c4fb68c02784e..6c4160c36aa39 100644 --- a/src/test/ui/loops/loop-break-value.rs +++ b/src/test/ui/loops/loop-break-value.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + fn main() { let val: ! = loop { break break; }; //~^ ERROR mismatched types diff --git a/src/test/ui/loops/loop-break-value.stderr b/src/test/ui/loops/loop-break-value.stderr index 1f2d81ff03f0a..3bb0cd50d63fb 100644 --- a/src/test/ui/loops/loop-break-value.stderr +++ b/src/test/ui/loops/loop-break-value.stderr @@ -1,5 +1,5 @@ warning: denote infinite loops with `loop { ... }` - --> $DIR/loop-break-value.rs:24:5 + --> $DIR/loop-break-value.rs:26:5 | LL | 'while_loop: while true { | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `loop` @@ -7,7 +7,7 @@ LL | 'while_loop: while true { = note: `#[warn(while_true)]` on by default error[E0571]: `break` with value from a `while` loop - --> $DIR/loop-break-value.rs:26:9 + --> $DIR/loop-break-value.rs:28:9 | LL | break (); | ^^^^^^^^ can only break with a value inside `loop` or breakable block @@ -18,7 +18,7 @@ LL | break; | ^^^^^ error[E0571]: `break` with value from a `while` loop - --> $DIR/loop-break-value.rs:28:13 + --> $DIR/loop-break-value.rs:30:13 | LL | break 'while_loop 123; | ^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block @@ -29,7 +29,7 @@ LL | break; | ^^^^^ error[E0571]: `break` with value from a `while` loop - --> $DIR/loop-break-value.rs:36:12 + --> $DIR/loop-break-value.rs:38:12 | LL | if break () { | ^^^^^^^^ can only break with a value inside `loop` or breakable block @@ -40,7 +40,7 @@ LL | if break { | ^^^^^ error[E0571]: `break` with value from a `while` loop - --> $DIR/loop-break-value.rs:41:9 + --> $DIR/loop-break-value.rs:43:9 | LL | break None; | ^^^^^^^^^^ can only break with a value inside `loop` or breakable block @@ -51,7 +51,7 @@ LL | break; | ^^^^^ error[E0571]: `break` with value from a `while` loop - --> $DIR/loop-break-value.rs:47:13 + --> $DIR/loop-break-value.rs:49:13 | LL | break 'while_let_loop "nope"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block @@ -62,7 +62,7 @@ LL | break; | ^^^^^ error[E0571]: `break` with value from a `for` loop - --> $DIR/loop-break-value.rs:54:9 + --> $DIR/loop-break-value.rs:56:9 | LL | break (); | ^^^^^^^^ can only break with a value inside `loop` or breakable block @@ -73,7 +73,7 @@ LL | break; | ^^^^^ error[E0571]: `break` with value from a `for` loop - --> $DIR/loop-break-value.rs:55:9 + --> $DIR/loop-break-value.rs:57:9 | LL | break [()]; | ^^^^^^^^^^ can only break with a value inside `loop` or breakable block @@ -84,7 +84,7 @@ LL | break; | ^^^^^ error[E0571]: `break` with value from a `for` loop - --> $DIR/loop-break-value.rs:62:13 + --> $DIR/loop-break-value.rs:64:13 | LL | break 'for_loop Some(17); | ^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block @@ -95,7 +95,7 @@ LL | break; | ^^^^^ error[E0308]: mismatched types - --> $DIR/loop-break-value.rs:2:31 + --> $DIR/loop-break-value.rs:4:31 | LL | let val: ! = loop { break break; }; | ^^^^^ expected `!`, found `()` @@ -104,31 +104,31 @@ LL | let val: ! = loop { break break; }; found unit type `()` error[E0308]: mismatched types - --> $DIR/loop-break-value.rs:9:19 + --> $DIR/loop-break-value.rs:11:19 | LL | break 123; | ^^^ expected `&str`, found integer error[E0308]: mismatched types - --> $DIR/loop-break-value.rs:14:15 + --> $DIR/loop-break-value.rs:16:15 | LL | break "asdf"; | ^^^^^^ expected `i32`, found `&str` error[E0308]: mismatched types - --> $DIR/loop-break-value.rs:19:31 + --> $DIR/loop-break-value.rs:21:31 | LL | break 'outer_loop "nope"; | ^^^^^^ expected `i32`, found `&str` error[E0308]: mismatched types - --> $DIR/loop-break-value.rs:71:26 + --> $DIR/loop-break-value.rs:73:26 | LL | break 'c 123; | ^^^ expected `()`, found integer error[E0308]: mismatched types - --> $DIR/loop-break-value.rs:78:15 + --> $DIR/loop-break-value.rs:80:15 | LL | break (break, break); | ^^^^^^^^^^^^^^ expected `()`, found tuple @@ -137,13 +137,13 @@ LL | break (break, break); found tuple `(!, !)` error[E0308]: mismatched types - --> $DIR/loop-break-value.rs:83:15 + --> $DIR/loop-break-value.rs:85:15 | LL | break 2; | ^ expected `()`, found integer error[E0308]: mismatched types - --> $DIR/loop-break-value.rs:88:9 + --> $DIR/loop-break-value.rs:90:9 | LL | break; | ^^^^^ diff --git a/src/test/ui/mir/mir_calls_to_shims.rs b/src/test/ui/mir/mir_calls_to_shims.rs index df7c45ad1d1c7..6f13d5612ce51 100644 --- a/src/test/ui/mir/mir_calls_to_shims.rs +++ b/src/test/ui/mir/mir_calls_to_shims.rs @@ -2,6 +2,7 @@ // ignore-wasm32-bare compiled with panic=abort by default #![feature(fn_traits)] +#![feature(never_type)] use std::panic; diff --git a/src/test/ui/never_type/adjust_never.rs b/src/test/ui/never_type/adjust_never.rs index e4d15c8a17dfa..0d7d2c0ed3fa9 100644 --- a/src/test/ui/never_type/adjust_never.rs +++ b/src/test/ui/never_type/adjust_never.rs @@ -2,6 +2,8 @@ // check-pass +#![feature(never_type)] + fn main() { let x: ! = panic!(); let y: u32 = x; diff --git a/src/test/ui/never_type/auto-traits.rs b/src/test/ui/never_type/auto-traits.rs index 8a02720ab27fd..2d9689888cb30 100644 --- a/src/test/ui/never_type/auto-traits.rs +++ b/src/test/ui/never_type/auto-traits.rs @@ -1,6 +1,7 @@ // check-pass #![feature(optin_builtin_traits)] +#![feature(never_type)] fn main() { enum Void {} diff --git a/src/test/ui/never_type/call-fn-never-arg-wrong-type.rs b/src/test/ui/never_type/call-fn-never-arg-wrong-type.rs index a2b44e91f1141..d06637e74a2f2 100644 --- a/src/test/ui/never_type/call-fn-never-arg-wrong-type.rs +++ b/src/test/ui/never_type/call-fn-never-arg-wrong-type.rs @@ -1,5 +1,7 @@ // Test that we can't pass other types for ! +#![feature(never_type)] + fn foo(x: !) -> ! { x } diff --git a/src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr b/src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr index 69049fc8db69b..eacef1dc3302d 100644 --- a/src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr +++ b/src/test/ui/never_type/call-fn-never-arg-wrong-type.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/call-fn-never-arg-wrong-type.rs:8:9 + --> $DIR/call-fn-never-arg-wrong-type.rs:10:9 | LL | foo("wow"); | ^^^^^ expected `!`, found `&str` diff --git a/src/test/ui/never_type/call-fn-never-arg.rs b/src/test/ui/never_type/call-fn-never-arg.rs index 55a7b79157a82..9d355817ee80d 100644 --- a/src/test/ui/never_type/call-fn-never-arg.rs +++ b/src/test/ui/never_type/call-fn-never-arg.rs @@ -2,6 +2,7 @@ // check-pass +#![feature(never_type)] #![allow(unreachable_code)] fn foo(x: !) -> ! { diff --git a/src/test/ui/never_type/cast-never.rs b/src/test/ui/never_type/cast-never.rs index fbba114ab3274..0139ebe4640be 100644 --- a/src/test/ui/never_type/cast-never.rs +++ b/src/test/ui/never_type/cast-never.rs @@ -2,6 +2,8 @@ // check-pass +#![feature(never_type)] + fn main() { let x: ! = panic!(); let y: u32 = x as u32; diff --git a/src/test/ui/never_type/defaulted-never-note.rs b/src/test/ui/never_type/defaulted-never-note.rs index c58b611748423..1780cb6535d05 100644 --- a/src/test/ui/never_type/defaulted-never-note.rs +++ b/src/test/ui/never_type/defaulted-never-note.rs @@ -1,6 +1,6 @@ // We need to opt into the `never_type_fallback` feature // to trigger the requirement that this is testing. -#![feature(never_type_fallback)] +#![feature(never_type, never_type_fallback)] #![allow(unused)] diff --git a/src/test/ui/never_type/dispatch_from_dyn_zst.rs b/src/test/ui/never_type/dispatch_from_dyn_zst.rs index 342d5e4791515..764f58ce9e805 100644 --- a/src/test/ui/never_type/dispatch_from_dyn_zst.rs +++ b/src/test/ui/never_type/dispatch_from_dyn_zst.rs @@ -1,6 +1,6 @@ // run-pass -#![feature(unsize, dispatch_from_dyn)] +#![feature(unsize, dispatch_from_dyn, never_type)] #![allow(dead_code)] diff --git a/src/test/ui/never_type/diverging-fallback-control-flow.rs b/src/test/ui/never_type/diverging-fallback-control-flow.rs index df04437b1ae20..ea4881049d792 100644 --- a/src/test/ui/never_type/diverging-fallback-control-flow.rs +++ b/src/test/ui/never_type/diverging-fallback-control-flow.rs @@ -11,7 +11,7 @@ // These represent current behavior, but are pretty dubious. I would // like to revisit these and potentially change them. --nmatsakis -#![feature(never_type_fallback)] +#![feature(never_type, never_type_fallback)] trait BadDefault { fn default() -> Self; diff --git a/src/test/ui/never_type/impl-for-never.rs b/src/test/ui/never_type/impl-for-never.rs index cbfda9a2cc00a..9423f08858b9b 100644 --- a/src/test/ui/never_type/impl-for-never.rs +++ b/src/test/ui/never_type/impl-for-never.rs @@ -1,5 +1,7 @@ // run-pass +#![feature(never_type)] + // Test that we can call static methods on ! both directly and when it appears in a generic trait StringifyType { diff --git a/src/test/ui/never_type/issue-44402.rs b/src/test/ui/never_type/issue-44402.rs index 0e6588bbe78ea..699e480dfe7e5 100644 --- a/src/test/ui/never_type/issue-44402.rs +++ b/src/test/ui/never_type/issue-44402.rs @@ -1,6 +1,7 @@ // check-pass #![allow(dead_code)] +#![feature(never_type)] #![feature(exhaustive_patterns)] // Regression test for inhabitedness check. The old diff --git a/src/test/ui/never_type/never-assign-dead-code.rs b/src/test/ui/never_type/never-assign-dead-code.rs index 5c1300c715128..7bb7c87097c50 100644 --- a/src/test/ui/never_type/never-assign-dead-code.rs +++ b/src/test/ui/never_type/never-assign-dead-code.rs @@ -2,6 +2,7 @@ // check-pass +#![feature(never_type)] #![warn(unused)] fn main() { diff --git a/src/test/ui/never_type/never-assign-dead-code.stderr b/src/test/ui/never_type/never-assign-dead-code.stderr index 1dc15251d1aa1..1860150fa8bc6 100644 --- a/src/test/ui/never_type/never-assign-dead-code.stderr +++ b/src/test/ui/never_type/never-assign-dead-code.stderr @@ -1,5 +1,5 @@ warning: unreachable statement - --> $DIR/never-assign-dead-code.rs:9:5 + --> $DIR/never-assign-dead-code.rs:10:5 | LL | let x: ! = panic!("aah"); | ------------- any code following this expression is unreachable @@ -7,7 +7,7 @@ LL | drop(x); | ^^^^^^^^ unreachable statement | note: lint level defined here - --> $DIR/never-assign-dead-code.rs:5:9 + --> $DIR/never-assign-dead-code.rs:6:9 | LL | #![warn(unused)] | ^^^^^^ @@ -15,7 +15,7 @@ LL | #![warn(unused)] = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: unreachable call - --> $DIR/never-assign-dead-code.rs:9:5 + --> $DIR/never-assign-dead-code.rs:10:5 | LL | drop(x); | ^^^^ - any code following this expression is unreachable @@ -23,13 +23,13 @@ LL | drop(x); | unreachable call warning: unused variable: `x` - --> $DIR/never-assign-dead-code.rs:8:9 + --> $DIR/never-assign-dead-code.rs:9:9 | LL | let x: ! = panic!("aah"); | ^ help: consider prefixing with an underscore: `_x` | note: lint level defined here - --> $DIR/never-assign-dead-code.rs:5:9 + --> $DIR/never-assign-dead-code.rs:6:9 | LL | #![warn(unused)] | ^^^^^^ diff --git a/src/test/ui/never_type/never-assign-wrong-type.rs b/src/test/ui/never_type/never-assign-wrong-type.rs index 9ca1ac7462d4d..67e26f5663f41 100644 --- a/src/test/ui/never_type/never-assign-wrong-type.rs +++ b/src/test/ui/never_type/never-assign-wrong-type.rs @@ -1,5 +1,6 @@ // Test that we can't use another type in place of ! +#![feature(never_type)] #![deny(warnings)] fn main() { diff --git a/src/test/ui/never_type/never-assign-wrong-type.stderr b/src/test/ui/never_type/never-assign-wrong-type.stderr index 4349d98029eaf..ce34d9483247f 100644 --- a/src/test/ui/never_type/never-assign-wrong-type.stderr +++ b/src/test/ui/never_type/never-assign-wrong-type.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/never-assign-wrong-type.rs:6:16 + --> $DIR/never-assign-wrong-type.rs:7:16 | LL | let x: ! = "hello"; | - ^^^^^^^ expected `!`, found `&str` diff --git a/src/test/ui/never_type/never-associated-type.rs b/src/test/ui/never_type/never-associated-type.rs index 45e54b9bf7c18..3bb917c931635 100644 --- a/src/test/ui/never_type/never-associated-type.rs +++ b/src/test/ui/never_type/never-associated-type.rs @@ -2,6 +2,8 @@ // check-pass +#![feature(never_type)] + trait Foo { type Wow; diff --git a/src/test/ui/never_type/never-from-impl-is-reserved.rs b/src/test/ui/never_type/never-from-impl-is-reserved.rs index df74b6a53f888..9d16015bdc129 100644 --- a/src/test/ui/never_type/never-from-impl-is-reserved.rs +++ b/src/test/ui/never_type/never-from-impl-is-reserved.rs @@ -1,5 +1,7 @@ // check that the `for T: From` impl is reserved +#![feature(never_type)] + pub struct MyFoo; pub trait MyTrait {} diff --git a/src/test/ui/never_type/never-from-impl-is-reserved.stderr b/src/test/ui/never_type/never-from-impl-is-reserved.stderr index 8b3155988ea95..8b8d0f4ea73be 100644 --- a/src/test/ui/never_type/never-from-impl-is-reserved.stderr +++ b/src/test/ui/never_type/never-from-impl-is-reserved.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyFoo`: - --> $DIR/never-from-impl-is-reserved.rs:8:1 + --> $DIR/never-from-impl-is-reserved.rs:10:1 | LL | impl MyTrait for MyFoo {} | ---------------------- first implementation here diff --git a/src/test/ui/never_type/never-result.rs b/src/test/ui/never_type/never-result.rs index 800553fce874d..35af37910ef3e 100644 --- a/src/test/ui/never_type/never-result.rs +++ b/src/test/ui/never_type/never-result.rs @@ -5,6 +5,8 @@ // Test that we can extract a ! through pattern matching then use it as several different types. +#![feature(never_type)] + fn main() { let x: Result = Ok(123); match x { diff --git a/src/test/ui/never_type/never-type-arg.rs b/src/test/ui/never_type/never-type-arg.rs index 3cbb114f43b94..13cd59e6aa9f1 100644 --- a/src/test/ui/never_type/never-type-arg.rs +++ b/src/test/ui/never_type/never-type-arg.rs @@ -2,6 +2,8 @@ // check-pass +#![feature(never_type)] + struct Wub; impl PartialEq for Wub { diff --git a/src/test/ui/never_type/never-type-rvalues.rs b/src/test/ui/never_type/never-type-rvalues.rs index 9bfc5572b9ee6..9ccc73dbf92d4 100644 --- a/src/test/ui/never_type/never-type-rvalues.rs +++ b/src/test/ui/never_type/never-type-rvalues.rs @@ -1,5 +1,6 @@ // run-pass +#![feature(never_type)] #![allow(dead_code)] #![allow(path_statements)] #![allow(unreachable_patterns)] diff --git a/src/test/ui/never_type/never-value-fallback-issue-66757.rs b/src/test/ui/never_type/never-value-fallback-issue-66757.rs new file mode 100644 index 0000000000000..f2e9e087307db --- /dev/null +++ b/src/test/ui/never_type/never-value-fallback-issue-66757.rs @@ -0,0 +1,29 @@ +// Regression test for #66757 +// +// Test than when you have a `!` value (e.g., the local variable +// never) and an uninferred variable (here the argument to `From`) it +// doesn't fallback to `()` but rather `!`. +// +// run-pass + +#![feature(never_type)] + +// FIXME(#67225) -- this should be true even without the fallback gate. +#![feature(never_type_fallback)] + +struct E; + +impl From for E { + fn from(_: !) -> E { + E + } +} + +#[allow(unreachable_code)] +#[allow(dead_code)] +fn foo(never: !) { + >::from(never); // Ok + >::from(never); // Inference fails here +} + +fn main() { } diff --git a/src/test/ui/never_type/never_transmute_never.rs b/src/test/ui/never_type/never_transmute_never.rs index cdf04de19e523..fce3ced9aac7f 100644 --- a/src/test/ui/never_type/never_transmute_never.rs +++ b/src/test/ui/never_type/never_transmute_never.rs @@ -2,6 +2,7 @@ #![crate_type="lib"] +#![feature(never_type)] #![allow(dead_code)] #![allow(unreachable_code)] #![allow(unused_variables)] diff --git a/src/test/ui/never_type/panic-uninitialized-zeroed.rs b/src/test/ui/never_type/panic-uninitialized-zeroed.rs index e5e0e188de63c..e0c30160b9e94 100644 --- a/src/test/ui/never_type/panic-uninitialized-zeroed.rs +++ b/src/test/ui/never_type/panic-uninitialized-zeroed.rs @@ -3,6 +3,7 @@ // This test checks that instantiating an uninhabited type via `mem::{uninitialized,zeroed}` results // in a runtime panic. +#![feature(never_type)] #![allow(deprecated, invalid_value)] use std::{mem, panic}; diff --git a/src/test/ui/never_type/try_from.rs b/src/test/ui/never_type/try_from.rs index 977ea3656b3dd..50451576f9c97 100644 --- a/src/test/ui/never_type/try_from.rs +++ b/src/test/ui/never_type/try_from.rs @@ -5,6 +5,8 @@ // This test was added to show the motivation for doing this // over `TryFrom` being blanket impl for all `T: From` +#![feature(never_type)] + use std::convert::{TryInto, Infallible}; struct Foo { diff --git a/src/test/ui/pattern/usefulness/match-privately-empty.rs b/src/test/ui/pattern/usefulness/match-privately-empty.rs index ea608651387b7..315eb03d16564 100644 --- a/src/test/ui/pattern/usefulness/match-privately-empty.rs +++ b/src/test/ui/pattern/usefulness/match-privately-empty.rs @@ -1,3 +1,4 @@ +#![feature(never_type)] #![feature(exhaustive_patterns)] mod private { diff --git a/src/test/ui/pattern/usefulness/match-privately-empty.stderr b/src/test/ui/pattern/usefulness/match-privately-empty.stderr index 66d0d9587741b..f79d180a1b8b5 100644 --- a/src/test/ui/pattern/usefulness/match-privately-empty.stderr +++ b/src/test/ui/pattern/usefulness/match-privately-empty.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `Some(Private { misc: true, .. })` not covered - --> $DIR/match-privately-empty.rs:12:11 + --> $DIR/match-privately-empty.rs:13:11 | LL | match private::DATA { | ^^^^^^^^^^^^^ pattern `Some(Private { misc: true, .. })` not covered diff --git a/src/test/ui/print_type_sizes/uninhabited.rs b/src/test/ui/print_type_sizes/uninhabited.rs index 3a2ca19d8e0c3..ae4e492456af9 100644 --- a/src/test/ui/print_type_sizes/uninhabited.rs +++ b/src/test/ui/print_type_sizes/uninhabited.rs @@ -4,6 +4,7 @@ // ^-- needed because `--pass check` does not emit the output needed. // FIXME: consider using an attribute instead of side-effects. +#![feature(never_type)] #![feature(start)] #[start] diff --git a/src/test/ui/reachable/expr_add.rs b/src/test/ui/reachable/expr_add.rs index 640c2a2cf8fcc..b45e5daf42c8d 100644 --- a/src/test/ui/reachable/expr_add.rs +++ b/src/test/ui/reachable/expr_add.rs @@ -1,3 +1,4 @@ +#![feature(never_type)] #![allow(unused_variables)] #![deny(unreachable_code)] diff --git a/src/test/ui/reachable/expr_add.stderr b/src/test/ui/reachable/expr_add.stderr index 11c41fdc3946b..880dea1cc3516 100644 --- a/src/test/ui/reachable/expr_add.stderr +++ b/src/test/ui/reachable/expr_add.stderr @@ -1,5 +1,5 @@ error: unreachable expression - --> $DIR/expr_add.rs:16:13 + --> $DIR/expr_add.rs:17:13 | LL | let x = Foo + return; | ^^^^^^------ @@ -8,7 +8,7 @@ LL | let x = Foo + return; | unreachable expression | note: lint level defined here - --> $DIR/expr_add.rs:2:9 + --> $DIR/expr_add.rs:3:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/reachable/expr_assign.rs b/src/test/ui/reachable/expr_assign.rs index 3914fb32432ef..e547f75e2697b 100644 --- a/src/test/ui/reachable/expr_assign.rs +++ b/src/test/ui/reachable/expr_assign.rs @@ -1,3 +1,4 @@ +#![feature(never_type)] #![allow(unused_variables)] #![allow(unused_assignments)] #![allow(dead_code)] diff --git a/src/test/ui/reachable/expr_assign.stderr b/src/test/ui/reachable/expr_assign.stderr index 90aec15e3be1e..3004da0406328 100644 --- a/src/test/ui/reachable/expr_assign.stderr +++ b/src/test/ui/reachable/expr_assign.stderr @@ -1,5 +1,5 @@ error: unreachable expression - --> $DIR/expr_assign.rs:9:5 + --> $DIR/expr_assign.rs:10:5 | LL | x = return; | ^^^^------ @@ -8,13 +8,13 @@ LL | x = return; | unreachable expression | note: lint level defined here - --> $DIR/expr_assign.rs:4:9 + --> $DIR/expr_assign.rs:5:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ error: unreachable expression - --> $DIR/expr_assign.rs:19:14 + --> $DIR/expr_assign.rs:20:14 | LL | *p = return; | -- ^^^^^^ unreachable expression @@ -22,7 +22,7 @@ LL | *p = return; | any code following this expression is unreachable error: unreachable expression - --> $DIR/expr_assign.rs:25:15 + --> $DIR/expr_assign.rs:26:15 | LL | *{return; &mut i} = 22; | ------ ^^^^^^ unreachable expression diff --git a/src/test/ui/reachable/expr_call.rs b/src/test/ui/reachable/expr_call.rs index ce1a94e3c4a25..1eaa96c3ce773 100644 --- a/src/test/ui/reachable/expr_call.rs +++ b/src/test/ui/reachable/expr_call.rs @@ -1,3 +1,4 @@ +#![feature(never_type)] #![allow(unused_variables)] #![allow(unused_assignments)] #![allow(dead_code)] diff --git a/src/test/ui/reachable/expr_call.stderr b/src/test/ui/reachable/expr_call.stderr index 613fc31b8613e..ae8b4dd87b5b9 100644 --- a/src/test/ui/reachable/expr_call.stderr +++ b/src/test/ui/reachable/expr_call.stderr @@ -1,5 +1,5 @@ error: unreachable expression - --> $DIR/expr_call.rs:12:17 + --> $DIR/expr_call.rs:13:17 | LL | foo(return, 22); | ------ ^^ unreachable expression @@ -7,13 +7,13 @@ LL | foo(return, 22); | any code following this expression is unreachable | note: lint level defined here - --> $DIR/expr_call.rs:4:9 + --> $DIR/expr_call.rs:5:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ error: unreachable call - --> $DIR/expr_call.rs:17:5 + --> $DIR/expr_call.rs:18:5 | LL | bar(return); | ^^^ ------ any code following this expression is unreachable diff --git a/src/test/ui/reachable/expr_cast.rs b/src/test/ui/reachable/expr_cast.rs index 76a7306b9d9e0..f53bcb97e6972 100644 --- a/src/test/ui/reachable/expr_cast.rs +++ b/src/test/ui/reachable/expr_cast.rs @@ -2,7 +2,7 @@ #![allow(unused_assignments)] #![allow(dead_code)] #![deny(unreachable_code)] -#![feature(type_ascription)] +#![feature(never_type, type_ascription)] fn a() { // the cast is unreachable: diff --git a/src/test/ui/reachable/expr_method.rs b/src/test/ui/reachable/expr_method.rs index e74a7daec8828..d917df05b3c3d 100644 --- a/src/test/ui/reachable/expr_method.rs +++ b/src/test/ui/reachable/expr_method.rs @@ -1,3 +1,4 @@ +#![feature(never_type)] #![allow(unused_variables)] #![allow(unused_assignments)] #![allow(dead_code)] diff --git a/src/test/ui/reachable/expr_method.stderr b/src/test/ui/reachable/expr_method.stderr index 7475cf7a365b5..82a0745f0629f 100644 --- a/src/test/ui/reachable/expr_method.stderr +++ b/src/test/ui/reachable/expr_method.stderr @@ -1,5 +1,5 @@ error: unreachable expression - --> $DIR/expr_method.rs:15:21 + --> $DIR/expr_method.rs:16:21 | LL | Foo.foo(return, 22); | ------ ^^ unreachable expression @@ -7,13 +7,13 @@ LL | Foo.foo(return, 22); | any code following this expression is unreachable | note: lint level defined here - --> $DIR/expr_method.rs:4:9 + --> $DIR/expr_method.rs:5:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ error: unreachable call - --> $DIR/expr_method.rs:20:9 + --> $DIR/expr_method.rs:21:9 | LL | Foo.bar(return); | ^^^ ------ any code following this expression is unreachable diff --git a/src/test/ui/reachable/expr_type.rs b/src/test/ui/reachable/expr_type.rs index ff647bda0e87e..8d32397b54248 100644 --- a/src/test/ui/reachable/expr_type.rs +++ b/src/test/ui/reachable/expr_type.rs @@ -2,7 +2,7 @@ #![allow(unused_assignments)] #![allow(dead_code)] #![deny(unreachable_code)] -#![feature(type_ascription)] +#![feature(never_type, type_ascription)] fn a() { // the cast is unreachable: diff --git a/src/test/ui/reachable/expr_unary.rs b/src/test/ui/reachable/expr_unary.rs index 6f221c360cb17..e229d22ebc798 100644 --- a/src/test/ui/reachable/expr_unary.rs +++ b/src/test/ui/reachable/expr_unary.rs @@ -1,3 +1,4 @@ +#![feature(never_type)] #![allow(unused_variables)] #![allow(unused_assignments)] #![allow(dead_code)] diff --git a/src/test/ui/reachable/expr_unary.stderr b/src/test/ui/reachable/expr_unary.stderr index a576f92092335..f5c3564217bba 100644 --- a/src/test/ui/reachable/expr_unary.stderr +++ b/src/test/ui/reachable/expr_unary.stderr @@ -1,11 +1,11 @@ error[E0600]: cannot apply unary operator `!` to type `!` - --> $DIR/expr_unary.rs:7:16 + --> $DIR/expr_unary.rs:8:16 | LL | let x: ! = ! { return; }; | ^^^^^^^^^^^^^ cannot apply unary operator `!` error: unreachable expression - --> $DIR/expr_unary.rs:7:16 + --> $DIR/expr_unary.rs:8:16 | LL | let x: ! = ! { return; }; | ^^^^------^^^ @@ -14,7 +14,7 @@ LL | let x: ! = ! { return; }; | unreachable expression | note: lint level defined here - --> $DIR/expr_unary.rs:4:9 + --> $DIR/expr_unary.rs:5:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/reachable/unreachable-loop-patterns.rs b/src/test/ui/reachable/unreachable-loop-patterns.rs index c8ff56539116f..4de29c3c3d761 100644 --- a/src/test/ui/reachable/unreachable-loop-patterns.rs +++ b/src/test/ui/reachable/unreachable-loop-patterns.rs @@ -1,4 +1,4 @@ -#![feature(never_type_fallback)] +#![feature(never_type, never_type_fallback)] #![feature(exhaustive_patterns)] #![allow(unreachable_code)] diff --git a/src/test/ui/reachable/unreachable-try-pattern.rs b/src/test/ui/reachable/unreachable-try-pattern.rs index e2d89e93a2aa0..23360e73f4a3a 100644 --- a/src/test/ui/reachable/unreachable-try-pattern.rs +++ b/src/test/ui/reachable/unreachable-try-pattern.rs @@ -1,5 +1,5 @@ // check-pass -#![feature(exhaustive_patterns)] +#![feature(never_type, exhaustive_patterns)] #![warn(unreachable_code)] #![warn(unreachable_patterns)] diff --git a/src/test/ui/reachable/unwarned-match-on-never.rs b/src/test/ui/reachable/unwarned-match-on-never.rs index c38ea6ab9ad01..71f8fe3a783e2 100644 --- a/src/test/ui/reachable/unwarned-match-on-never.rs +++ b/src/test/ui/reachable/unwarned-match-on-never.rs @@ -1,6 +1,8 @@ #![deny(unreachable_code)] #![allow(dead_code)] +#![feature(never_type)] + fn foo(x: !) -> bool { // Explicit matches on the never type are unwarned. match x {} diff --git a/src/test/ui/reachable/unwarned-match-on-never.stderr b/src/test/ui/reachable/unwarned-match-on-never.stderr index 6710fcb777f7a..6b2fb4a33c1e8 100644 --- a/src/test/ui/reachable/unwarned-match-on-never.stderr +++ b/src/test/ui/reachable/unwarned-match-on-never.stderr @@ -1,5 +1,5 @@ error: unreachable expression - --> $DIR/unwarned-match-on-never.rs:8:5 + --> $DIR/unwarned-match-on-never.rs:10:5 | LL | match x {} | - any code following this expression is unreachable @@ -14,7 +14,7 @@ LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ error: unreachable arm - --> $DIR/unwarned-match-on-never.rs:13:15 + --> $DIR/unwarned-match-on-never.rs:15:15 | LL | match (return) { | -------- any code following this expression is unreachable @@ -22,7 +22,7 @@ LL | () => () | ^^ unreachable arm error: unreachable expression - --> $DIR/unwarned-match-on-never.rs:19:5 + --> $DIR/unwarned-match-on-never.rs:21:5 | LL | return; | ------ any code following this expression is unreachable diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs index e074183a0490c..a2735d4cbfb29 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/auxiliary/uninhabited.rs @@ -1,4 +1,5 @@ #![crate_type = "rlib"] +#![feature(never_type)] #[non_exhaustive] pub enum UninhabitedEnum { diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions.rs index 5684ee6b7bf86..80b9dc4c1c338 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions.rs @@ -1,4 +1,5 @@ // aux-build:uninhabited.rs +#![feature(never_type)] extern crate uninhabited; diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions.stderr index d50e5f6b795f7..d2d319f50c78d 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/coercions.rs:22:5 + --> $DIR/coercions.rs:23:5 | LL | fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { | - expected `A` because of return type @@ -7,7 +7,7 @@ LL | x | ^ expected struct `A`, found enum `uninhabited::UninhabitedEnum` error[E0308]: mismatched types - --> $DIR/coercions.rs:26:5 + --> $DIR/coercions.rs:27:5 | LL | fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { | - expected `A` because of return type @@ -15,7 +15,7 @@ LL | x | ^ expected struct `A`, found struct `uninhabited::UninhabitedTupleStruct` error[E0308]: mismatched types - --> $DIR/coercions.rs:30:5 + --> $DIR/coercions.rs:31:5 | LL | fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { | - expected `A` because of return type @@ -23,7 +23,7 @@ LL | x | ^ expected struct `A`, found struct `uninhabited::UninhabitedStruct` error[E0308]: mismatched types - --> $DIR/coercions.rs:34:5 + --> $DIR/coercions.rs:35:5 | LL | fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { | - expected `A` because of return type diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs index c3c0ce650d73e..6b911dd989cc5 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + #[non_exhaustive] pub enum UninhabitedEnum { } diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr index 16a62a992497d..fd2c56974bd4a 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/coercions_same_crate.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/coercions_same_crate.rs:28:5 + --> $DIR/coercions_same_crate.rs:30:5 | LL | fn cannot_coerce_empty_enum_to_anything(x: UninhabitedEnum) -> A { | - expected `A` because of return type @@ -7,7 +7,7 @@ LL | x | ^ expected struct `A`, found enum `UninhabitedEnum` error[E0308]: mismatched types - --> $DIR/coercions_same_crate.rs:32:5 + --> $DIR/coercions_same_crate.rs:34:5 | LL | fn cannot_coerce_empty_tuple_struct_to_anything(x: UninhabitedTupleStruct) -> A { | - expected `A` because of return type @@ -15,7 +15,7 @@ LL | x | ^ expected struct `A`, found struct `UninhabitedTupleStruct` error[E0308]: mismatched types - --> $DIR/coercions_same_crate.rs:36:5 + --> $DIR/coercions_same_crate.rs:38:5 | LL | fn cannot_coerce_empty_struct_to_anything(x: UninhabitedStruct) -> A { | - expected `A` because of return type @@ -23,7 +23,7 @@ LL | x | ^ expected struct `A`, found struct `UninhabitedStruct` error[E0308]: mismatched types - --> $DIR/coercions_same_crate.rs:40:5 + --> $DIR/coercions_same_crate.rs:42:5 | LL | fn cannot_coerce_enum_with_empty_variants_to_anything(x: UninhabitedVariants) -> A { | - expected `A` because of return type diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs index 511b6b1bf8f6c..98a7fdbc5049a 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.rs @@ -1,4 +1,5 @@ // aux-build:uninhabited.rs +#![feature(never_type)] extern crate uninhabited; diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr index b903e9b288ef7..af82022e1da99 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: pattern `IndirectUninhabitedEnum` of type `uninhabited::IndirectUninhabitedEnum` is not handled - --> $DIR/indirect_match.rs:18:11 + --> $DIR/indirect_match.rs:19:11 | LL | match x {} | ^ @@ -7,7 +7,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: pattern `IndirectUninhabitedStruct` of type `uninhabited::IndirectUninhabitedStruct` is not handled - --> $DIR/indirect_match.rs:22:11 + --> $DIR/indirect_match.rs:23:11 | LL | match x {} | ^ @@ -15,7 +15,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: pattern `IndirectUninhabitedTupleStruct` of type `uninhabited::IndirectUninhabitedTupleStruct` is not handled - --> $DIR/indirect_match.rs:26:11 + --> $DIR/indirect_match.rs:27:11 | LL | match x {} | ^ @@ -23,7 +23,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: pattern `IndirectUninhabitedVariants` of type `uninhabited::IndirectUninhabitedVariants` is not handled - --> $DIR/indirect_match.rs:32:11 + --> $DIR/indirect_match.rs:33:11 | LL | match x {} | ^ diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs index 9c3ec4240a5fd..8f090fe886a00 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + #[non_exhaustive] pub enum UninhabitedEnum { } diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr index f94616dc64b1b..c03018a523647 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_same_crate.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: pattern `IndirectUninhabitedEnum` of type `IndirectUninhabitedEnum` is not handled - --> $DIR/indirect_match_same_crate.rs:32:11 + --> $DIR/indirect_match_same_crate.rs:34:11 | LL | pub struct IndirectUninhabitedEnum(UninhabitedEnum); | ---------------------------------------------------- @@ -13,7 +13,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: pattern `IndirectUninhabitedStruct` of type `IndirectUninhabitedStruct` is not handled - --> $DIR/indirect_match_same_crate.rs:36:11 + --> $DIR/indirect_match_same_crate.rs:38:11 | LL | pub struct IndirectUninhabitedStruct(UninhabitedStruct); | -------------------------------------------------------- @@ -27,7 +27,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: pattern `IndirectUninhabitedTupleStruct` of type `IndirectUninhabitedTupleStruct` is not handled - --> $DIR/indirect_match_same_crate.rs:40:11 + --> $DIR/indirect_match_same_crate.rs:42:11 | LL | pub struct IndirectUninhabitedTupleStruct(UninhabitedTupleStruct); | ------------------------------------------------------------------ @@ -41,7 +41,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: pattern `IndirectUninhabitedVariants` of type `IndirectUninhabitedVariants` is not handled - --> $DIR/indirect_match_same_crate.rs:46:11 + --> $DIR/indirect_match_same_crate.rs:48:11 | LL | pub struct IndirectUninhabitedVariants(UninhabitedVariants); | ------------------------------------------------------------ diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs index 68ac42ef5878d..be86519ecb159 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.rs @@ -1,6 +1,7 @@ // aux-build:uninhabited.rs #![deny(unreachable_patterns)] #![feature(exhaustive_patterns)] +#![feature(never_type)] extern crate uninhabited; diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr index 2c2e542934177..17a8d01007205 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: type `uninhabited::IndirectUninhabitedEnum` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:22:11 + --> $DIR/indirect_match_with_exhaustive_patterns.rs:23:11 | LL | match x {} | ^ @@ -7,7 +7,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: type `uninhabited::IndirectUninhabitedStruct` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:26:11 + --> $DIR/indirect_match_with_exhaustive_patterns.rs:27:11 | LL | match x {} | ^ @@ -15,7 +15,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: type `uninhabited::IndirectUninhabitedTupleStruct` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:30:11 + --> $DIR/indirect_match_with_exhaustive_patterns.rs:31:11 | LL | match x {} | ^ @@ -23,7 +23,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: type `uninhabited::IndirectUninhabitedVariants` is non-empty - --> $DIR/indirect_match_with_exhaustive_patterns.rs:36:11 + --> $DIR/indirect_match_with_exhaustive_patterns.rs:37:11 | LL | match x {} | ^ diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs index 06c318414f03f..60289aa780378 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/indirect_match_with_exhaustive_patterns_same_crate.rs @@ -2,6 +2,7 @@ #![deny(unreachable_patterns)] #![feature(exhaustive_patterns)] +#![feature(never_type)] #[non_exhaustive] pub enum UninhabitedEnum { diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.rs index fd3dbca04c00f..e54098d4d48b9 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.rs @@ -1,4 +1,5 @@ // aux-build:uninhabited.rs +#![feature(never_type)] extern crate uninhabited; diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr index de3fa900cd622..de39688f45a4d 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: type `uninhabited::UninhabitedEnum` is non-empty - --> $DIR/match.rs:18:11 + --> $DIR/match.rs:19:11 | LL | match x {} | ^ @@ -7,7 +7,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: pattern `UninhabitedStruct` of type `uninhabited::UninhabitedStruct` is not handled - --> $DIR/match.rs:22:11 + --> $DIR/match.rs:23:11 | LL | match x {} | ^ @@ -15,7 +15,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: pattern `UninhabitedTupleStruct` of type `uninhabited::UninhabitedTupleStruct` is not handled - --> $DIR/match.rs:26:11 + --> $DIR/match.rs:27:11 | LL | match x {} | ^ @@ -23,7 +23,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: multiple patterns of type `uninhabited::UninhabitedVariants` are not handled - --> $DIR/match.rs:30:11 + --> $DIR/match.rs:31:11 | LL | match x {} | ^ diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs index c31688add91b2..ebbdfba15f3a3 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.rs @@ -1,3 +1,5 @@ +#![feature(never_type)] + #[non_exhaustive] pub enum UninhabitedEnum { } diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr index 3dd1a914d5542..c39df05a8f74e 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_same_crate.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: pattern `UninhabitedStruct` of type `UninhabitedStruct` is not handled - --> $DIR/match_same_crate.rs:28:11 + --> $DIR/match_same_crate.rs:30:11 | LL | pub struct UninhabitedStruct { | - ----------------- variant not covered @@ -15,7 +15,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: pattern `UninhabitedTupleStruct` of type `UninhabitedTupleStruct` is not handled - --> $DIR/match_same_crate.rs:32:11 + --> $DIR/match_same_crate.rs:34:11 | LL | pub struct UninhabitedTupleStruct(!); | ------------------------------------- @@ -29,7 +29,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: multiple patterns of type `UninhabitedVariants` are not handled - --> $DIR/match_same_crate.rs:36:11 + --> $DIR/match_same_crate.rs:38:11 | LL | / pub enum UninhabitedVariants { LL | | #[non_exhaustive] Tuple(!), diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs index 37d739834d20c..900dfff652ea6 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.rs @@ -1,6 +1,7 @@ // aux-build:uninhabited.rs #![deny(unreachable_patterns)] #![feature(exhaustive_patterns)] +#![feature(never_type)] extern crate uninhabited; diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr index 3b56c6890710d..48a888bc50be0 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: type `uninhabited::UninhabitedEnum` is non-empty - --> $DIR/match_with_exhaustive_patterns.rs:21:11 + --> $DIR/match_with_exhaustive_patterns.rs:22:11 | LL | match x {} | ^ @@ -7,7 +7,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: type `uninhabited::UninhabitedStruct` is non-empty - --> $DIR/match_with_exhaustive_patterns.rs:25:11 + --> $DIR/match_with_exhaustive_patterns.rs:26:11 | LL | match x {} | ^ @@ -15,7 +15,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: type `uninhabited::UninhabitedTupleStruct` is non-empty - --> $DIR/match_with_exhaustive_patterns.rs:29:11 + --> $DIR/match_with_exhaustive_patterns.rs:30:11 | LL | match x {} | ^ @@ -23,7 +23,7 @@ LL | match x {} = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms error[E0004]: non-exhaustive patterns: type `uninhabited::UninhabitedVariants` is non-empty - --> $DIR/match_with_exhaustive_patterns.rs:33:11 + --> $DIR/match_with_exhaustive_patterns.rs:34:11 | LL | match x {} | ^ diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs index 2b2e4b6e77d87..de5530485f3e6 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns_same_crate.rs @@ -2,6 +2,7 @@ #![deny(unreachable_patterns)] #![feature(exhaustive_patterns)] +#![feature(never_type)] #[non_exhaustive] pub enum UninhabitedEnum { diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs index 3d4cca4505ef1..ffc496a975ecf 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.rs @@ -1,5 +1,6 @@ #![deny(unreachable_patterns)] #![feature(exhaustive_patterns)] +#![feature(never_type)] #[non_exhaustive] pub enum UninhabitedEnum { diff --git a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr index fea883f891200..e3de94be1282e 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/patterns_same_crate.rs:51:9 + --> $DIR/patterns_same_crate.rs:52:9 | LL | Some(_x) => (), | ^^^^^^^^ @@ -11,25 +11,25 @@ LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/patterns_same_crate.rs:56:9 + --> $DIR/patterns_same_crate.rs:57:9 | LL | Some(_x) => (), | ^^^^^^^^ error: unreachable pattern - --> $DIR/patterns_same_crate.rs:60:15 + --> $DIR/patterns_same_crate.rs:61:15 | LL | while let PartiallyInhabitedVariants::Struct { x } = partially_inhabited_variant() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/patterns_same_crate.rs:64:15 + --> $DIR/patterns_same_crate.rs:65:15 | LL | while let Some(_x) = uninhabited_struct() { | ^^^^^^^^ error: unreachable pattern - --> $DIR/patterns_same_crate.rs:67:15 + --> $DIR/patterns_same_crate.rs:68:15 | LL | while let Some(_x) = uninhabited_tuple_struct() { | ^^^^^^^^ diff --git a/src/test/ui/suggestions/option-content-move2.rs b/src/test/ui/suggestions/option-content-move2.rs new file mode 100644 index 0000000000000..88e8a5b7aeef0 --- /dev/null +++ b/src/test/ui/suggestions/option-content-move2.rs @@ -0,0 +1,16 @@ +struct NotCopyable; + +fn func H, H: FnMut()>(_: F) {} + +fn parse() { + let mut var = None; + func(|| { + // Shouldn't suggest `move ||.as_ref()` here + move || { + //~^ ERROR: cannot move out of `var` + var = Some(NotCopyable); + } + }); +} + +fn main() {} diff --git a/src/test/ui/suggestions/option-content-move2.stderr b/src/test/ui/suggestions/option-content-move2.stderr new file mode 100644 index 0000000000000..71f745374e5ac --- /dev/null +++ b/src/test/ui/suggestions/option-content-move2.stderr @@ -0,0 +1,18 @@ +error[E0507]: cannot move out of `var`, a captured variable in an `FnMut` closure + --> $DIR/option-content-move2.rs:9:9 + | +LL | let mut var = None; + | ------- captured outer variable +... +LL | move || { + | ^^^^^^^ move out of `var` occurs here +LL | +LL | var = Some(NotCopyable); + | --- + | | + | move occurs because `var` has type `std::option::Option`, which does not implement the `Copy` trait + | move occurs due to use in closure + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs b/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs index 0e0197803b761..f14589ccf846d 100644 --- a/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs +++ b/src/test/ui/traits/reservation-impls/reservation-impl-non-lattice-ok.rs @@ -30,7 +30,7 @@ // // [ii]: http://smallcultfollowing.com/babysteps/blog/2016/09/24/intersection-impls/ -#![feature(rustc_attrs)] +#![feature(rustc_attrs, never_type)] trait MyTrait {} diff --git a/src/test/ui/type-sizes.rs b/src/test/ui/type-sizes.rs index 3dfe0ad7f72c1..27433fd770b05 100644 --- a/src/test/ui/type-sizes.rs +++ b/src/test/ui/type-sizes.rs @@ -2,6 +2,7 @@ #![allow(non_camel_case_types)] #![allow(dead_code)] +#![feature(never_type)] use std::mem::size_of; diff --git a/src/test/ui/uninhabited/uninhabited-irrefutable.rs b/src/test/ui/uninhabited/uninhabited-irrefutable.rs index 84daa35484f81..48cd92719b49a 100644 --- a/src/test/ui/uninhabited/uninhabited-irrefutable.rs +++ b/src/test/ui/uninhabited/uninhabited-irrefutable.rs @@ -1,3 +1,4 @@ +#![feature(never_type)] #![feature(exhaustive_patterns)] mod foo { diff --git a/src/test/ui/uninhabited/uninhabited-irrefutable.stderr b/src/test/ui/uninhabited/uninhabited-irrefutable.stderr index 6ba03ee508316..26e1be34ea75d 100644 --- a/src/test/ui/uninhabited/uninhabited-irrefutable.stderr +++ b/src/test/ui/uninhabited/uninhabited-irrefutable.stderr @@ -1,5 +1,5 @@ error[E0005]: refutable pattern in local binding: `A(_)` not covered - --> $DIR/uninhabited-irrefutable.rs:26:9 + --> $DIR/uninhabited-irrefutable.rs:27:9 | LL | / enum Foo { LL | | A(foo::SecretlyEmpty), diff --git a/src/test/ui/uninhabited/uninhabited-patterns.rs b/src/test/ui/uninhabited/uninhabited-patterns.rs index 66a1a7f7735eb..1bf01184a08e7 100644 --- a/src/test/ui/uninhabited/uninhabited-patterns.rs +++ b/src/test/ui/uninhabited/uninhabited-patterns.rs @@ -1,5 +1,6 @@ #![feature(box_patterns)] #![feature(box_syntax)] +#![feature(never_type)] #![feature(exhaustive_patterns)] #![feature(slice_patterns)] #![deny(unreachable_patterns)] diff --git a/src/test/ui/uninhabited/uninhabited-patterns.stderr b/src/test/ui/uninhabited/uninhabited-patterns.stderr index 4a793c4510ec1..3e5329cfb3011 100644 --- a/src/test/ui/uninhabited/uninhabited-patterns.stderr +++ b/src/test/ui/uninhabited/uninhabited-patterns.stderr @@ -1,35 +1,35 @@ error: unreachable pattern - --> $DIR/uninhabited-patterns.rs:26:9 + --> $DIR/uninhabited-patterns.rs:27:9 | LL | &[..] => (), | ^^^^^ | note: lint level defined here - --> $DIR/uninhabited-patterns.rs:5:9 + --> $DIR/uninhabited-patterns.rs:6:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/uninhabited-patterns.rs:31:9 + --> $DIR/uninhabited-patterns.rs:32:9 | LL | Ok(box _) => (), | ^^^^^^^^^ error: unreachable pattern - --> $DIR/uninhabited-patterns.rs:33:9 + --> $DIR/uninhabited-patterns.rs:34:9 | LL | Err(&[..]) => (), | ^^^^^^^^^^ error: unreachable pattern - --> $DIR/uninhabited-patterns.rs:40:9 + --> $DIR/uninhabited-patterns.rs:41:9 | LL | Err(Ok(_y)) => (), | ^^^^^^^^^^^ error: unreachable pattern - --> $DIR/uninhabited-patterns.rs:43:15 + --> $DIR/uninhabited-patterns.rs:44:15 | LL | while let Some(_y) = foo() { | ^^^^^^^^