Skip to content

Commit aa7ce89

Browse files
committed
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.)
2 parents 699eb95 + 42b6d46 commit aa7ce89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+188
-49
lines changed

src/libcore/array.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
5959
}
6060

6161
/// The error type returned when a conversion from a slice to an array fails.
62-
#[stable(feature = "try_from", since = "1.26.0")]
62+
#[unstable(feature = "try_from", issue = "33417")]
6363
#[derive(Debug, Copy, Clone)]
6464
pub struct TryFromSliceError(());
6565

@@ -148,7 +148,7 @@ macro_rules! array_impls {
148148
}
149149
}
150150

151-
#[stable(feature = "try_from", since = "1.26.0")]
151+
#[unstable(feature = "try_from", issue = "33417")]
152152
impl<'a, T> TryFrom<&'a [T]> for &'a [T; $N] {
153153
type Error = TryFromSliceError;
154154

@@ -162,7 +162,7 @@ macro_rules! array_impls {
162162
}
163163
}
164164

165-
#[stable(feature = "try_from", since = "1.26.0")]
165+
#[unstable(feature = "try_from", issue = "33417")]
166166
impl<'a, T> TryFrom<&'a mut [T]> for &'a mut [T; $N] {
167167
type Error = TryFromSliceError;
168168

src/libcore/char/convert.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl FromStr for char {
204204
}
205205

206206

