Skip to content

Commit 6b36e86

Browse files
committed
remove feature(never_type_fallback)
1 parent a7b102a commit 6b36e86

32 files changed

+227
-372
lines changed

compiler/rustc_feature/src/removed.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ declare_features! (
189189
Some("subsumed by `#![feature(allocator_internals)]`")),
190190
/// Allows use of unary negate on unsigned integers, e.g., -e for e: u8
191191
(removed, negate_unsigned, "1.0.0", Some(29645), None),
192+
/// Allows diverging expressions to fall back to `!` rather than `()`.
193+
(removed, never_type_fallback, "CURRENT_RUSTC_VERSION", Some(65992), Some("removed in favor of unconditional fallback"), 148871),
192194
/// Allows `#[no_coverage]` on functions.
193195
/// The feature was renamed to `coverage_attribute` and the attribute to `#[coverage(on|off)]`
194196
(removed, no_coverage, "1.74.0", Some(84605), Some("renamed to `coverage_attribute`"), 114656),

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,6 @@ declare_features! (
596596
(incomplete, never_patterns, "1.76.0", Some(118155)),
597597
/// Allows the `!` type. Does not imply 'exhaustive_patterns' (below) any more.
598598
(unstable, never_type, "1.13.0", Some(35121)),
599-
/// Allows diverging expressions to fall back to `!` rather than `()`.
600-
(unstable, never_type_fallback, "1.41.0", Some(65992)),
601599
/// Switch `..` syntax to use the new (`Copy + IntoIterator`) range types.
602600
(unstable, new_range, "1.86.0", Some(123741)),
603601
/// Allows `#![no_core]`.

compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
265265
// so we can just make the hidden type be `!`.
266266
// For backwards compatibility reasons, we fall back to
267267
// `()` until we the diverging default is changed.
268-
EarlyBinder::bind(Ty::new_diverging_default(tcx))
268+
EarlyBinder::bind(tcx.types.unit)
269269
}
270270
}
271271
DefiningScopeKind::MirBorrowck => match tcx.mir_borrowck(owner_def_id) {

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,11 +878,6 @@ impl<'tcx> Ty<'tcx> {
878878
Ty::new_imm_ref(tcx, tcx.lifetimes.re_static, tcx.types.str_)
879879
}
880880

881-
#[inline]
882-
pub fn new_diverging_default(tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
883-
if tcx.features().never_type_fallback() { tcx.types.never } else { tcx.types.unit }
884-
}
885-
886881
// lang and diagnostic tys
887882

888883
fn new_generic_adt(tcx: TyCtxt<'tcx>, wrapper_def_id: DefId, ty_param: Ty<'tcx>) -> Ty<'tcx> {

tests/ui/binding/empty-types-in-patterns.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ run-pass
2+
//@ edition: 2024
23

3-
#![feature(never_type, never_type_fallback)]
4+
#![feature(never_type)]
45
#![feature(exhaustive_patterns)]
56

67
#![allow(unreachable_patterns)]

tests/ui/coercion/coerce-issue-49593-box-never.nofallback.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0277]: the trait bound `(): std::error::Error` is not satisfied
2-
--> $DIR/coerce-issue-49593-box-never.rs:18:5
2+
--> $DIR/coerce-issue-49593-box-never.rs:17:5
33
|
44
LL | Box::<_ /* ! */>::new(x)
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`
66
|
77
= note: required for the cast from `Box<()>` to `Box<(dyn std::error::Error + 'static)>`
88

99
error[E0277]: the trait bound `(): std::error::Error` is not satisfied
10-
--> $DIR/coerce-issue-49593-box-never.rs:24:5
10+
--> $DIR/coerce-issue-49593-box-never.rs:23:5
1111
|
1212
LL | raw_ptr_box::<_ /* ! */>(x)
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `()`

tests/ui/coercion/coerce-issue-49593-box-never.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//@ revisions: nofallback fallback
2+
//@[fallback] edition: 2024
23
//@[fallback] check-pass
34

45
#![feature(never_type)]
5-
#![cfg_attr(fallback, feature(never_type_fallback))]
6-
#![allow(unreachable_code)]
76

87
use std::error::Error;
98
use std::mem;

tests/ui/never_type/defaulted-never-note.fallback.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
error[E0277]: the trait bound `!: ImplementedForUnitButNotNever` is not satisfied
2-
--> $DIR/defaulted-never-note.rs:31:9
2+
--> $DIR/defaulted-never-note.rs:27:9
33
|
44
LL | foo(_x);
55
| --- ^^ the trait `ImplementedForUnitButNotNever` is not implemented for `!`
66
| |
77
| required by a bound introduced by this call
88
|
99
help: the trait `ImplementedForUnitButNotNever` is implemented for `()`
10-
--> $DIR/defaulted-never-note.rs:24:1
10+
--> $DIR/defaulted-never-note.rs:20:1
1111
|
1212
LL | impl ImplementedForUnitButNotNever for () {}
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
1515
= help: you might have intended to use the type `()` here instead
1616
note: required by a bound in `foo`
17-
--> $DIR/defaulted-never-note.rs:26:11
17+
--> $DIR/defaulted-never-note.rs:22:11
1818
|
1919
LL | fn foo<T: ImplementedForUnitButNotNever>(_t: T) {}
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo`

tests/ui/never_type/defaulted-never-note.nofallback.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Future incompatibility report: Future breakage diagnostic:
22
warning: this function depends on never type fallback being `()`
3-
--> $DIR/defaulted-never-note.rs:29:1
3+
--> $DIR/defaulted-never-note.rs:25:1
44
|
55
LL | fn smeg() {
66
| ^^^^^^^^^
77
|
88
= help: specify the types explicitly
99
note: in edition 2024, the requirement `!: ImplementedForUnitButNotNever` will fail
10-
--> $DIR/defaulted-never-note.rs:31:9
10+
--> $DIR/defaulted-never-note.rs:27:9
1111
|
1212
LL | foo(_x);
1313
| ^^

tests/ui/never_type/defaulted-never-note.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
//@ revisions: nofallback fallback
2+
//@[fallback] edition: 2024
23
//@[nofallback] run-pass
34
//@[fallback] check-fail
45

5-
// We need to opt into the `never_type_fallback` feature
6-
// to trigger the requirement that this is testing.
7-
#![cfg_attr(fallback, feature(never_type, never_type_fallback))]
8-
9-
#![allow(unused)]
10-
#![expect(dependency_on_unit_never_type_fallback)]
6+
#![expect(dependency_on_unit_never_type_fallback, unused)]
117

128
trait Deserialize: Sized {
139
fn deserialize() -> Result<Self, String>;

0 commit comments

Comments
 (0)