Skip to content

Commit e2e6c4a

Browse files
committed
Auto merge of #47630 - canndrew:exhaustive-patterns, r=<try>
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 3a39b2a + 72ce701 commit e2e6c4a

File tree

134 files changed

+238
-444
lines changed

Some content is hidden

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

134 files changed

+238
-444
lines changed

src/libcore/cmp.rs

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

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

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

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

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

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

src/libcore/fmt/mod.rs

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

15711571
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
15721572

1573-
#[unstable(feature = "never_type", issue = "35121")]
1573+
#[stable(feature = "never_type", since = "1.25.0")]
15741574
impl Debug for ! {
15751575
fn fmt(&self, _: &mut Formatter) -> Result {
15761576
*self
15771577
}
15781578
}
15791579

1580-
#[unstable(feature = "never_type", issue = "35121")]
1580+
#[stable(feature = "never_type", since = "1.25.0")]
15811581
impl Display for ! {
15821582
fn fmt(&self, _: &mut Formatter) -> Result {
15831583
*self

src/libcore/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
#![feature(inclusive_range_syntax)]
7979
#![feature(intrinsics)]
8080
#![feature(lang_items)]
81-
#![feature(never_type)]
81+
#![feature(exhaustive_patterns)]
8282
#![feature(no_core)]
8383
#![feature(on_unimplemented)]
8484
#![feature(optin_builtin_traits)]
@@ -91,6 +91,7 @@
9191
#![feature(untagged_unions)]
9292
#![feature(unwind_attributes)]
9393
#![feature(doc_spotlight)]
94+
#![cfg_attr(stage0, feature(never_type))]
9495

9596
#[prelude_import]
9697
#[allow(unused)]

src/librustc/ich/impls_ty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,8 @@ for ty::TypeVariants<'gcx>
656656
closure_substs.hash_stable(hcx, hasher);
657657
interior.hash_stable(hcx, hasher);
658658
}
659-
TyTuple(inner_tys, from_diverging_type_var) => {
659+
TyTuple(inner_tys) => {
660660
inner_tys.hash_stable(hcx, hasher);
661-
from_diverging_type_var.hash_stable(hcx, hasher);
662661
}
663662
TyProjection(ref projection_ty) => {
664663
projection_ty.hash_stable(hcx, hasher);

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
@@ -57,7 +57,7 @@
5757
#![cfg_attr(windows, feature(libc))]
5858
#![feature(macro_vis_matcher)]
5959
#![feature(match_default_bindings)]
60-
#![feature(never_type)]
60+
#![feature(exhaustive_patterns)]
6161
#![feature(nonzero)]
6262
#![feature(quote)]
6363
#![feature(refcell_replace_swap)]

src/librustc/lint/builtin.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,6 @@ declare_lint! {
142142
"lints that have been renamed or removed"
143143
}
144144

145-
declare_lint! {
146-
pub RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
147-
Deny,
148-
"attempt to resolve a trait on an expression whose type cannot be inferred but which \
149-
currently defaults to ()"
150-
}
151-
152145
declare_lint! {
153146
pub SAFE_EXTERN_STATICS,
154147
Deny,
@@ -275,7 +268,6 @@ impl LintPass for HardwiredLints {
275268
INVALID_TYPE_PARAM_DEFAULT,
276269
CONST_ERR,
277270
RENAMED_AND_REMOVED_LINTS,
278-
RESOLVE_TRAIT_ON_DEFAULTED_UNIT,
279271
SAFE_EXTERN_STATICS,
280272
SAFE_PACKED_BORROWS,
281273
PATTERNS_IN_FNS_WITHOUT_BODY,

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) {

src/librustc/mir/tcx.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'tcx> Rvalue<'tcx> {
171171
let lhs_ty = lhs.ty(local_decls, tcx);
172172
let rhs_ty = rhs.ty(local_decls, tcx);
173173
let ty = op.ty(tcx, lhs_ty, rhs_ty);
174-
tcx.intern_tup(&[ty, tcx.types.bool], false)
174+
tcx.intern_tup(&[ty, tcx.types.bool])
175175
}
176176
Rvalue::UnaryOp(UnOp::Not, ref operand) |
177177
Rvalue::UnaryOp(UnOp::Neg, ref operand) => {
@@ -195,10 +195,7 @@ impl<'tcx> Rvalue<'tcx> {
195195
tcx.mk_array(ty, ops.len() as u64)
196196
}
197197
AggregateKind::Tuple => {
198-
tcx.mk_tup(
199-
ops.iter().map(|op| op.ty(local_decls, tcx)),
200-
false
201-
)
198+
tcx.mk_tup(ops.iter().map(|op| op.ty(local_decls, tcx)))
202199
}
203200
AggregateKind::Adt(def, _, substs, _) => {
204201
tcx.type_of(def.did).subst(tcx, substs)

src/librustc/traits/error_reporting.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,14 +718,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
718718
}).map(|sp| self.tcx.sess.codemap().def_span(sp)); // the sp could be an fn def
719719

720720
let found = match found_trait_ref.skip_binder().substs.type_at(1).sty {
721-
ty::TyTuple(ref tys, _) => tys.iter()
721+
ty::TyTuple(ref tys) => tys.iter()
722722
.map(|_| ArgKind::empty()).collect::<Vec<_>>(),
723723
_ => vec![ArgKind::empty()],
724724
};
725725
let expected = match expected_trait_ref.skip_binder().substs.type_at(1).sty {
726-
ty::TyTuple(ref tys, _) => tys.iter()
726+
ty::TyTuple(ref tys) => tys.iter()
727727
.map(|t| match t.sty {
728-
ty::TypeVariants::TyTuple(ref tys, _) => ArgKind::Tuple(
728+
ty::TypeVariants::TyTuple(ref tys) => ArgKind::Tuple(
729729
span,
730730
tys.iter()
731731
.map(|ty| ("_".to_owned(), format!("{}", ty.sty)))
@@ -937,7 +937,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
937937
fn build_fn_sig_string<'a, 'gcx, 'tcx>(tcx: ty::TyCtxt<'a, 'gcx, 'tcx>,
938938
trait_ref: &ty::TraitRef<'tcx>) -> String {
939939
let inputs = trait_ref.substs.type_at(1);
940-
let sig = if let ty::TyTuple(inputs, _) = inputs.sty {
940+
let sig = if let ty::TyTuple(inputs) = inputs.sty {
941941
tcx.mk_fn_sig(
942942
inputs.iter().map(|&x| x),
943943
tcx.mk_infer(ty::TyVar(ty::TyVid { index: 0 })),

0 commit comments

Comments
 (0)