Change:
I tried this code: I expected to see this happen: “error[E0658]: the type is experimental” Instead, this happened: Successful compilation, as long as I'm using a nightly compiler, but the error when on stable 1.75. This is incorrect because nightly features should always require attributes on nightly (until they're stabilized, which hasn't happened yet for ). <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: label +F-never_type +requires-nightly
searched nightlies: from nightly-2023-11-11 to nightly-2024-02-01 regressed nightly: nightly-2024-01-27 searched commit range: regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.6.5</summaryHost triple: x86_64-unknown-linux-gnu Reproduce with: </detailsThen, bisecting Manually verified that reverting (as ) restored the error. cc
Not sure to understand why fixing the visitor implementation introduced this bug. Maybe it highlighted a limitation? Gonna check.
Ok I think I know why: implementation of the not calling the equivalent function. Checking where it is used.
WG-prioritization assigning priority (). label -I-prioritize +P-high
Fix was already approved in . Waiting for CI to be unlocked.

Discussion:
} } <ins> fn visit_generic_args(&mut self, args: &'a ast::GenericArgs) { // This check needs to happen here because the never type can be returned from a function, // but cannot be used in any other context. If this check was in `visit_fn_ret_ty`, it // include both functions and generics like `impl Fn() -> !`. if let ast::GenericArgs::Parenthesized(generic_args) = args && let ast::FnRetTy::Ty(ref ty) = generic_args.output && matches!(ty.kind, ast::TyKind::Never) { gate!(&self, never_type, ty.span, "the `!` type is experimental"); } visit::walk_generic_args(self, args); } </ins> fn visit_expr(&mut self, e: &'a ast::Expr) { match e.kind { ast::ExprKind::TryBlock(_) => {

type Wub = !; //~ ERROR type is experimental } <ins> fn look_ma_no_feature_gate<F: FnOnce() -> !>() {} //~ ERROR type is experimental fn tadam(f: &dyn Fn() -> !) {} //~ ERROR type is experimental fn panic() -> ! { panic!(); } fn toudoum() -> impl Fn() -> ! { //~ ERROR type is experimental panic } </ins> fn main() { }

= help: add `#![feature(never_type)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date <del> error: aborting due to 5 previous errors </del> <ins> error[E0658]: the `!` type is experimental --> $DIR/feature-gate-never_type.rs:16:43 | LL | fn look_ma_no_feature_gate<F: FnOnce() -> !>() {} |                                           ^ | = note: see issue #35121 <https://github.com/rust-lang/rust/issues/35121> for more information = help: add `#![feature(never_type)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the `!` type is experimental --> $DIR/feature-gate-never_type.rs:17:26 | LL | fn tadam(f: &dyn Fn() -> !) {} |                          ^ | = note: see issue #35121 <https://github.com/rust-lang/rust/issues/35121> for more information = help: add `#![feature(never_type)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the `!` type is experimental --> $DIR/feature-gate-never_type.rs:21:30 | LL | fn toudoum() -> impl Fn() -> ! { |                              ^ | = note: see issue #35121 <https://github.com/rust-lang/rust/issues/35121> for more information = help: add `#![feature(never_type)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: aborting due to 8 previous errors </ins> For more information about this error, try `rustc --explain E0658`.

<ins> // build-pass trait X<const N: i32> {} fn hello<T: X<{ fn hello() -> ! { loop {} } 1 }>>() {} fn main() {} </ins>