Auto merge of #50121 - pnkfelix:revert-stabilization-of-never-type-et-al, r=alexcrichton
Revert stabilization of never_type (!) et al Fix #49691 I *think* this correctly adopts @nikomatsakis 's desired fix of: * reverting stabilization of `!` and `TryFrom`, and * returning to the previous fallback semantics (i.e. it is once again dependent on whether the crate has opted into `#[feature(never_type)]`, * **without** attempting to put back in the previous future-proofing warnings regarding the change in fallback semantics. (I'll be away from computers for a week starting now, so any updates to this PR should be either pushed into it, or someone else should adopt the task of polishing this fix and put up their own PR.)
This commit is contained in:
@@ -59,7 +59,7 @@ unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The error type returned when a conversion from a slice to an array fails.
|
/// The error type returned when a conversion from a slice to an array fails.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct TryFromSliceError(());
|
pub struct TryFromSliceError(());
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ macro_rules! array_impls {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl<'a, T> TryFrom<&'a [T]> for &'a [T; $N] {
|
impl<'a, T> TryFrom<&'a [T]> for &'a [T; $N] {
|
||||||
type Error = TryFromSliceError;
|
type Error = TryFromSliceError;
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ macro_rules! array_impls {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl<'a, T> TryFrom<&'a mut [T]> for &'a mut [T; $N] {
|
impl<'a, T> TryFrom<&'a mut [T]> for &'a mut [T; $N] {
|
||||||
type Error = TryFromSliceError;
|
type Error = TryFromSliceError;
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ impl FromStr for char {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl TryFrom<u32> for char {
|
impl TryFrom<u32> for char {
|
||||||
type Error = CharTryFromError;
|
type Error = CharTryFromError;
|
||||||
|
|
||||||
@@ -219,11 +219,11 @@ impl TryFrom<u32> for char {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The error type returned when a conversion from u32 to char fails.
|
/// The error type returned when a conversion from u32 to char fails.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct CharTryFromError(());
|
pub struct CharTryFromError(());
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl fmt::Display for CharTryFromError {
|
impl fmt::Display for CharTryFromError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
"converted integer out of range for `char`".fmt(f)
|
"converted integer out of range for `char`".fmt(f)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ pub use self::convert::{from_u32, from_digit};
|
|||||||
pub use self::convert::from_u32_unchecked;
|
pub use self::convert::from_u32_unchecked;
|
||||||
#[stable(feature = "char_from_str", since = "1.20.0")]
|
#[stable(feature = "char_from_str", since = "1.20.0")]
|
||||||
pub use self::convert::ParseCharError;
|
pub use self::convert::ParseCharError;
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
pub use self::convert::CharTryFromError;
|
pub use self::convert::CharTryFromError;
|
||||||
#[stable(feature = "decode_utf16", since = "1.9.0")]
|
#[stable(feature = "decode_utf16", since = "1.9.0")]
|
||||||
pub use self::decode::{decode_utf16, DecodeUtf16, DecodeUtf16Error};
|
pub use self::decode::{decode_utf16, DecodeUtf16, DecodeUtf16Error};
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ mod impls {
|
|||||||
bool char
|
bool char
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "never_type", since = "1.26.0")]
|
#[unstable(feature = "never_type", issue = "35121")]
|
||||||
impl Clone for ! {
|
impl Clone for ! {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
|
|||||||
@@ -881,24 +881,24 @@ mod impls {
|
|||||||
|
|
||||||
ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
|
||||||
|
|
||||||
#[stable(feature = "never_type", since = "1.26.0")]
|
#[unstable(feature = "never_type", issue = "35121")]
|
||||||
impl PartialEq for ! {
|
impl PartialEq for ! {
|
||||||
fn eq(&self, _: &!) -> bool {
|
fn eq(&self, _: &!) -> bool {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "never_type", since = "1.26.0")]
|
#[unstable(feature = "never_type", issue = "35121")]
|
||||||
impl Eq for ! {}
|
impl Eq for ! {}
|
||||||
|
|
||||||
#[stable(feature = "never_type", since = "1.26.0")]
|
#[unstable(feature = "never_type", issue = "35121")]
|
||||||
impl PartialOrd for ! {
|
impl PartialOrd for ! {
|
||||||
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
|
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "never_type", since = "1.26.0")]
|
#[unstable(feature = "never_type", issue = "35121")]
|
||||||
impl Ord for ! {
|
impl Ord for ! {
|
||||||
fn cmp(&self, _: &!) -> Ordering {
|
fn cmp(&self, _: &!) -> Ordering {
|
||||||
*self
|
*self
|
||||||
|
|||||||
@@ -322,26 +322,22 @@ pub trait From<T>: Sized {
|
|||||||
///
|
///
|
||||||
/// [`TryFrom`]: trait.TryFrom.html
|
/// [`TryFrom`]: trait.TryFrom.html
|
||||||
/// [`Into`]: trait.Into.html
|
/// [`Into`]: trait.Into.html
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
pub trait TryInto<T>: Sized {
|
pub trait TryInto<T>: Sized {
|
||||||
/// The type returned in the event of a conversion error.
|
/// The type returned in the event of a conversion error.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
|
||||||
type Error;
|
type Error;
|
||||||
|
|
||||||
/// Performs the conversion.
|
/// Performs the conversion.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
|
||||||
fn try_into(self) -> Result<T, Self::Error>;
|
fn try_into(self) -> Result<T, Self::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to construct `Self` via a conversion.
|
/// Attempt to construct `Self` via a conversion.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
pub trait TryFrom<T>: Sized {
|
pub trait TryFrom<T>: Sized {
|
||||||
/// The type returned in the event of a conversion error.
|
/// The type returned in the event of a conversion error.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
|
||||||
type Error;
|
type Error;
|
||||||
|
|
||||||
/// Performs the conversion.
|
/// Performs the conversion.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
|
||||||
fn try_from(value: T) -> Result<Self, Self::Error>;
|
fn try_from(value: T) -> Result<Self, Self::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,7 +405,7 @@ impl<T> From<T> for T {
|
|||||||
|
|
||||||
|
|
||||||
// TryFrom implies TryInto
|
// TryFrom implies TryInto
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl<T, U> TryInto<U> for T where U: TryFrom<T>
|
impl<T, U> TryInto<U> for T where U: TryFrom<T>
|
||||||
{
|
{
|
||||||
type Error = U::Error;
|
type Error = U::Error;
|
||||||
@@ -421,7 +417,7 @@ impl<T, U> TryInto<U> for T where U: TryFrom<T>
|
|||||||
|
|
||||||
// Infallible conversions are semantically equivalent to fallible conversions
|
// Infallible conversions are semantically equivalent to fallible conversions
|
||||||
// with an uninhabited error type.
|
// with an uninhabited error type.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl<T, U> TryFrom<U> for T where T: From<U> {
|
impl<T, U> TryFrom<U> for T where T: From<U> {
|
||||||
type Error = !;
|
type Error = !;
|
||||||
|
|
||||||
|
|||||||
@@ -1780,14 +1780,14 @@ macro_rules! fmt_refs {
|
|||||||
|
|
||||||
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
|
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
|
||||||
|
|
||||||
#[stable(feature = "never_type", since = "1.26.0")]
|
#[unstable(feature = "never_type", issue = "35121")]
|
||||||
impl Debug for ! {
|
impl Debug for ! {
|
||||||
fn fmt(&self, _: &mut Formatter) -> Result {
|
fn fmt(&self, _: &mut Formatter) -> Result {
|
||||||
*self
|
*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "never_type", since = "1.26.0")]
|
#[unstable(feature = "never_type", issue = "35121")]
|
||||||
impl Display for ! {
|
impl Display for ! {
|
||||||
fn fmt(&self, _: &mut Formatter) -> Result {
|
fn fmt(&self, _: &mut Formatter) -> Result {
|
||||||
*self
|
*self
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
#![feature(iterator_repeat_with)]
|
#![feature(iterator_repeat_with)]
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![feature(link_llvm_intrinsics)]
|
#![feature(link_llvm_intrinsics)]
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![feature(macro_at_most_once_rep)]
|
#![feature(macro_at_most_once_rep)]
|
||||||
#![feature(no_core)]
|
#![feature(no_core)]
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ mod copy_impls {
|
|||||||
bool char
|
bool char
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "never_type", since = "1.26.0")]
|
#[unstable(feature = "never_type", issue = "35121")]
|
||||||
impl Copy for ! {}
|
impl Copy for ! {}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|||||||
@@ -4192,7 +4192,7 @@ macro_rules! from_str_radix_int_impl {
|
|||||||
from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
|
from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
|
||||||
|
|
||||||
/// The error type returned when a checked integral type conversion fails.
|
/// The error type returned when a checked integral type conversion fails.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct TryFromIntError(());
|
pub struct TryFromIntError(());
|
||||||
|
|
||||||
@@ -4207,14 +4207,14 @@ impl TryFromIntError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl fmt::Display for TryFromIntError {
|
impl fmt::Display for TryFromIntError {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
self.__description().fmt(fmt)
|
self.__description().fmt(fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl From<!> for TryFromIntError {
|
impl From<!> for TryFromIntError {
|
||||||
fn from(never: !) -> TryFromIntError {
|
fn from(never: !) -> TryFromIntError {
|
||||||
never
|
never
|
||||||
@@ -4224,7 +4224,7 @@ impl From<!> for TryFromIntError {
|
|||||||
// only negative bounds
|
// only negative bounds
|
||||||
macro_rules! try_from_lower_bounded {
|
macro_rules! try_from_lower_bounded {
|
||||||
($source:ty, $($target:ty),*) => {$(
|
($source:ty, $($target:ty),*) => {$(
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl TryFrom<$source> for $target {
|
impl TryFrom<$source> for $target {
|
||||||
type Error = TryFromIntError;
|
type Error = TryFromIntError;
|
||||||
|
|
||||||
@@ -4243,7 +4243,7 @@ macro_rules! try_from_lower_bounded {
|
|||||||
// unsigned to signed (only positive bound)
|
// unsigned to signed (only positive bound)
|
||||||
macro_rules! try_from_upper_bounded {
|
macro_rules! try_from_upper_bounded {
|
||||||
($source:ty, $($target:ty),*) => {$(
|
($source:ty, $($target:ty),*) => {$(
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl TryFrom<$source> for $target {
|
impl TryFrom<$source> for $target {
|
||||||
type Error = TryFromIntError;
|
type Error = TryFromIntError;
|
||||||
|
|
||||||
@@ -4262,7 +4262,7 @@ macro_rules! try_from_upper_bounded {
|
|||||||
// all other cases
|
// all other cases
|
||||||
macro_rules! try_from_both_bounded {
|
macro_rules! try_from_both_bounded {
|
||||||
($source:ty, $($target:ty),*) => {$(
|
($source:ty, $($target:ty),*) => {$(
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl TryFrom<$source> for $target {
|
impl TryFrom<$source> for $target {
|
||||||
type Error = TryFromIntError;
|
type Error = TryFromIntError;
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#![feature(str_internals)]
|
#![feature(str_internals)]
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
#![feature(trusted_len)]
|
#![feature(trusted_len)]
|
||||||
|
#![feature(try_from)]
|
||||||
#![feature(try_trait)]
|
#![feature(try_trait)]
|
||||||
#![feature(exact_chunks)]
|
#![feature(exact_chunks)]
|
||||||
#![cfg_attr(stage0, feature(atomic_nand))]
|
#![cfg_attr(stage0, feature(atomic_nand))]
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
#![cfg_attr(windows, feature(libc))]
|
#![cfg_attr(windows, feature(libc))]
|
||||||
#![feature(macro_lifetime_matcher)]
|
#![feature(macro_lifetime_matcher)]
|
||||||
#![feature(macro_vis_matcher)]
|
#![feature(macro_vis_matcher)]
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![feature(non_exhaustive)]
|
#![feature(non_exhaustive)]
|
||||||
#![feature(nonzero)]
|
#![feature(nonzero)]
|
||||||
|
|||||||
@@ -2374,6 +2374,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||||||
self.intern_tup(&[])
|
self.intern_tup(&[])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn mk_diverging_default(self) -> Ty<'tcx> {
|
||||||
|
if self.features().never_type {
|
||||||
|
self.types.never
|
||||||
|
} else {
|
||||||
|
self.intern_tup(&[])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn mk_bool(self) -> Ty<'tcx> {
|
pub fn mk_bool(self) -> Ty<'tcx> {
|
||||||
self.mk_ty(TyBool)
|
self.mk_ty(TyBool)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
|
#![feature(try_from)]
|
||||||
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
|
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
extern crate rustc_cratesio_shim;
|
extern crate rustc_cratesio_shim;
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
|
PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
|
||||||
let irrefutable = adt_def.variants.iter().enumerate().all(|(i, v)| {
|
let irrefutable = adt_def.variants.iter().enumerate().all(|(i, v)| {
|
||||||
i == variant_index || {
|
i == variant_index || {
|
||||||
|
self.hir.tcx().features().never_type &&
|
||||||
self.hir.tcx().features().exhaustive_patterns &&
|
self.hir.tcx().features().exhaustive_patterns &&
|
||||||
self.hir.tcx().is_variant_uninhabited_from_all_modules(v, substs)
|
self.hir.tcx().is_variant_uninhabited_from_all_modules(v, substs)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
|
|||||||
#![feature(nonzero)]
|
#![feature(nonzero)]
|
||||||
#![feature(inclusive_range_fields)]
|
#![feature(inclusive_range_fields)]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
|
#![feature(never_type)]
|
||||||
#![cfg_attr(stage0, feature(try_trait))]
|
#![cfg_attr(stage0, feature(try_trait))]
|
||||||
|
|
||||||
extern crate arena;
|
extern crate arena;
|
||||||
|
|||||||
@@ -2217,7 +2217,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tries to apply a fallback to `ty` if it is an unsolved variable.
|
// Tries to apply a fallback to `ty` if it is an unsolved variable.
|
||||||
// Non-numerics get replaced with !, unconstrained ints with i32,
|
// Non-numerics get replaced with ! or () (depending on whether
|
||||||
|
// feature(never_type) is enabled, unconstrained ints with i32,
|
||||||
// unconstrained floats with f64.
|
// unconstrained floats with f64.
|
||||||
// Fallback becomes very dubious if we have encountered type-checking errors.
|
// Fallback becomes very dubious if we have encountered type-checking errors.
|
||||||
// In that case, fallback to TyError.
|
// In that case, fallback to TyError.
|
||||||
@@ -2231,7 +2232,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
_ if self.is_tainted_by_errors() => self.tcx().types.err,
|
_ if self.is_tainted_by_errors() => self.tcx().types.err,
|
||||||
UnconstrainedInt => self.tcx.types.i32,
|
UnconstrainedInt => self.tcx.types.i32,
|
||||||
UnconstrainedFloat => self.tcx.types.f64,
|
UnconstrainedFloat => self.tcx.types.f64,
|
||||||
Neither if self.type_var_diverges(ty) => self.tcx.types.never,
|
Neither if self.type_var_diverges(ty) => self.tcx.mk_diverging_default(),
|
||||||
Neither => return false,
|
Neither => return false,
|
||||||
};
|
};
|
||||||
debug!("default_type_parameters: defaulting `{:?}` to `{:?}`", ty, fallback);
|
debug!("default_type_parameters: defaulting `{:?}` to `{:?}`", ty, fallback);
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ This API is completely unstable and subject to change.
|
|||||||
#![feature(slice_patterns)]
|
#![feature(slice_patterns)]
|
||||||
#![feature(slice_sort_by_cached_key)]
|
#![feature(slice_sort_by_cached_key)]
|
||||||
#![feature(dyn_trait)]
|
#![feature(dyn_trait)]
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
#[macro_use] extern crate syntax;
|
#[macro_use] extern crate syntax;
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ impl<'a> From<Cow<'a, str>> for Box<Error> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "never_type", since = "1.26.0")]
|
#[unstable(feature = "never_type", issue = "35121")]
|
||||||
impl Error for ! {
|
impl Error for ! {
|
||||||
fn description(&self) -> &str { *self }
|
fn description(&self) -> &str { *self }
|
||||||
}
|
}
|
||||||
@@ -284,14 +284,14 @@ impl Error for num::ParseIntError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl Error for num::TryFromIntError {
|
impl Error for num::TryFromIntError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
self.__description()
|
self.__description()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl Error for array::TryFromSliceError {
|
impl Error for array::TryFromSliceError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
self.__description()
|
self.__description()
|
||||||
@@ -365,7 +365,7 @@ impl Error for cell::BorrowMutError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl Error for char::CharTryFromError {
|
impl Error for char::CharTryFromError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
"converted integer out of range for `char`"
|
"converted integer out of range for `char`"
|
||||||
|
|||||||
@@ -275,6 +275,7 @@
|
|||||||
#![feature(macro_reexport)]
|
#![feature(macro_reexport)]
|
||||||
#![feature(macro_vis_matcher)]
|
#![feature(macro_vis_matcher)]
|
||||||
#![feature(needs_panic_runtime)]
|
#![feature(needs_panic_runtime)]
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![feature(nonzero)]
|
#![feature(nonzero)]
|
||||||
#![feature(num_bits_bytes)]
|
#![feature(num_bits_bytes)]
|
||||||
@@ -306,6 +307,7 @@
|
|||||||
#![feature(test, rustc_private)]
|
#![feature(test, rustc_private)]
|
||||||
#![feature(thread_local)]
|
#![feature(thread_local)]
|
||||||
#![feature(toowned_clone_into)]
|
#![feature(toowned_clone_into)]
|
||||||
|
#![feature(try_from)]
|
||||||
#![feature(try_reserve)]
|
#![feature(try_reserve)]
|
||||||
#![feature(unboxed_closures)]
|
#![feature(unboxed_closures)]
|
||||||
#![feature(untagged_unions)]
|
#![feature(untagged_unions)]
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ mod prim_bool { }
|
|||||||
/// write:
|
/// write:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// #![feature(never_type)]
|
||||||
/// # fn foo() -> u32 {
|
/// # fn foo() -> u32 {
|
||||||
/// let x: ! = {
|
/// let x: ! = {
|
||||||
/// return 123
|
/// return 123
|
||||||
@@ -155,6 +156,7 @@ mod prim_bool { }
|
|||||||
/// for example:
|
/// for example:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// #![feature(never_type)]
|
||||||
/// # use std::fmt;
|
/// # use std::fmt;
|
||||||
/// # trait Debug {
|
/// # trait Debug {
|
||||||
/// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result;
|
/// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result;
|
||||||
|
|||||||
@@ -272,6 +272,9 @@ declare_features! (
|
|||||||
// Allows cfg(target_has_atomic = "...").
|
// Allows cfg(target_has_atomic = "...").
|
||||||
(active, cfg_target_has_atomic, "1.9.0", Some(32976), None),
|
(active, cfg_target_has_atomic, "1.9.0", Some(32976), None),
|
||||||
|
|
||||||
|
// 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.
|
// Allows exhaustive pattern matching on types that contain uninhabited types.
|
||||||
(active, exhaustive_patterns, "1.13.0", None, None),
|
(active, exhaustive_patterns, "1.13.0", None, None),
|
||||||
|
|
||||||
@@ -1644,6 +1647,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||||||
ast::TyKind::BareFn(ref bare_fn_ty) => {
|
ast::TyKind::BareFn(ref bare_fn_ty) => {
|
||||||
self.check_abi(bare_fn_ty.abi, ty.span);
|
self.check_abi(bare_fn_ty.abi, ty.span);
|
||||||
}
|
}
|
||||||
|
ast::TyKind::Never => {
|
||||||
|
gate_feature_post!(&self, never_type, ty.span,
|
||||||
|
"The `!` type is experimental");
|
||||||
|
}
|
||||||
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
|
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
|
||||||
gate_feature_post!(&self, dyn_trait, ty.span,
|
gate_feature_post!(&self, dyn_trait, ty.span,
|
||||||
"`dyn Trait` syntax is unstable");
|
"`dyn Trait` syntax is unstable");
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
// Test that we can't pass other types for !
|
// Test that we can't pass other types for !
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
fn foo(x: !) -> ! {
|
fn foo(x: !) -> ! {
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
fn foo(x: usize, y: !, z: usize) { }
|
fn foo(x: usize, y: !, z: usize) { }
|
||||||
|
|
||||||
fn cast_a() {
|
fn cast_a() {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
fn foo(x: usize, y: !, z: usize) { }
|
fn foo(x: usize, y: !, z: usize) { }
|
||||||
|
|
||||||
fn call_foo_a() {
|
fn call_foo_a() {
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// We need to opt inot the `!` feature in order to trigger the
|
||||||
|
// requirement that this is testing.
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
|
||||||
trait Deserialize: Sized {
|
trait Deserialize: Sized {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
// error-pattern:reached recursion limit
|
// error-pattern:reached recursion limit
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
|
|
||||||
struct Foo<'a, T: 'a> {
|
struct Foo<'a, T: 'a> {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let val: ! = loop { break break; };
|
let val: ! = loop { break break; };
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
|
|
||||||
mod private {
|
mod private {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
// Test that an assignment of type ! makes the rest of the block dead code.
|
// Test that an assignment of type ! makes the rest of the block dead code.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
#![warn(unused)]
|
#![warn(unused)]
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
// Test that we can't use another type in place of !
|
// Test that we can't use another type in place of !
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
|
|
||||||
mod foo {
|
mod foo {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![feature(slice_patterns)]
|
#![feature(slice_patterns)]
|
||||||
#![deny(unreachable_patterns)]
|
#![deny(unreachable_patterns)]
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![deny(unreachable_patterns)]
|
#![deny(unreachable_patterns)]
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns, rustc_attrs)]
|
#![feature(exhaustive_patterns, rustc_attrs)]
|
||||||
#![warn(unreachable_code)]
|
#![warn(unreachable_code)]
|
||||||
#![warn(unreachable_patterns)]
|
#![warn(unreachable_patterns)]
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
// Test that a variable of type ! can coerce to another type.
|
// Test that a variable of type ! can coerce to another type.
|
||||||
|
|
||||||
// error-pattern:explicit
|
// error-pattern:explicit
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: ! = panic!();
|
let x: ! = panic!();
|
||||||
let y: u32 = x;
|
let y: u32 = x;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
// error-pattern:wowzers!
|
// error-pattern:wowzers!
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![allow(unreachable_code)]
|
#![allow(unreachable_code)]
|
||||||
|
|
||||||
fn foo(x: !) -> ! {
|
fn foo(x: !) -> ! {
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
// Test that we can explicitly cast ! to another type
|
// Test that we can explicitly cast ! to another type
|
||||||
|
|
||||||
// error-pattern:explicit
|
// error-pattern:explicit
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: ! = panic!();
|
let x: ! = panic!();
|
||||||
let y: u32 = x as u32;
|
let y: u32 = x as u32;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
// error-pattern:kapow!
|
// error-pattern:kapow!
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
type Wow;
|
type Wow;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
// error-pattern:oh no!
|
// error-pattern:oh no!
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
struct Wub;
|
struct Wub;
|
||||||
|
|
||||||
impl PartialEq<!> for Wub {
|
impl PartialEq<!> for Wub {
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
// These represent current behavior, but are pretty dubious. I would
|
// These represent current behavior, but are pretty dubious. I would
|
||||||
// like to revisit these and potentially change them. --nmatsakis
|
// like to revisit these and potentially change them. --nmatsakis
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
trait BadDefault {
|
trait BadDefault {
|
||||||
fn default() -> Self;
|
fn default() -> Self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![feature(slice_patterns)]
|
#![feature(slice_patterns)]
|
||||||
#![allow(unreachable_patterns)]
|
#![allow(unreachable_patterns)]
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
// Test that we can call static methods on ! both directly and when it appears in a generic
|
// Test that we can call static methods on ! both directly and when it appears in a generic
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
trait StringifyType {
|
trait StringifyType {
|
||||||
fn stringify_type() -> &'static str;
|
fn stringify_type() -> &'static str;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
|
|
||||||
// Regression test for inhabitedness check. The old
|
// Regression test for inhabitedness check. The old
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
fn never_returns() {
|
fn never_returns() {
|
||||||
loop {
|
loop {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
// ignore-wasm32-bare compiled with panic=abort by default
|
// ignore-wasm32-bare compiled with panic=abort by default
|
||||||
|
|
||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
use std::panic;
|
use std::panic;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
// Test that we can extract a ! through pattern matching then use it as several different types.
|
// Test that we can extract a ! through pattern matching then use it as several different types.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: Result<u32, !> = Ok(123);
|
let x: Result<u32, !> = Ok(123);
|
||||||
match x {
|
match x {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
|
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
|
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ trait Add<RHS=Self> {
|
|||||||
fn ice<A>(a: A) {
|
fn ice<A>(a: A) {
|
||||||
let r = loop {};
|
let r = loop {};
|
||||||
r = r + a;
|
r = r + a;
|
||||||
//~^ ERROR the trait bound `!: Add<A>` is not satisfied
|
//~^ ERROR the trait bound `(): Add<A>` is not satisfied
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error[E0277]: the trait bound `!: Add<A>` is not satisfied
|
error[E0277]: the trait bound `(): Add<A>` is not satisfied
|
||||||
--> $DIR/associated-types-ICE-when-projecting-out-of-err.rs:33:11
|
--> $DIR/associated-types-ICE-when-projecting-out-of-err.rs:33:11
|
||||||
|
|
|
|
||||||
LL | r = r + a;
|
LL | r = r + a;
|
||||||
| ^ the trait `Add<A>` is not implemented for `!`
|
| ^ the trait `Add<A>` is not implemented for `()`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(try_from)]
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::convert::{TryFrom, AsRef};
|
use std::convert::{TryFrom, AsRef};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
error[E0119]: conflicting implementations of trait `std::convert::AsRef<Q>` for type `std::boxed::Box<Q>`:
|
error[E0119]: conflicting implementations of trait `std::convert::AsRef<Q>` for type `std::boxed::Box<Q>`:
|
||||||
--> $DIR/conflict-with-std.rs:15:1
|
--> $DIR/conflict-with-std.rs:17:1
|
||||||
|
|
|
|
||||||
LL | impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations
|
LL | impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@@ -9,7 +9,7 @@ LL | impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations
|
|||||||
where T: ?Sized;
|
where T: ?Sized;
|
||||||
|
|
||||||
error[E0119]: conflicting implementations of trait `std::convert::From<S>` for type `S`:
|
error[E0119]: conflicting implementations of trait `std::convert::From<S>` for type `S`:
|
||||||
--> $DIR/conflict-with-std.rs:22:1
|
--> $DIR/conflict-with-std.rs:24:1
|
||||||
|
|
|
|
||||||
LL | impl From<S> for S { //~ ERROR conflicting implementations
|
LL | impl From<S> for S { //~ ERROR conflicting implementations
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
@@ -18,7 +18,7 @@ LL | impl From<S> for S { //~ ERROR conflicting implementations
|
|||||||
- impl<T> std::convert::From<T> for T;
|
- impl<T> std::convert::From<T> for T;
|
||||||
|
|
||||||
error[E0119]: conflicting implementations of trait `std::convert::TryFrom<X>` for type `X`:
|
error[E0119]: conflicting implementations of trait `std::convert::TryFrom<X>` for type `X`:
|
||||||
--> $DIR/conflict-with-std.rs:29:1
|
--> $DIR/conflict-with-std.rs:31:1
|
||||||
|
|
|
|
||||||
LL | impl TryFrom<X> for X { //~ ERROR conflicting implementations
|
LL | impl TryFrom<X> for X { //~ ERROR conflicting implementations
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
#![feature(never_type)]
|
||||||
fn foo() -> Result<u32, !> {
|
fn foo() -> Result<u32, !> {
|
||||||
Ok(123)
|
Ok(123)
|
||||||
}
|
}
|
||||||
|
|||||||
27
src/test/ui/feature-gate-never_type.rs
Normal file
27
src/test/ui/feature-gate-never_type.rs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||||
|
// file at the top-level directory of this distribution and at
|
||||||
|
// http://rust-lang.org/COPYRIGHT.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||||
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
|
// option. This file may not be copied, modified, or distributed
|
||||||
|
// except according to those terms.
|
||||||
|
|
||||||
|
// 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 = &fn(!) -> !; //~ ERROR type is experimental
|
||||||
|
type Skwoz = &mut !; //~ ERROR type is experimental
|
||||||
|
|
||||||
|
impl Foo for Meeshka {
|
||||||
|
type Wub = !; //~ ERROR type is experimental
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
}
|
||||||
43
src/test/ui/feature-gate-never_type.stderr
Normal file
43
src/test/ui/feature-gate-never_type.stderr
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
error[E0658]: The `!` type is experimental (see issue #35121)
|
||||||
|
--> $DIR/feature-gate-never_type.rs:17:17
|
||||||
|
|
|
||||||
|
LL | type Ma = (u32, !, i32); //~ ERROR type is experimental
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= help: add #![feature(never_type)] to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: The `!` type is experimental (see issue #35121)
|
||||||
|
--> $DIR/feature-gate-never_type.rs:18:20
|
||||||
|
|
|
||||||
|
LL | type Meeshka = Vec<!>; //~ ERROR type is experimental
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= help: add #![feature(never_type)] to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: The `!` type is experimental (see issue #35121)
|
||||||
|
--> $DIR/feature-gate-never_type.rs:19:16
|
||||||
|
|
|
||||||
|
LL | type Mow = &fn(!) -> !; //~ ERROR type is experimental
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= help: add #![feature(never_type)] to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: The `!` type is experimental (see issue #35121)
|
||||||
|
--> $DIR/feature-gate-never_type.rs:20:19
|
||||||
|
|
|
||||||
|
LL | type Skwoz = &mut !; //~ ERROR type is experimental
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= help: add #![feature(never_type)] to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: The `!` type is experimental (see issue #35121)
|
||||||
|
--> $DIR/feature-gate-never_type.rs:23:16
|
||||||
|
|
|
||||||
|
LL | type Wub = !; //~ ERROR type is experimental
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= 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`.
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
// compile-flags: -Z print-type-sizes
|
// compile-flags: -Z print-type-sizes
|
||||||
// compile-pass
|
// compile-pass
|
||||||
|
|
||||||
|
#![feature(never_type)]
|
||||||
#![feature(start)]
|
#![feature(start)]
|
||||||
|
|
||||||
#[start]
|
#[start]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
#![feature(never_type)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![deny(unreachable_code)]
|
#![deny(unreachable_code)]
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
#![feature(never_type)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(unused_assignments)]
|
#![allow(unused_assignments)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
#![feature(never_type)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(unused_assignments)]
|
#![allow(unused_assignments)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#![allow(unused_assignments)]
|
#![allow(unused_assignments)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![deny(unreachable_code)]
|
#![deny(unreachable_code)]
|
||||||
#![feature(type_ascription)]
|
#![feature(never_type, type_ascription)]
|
||||||
|
|
||||||
fn a() {
|
fn a() {
|
||||||
// the cast is unreachable:
|
// the cast is unreachable:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
#![feature(never_type)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(unused_assignments)]
|
#![allow(unused_assignments)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#![allow(unused_assignments)]
|
#![allow(unused_assignments)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![deny(unreachable_code)]
|
#![deny(unreachable_code)]
|
||||||
#![feature(type_ascription)]
|
#![feature(never_type, type_ascription)]
|
||||||
|
|
||||||
fn a() {
|
fn a() {
|
||||||
// the cast is unreachable:
|
// the cast is unreachable:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
#![feature(never_type)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![allow(unused_assignments)]
|
#![allow(unused_assignments)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|||||||
Reference in New Issue
Block a user