207-
#[stable(feature = "try_from", since = "1.26.0")]
207+
#[unstable(feature = "try_from", issue = "33417")]
208208
impl TryFrom<u32> for char {
209209
type Error = CharTryFromError;
210210

@@ -219,11 +219,11 @@ impl TryFrom<u32> for char {
219219
}
220220

221221
/// The error type returned when a conversion from u32 to char fails.
222-
#[stable(feature = "try_from", since = "1.26.0")]
222+
#[unstable(feature = "try_from", issue = "33417")]
223223
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
224224
pub struct CharTryFromError(());
225225

226-
#[stable(feature = "try_from", since = "1.26.0")]
226+
#[unstable(feature = "try_from", issue = "33417")]
227227
impl fmt::Display for CharTryFromError {
228228
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
229229
"converted integer out of range for `char`".fmt(f)

src/libcore/char/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub use self::convert::{from_u32, from_digit};
4040
pub use self::convert::from_u32_unchecked;
4141
#[stable(feature = "char_from_str", since = "1.20.0")]
4242
pub use self::convert::ParseCharError;
43-
#[stable(feature = "try_from", since = "1.26.0")]
43+
#[unstable(feature = "try_from", issue = "33417")]
4444
pub use self::convert::CharTryFromError;
4545
#[stable(feature = "decode_utf16", since = "1.9.0")]
4646
pub use self::decode::{decode_utf16, DecodeUtf16, DecodeUtf16Error};

src/libcore/clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ mod impls {
179179
bool char
180180
}
181181

182-
#[stable(feature = "never_type", since = "1.26.0")]
182+
#[unstable(feature = "never_type", issue = "35121")]
183183
impl Clone for ! {
184184
#[inline]
185185
fn clone(&self) -> Self {

src/libcore/cmp.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -881,24 +881,24 @@ mod impls {
881881

882882
ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
883883

884-
#[stable(feature = "never_type", since = "1.26.0")]
884+
#[unstable(feature = "never_type", issue = "35121")]
885885
impl PartialEq for ! {
886886
fn eq(&self, _: &!) -> bool {
887887
*self
888888
}
889889
}
890890

891-
#[stable(feature = "never_type", since = "1.26.0")]
891+
#[unstable(feature = "never_type", issue = "35121")]
892892
impl Eq for ! {}
893893

894-
#[stable(feature = "never_type", since = "1.26.0")]
894+
#[unstable(feature = "never_type", issue = "35121")]
895895
impl PartialOrd for ! {
896896
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
897897
*self
898898
}
899899
}
900900

901-
#[stable(feature = "never_type", since = "1.26.0")]
901+
#[unstable(feature = "never_type", issue = "35121")]
902902
impl Ord for ! {
903903
fn cmp(&self, _: &!) -> Ordering {
904904
*self

src/libcore/convert.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -322,26 +322,22 @@ pub trait From<T>: Sized {
322322
///
323323
/// [`TryFrom`]: trait.TryFrom.html
324324
/// [`Into`]: trait.Into.html
325-
#[stable(feature = "try_from", since = "1.26.0")]
325+
#[unstable(feature = "try_from", issue = "33417")]
326326
pub trait TryInto<T>: Sized {
327327
/// The type returned in the event of a conversion error.
328-
#[stable(feature = "try_from", since = "1.26.0")]
329328
type Error;
330329

331330
/// Performs the conversion.
332-
#[stable(feature = "try_from", since = "1.26.0")]
333331
fn try_into(self) -> Result<T, Self::Error>;
334332
}
335333

336334
/// Attempt to construct `Self` via a conversion.
337-
#[stable(feature = "try_from", since = "1.26.0")]
335+
#[unstable(feature = "try_from", issue = "33417")]
338336
pub trait TryFrom<T>: Sized {
339337
/// The type returned in the event of a conversion error.
340-
#[stable(feature = "try_from", since = "1.26.0")]
341338
type Error;
342339

343340
/// Performs the conversion.
344-
#[stable(feature = "try_from", since = "1.26.0")]
345341
fn try_from(value: T) -> Result<Self, Self::Error>;
346342
}
347343

@@ -409,7 +405,7 @@ impl<T> From<T> for T {
409405

410406

411407
// TryFrom implies TryInto
412-
#[stable(feature = "try_from", since = "1.26.0")]
408+
#[unstable(feature = "try_from", issue = "33417")]
413409
impl<T, U> TryInto<U> for T where U: TryFrom<T>
414410
{
415411
type Error = U::Error;
@@ -421,7 +417,7 @@ impl<T, U> TryInto<U> for T where U: TryFrom<T>
421417

422418
// Infallible conversions are semantically equivalent to fallible conversions
423419
// with an uninhabited error type.
424-
#[stable(feature = "try_from", since = "1.26.0")]
420+
#[unstable(feature = "try_from", issue = "33417")]
425421
impl<T, U> TryFrom<U> for T where T: From<U> {
426422
type Error = !;
427423

src/libcore/fmt/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1780,14 +1780,14 @@ macro_rules! fmt_refs {
17801780

17811781
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
17821782

1783-
#[stable(feature = "never_type", since = "1.26.0")]
1783+
#[unstable(feature = "never_type", issue = "35121")]
17841784
impl Debug for ! {
17851785
fn fmt(&self, _: &mut Formatter) -> Result {
17861786
*self
17871787
}
17881788
}
17891789

1790-
#[stable(feature = "never_type", since = "1.26.0")]
1790+
#[unstable(feature = "never_type", issue = "35121")]
17911791
impl Display for ! {
17921792
fn fmt(&self, _: &mut Formatter) -> Result {
17931793
*self

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
#![feature(iterator_repeat_with)]
8383
#![feature(lang_items)]
8484
#![feature(link_llvm_intrinsics)]
85+
#![feature(never_type)]
8586
#![feature(exhaustive_patterns)]
8687
#![feature(macro_at_most_once_rep)]
8788
#![feature(no_core)]

src/libcore/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ mod copy_impls {
630630
bool char
631631
}
632632

633-
#[stable(feature = "never_type", since = "1.26.0")]
633+
#[unstable(feature = "never_type", issue = "35121")]
634634
impl Copy for ! {}
635635

636636
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/num/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4192,7 +4192,7 @@ macro_rules! from_str_radix_int_impl {
41924192
from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
41934193

41944194
/// The error type returned when a checked integral type conversion fails.
4195-
#[stable(feature = "try_from", since = "1.26.0")]
4195+
#[unstable(feature = "try_from", issue = "33417")]
41964196
#[derive(Debug, Copy, Clone)]
41974197
pub struct TryFromIntError(());
41984198

@@ -4207,14 +4207,14 @@ impl TryFromIntError {
42074207
}
42084208
}
42094209

4210-
#[stable(feature = "try_from", since = "1.26.0")]
4210+
#[unstable(feature = "try_from", issue = "33417")]
42114211
impl fmt::Display for TryFromIntError {
42124212
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
42134213
self.__description().fmt(fmt)
42144214
}
42154215
}
42164216

4217-
#[stable(feature = "try_from", since = "1.26.0")]
4217+
#[unstable(feature = "try_from", issue = "33417")]
42184218
impl From<!> for TryFromIntError {
42194219
fn from(never: !) -> TryFromIntError {
42204220
never
@@ -4224,7 +4224,7 @@ impl From<!> for TryFromIntError {
42244224
// only negative bounds
42254225
macro_rules! try_from_lower_bounded {
42264226
($source:ty, $($target:ty),*) => {$(
4227-
#[stable(feature = "try_from", since = "1.26.0")]
4227+
#[unstable(feature = "try_from", issue = "33417")]
42284228
impl TryFrom<$source> for $target {
42294229
type Error = TryFromIntError;
42304230

@@ -4243,7 +4243,7 @@ macro_rules! try_from_lower_bounded {
42434243
// unsigned to signed (only positive bound)
42444244
macro_rules! try_from_upper_bounded {
42454245
($source:ty, $($target:ty),*) => {$(
4246-
#[stable(feature = "try_from", since = "1.26.0")]
4246+
#[unstable(feature = "try_from", issue = "33417")]
42474247
impl TryFrom<$source> for $target {
42484248
type Error = TryFromIntError;
42494249

@@ -4262,7 +4262,7 @@ macro_rules! try_from_upper_bounded {
42624262
// all other cases
42634263
macro_rules! try_from_both_bounded {
42644264
($source:ty, $($target:ty),*) => {$(
4265-
#[stable(feature = "try_from", since = "1.26.0")]
4265+
#[unstable(feature = "try_from", issue = "33417")]
42664266
impl TryFrom<$source> for $target {
42674267
type Error = TryFromIntError;
42684268

src/libcore/tests/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#![feature(str_internals)]
3737
#![feature(test)]
3838
#![feature(trusted_len)]
39+
#![feature(try_from)]
3940
#![feature(try_trait)]
4041
#![feature(exact_chunks)]
4142
#![cfg_attr(stage0, feature(atomic_nand))]

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#![cfg_attr(windows, feature(libc))]
5353
#![feature(macro_lifetime_matcher)]
5454
#![feature(macro_vis_matcher)]
55+
#![feature(never_type)]
5556
#![feature(exhaustive_patterns)]
5657
#![feature(non_exhaustive)]
5758
#![feature(nonzero)]

src/librustc/ty/context.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23742374
self.intern_tup(&[])
23752375
}
23762376

2377+
pub fn mk_diverging_default(self) -> Ty<'tcx> {
2378+
if self.features().never_type {
2379+
self.types.never
2380+
} else {
2381+
self.intern_tup(&[])
2382+
}
2383+
}
2384+
23772385
pub fn mk_bool(self) -> Ty<'tcx> {
23782386
self.mk_ty(TyBool)
23792387
}

src/librustc_apfloat/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
html_root_url = "https://doc.rust-lang.org/nightly/")]
4646
#![forbid(unsafe_code)]
4747

48+
#![feature(try_from)]
4849
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
4950
#[allow(unused_extern_crates)]
5051
extern crate rustc_cratesio_shim;

src/librustc_mir/build/matches/simplify.rs

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
113113
PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
114114
let irrefutable = adt_def.variants.iter().enumerate().all(|(i, v)| {
115115
i == variant_index || {
116+
self.hir.tcx().features().never_type &&
116117
self.hir.tcx().features().exhaustive_patterns &&
117118
self.hir.tcx().is_variant_uninhabited_from_all_modules(v, substs)
118119
}

src/librustc_mir/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
3333
#![feature(nonzero)]
3434
#![feature(inclusive_range_fields)]
3535
#![feature(crate_visibility_modifier)]
36+
#![feature(never_type)]
3637
#![cfg_attr(stage0, feature(try_trait))]
3738

3839
extern crate arena;

src/librustc_typeck/check/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
22172217
}
22182218

22192219
// Tries to apply a fallback to `ty` if it is an unsolved variable.
2220-
// Non-numerics get replaced with !, unconstrained ints with i32,
2220+
// Non-numerics get replaced with ! or () (depending on whether
2221+
// feature(never_type) is enabled, unconstrained ints with i32,
22212222
// unconstrained floats with f64.
22222223
// Fallback becomes very dubious if we have encountered type-checking errors.
22232224
// In that case, fallback to TyError.
@@ -2231,7 +2232,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
22312232
_ if self.is_tainted_by_errors() => self.tcx().types.err,
22322233
UnconstrainedInt => self.tcx.types.i32,
22332234
UnconstrainedFloat => self.tcx.types.f64,
2234-
Neither if self.type_var_diverges(ty) => self.tcx.types.never,
2235+
Neither if self.type_var_diverges(ty) => self.tcx.mk_diverging_default(),
22352236
Neither => return false,
22362237
};
22372238
debug!("default_type_parameters: defaulting `{:?}` to `{:?}`", ty, fallback);

src/librustc_typeck/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ This API is completely unstable and subject to change.
8282
#![feature(slice_patterns)]
8383
#![feature(slice_sort_by_cached_key)]
8484
#![feature(dyn_trait)]
85+
#![feature(never_type)]
8586

8687
#[macro_use] extern crate log;
8788
#[macro_use] extern crate syntax;

src/libstd/error.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'a> From<Cow<'a, str>> for Box<Error> {
233233
}
234234
}
235235

236-
#[stable(feature = "never_type", since = "1.26.0")]
236+
#[unstable(feature = "never_type", issue = "35121")]
237237
impl Error for ! {
238238
fn description(&self) -> &str { *self }
239239
}
@@ -284,14 +284,14 @@ impl Error for num::ParseIntError {
284284
}
285285
}
286286

287-
#[stable(feature = "try_from", since = "1.26.0")]
287+
#[unstable(feature = "try_from", issue = "33417")]
288288
impl Error for num::TryFromIntError {
289289
fn description(&self) -> &str {
290290
self.__description()
291291
}
292292
}
293293

294-
#[stable(feature = "try_from", since = "1.26.0")]
294+
#[unstable(feature = "try_from", issue = "33417")]
295295
impl Error for array::TryFromSliceError {
296296
fn description(&self) -> &str {
297297
self.__description()
@@ -365,7 +365,7 @@ impl Error for cell::BorrowMutError {
365365
}
366366
}
367367

368-
#[stable(feature = "try_from", since = "1.26.0")]
368+
#[unstable(feature = "try_from", issue = "33417")]
369369
impl Error for char::CharTryFromError {
370370
fn description(&self) -> &str {
371371
"converted integer out of range for `char`"

src/libstd/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
#![feature(macro_reexport)]
276276
#![feature(macro_vis_matcher)]
277277
#![feature(needs_panic_runtime)]
278+
#![feature(never_type)]
278279
#![feature(exhaustive_patterns)]
279280
#![feature(nonzero)]
280281
#![feature(num_bits_bytes)]
@@ -306,6 +307,7 @@
306307
#![feature(test, rustc_private)]
307308
#![feature(thread_local)]
308309
#![feature(toowned_clone_into)]
310+
#![feature(try_from)]
309311
#![feature(try_reserve)]
310312
#![feature(unboxed_closures)]
311313
#![feature(untagged_unions)]

src/libstd/primitive_docs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ mod prim_bool { }
7979
/// write:
8080
///
8181
/// ```
82+
/// #![feature(never_type)]
8283
/// # fn foo() -> u32 {
8384
/// let x: ! = {
8485
/// return 123
@@ -155,6 +156,7 @@ mod prim_bool { }
155156
/// for example:
156157
///
157158
/// ```
159+
/// #![feature(never_type)]
158160
/// # use std::fmt;
159161
/// # trait Debug {
160162
/// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result;

0 commit comments

Comments
 (0)