Skip to content

Commit 5ebf748

Browse files
committed
Auto merge of #47630 - canndrew:exhaustive-patterns, r=nikomatsakis
Stabilise feature(never_type). Introduce feature(exhaustive_patterns) This stabilizes `!`, removing the feature gate as well as the old defaulting-to-`()` behavior. The pattern exhaustiveness checks which were covered by `feature(never_type)` have been moved behind a new `feature(exhaustive_patterns)` gate.
2 parents 521d91c + a8a0c69 commit 5ebf748

File tree

147 files changed

+295
-547
lines changed

Some content is hidden

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

147 files changed

+295
-547
lines changed

src/libcore/cmp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -882,24 +882,24 @@ mod impls {
882882

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

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

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

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

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

src/libcore/fmt/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,14 +1711,14 @@ macro_rules! fmt_refs {
17111711

17121712
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
17131713

1714-
#[unstable(feature = "never_type", issue = "35121")]
1714+
#[stable(feature = "never_type", since = "1.26.0")]
17151715
impl Debug for ! {
17161716
fn fmt(&self, _: &mut Formatter) -> Result {
17171717
*self
17181718
}
17191719
}
17201720

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

src/libcore/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
#![feature(iterator_repeat_with)]
8686
#![feature(lang_items)]
8787
#![feature(link_llvm_intrinsics)]
88-
#![feature(never_type)]
88+
#![feature(exhaustive_patterns)]
8989
#![feature(no_core)]
9090
#![feature(on_unimplemented)]
9191
#![feature(optin_builtin_traits)]
@@ -103,6 +103,7 @@
103103
#![feature(unwind_attributes)]
104104

105105
#![cfg_attr(stage0, allow(unused_attributes))]
106+
#![cfg_attr(stage0, feature(never_type))]
106107

107108
#[prelude_import]
108109
#[allow(unused)]

src/librustc/ich/impls_ty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,8 @@ for ty::TypeVariants<'gcx>
886886
TyGeneratorWitness(types) => {
887887
types.hash_stable(hcx, hasher)
888888
}
889-
TyTuple(inner_tys, from_diverging_type_var) => {
889+
TyTuple(inner_tys) => {
890890
inner_tys.hash_stable(hcx, hasher);
891-
from_diverging_type_var.hash_stable(hcx, hasher);
892891
}
893892
TyProjection(ref projection_ty) => {
894893
projection_ty.hash_stable(hcx, hasher);

src/librustc/infer/canonical.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,12 +609,6 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
609609
bug!("encountered a canonical type during canonicalization")
610610
}
611611

612-
// Replace a `()` that "would've fallen back" to `!` with just `()`.
613-
ty::TyTuple(ref tys, true) => {
614-
assert!(tys.is_empty());
615-
self.tcx().mk_nil()
616-
}
617-
618612
ty::TyClosure(..)
619613
| ty::TyGenerator(..)
620614
| ty::TyGeneratorWitness(..)
@@ -634,7 +628,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
634628
| ty::TyFnPtr(_)
635629
| ty::TyDynamic(..)
636630
| ty::TyNever
637-
| ty::TyTuple(_, false)
631+
| ty::TyTuple(..)
638632
| ty::TyProjection(..)
639633
| ty::TyForeign(..)
640634
| ty::TyParam(..)

src/librustc/infer/outlives/bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
151151
// get solved *here*.
152152
match fulfill_cx.select_all_or_error(self) {
153153
Ok(()) => (),
154-
Err(errors) => self.report_fulfillment_errors(&errors, None),
154+
Err(errors) => self.report_fulfillment_errors(&errors, None, false),
155155
}
156156

157157
implied_bounds

src/librustc/infer/resolve.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,6 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for FullTypeResolver<'a, 'gcx, 'tcx>
173173
ty::TyInfer(_) => {
174174
bug!("Unexpected type in full type resolver: {:?}", t);
175175
}
176-
ty::TyTuple(tys, true) => {
177-
// Un-default defaulted tuples - we are going to a
178-
// different infcx, and the default will just cause
179-
// pollution.
180-
self.tcx().intern_tup(tys, false)
181-
}
182176
_ => {
183177
t.super_fold_with(self)
184178
}

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#![feature(match_default_bindings)]
6161
#![feature(macro_lifetime_matcher)]
6262
#![feature(macro_vis_matcher)]
63-
#![feature(never_type)]
63+
#![feature(exhaustive_patterns)]
6464
#![feature(non_exhaustive)]
6565
#![feature(nonzero)]
6666
#![feature(proc_macro_internals)]

src/librustc/lint/builtin.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,6 @@ declare_lint! {
151151
"lints that have been renamed or removed"
152152
}
153153

154-
declare_lint! {
155-
pub RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
156-
Deny,
157-
"attempt to resolve a trait on an expression whose type cannot be inferred but which \
158-
currently defaults to ()"
159-
}
160-
161154
declare_lint! {
162155
pub SAFE_EXTERN_STATICS,
163156
Deny,
@@ -237,12 +230,6 @@ declare_lint! {
237230
"detect mut variables which don't need to be mutable"
238231
}
239232

240-
declare_lint! {
241-
pub COERCE_NEVER,
242-
Deny,
243-
"detect coercion to !"
244-
}
245-
246233
declare_lint! {
247234
pub SINGLE_USE_LIFETIME,
248235
Allow,
@@ -304,7 +291,6 @@ impl LintPass for HardwiredLints {
304291
INVALID_TYPE_PARAM_DEFAULT,
305292
CONST_ERR,
306293
RENAMED_AND_REMOVED_LINTS,
307-
RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
308294
SAFE_EXTERN_STATICS,
309295
SAFE_PACKED_BORROWS,
310296
PATTERNS_IN_FNS_WITHOUT_BODY,
@@ -318,7 +304,6 @@ impl LintPass for HardwiredLints {
318304
DEPRECATED,
319305
UNUSED_UNSAFE,
320306
UNUSED_MUT,
321-
COERCE_NEVER,
322307
SINGLE_USE_LIFETIME,
323308
TYVAR_BEHIND_RAW_POINTER,
324309
ELIDED_LIFETIME_IN_PATH,

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
12981298
PatKind::Tuple(ref subpats, ddpos) => {
12991299
// (p1, ..., pN)
13001300
let expected_len = match self.pat_ty(&pat)?.sty {
1301-
ty::TyTuple(ref tys, _) => tys.len(),
1301+
ty::TyTuple(ref tys) => tys.len(),
13021302
ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
13031303
};
13041304
for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) {

0 commit comments

Comments
 (0)