diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index 3e9012f2d3871..c33765f03d77d 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -10,12 +10,12 @@ // tidy-alphabetical-start #![allow(clippy::mut_from_ref)] // Arena allocators are one place where this pattern is fine. #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(never_type))] #![cfg_attr(test, feature(test))] #![deny(unsafe_op_in_unsafe_fn)] #![doc(test(no_crate_inject, attr(deny(warnings), allow(internal_features))))] #![feature(decl_macro)] #![feature(dropck_eyepatch)] -#![feature(never_type)] #![feature(rustc_attrs)] #![feature(unwrap_infallible)] // tidy-alphabetical-end diff --git a/compiler/rustc_ast_ir/src/lib.rs b/compiler/rustc_ast_ir/src/lib.rs index f90359c515264..e919e7df99ee0 100644 --- a/compiler/rustc_ast_ir/src/lib.rs +++ b/compiler/rustc_ast_ir/src/lib.rs @@ -7,7 +7,7 @@ // tidy-alphabetical-start #![cfg_attr(feature = "nightly", allow(internal_features))] -#![cfg_attr(feature = "nightly", feature(never_type))] +#![cfg_attr(feature = "nightly", cfg_attr(bootstrap, feature(never_type)))] #![cfg_attr(feature = "nightly", feature(rustc_attrs))] // tidy-alphabetical-end diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 01d81bab55075..ec9a2a1d23084 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -261,9 +261,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { // Function pointers cannot be `const` self.check_late_bound_lifetime_defs(&fn_ptr_ty.generic_params); } - ast::TyKind::Never => { - gate!(self, never_type, ty.span, "the `!` type is experimental"); - } ast::TyKind::Pat(..) => { gate!(self, pattern_types, ty.span, "pattern types are unstable"); } @@ -294,15 +291,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } 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); } diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 42b525ea97d94..692941f066314 100644 --- a/compiler/rustc_borrowck/src/lib.rs +++ b/compiler/rustc_borrowck/src/lib.rs @@ -2,11 +2,11 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(never_type))] #![feature(default_field_values)] #![feature(deref_patterns)] #![feature(file_buffered)] #![feature(negative_impls)] -#![feature(never_type)] #![feature(option_into_flat_iter)] #![feature(rustc_attrs)] #![feature(stmt_expr_attributes)] diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index 6c4575caebd8e..dc4ab18e94f8d 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -87,12 +87,12 @@ pub trait ArchiveBuilderBuilder { items: Vec, output_path: &Path, ) { - if common::is_mingw_gnu_toolchain(&sess.target) { - // The binutils linker used on -windows-gnu targets cannot read the import - // libraries generated by LLVM: in our attempts, the linker produced an .EXE - // that loaded but crashed with an AV upon calling one of the imported - // functions. Therefore, use binutils to create the import library instead, - // by writing a .DEF file to the temp dir and calling binutils's dlltool. + if common::is_mingw_gnu_toolchain(&sess.target) && sess.opts.cg.dlltool.is_some() { + // Previously we always used dlltool on -windows-gnu targets due to the binutils + // linker not entirely correctly handling import libraries generated by + // LLVM/ar_archive_writer. This has since been fixed. To ease the transition, will + // temporarily still use dlltool if explicitly specified, but use ar_archive_writer + // like on MSVC if not. create_mingw_dll_import_lib(sess, lib_name, items, output_path); } else { trace!("creating import library"); diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index 7fe32b4e75ffb..a7cad6c0adfb2 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -1,8 +1,8 @@ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(never_type))] #![feature(array_try_map)] #![feature(decl_macro)] #![feature(deref_patterns)] -#![feature(never_type)] #![feature(slice_ptr_get)] #![feature(trait_alias)] #![feature(unqualified_local_imports)] diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index d8c1e2bd0ed30..ab30806bd2a59 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -10,6 +10,7 @@ #![allow(internal_features)] #![allow(rustc::default_hash_types)] #![allow(rustc::potential_query_instability)] +#![cfg_attr(bootstrap, feature(never_type))] #![cfg_attr(test, feature(test))] #![deny(unsafe_op_in_unsafe_fn)] #![feature(allocator_api)] @@ -24,7 +25,6 @@ #![feature(map_try_insert)] #![feature(min_specialization)] #![feature(negative_impls)] -#![feature(never_type)] #![feature(nonzero_internals)] #![feature(pattern_type_macro)] #![feature(pattern_types)] diff --git a/compiler/rustc_error_codes/src/error_codes/E0725.md b/compiler/rustc_error_codes/src/error_codes/E0725.md index 9bd321e5f82d6..20019bf59c36a 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0725.md +++ b/compiler/rustc_error_codes/src/error_codes/E0725.md @@ -4,8 +4,9 @@ command line flags. Erroneous code example: ```ignore (can't specify compiler flags from doctests) -#![feature(never_type)] // error: the feature `never_type` is not in - // the list of allowed features +#![feature(extern_item_impls)] +//~^ error: the feature `extern_item_impls` +// is not in the list of allowed features ``` Delete the offending feature attribute, or add it to the list of allowed diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index b487187842029..f868b11ea6fd2 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -3,11 +3,11 @@ //! This module contains the code for creating and emitting diagnostics. // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(never_type))] #![feature(associated_type_defaults)] #![feature(default_field_values)] #![feature(macro_metavar_expr_concat)] #![feature(negative_impls)] -#![feature(never_type)] // tidy-alphabetical-end extern crate self as rustc_errors; diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index f57a280968322..a6e6f4f78323c 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -335,6 +335,8 @@ declare_features! ( (accepted, native_link_modifiers_verbatim, "1.67.0", Some(81490)), /// Allows specifying the whole-archive link modifier (accepted, native_link_modifiers_whole_archive, "1.61.0", Some(81490)), + /// Allows the `!` type. + (accepted, never_type, "CURRENT_RUSTC_VERSION", Some(35121)), /// Allows using non lexical lifetimes (RFC 2094). (accepted, nll, "1.63.0", Some(43234)), /// Allows using `#![no_std]`. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 00ca1e07c93fd..8731c41da1884 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -673,8 +673,6 @@ declare_features! ( (unstable, negative_impls, "1.44.0", Some(68318)), /// Allows the `!` pattern. (incomplete, never_patterns, "1.76.0", Some(118155)), - /// Allows the `!` type. Does not imply 'exhaustive_patterns' (below) any more. - (unstable, never_type, "1.13.0", Some(35121)), /// Switch `..` syntax to use the new (`Copy + IntoIterator`) range types. (unstable, new_range, "1.86.0", Some(123741)), /// Allows `#![no_core]`. diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index 0b279f334e9fb..55ef1c9fb3ef9 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -3,6 +3,7 @@ //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(never_type))] #![feature(associated_type_defaults)] #![feature(closure_track_caller)] #![feature(const_default)] @@ -10,7 +11,6 @@ #![feature(default_field_values)] #![feature(derive_const)] #![feature(exhaustive_patterns)] -#![feature(never_type)] #![recursion_limit = "256"] // tidy-alphabetical-end diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 1f342f10f8b17..9799208efdb2a 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -56,10 +56,10 @@ This API is completely unstable and subject to change. */ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(never_type))] #![feature(default_field_values)] #![feature(gen_blocks)] #![feature(iter_intersperse)] -#![feature(never_type)] #![feature(slice_partition_dedup)] #![feature(try_blocks)] #![feature(unwrap_infallible)] diff --git a/compiler/rustc_hir_typeck/src/diagnostics.rs b/compiler/rustc_hir_typeck/src/diagnostics.rs index fd74693e7f9fb..2d4cf3d9b400d 100644 --- a/compiler/rustc_hir_typeck/src/diagnostics.rs +++ b/compiler/rustc_hir_typeck/src/diagnostics.rs @@ -12,7 +12,7 @@ use rustc_errors::{ use rustc_hir as hir; use rustc_hir::ExprKind; use rustc_macros::{Diagnostic, Subdiagnostic}; -use rustc_middle::ty::{self, Ty}; +use rustc_middle::ty::Ty; use rustc_span::edition::{Edition, LATEST_STABLE_EDITION}; use rustc_span::{Ident, Span, Spanned, Symbol}; @@ -262,17 +262,6 @@ pub(crate) enum NeverTypeFallbackFlowingIntoUnsafe { }, } -#[derive(Diagnostic)] -#[help("specify the types explicitly")] -#[diag("this function depends on never type fallback being `()`")] -pub(crate) struct DependencyOnUnitNeverTypeFallback<'tcx> { - #[note("in edition 2024, the requirement `{$obligation}` will fail")] - pub obligation_span: Span, - pub obligation: ty::Predicate<'tcx>, - #[subdiagnostic] - pub sugg: SuggestAnnotations, -} - #[derive(Clone)] pub(crate) enum SuggestAnnotation { Unit(Span), diff --git a/compiler/rustc_hir_typeck/src/fallback.rs b/compiler/rustc_hir_typeck/src/fallback.rs index e6f87304ee396..889b8e841febc 100644 --- a/compiler/rustc_hir_typeck/src/fallback.rs +++ b/compiler/rustc_hir_typeck/src/fallback.rs @@ -10,13 +10,12 @@ use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{InferKind, Visitor}; use rustc_hir::{self as hir, CRATE_HIR_ID, HirId}; use rustc_lint_defs::builtin::{ - DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, FLOAT_LITERAL_F32_FALLBACK, - NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE, + FLOAT_LITERAL_F32_FALLBACK, NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE, }; use rustc_middle::ty::{self, FloatVid, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable}; use rustc_span::def_id::LocalDefId; use rustc_span::{DUMMY_SP, Span}; -use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt, TraitEngine}; +use rustc_trait_selection::traits::TraitEngine; use tracing::debug; use crate::{FnCtxt, diagnostics}; @@ -237,11 +236,6 @@ impl<'tcx> FnCtxt<'_, 'tcx> { // a type variable is that is coerced let coercion_graph = self.create_coercion_graph(); - self.lint_obligations_broken_by_never_type_fallback_change( - &diverging_root_vids, - &coercion_graph, - ); - if !diverging_root_vids.is_empty() { let unsafe_infer_vars = compute_unsafe_infer_vars(self, self.body_def_id); @@ -305,58 +299,6 @@ impl<'tcx> FnCtxt<'_, 'tcx> { } } - fn lint_obligations_broken_by_never_type_fallback_change( - &self, - diverging_vids: &[ty::TyVid], - coercions: &VecGraph, - ) { - let DivergingFallbackBehavior::ToUnit = self.diverging_fallback_behavior else { return }; - - // Fallback happens if and only if there are diverging variables - if diverging_vids.is_empty() { - return; - } - - // Returns errors which happen if fallback is set to `fallback` - let remaining_errors_if_fallback_to = |fallback| { - self.probe(|_| { - let obligations = self.fulfillment_cx.borrow().pending_obligations(); - let ocx = ObligationCtxt::new_with_diagnostics(&self.infcx); - ocx.register_obligations(obligations.iter().cloned()); - - for &diverging_vid in diverging_vids { - let diverging_ty = Ty::new_var(self.tcx, diverging_vid); - - ocx.eq(&ObligationCause::dummy(), self.param_env, diverging_ty, fallback) - .expect("expected diverging var to be unconstrained"); - } - - ocx.try_evaluate_obligations() - }) - }; - - // If we have no errors with `fallback = ()`, but *do* have errors with `fallback = !`, - // then this code will be broken by the never type fallback change. - let unit_errors = remaining_errors_if_fallback_to(self.tcx.types.unit); - if unit_errors.no_errors() - && let mut never_errors = remaining_errors_if_fallback_to(self.tcx.types.never) - && let [never_error, ..] = never_errors.as_mut_slice() - { - self.adjust_fulfillment_error_for_expr_obligation(never_error); - let sugg = self.try_to_suggest_annotations(diverging_vids, coercions); - self.tcx.emit_node_span_lint( - DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, - self.tcx.local_def_id_to_hir_id(self.body_def_id), - self.tcx.def_span(self.body_def_id), - diagnostics::DependencyOnUnitNeverTypeFallback { - obligation_span: never_error.obligation.cause.span, - obligation: never_error.obligation.predicate, - sugg, - }, - ) - } - } - /// Returns a graph whose nodes are (unresolved) inference variables and where /// an edge `?A -> ?B` indicates that the variable `?A` is coerced to `?B`. fn create_coercion_graph(&self) -> VecGraph { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index e488f8c9a7887..06c8583b632ae 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -493,24 +493,14 @@ impl<'tcx> LoweredTy<'tcx> { } fn never_type_behavior(tcx: TyCtxt<'_>) -> (DivergingFallbackBehavior, DivergingBlockBehavior) { + // FIXME(waffle): rip out the whole system which allows you to choose never type fallback let (fallback, block) = parse_never_type_options_attr(tcx); - let fallback = fallback.unwrap_or_else(|| default_fallback(tcx)); + let fallback = fallback.unwrap_or_else(|| DivergingFallbackBehavior::ToNever); let block = block.unwrap_or_default(); (fallback, block) } -/// Returns the default fallback which is used when there is no explicit override via `#![never_type_options(...)]`. -fn default_fallback(tcx: TyCtxt<'_>) -> DivergingFallbackBehavior { - // Edition 2024: fallback to `!` - if tcx.sess.edition().at_least_rust_2024() { - return DivergingFallbackBehavior::ToNever; - } - - // Otherwise: fallback to `()` - DivergingFallbackBehavior::ToUnit -} - fn parse_never_type_options_attr( tcx: TyCtxt<'_>, ) -> (Option, Option) { diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 7f38aeb5ac3fa..57fd6a8658ae3 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -1,8 +1,8 @@ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(never_type))] #![feature(deref_patterns)] #![feature(iter_intersperse)] #![feature(iter_order_by)] -#![feature(never_type)] #![feature(option_into_flat_iter)] #![feature(option_reference_flattening)] #![feature(trim_prefix_suffix)] diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 852f1cfda5168..5310500fa84eb 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -713,6 +713,10 @@ fn register_builtins(store: &mut LintStore) { "converted into hard error, \ generic items must always be mangled", ); + store.register_removed( + "dependency_on_unit_never_type_fallback", + "the code warned by this lint no longer compiles", + ); } fn register_internals(store: &mut LintStore) { diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index d7339d1b60269..def2662e15837 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -36,7 +36,6 @@ pub mod hardwired { CONST_ITEM_MUTATION, DEAD_CODE, DEAD_CODE_PUB_IN_BINARY, - DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, DEPRECATED, DEPRECATED_IN_FUTURE, DEPRECATED_LLVM_INTRINSIC, @@ -4176,9 +4175,9 @@ declare_lint! { /// /// ### Explanation /// - /// Due to historic reasons never type fallback was `()`, meaning that `!` got spontaneously - /// coerced to `()`. There are plans to change that, but they may make the code such as above - /// unsound. Instead of depending on the fallback, you should specify the type explicitly: + /// The never type fallback used to be `()`, meaning that `!` got spontaneously coerced to `()`. + /// Since then the never type fallback has been changed to `!`, making the above code undefined + /// behavior. Instead of depending on the fallback, you should specify the type explicitly: /// ``` /// if true { /// return @@ -4195,64 +4194,6 @@ declare_lint! { pub NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE, Deny, "never type fallback affecting unsafe function calls", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionAndFutureReleaseSemanticsChange 2024 "never-type-fallback"), - report_in_deps: true, - }; - @edition Edition2024 => Deny; - report_in_external_macro -} - -declare_lint! { - /// The `dependency_on_unit_never_type_fallback` lint detects cases where code compiles with - /// [never type fallback] being [`()`], but will stop compiling with fallback being [`!`]. - /// - /// [never type fallback]: https://doc.rust-lang.org/nightly/core/primitive.never.html#never-type-fallback - /// [`!`]: https://doc.rust-lang.org/core/primitive.never.html - /// [`()`]: https://doc.rust-lang.org/core/primitive.unit.html - /// - /// ### Example - /// - /// ```rust,compile_fail,edition2021 - /// # #![deny(dependency_on_unit_never_type_fallback)] - /// fn main() { - /// if true { - /// // return has type `!` which, is some cases, causes never type fallback - /// return - /// } else { - /// // the type produced by this call is not specified explicitly, - /// // so it will be inferred from the previous branch - /// Default::default() - /// }; - /// // depending on the fallback, this may compile (because `()` implements `Default`), - /// // or it may not (because `!` does not implement `Default`) - /// } - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// Due to historic reasons never type fallback was `()`, meaning that `!` got spontaneously - /// coerced to `()`. There are plans to change that, but they may make the code such as above - /// not compile. Instead of depending on the fallback, you should specify the type explicitly: - /// ``` - /// if true { - /// return - /// } else { - /// // type is explicitly specified, fallback can't hurt us no more - /// <() as Default>::default() - /// }; - /// ``` - /// - /// See [Tracking Issue for making `!` fall back to `!`](https://github.com/rust-lang/rust/issues/123748). - pub DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, - Deny, - "never type fallback affecting unsafe function calls", - @future_incompatible = FutureIncompatibleInfo { - reason: fcw!(EditionAndFutureReleaseError 2024 "never-type-fallback"), - report_in_deps: true, - }; report_in_external_macro } diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 81a506c63a8ee..0dc70a07efa25 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -529,6 +529,17 @@ extern "C" typedef void (*LLVMRustSelfProfileBeforePassCallback)( extern "C" typedef void (*LLVMRustSelfProfileAfterPassCallback)( void *); // LlvmSelfProfiler +#if LLVM_VERSION_GE(24, 0) +std::string LLVMRustwrappedIrGetName(const llvm::IRUnitRef &WrappedIr) { + if (const auto *Cast = dyn_cast(WrappedIr)) + return Cast->getName().str(); + if (const auto *Cast = dyn_cast(WrappedIr)) + return Cast->getName().str(); + if (const auto *Cast = dyn_cast(WrappedIr)) + return Cast->getName().str(); + if (const auto *Cast = dyn_cast(WrappedIr)) + return Cast->getName(); +#else std::string LLVMRustwrappedIrGetName(const llvm::Any &WrappedIr) { if (const auto *Cast = any_cast(&WrappedIr)) return (*Cast)->getName().str(); @@ -538,6 +549,7 @@ std::string LLVMRustwrappedIrGetName(const llvm::Any &WrappedIr) { return (*Cast)->getName().str(); if (const auto *Cast = any_cast(&WrappedIr)) return (*Cast)->getName(); +#endif return ""; } @@ -546,15 +558,26 @@ void LLVMSelfProfileInitializeCallbacks( LLVMRustSelfProfileBeforePassCallback BeforePassCallback, LLVMRustSelfProfileAfterPassCallback AfterPassCallback) { PIC.registerBeforeNonSkippedPassCallback( +#if LLVM_VERSION_GE(24, 0) + [LlvmSelfProfiler, BeforePassCallback](StringRef Pass, + llvm::IRUnitRef Ir) { +#else [LlvmSelfProfiler, BeforePassCallback](StringRef Pass, llvm::Any Ir) { +#endif std::string PassName = Pass.str(); std::string IrName = LLVMRustwrappedIrGetName(Ir); BeforePassCallback(LlvmSelfProfiler, PassName.c_str(), IrName.c_str()); }); PIC.registerAfterPassCallback( +#if LLVM_VERSION_GE(24, 0) + [LlvmSelfProfiler, + AfterPassCallback](StringRef Pass, llvm::IRUnitRef IR, + const PreservedAnalyses &Preserved) { +#else [LlvmSelfProfiler, AfterPassCallback]( StringRef Pass, llvm::Any IR, const PreservedAnalyses &Preserved) { +#endif AfterPassCallback(LlvmSelfProfiler); }); @@ -564,17 +587,27 @@ void LLVMSelfProfileInitializeCallbacks( AfterPassCallback(LlvmSelfProfiler); }); +#if LLVM_VERSION_GE(24, 0) + PIC.registerBeforeAnalysisCallback([LlvmSelfProfiler, BeforePassCallback]( + StringRef Pass, llvm::IRUnitRef Ir) { +#else PIC.registerBeforeAnalysisCallback( [LlvmSelfProfiler, BeforePassCallback](StringRef Pass, llvm::Any Ir) { - std::string PassName = Pass.str(); - std::string IrName = LLVMRustwrappedIrGetName(Ir); - BeforePassCallback(LlvmSelfProfiler, PassName.c_str(), IrName.c_str()); - }); +#endif + std::string PassName = Pass.str(); + std::string IrName = LLVMRustwrappedIrGetName(Ir); + BeforePassCallback(LlvmSelfProfiler, PassName.c_str(), IrName.c_str()); + }); +#if LLVM_VERSION_GE(24, 0) + PIC.registerAfterAnalysisCallback([LlvmSelfProfiler, AfterPassCallback]( + StringRef Pass, llvm::IRUnitRef Ir) { +#else PIC.registerAfterAnalysisCallback( [LlvmSelfProfiler, AfterPassCallback](StringRef Pass, llvm::Any Ir) { - AfterPassCallback(LlvmSelfProfiler); - }); +#endif + AfterPassCallback(LlvmSelfProfiler); + }); } enum class LLVMRustOptStage { diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index 2f4e5606cd555..ec7495f95ac3a 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -3,11 +3,11 @@ rustc::default_hash_types, reason = "we like performance but can't use `rustc_data_structures`" )] +#![cfg_attr(bootstrap, feature(never_type))] #![deny( rustc::potential_query_instability, reason = "macros shall produce deterministic output/errors" )] -#![feature(never_type)] #![feature(proc_macro_diagnostic)] #![feature(proc_macro_tracked_env)] // tidy-alphabetical-end diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 306e344c23095..dd963fc8773c7 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -1,11 +1,11 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(never_type))] #![feature(error_iter)] #![feature(file_buffered)] #![feature(gen_blocks)] #![feature(macro_metavar_expr)] #![feature(min_specialization)] -#![feature(never_type)] #![feature(option_into_flat_iter)] #![feature(proc_macro_internals)] #![feature(trusted_len)] diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 60fb7fb53a533..993cb6e7769dd 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -27,6 +27,7 @@ // tidy-alphabetical-start #![allow(internal_features)] #![allow(rustc::direct_use_of_rustc_type_ir)] +#![cfg_attr(bootstrap, feature(never_type))] #![cfg_attr(doc, feature(intra_doc_pointers))] #![feature(allocator_api)] #![feature(associated_type_defaults)] @@ -44,7 +45,6 @@ #![feature(gen_blocks)] #![feature(min_specialization)] #![feature(negative_impls)] -#![feature(never_type)] #![feature(option_into_flat_iter)] #![feature(ptr_alignment_type)] #![feature(range_bounds_is_empty)] diff --git a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs index 42485a17f1011..9261986137d9d 100644 --- a/compiler/rustc_middle/src/ty/inhabitedness/mod.rs +++ b/compiler/rustc_middle/src/ty/inhabitedness/mod.rs @@ -5,7 +5,7 @@ //! //! # Example //! ```rust -//! #![feature(never_type)] +#![cfg_attr(bootstrap, doc = "#![feature(never_type)]")] //! mod a { //! pub mod b { //! pub struct SecretlyUninhabited { @@ -154,7 +154,7 @@ impl<'tcx> Ty<'tcx> { /// /// # Example /// ``` - /// #![feature(never_type)] + #[cfg_attr(bootstrap, doc = "#![feature(never_type)]")] /// # fn main() {} /// enum Void {} /// mod a { diff --git a/compiler/rustc_mir_dataflow/src/lib.rs b/compiler/rustc_mir_dataflow/src/lib.rs index 56351e817efcd..c0929bef38465 100644 --- a/compiler/rustc_mir_dataflow/src/lib.rs +++ b/compiler/rustc_mir_dataflow/src/lib.rs @@ -1,9 +1,9 @@ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(never_type))] #![feature(associated_type_defaults)] #![feature(deref_patterns)] #![feature(exact_size_is_empty)] #![feature(file_buffered)] -#![feature(never_type)] #![feature(try_blocks)] // tidy-alphabetical-end diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs index b9f9fb773c126..1d8617812937f 100644 --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs @@ -365,8 +365,9 @@ where } FetchEligibleAssocItemResponse::Err(guar) => return error_response(ecx, guar), FetchEligibleAssocItemResponse::NotFoundBecauseErased => { - ecx.opaque_accesses.rerun_always(RerunReason::FetchEligibleAssocItem)?; - return Err(NoSolution.into()); + match ecx + .opaque_accesses + .rerun_always(RerunReason::FetchEligibleAssocItem)? {} } }; diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index ccd3856fc962b..14cb3acad68e0 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -257,8 +257,7 @@ where { debug_assert!(is_rigid == ty::IsRigid::Yes); if ecx.opaque_accesses.might_rerun() { - ecx.opaque_accesses.rerun_always(RerunReason::AutoTraitLeakage)?; - return Err(NoSolution.into()); + match ecx.opaque_accesses.rerun_always(RerunReason::AutoTraitLeakage)? {} } for item_bound in cx.item_self_bounds(def_id.into()).skip_binder() { diff --git a/compiler/rustc_pattern_analysis/src/constructor.rs b/compiler/rustc_pattern_analysis/src/constructor.rs index 6f07e922ceef4..2159a8533508f 100644 --- a/compiler/rustc_pattern_analysis/src/constructor.rs +++ b/compiler/rustc_pattern_analysis/src/constructor.rs @@ -94,7 +94,6 @@ //! constructors of a type. For example, all the following is ok: //! //! ```rust,ignore(example) -//! # #![feature(never_type)] //! # #![feature(exhaustive_patterns)] //! fn foo(x: Option) { //! match x { @@ -114,8 +113,8 @@ //! Moreover, take the following: //! //! ```rust -//! # #![feature(never_type)] //! # #![feature(exhaustive_patterns)] +#![cfg_attr(feature = "rustc", cfg_attr(bootstrap, doc = "#![feature(never_type)]"))] //! # let x = None::; //! match x { //! None => {} diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 0e99db1b95cc1..16a7d1d77301c 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -3957,8 +3957,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { /// A never pattern by definition indicates an unreachable case. For example, matching on /// `Result` could look like: /// ```rust - /// # #![feature(never_type)] /// # #![feature(never_patterns)] + #[cfg_attr(bootstrap, doc = "#![feature(never_type)]")] /// # fn bar(_x: u32) {} /// let foo: Result = Ok(0); /// match foo { @@ -4023,8 +4023,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { /// A never pattern by definition indicates an unreachable case. For example, destructuring a /// `Result` could look like: /// ```rust - /// # #![feature(never_type)] /// # #![feature(never_patterns)] + #[cfg_attr(bootstrap, doc = "#![feature(never_type)]")] /// # fn foo() -> Result { Ok(true) } /// let (Ok(x) | Err(&!)) = foo(); /// # let _ = x; diff --git a/compiler/rustc_serialize/src/lib.rs b/compiler/rustc_serialize/src/lib.rs index 8b383cc3cbc04..39333ab00b57f 100644 --- a/compiler/rustc_serialize/src/lib.rs +++ b/compiler/rustc_serialize/src/lib.rs @@ -3,10 +3,10 @@ // tidy-alphabetical-start #![allow(internal_features)] #![allow(rustc::internal)] +#![cfg_attr(bootstrap, feature(never_type))] #![doc(test(attr(allow(unused_variables), deny(warnings), allow(internal_features))))] #![feature(core_intrinsics)] #![feature(min_specialization)] -#![feature(never_type)] #![feature(nonzero_internals)] #![feature(sized_hierarchy)] // tidy-alphabetical-end diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 44fa3ea59ac50..bbaf683f4288a 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -11,13 +11,13 @@ //! This API is completely unstable and subject to change. // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(never_type))] #![feature(associated_type_defaults)] #![feature(default_field_values)] #![feature(deref_patterns)] #![feature(hash_set_entry)] #![feature(iter_intersperse)] #![feature(iterator_try_reduce)] -#![feature(never_type)] #![feature(option_into_flat_iter)] #![feature(try_blocks)] #![feature(unwrap_infallible)] diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index 0c031d978d6ac..b49836dd0b8ea 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -1,6 +1,6 @@ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(never_type))] #![cfg_attr(test, feature(test))] -#![feature(never_type)] #![feature(option_into_flat_iter)] // tidy-alphabetical-end diff --git a/compiler/rustc_ty_utils/src/lib.rs b/compiler/rustc_ty_utils/src/lib.rs index 6eaf040f45f90..ba37f7f72691a 100644 --- a/compiler/rustc_ty_utils/src/lib.rs +++ b/compiler/rustc_ty_utils/src/lib.rs @@ -5,9 +5,9 @@ //! This API is completely unstable and subject to change. // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(never_type))] #![feature(deref_patterns)] #![feature(iterator_try_collect)] -#![feature(never_type)] #![feature(option_into_flat_iter)] // tidy-alphabetical-end diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 09b752491673e..2b0b1ade64087 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -208,7 +208,6 @@ #![feature(min_specialization)] #![feature(multiple_supertrait_upcastable)] #![feature(negative_impls)] -#![feature(never_type)] #![feature(optimize_attribute)] #![feature(rustc_attrs)] #![feature(slice_internals)] diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index 83b017b7625b9..eca8444812521 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs @@ -62,7 +62,6 @@ #![feature(const_trait_impl)] #![feature(dropck_eyepatch)] #![feature(min_specialization)] -#![feature(never_type)] #![feature(optimize_attribute)] #![feature(prelude_import)] #![feature(rustc_attrs)] diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index f124b8bceaded..126ab37bc0b71 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -732,7 +732,7 @@ mod impls { bool char } - #[unstable(feature = "never_type", issue = "35121")] + #[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_clone", issue = "142757")] const impl Clone for ! { #[inline] diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index 43128302dfef4..87f0638df183e 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -2355,7 +2355,7 @@ mod impls { ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } - #[unstable(feature = "never_type", issue = "35121")] + #[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl PartialEq for ! { #[inline] @@ -2364,11 +2364,11 @@ mod impls { } } - #[unstable(feature = "never_type", issue = "35121")] + #[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl Eq for ! {} - #[unstable(feature = "never_type", issue = "35121")] + #[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl PartialOrd for ! { #[inline] @@ -2377,7 +2377,7 @@ mod impls { } } - #[unstable(feature = "never_type", issue = "35121")] + #[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl Ord for ! { #[inline] diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 540b4aa0efdda..7e675815edb2e 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -34,9 +34,6 @@ #![stable(feature = "rust1", since = "1.0.0")] -use crate::error::Error; -use crate::fmt; -use crate::hash::{Hash, Hasher}; use crate::marker::PointeeSized; mod num; @@ -872,7 +869,7 @@ const impl AsMut for str { /// The error type for errors that can never happen. /// -/// Since this enum has no variant, a value of this type can never actually exist. +/// Since this is an alias to the never type, a value of this type can never actually exist. /// This can be useful for generic APIs that use [`Result`] and parameterize the error type, /// to indicate that the result is always [`Ok`]. /// @@ -889,101 +886,7 @@ const impl AsMut for str { /// } /// ``` /// -/// # Future compatibility -/// -/// This enum has the same role as [the `!` “never” type][never], -/// which is unstable in this version of Rust. -/// When `!` is stabilized, we plan to make `Infallible` a type alias to it: -/// -/// ```ignore (illustrates future std change) -/// pub type Infallible = !; -/// ``` -/// -/// … and eventually deprecate `Infallible`. -/// -/// However there is one case where `!` syntax can be used -/// before `!` is stabilized as a full-fledged type: in the position of a function’s return type. -/// Specifically, it is possible to have implementations for two different function pointer types: -/// -/// ``` -/// trait MyTrait {} -/// impl MyTrait for fn() -> ! {} -/// impl MyTrait for fn() -> std::convert::Infallible {} -/// ``` -/// -/// With `Infallible` being an enum, this code is valid. -/// However when `Infallible` becomes an alias for the never type, -/// the two `impl`s will start to overlap -/// and therefore will be disallowed by the language’s trait coherence rules. +/// Note: since CURRENT_RUSTC_VERSION this is an alias to `!`. If targeting that or future versions, +/// prefer using the never type directly. #[stable(feature = "convert_infallible", since = "1.34.0")] -#[derive(Copy)] -pub enum Infallible {} - -#[stable(feature = "convert_infallible", since = "1.34.0")] -#[rustc_const_unstable(feature = "const_clone", issue = "142757")] -const impl Clone for Infallible { - fn clone(&self) -> Infallible { - match *self {} - } -} - -#[stable(feature = "convert_infallible", since = "1.34.0")] -impl fmt::Debug for Infallible { - fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self {} - } -} - -#[stable(feature = "convert_infallible", since = "1.34.0")] -impl fmt::Display for Infallible { - fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { - match *self {} - } -} - -#[stable(feature = "str_parse_error2", since = "1.8.0")] -impl Error for Infallible {} - -#[stable(feature = "convert_infallible", since = "1.34.0")] -#[rustc_const_unstable(feature = "const_cmp", issue = "143800")] -const impl PartialEq for Infallible { - fn eq(&self, _: &Infallible) -> bool { - match *self {} - } -} - -#[stable(feature = "convert_infallible", since = "1.34.0")] -#[rustc_const_unstable(feature = "const_cmp", issue = "143800")] -const impl Eq for Infallible {} - -#[stable(feature = "convert_infallible", since = "1.34.0")] -#[rustc_const_unstable(feature = "const_cmp", issue = "143800")] -const impl PartialOrd for Infallible { - fn partial_cmp(&self, _other: &Self) -> Option { - match *self {} - } -} - -#[stable(feature = "convert_infallible", since = "1.34.0")] -#[rustc_const_unstable(feature = "const_cmp", issue = "143800")] -const impl Ord for Infallible { - fn cmp(&self, _other: &Self) -> crate::cmp::Ordering { - match *self {} - } -} - -#[stable(feature = "convert_infallible", since = "1.34.0")] -#[rustc_const_unstable(feature = "const_convert", issue = "143773")] -const impl From for Infallible { - #[inline] - fn from(x: !) -> Self { - x - } -} - -#[stable(feature = "convert_infallible_hash", since = "1.44.0")] -impl Hash for Infallible { - fn hash(&self, _: &mut H) { - match *self {} - } -} +pub type Infallible = !; diff --git a/library/core/src/error.rs b/library/core/src/error.rs index 0f01c09c8d91c..7386c52849eab 100644 --- a/library/core/src/error.rs +++ b/library/core/src/error.rs @@ -268,7 +268,7 @@ mod private { pub struct Internal; } -#[unstable(feature = "never_type", issue = "35121")] +#[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] impl Error for ! {} // Copied from `any.rs`. diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 6a4c58afc16f3..7a3d874f3b6f4 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -2896,7 +2896,7 @@ macro_rules! fmt_refs { fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp } -#[unstable(feature = "never_type", issue = "35121")] +#[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] impl Debug for ! { #[inline] fn fmt(&self, _: &mut Formatter<'_>) -> Result { @@ -2904,7 +2904,7 @@ impl Debug for ! { } } -#[unstable(feature = "never_type", issue = "35121")] +#[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] impl Display for ! { #[inline] fn fmt(&self, _: &mut Formatter<'_>) -> Result { diff --git a/library/core/src/keyword_docs.rs b/library/core/src/keyword_docs.rs index 3d914556fc65c..38f48d29ff272 100644 --- a/library/core/src/keyword_docs.rs +++ b/library/core/src/keyword_docs.rs @@ -2219,7 +2219,6 @@ const _: () = (); /// It is also possible to have `unsafe fn` in a regular safe `trait`: /// /// ```rust -/// # #![feature(never_type)] /// #![deny(unsafe_op_in_unsafe_fn)] /// /// trait Indexable { diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index f026434acbbc1..89ae9179f4e25 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -145,7 +145,6 @@ #![feature(multiple_supertrait_upcastable)] #![feature(must_not_suspend)] #![feature(negative_impls)] -#![feature(never_type)] #![feature(no_core)] #![feature(optimize_attribute)] #![feature(pattern_types)] diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index c83972d6eae58..e499955df9479 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -480,7 +480,7 @@ marker_impls! { } -#[unstable(feature = "never_type", issue = "35121")] +#[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] impl Copy for ! {} /// Shared references can be copied, but mutable references *cannot*! diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 63d17f2832493..26390e5071c53 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -1427,7 +1427,6 @@ pub const fn discriminant(v: &T) -> Discriminant { /// # Examples /// /// ``` -/// # #![feature(never_type)] /// # #![feature(variant_count)] /// /// use std::mem; diff --git a/library/core/src/num/error.rs b/library/core/src/num/error.rs index ccf50a2c81a1b..d102c456f3b4a 100644 --- a/library/core/src/num/error.rs +++ b/library/core/src/num/error.rs @@ -1,6 +1,5 @@ //! Error types for conversion to integral types. -use crate::convert::Infallible; use crate::error::Error; use crate::fmt; @@ -35,23 +34,12 @@ impl fmt::Display for TryFromIntError { #[stable(feature = "try_from", since = "1.34.0")] impl Error for TryFromIntError {} -#[stable(feature = "try_from", since = "1.34.0")] -#[rustc_const_unstable(feature = "const_convert", issue = "143773")] -const impl From for TryFromIntError { - fn from(x: Infallible) -> TryFromIntError { - match x {} - } -} - -#[unstable(feature = "never_type", issue = "35121")] +#[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl From for TryFromIntError { #[inline] fn from(never: !) -> TryFromIntError { - // Match rather than coerce to make sure that code like - // `From for TryFromIntError` above will keep working - // when `Infallible` becomes an alias to `!`. - match never {} + never } } diff --git a/library/core/src/ops/try_trait.rs b/library/core/src/ops/try_trait.rs index f7486cddaae5d..614b104d9c2a2 100644 --- a/library/core/src/ops/try_trait.rs +++ b/library/core/src/ops/try_trait.rs @@ -229,7 +229,7 @@ pub const trait Try: [const] FromResidual { all( from_desugaring = "QuestionMark", Self = "core::result::Result", - R = "core::option::Option", + R = "core::option::Option", ), message = "the `?` operator can only be used on `Result`s, not `Option`s, \ in {ItemContext} that returns `Result`", diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs index 3e1596689e9d1..04865cccde94e 100644 --- a/library/core/src/primitive_docs.rs +++ b/library/core/src/primitive_docs.rs @@ -73,7 +73,6 @@ const _: () = (); /// write: /// /// ``` -/// #![feature(never_type)] /// # fn foo() -> u32 { /// let x: ! = { /// return 123 @@ -230,7 +229,6 @@ const _: () = (); /// for example: /// /// ``` -/// #![feature(never_type)] /// # use std::fmt; /// # trait Debug { /// # fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result; @@ -311,7 +309,7 @@ const _: () = (); /// [`()`]: prim@unit /// [2024 edition]: /// -#[unstable(feature = "never_type", issue = "35121")] +#[stable(feature = "never_type", since = "CURRENT_RUSTC_VERSION")] const _: () = (); // Required to make auto trait impls render. diff --git a/library/core/src/result.rs b/library/core/src/result.rs index b257cd8c82a0e..c38008cf73d2b 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -1343,7 +1343,6 @@ impl Result { /// # Examples /// /// ``` - /// # #![feature(never_type)] /// # #![feature(unwrap_infallible)] /// /// fn only_good_news() -> Result { @@ -1380,7 +1379,6 @@ impl Result { /// # Examples /// /// ``` - /// # #![feature(never_type)] /// # #![feature(unwrap_infallible)] /// /// fn only_bad_news() -> Result { diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index c653fdcdf4927..de90ce42c1529 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -88,7 +88,6 @@ #![feature(maybe_uninit_fill)] #![feature(maybe_uninit_uninit_array_transpose)] #![feature(min_specialization)] -#![feature(never_type)] #![feature(next_index)] #![feature(non_exhaustive_omitted_patterns_lint)] #![feature(num_internals)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 980ec4416f04a..cc652cb743353 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -302,7 +302,6 @@ #![feature(must_not_suspend)] #![feature(needs_panic_runtime)] #![feature(negative_impls)] -#![feature(never_type)] #![feature(optimize_attribute)] #![feature(prelude_import)] #![feature(rustc_attrs)] diff --git a/library/std/src/process.rs b/library/std/src/process.rs index a4c461737b620..6414a235698b8 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -162,7 +162,6 @@ ))] mod tests; -use crate::convert::Infallible; use crate::ffi::OsStr; use crate::io::prelude::*; use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; @@ -2700,13 +2699,6 @@ impl Termination for ! { } } -#[stable(feature = "termination_trait_lib", since = "1.61.0")] -impl Termination for Infallible { - fn report(self) -> ExitCode { - match self {} - } -} - #[stable(feature = "termination_trait_lib", since = "1.61.0")] impl Termination for ExitCode { #[inline] diff --git a/library/std/src/sys/path/windows/tests.rs b/library/std/src/sys/path/windows/tests.rs index 830f48d7bfc94..4ca47fc10c2e1 100644 --- a/library/std/src/sys/path/windows/tests.rs +++ b/library/std/src/sys/path/windows/tests.rs @@ -83,6 +83,9 @@ fn verbatim() { // Make sure opening a drive will work. check("Z:", "Z:"); + // Verbatim drive paths begin with `LETTER:\`. `/` is just a regular character here + check(r"\\?\C:/path\somewhere", r"\\?\C:/path\somewhere"); + // A path that contains null is not a valid path. assert!(maybe_verbatim(Path::new("\0")).is_err()); } @@ -93,9 +96,23 @@ fn parse_prefix(path: &str) -> Option> { #[test] fn test_parse_prefix_verbatim() { - let prefix = Some(Prefix::VerbatimDisk(b'C')); - assert_eq!(prefix, parse_prefix(r"\\?\C:/windows/system32/notepad.exe")); - assert_eq!(prefix, parse_prefix(r"\\?\C:\windows\system32\notepad.exe")); + assert_eq!( + parse_prefix(r"\\?\C:\windows\system32\notepad.exe"), + Some(Prefix::VerbatimDisk(b'C')), + ); +} + +#[test] +fn test_verbatim_disk_issue_161651() { + use crate::path::Path; + + // This is not a `VerbatimDisk` path, because `/` is not a separator in verbatim paths! + assert_eq!( + parse_prefix(r"\\?\C:/windows\system32"), + Some(Prefix::Verbatim(OsStr::new("C:/windows"))), + ); + + assert_ne!(Path::new(r"\\?\C:/foo"), Path::new(r"\\?\C:\foo")); } #[test] diff --git a/library/std/src/sys/path/windows_prefix.rs b/library/std/src/sys/path/windows_prefix.rs index b9dfe754485ab..5413269e9edee 100644 --- a/library/std/src/sys/path/windows_prefix.rs +++ b/library/std/src/sys/path/windows_prefix.rs @@ -142,7 +142,7 @@ fn parse_drive(path: &OsStr) -> Option { // Parses a drive prefix exactly, e.g. "C:" fn parse_drive_exact(path: &OsStr) -> Option { // only parse two bytes: the drive letter and the drive separator - if path.as_encoded_bytes().get(2).map(|&x| is_sep_byte(x)).unwrap_or(true) { + if path.as_encoded_bytes().get(2).map(|&x| is_verbatim_sep(x)).unwrap_or(true) { parse_drive(path) } else { None diff --git a/library/std/tests/path.rs b/library/std/tests/path.rs index 8997b8ad192dc..4d42437fbd871 100644 --- a/library/std/tests/path.rs +++ b/library/std/tests/path.rs @@ -989,14 +989,14 @@ pub fn test_decompositions_windows() { ); t!("\\\\?\\C:/foo/bar", - iter: ["\\\\?\\C:", "\\", "foo/bar"], + iter: ["\\\\?\\C:/foo/bar"], has_root: true, is_absolute: true, - parent: Some("\\\\?\\C:/"), - file_name: Some("foo/bar"), - file_stem: Some("foo/bar"), + parent: None, + file_name: None, + file_stem: None, extension: None, - file_prefix: Some("foo/bar") + file_prefix: None ); t!("\\\\.\\foo\\bar", diff --git a/src/doc/rustdoc/src/lints.md b/src/doc/rustdoc/src/lints.md index 9dee33ef6eb85..abd436bb5561c 100644 --- a/src/doc/rustdoc/src/lints.md +++ b/src/doc/rustdoc/src/lints.md @@ -456,3 +456,31 @@ note: the lint level is defined here | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: Remove explicit link instead ``` + +## `invalid_markdown_table` + +This lint is **warn-by-default**. It detects unescaped pipes (`|`) in table rows which +lead to some row cells being ignored. For example: + +```rust +//! | col1 | +//! | ---- | +//! | `code_with(|arg| arg)` | +``` + +Which will give: + +```text +error: table row has too many columns + --> $DIR/foo.rs:5:18 + | +5 | //! | `code_with(|arg| arg)` | + | ^ help: any content after this column divider is discarded + | + = help: to escape `|` characters in tables, add a `\` before them like `\|` +note: the lint level is defined here + --> $DIR/foo.rs:1:9 + | +1 | #![deny(rustdoc::invalid_markdown_table)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +``` diff --git a/src/librustdoc/lint.rs b/src/librustdoc/lint.rs index 1c3d1c421b545..5d8675aecb86a 100644 --- a/src/librustdoc/lint.rs +++ b/src/librustdoc/lint.rs @@ -209,6 +209,17 @@ declare_rustdoc_lint! { "detects unused footnote definitions" } +declare_rustdoc_lint! { + /// This lint is **warn-by-default**. It detects unescaped pipes in table rows which + /// lead to some row cells being ignored. This is a `rustdoc` only lint, see the + /// documentation in the [rustdoc book]. + /// + /// [rustdoc book]: ../../../rustdoc/lints.html#invalid_markdown_table + INVALID_MARKDOWN_TABLE, + Warn, + "detects unescaped pipe in table rows in doc comments" +} + pub(crate) static RUSTDOC_LINTS: Lazy> = Lazy::new(|| { vec![ BROKEN_INTRA_DOC_LINKS, @@ -224,6 +235,7 @@ pub(crate) static RUSTDOC_LINTS: Lazy> = Lazy::new(|| { REDUNDANT_EXPLICIT_LINKS, BROKEN_FOOTNOTE, UNUSED_FOOTNOTE_DEFINITION, + INVALID_MARKDOWN_TABLE, ] }); diff --git a/src/librustdoc/passes/lint.rs b/src/librustdoc/passes/lint.rs index bb952b32393cf..a417bbaab4ed5 100644 --- a/src/librustdoc/passes/lint.rs +++ b/src/librustdoc/passes/lint.rs @@ -5,6 +5,7 @@ mod bare_urls; mod check_code_block_syntax; mod footnotes; mod html_tags; +mod invalid_markdown_table; mod redundant_explicit_links; mod unescaped_backticks; @@ -35,6 +36,7 @@ impl DocVisitor<'_> for Linter<'_, '_> { if !dox.is_empty() { let may_have_link = dox.contains(&[':', '['][..]); let may_have_block_comment_or_html = dox.contains(['<', '>']); + let may_have_table = dox.contains(&['|'][..]); // ~~~rust // // This is a real, supported commonmark syntax for block code // ~~~ @@ -51,6 +53,9 @@ impl DocVisitor<'_> for Linter<'_, '_> { if may_have_block_comment_or_html { html_tags::visit_item(self.cx, item, hir_id, &dox); } + if may_have_table { + invalid_markdown_table::visit_item(self.cx, item, hir_id, &dox); + } } self.visit_item_recur(item) diff --git a/src/librustdoc/passes/lint/invalid_markdown_table.rs b/src/librustdoc/passes/lint/invalid_markdown_table.rs new file mode 100644 index 0000000000000..dd44f2ec92445 --- /dev/null +++ b/src/librustdoc/passes/lint/invalid_markdown_table.rs @@ -0,0 +1,120 @@ +//! Detects table rows where some content seems to have been discarded because there are too many +//! pipe characters. + +use std::ops::Range; + +use rustc_hir::HirId; +use rustc_macros::Diagnostic; +use rustc_resolve::rustdoc::pulldown_cmark::{Event, Parser, Tag, TagEnd}; +use rustc_resolve::rustdoc::source_span_for_markdown_range; + +use crate::clean::*; +use crate::core::DocContext; +use crate::html::markdown::main_body_opts; + +#[derive(Diagnostic)] +#[diag("table row has too many columns")] +#[help(r"to escape `|` characters in tables, add a `\` before them like `\|`")] +struct UnescapedPipeInTableCell { + #[primary_span] + #[label("any content after this column divider is discarded")] + span: rustc_span::Span, +} + +#[derive(Diagnostic)] +#[diag("unused content after last table cell")] +struct ContentAfterLastPipe { + #[primary_span] + #[label("this content is discarded")] + span: rustc_span::Span, +} + +pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item, hir_id: HirId, dox: &str) { + let mut p = Parser::new_ext(dox, main_body_opts()).into_offset_iter(); + + while let Some((event, _range)) = p.next() { + if Event::Start(Tag::TableRow) == event { + let mut prev_range = None; + while let Some((event, range)) = p.next() { + match event { + Event::End(TagEnd::TableCell) => { + prev_range = Some(range); + } + Event::End(TagEnd::TableRow) => { + if let Some(prev_range) = &prev_range + // So here what is happening: when `pulldown-cmark` is parsing a table + // and a table row has too many cells, it doesn't emit events for the + // extra cells. So the only way for us to know these extra cells exist + // is to compare the row's span with the last emitted cell event's span. + // If the span ends don't match, then there are extra cells. + && prev_range.end + 1 < range.end + { + // Something seems wrong, the range diff doesn't match, some content + // was left out. + let mut after_last_cell_range = + Range { start: prev_range.end + 1, end: range.end }; + if dox[after_last_cell_range.clone()].trim().is_empty() { + // Seems all good so let's ignore it and continue;. + continue; + } + // Check if any pipes appear after the end of the row. + let mut iter = dox[after_last_cell_range.clone()].bytes().peekable(); + let mut found_divider = false; + while let Some(c) = iter.next() { + // the sequence `\\|` still escapes the pipe because GFM + // processes block structures like tables in its own pass + if c == b'\\' && iter.peek() == Some(&b'|') { + iter.next(); + } else if c == b'|' { + found_divider = true; + break; + } + } + if found_divider { + // Seems like a pipe was not escaped as it should have been. + let last_cell_separator = + Range { start: prev_range.end, end: prev_range.end + 1 }; + + if let Some((span, _)) = source_span_for_markdown_range( + cx.tcx, + dox, + &last_cell_separator, + &item.attrs.doc_strings, + ) { + cx.tcx.emit_node_span_lint( + crate::lint::INVALID_MARKDOWN_TABLE, + hir_id, + span, + UnescapedPipeInTableCell { span }, + ); + } + } else { + // An unclosed cell maybe? There is content after the last cell so + // let's lint about it. + let content = &dox[after_last_cell_range.clone()]; + after_last_cell_range.end -= + content.len() - content.trim_end().len(); + + if let Some((span, _)) = source_span_for_markdown_range( + cx.tcx, + dox, + &after_last_cell_range, + &item.attrs.doc_strings, + ) { + cx.tcx.emit_node_span_lint( + crate::lint::INVALID_MARKDOWN_TABLE, + hir_id, + span, + ContentAfterLastPipe { span }, + ); + } + } + } + } + Event::End(TagEnd::Table) => break, + _ => {} + } + } + } + } +} diff --git a/src/tools/clippy/clippy_lints/src/empty_enums.rs b/src/tools/clippy/clippy_lints/src/empty_enums.rs index 8c113e6febc92..0ee29584d1a5e 100644 --- a/src/tools/clippy/clippy_lints/src/empty_enums.rs +++ b/src/tools/clippy/clippy_lints/src/empty_enums.rs @@ -8,9 +8,6 @@ declare_clippy_lint! { /// Checks for `enum`s with no variants, which therefore are uninhabited types /// (cannot be instantiated). /// - /// As of this writing, the `never_type` is still a nightly-only experimental API. - /// Therefore, this lint is only triggered if `#![feature(never_type)]` is enabled. - /// /// ### Why is this bad? /// * If you only want a type which can’t be instantiated, you should use [`!`] /// (the primitive type "never"), because [`!`] has more extensive compiler support @@ -35,8 +32,6 @@ declare_clippy_lint! { /// /// Use instead: /// ```no_run - /// #![feature(never_type)] - /// /// /// Use the `!` type directly... /// type CannotExist = !; /// @@ -60,8 +55,6 @@ impl LateLintPass<'_> for EmptyEnums { fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) { if let ItemKind::Enum(.., def) = item.kind && def.variants.is_empty() - // Only suggest the `never_type` if the feature is enabled - && cx.tcx.features().never_type() && !span_contains_cfg(cx, item.span) { span_lint_and_help( diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index f7f5341772623..8df0aad4024ca 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -7,7 +7,7 @@ #![feature(iter_partition_in_place)] #![feature(macro_metavar_expr)] #![feature(macro_metavar_expr_concat)] -#![feature(never_type)] +#![cfg_attr(bootstrap, feature(never_type))] #![feature(rustc_private)] #![feature(stmt_expr_attributes)] #![feature(unwrap_infallible)] diff --git a/src/tools/clippy/clippy_lints/src/zero_repeat_side_effects.rs b/src/tools/clippy/clippy_lints/src/zero_repeat_side_effects.rs index 1c5e26a590613..24f37ec67528b 100644 --- a/src/tools/clippy/clippy_lints/src/zero_repeat_side_effects.rs +++ b/src/tools/clippy/clippy_lints/src/zero_repeat_side_effects.rs @@ -73,7 +73,6 @@ fn inner_check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, inner_expr: &'_ Expr<'_ // check if expr is a call or has a call inside it if inner_expr.can_have_side_effects() { let parent_hir_node = cx.tcx.parent_hir_node(expr.hir_id); - let inner_expr_ty = cx.typeck_results().expr_ty(inner_expr); let return_type = cx.typeck_results().expr_ty(expr); let inner_expr = snippet(cx, inner_expr.span.source_callsite(), ".."); @@ -118,9 +117,7 @@ fn inner_check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, inner_expr: &'_ Expr<'_ span, "expression with side effects as the initial value in a zero-sized array initializer", |diag| { - if (!inner_expr_ty.is_never() || cx.tcx.features().never_type()) - && return_type.is_suggestable(cx.tcx, true) - { + if return_type.is_suggestable(cx.tcx, true) { diag.span_suggestion_verbose( span, "consider performing the side effect separately", diff --git a/src/tools/clippy/tests/ui/double_must_use.fixed b/src/tools/clippy/tests/ui/double_must_use.fixed index 81c62b4726f57..121d8c631adf5 100644 --- a/src/tools/clippy/tests/ui/double_must_use.fixed +++ b/src/tools/clippy/tests/ui/double_must_use.fixed @@ -1,6 +1,5 @@ #![warn(clippy::double_must_use)] #![expect(clippy::result_unit_err)] -#![feature(never_type)] use std::ops::ControlFlow; diff --git a/src/tools/clippy/tests/ui/double_must_use.rs b/src/tools/clippy/tests/ui/double_must_use.rs index e3c01b6f57a8b..f26161483b412 100644 --- a/src/tools/clippy/tests/ui/double_must_use.rs +++ b/src/tools/clippy/tests/ui/double_must_use.rs @@ -1,6 +1,5 @@ #![warn(clippy::double_must_use)] #![expect(clippy::result_unit_err)] -#![feature(never_type)] use std::ops::ControlFlow; diff --git a/src/tools/clippy/tests/ui/double_must_use.stderr b/src/tools/clippy/tests/ui/double_must_use.stderr index edb56104e6f24..a7a8c9f2dbb46 100644 --- a/src/tools/clippy/tests/ui/double_must_use.stderr +++ b/src/tools/clippy/tests/ui/double_must_use.stderr @@ -1,5 +1,5 @@ error: this function has a `#[must_use]` attribute with no message, but returns a type already considered as `#[must_use]` - --> tests/ui/double_must_use.rs:8:1 + --> tests/ui/double_must_use.rs:7:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -11,7 +11,7 @@ LL | pub fn must_use_result() -> Result<(), ()> { = help: to override `-D warnings` add `#[allow(clippy::double_must_use)]` error: this function has a `#[must_use]` attribute with no message, but returns a type already considered as `#[must_use]` - --> tests/ui/double_must_use.rs:15:1 + --> tests/ui/double_must_use.rs:14:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -19,14 +19,14 @@ LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the return type is `std::result::Result` in tuple element 0 - --> tests/ui/double_must_use.rs:15:28 + --> tests/ui/double_must_use.rs:14:28 | LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) { | ^^^^^^^^^^^^^^^^^^^^ = note: alternatively, you may add an explicit reason to the `must_use` attribute error: this function has a `#[must_use]` attribute with no message, but returns a type already considered as `#[must_use]` - --> tests/ui/double_must_use.rs:22:1 + --> tests/ui/double_must_use.rs:21:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -34,14 +34,14 @@ LL | pub fn must_use_array() -> [Result<(), ()>; 1] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the return type is array of `std::result::Result`s - --> tests/ui/double_must_use.rs:22:28 + --> tests/ui/double_must_use.rs:21:28 | LL | pub fn must_use_array() -> [Result<(), ()>; 1] { | ^^^^^^^^^^^^^^^^^^^ = note: alternatively, you may add an explicit reason to the `must_use` attribute error: this function has a `#[must_use]` attribute with no message, but returns a type already considered as `#[must_use]` - --> tests/ui/double_must_use.rs:40:1 + --> tests/ui/double_must_use.rs:39:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -49,14 +49,14 @@ LL | async fn async_must_use_result() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the return type is implementer of `std::future::Future` - --> tests/ui/double_must_use.rs:40:37 + --> tests/ui/double_must_use.rs:39:37 | LL | async fn async_must_use_result() -> Result<(), ()> { | ^^^^^^^^^^^^^^ = note: alternatively, you may add an explicit reason to the `must_use` attribute error: this function has a `#[must_use]` attribute with no message, but returns a type already considered as `#[must_use]` - --> tests/ui/double_must_use.rs:55:1 + --> tests/ui/double_must_use.rs:54:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -64,14 +64,14 @@ LL | pub fn must_use_result_with_uninhabited_2() -> Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the return type is `T` in a `Result` with an uninhabited error - --> tests/ui/double_must_use.rs:55:48 + --> tests/ui/double_must_use.rs:54:48 | LL | pub fn must_use_result_with_uninhabited_2() -> Result { | ^^^^^^^^^^^^ = note: alternatively, you may add an explicit reason to the `must_use` attribute error: this function has a `#[must_use]` attribute with no message, but returns a type already considered as `#[must_use]` - --> tests/ui/double_must_use.rs:66:1 + --> tests/ui/double_must_use.rs:65:1 | LL | #[must_use] | ----------- help: remove the attribute @@ -79,7 +79,7 @@ LL | pub fn must_use_controlflow_with_uninhabited_2() -> ControlFlow tests/ui/double_must_use.rs:66:53 + --> tests/ui/double_must_use.rs:65:53 | LL | pub fn must_use_controlflow_with_uninhabited_2() -> ControlFlow { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/double_must_use_unfixable.rs b/src/tools/clippy/tests/ui/double_must_use_unfixable.rs index 88c2502da9f74..677a42a7ece66 100644 --- a/src/tools/clippy/tests/ui/double_must_use_unfixable.rs +++ b/src/tools/clippy/tests/ui/double_must_use_unfixable.rs @@ -1,6 +1,5 @@ #![warn(clippy::double_must_use)] #![expect(clippy::result_unit_err)] -#![feature(never_type)] #[cfg_attr(all(), must_use, deprecated)] pub fn issue_12320() -> Result<(), ()> { diff --git a/src/tools/clippy/tests/ui/double_must_use_unfixable.stderr b/src/tools/clippy/tests/ui/double_must_use_unfixable.stderr index 5d9c02e5d6cea..aa7da6b10405e 100644 --- a/src/tools/clippy/tests/ui/double_must_use_unfixable.stderr +++ b/src/tools/clippy/tests/ui/double_must_use_unfixable.stderr @@ -1,11 +1,11 @@ error: this function has a `#[must_use]` attribute with no message, but returns a type already considered as `#[must_use]` - --> tests/ui/double_must_use_unfixable.rs:6:1 + --> tests/ui/double_must_use_unfixable.rs:5:1 | LL | pub fn issue_12320() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove `must_use` - --> tests/ui/double_must_use_unfixable.rs:5:19 + --> tests/ui/double_must_use_unfixable.rs:4:19 | LL | #[cfg_attr(all(), must_use, deprecated)] | ^^^^^^^^ @@ -14,13 +14,13 @@ LL | #[cfg_attr(all(), must_use, deprecated)] = help: to override `-D warnings` add `#[allow(clippy::double_must_use)]` error: this function has a `#[must_use]` attribute with no message, but returns a type already considered as `#[must_use]` - --> tests/ui/double_must_use_unfixable.rs:12:1 + --> tests/ui/double_must_use_unfixable.rs:11:1 | LL | pub fn issue_12320_2() -> Result<(), ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: remove `must_use` - --> tests/ui/double_must_use_unfixable.rs:11:31 + --> tests/ui/double_must_use_unfixable.rs:10:31 | LL | #[cfg_attr(all(), deprecated, must_use)] | ^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/drop_non_drop.stderr b/src/tools/clippy/tests/ui/drop_non_drop.stderr index 567a820990c60..252ba3915ed84 100644 --- a/src/tools/clippy/tests/ui/drop_non_drop.stderr +++ b/src/tools/clippy/tests/ui/drop_non_drop.stderr @@ -30,7 +30,7 @@ error: call to `std::mem::drop` with a value that does not implement `Drop`. Dro LL | drop(make_result_uninhabited_err(Foo)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: argument has type `std::result::Result` +note: argument has type `std::result::Result` --> tests/ui/drop_non_drop.rs:51:10 | LL | drop(make_result_uninhabited_err(Foo)); diff --git a/src/tools/clippy/tests/ui/empty_enums.rs b/src/tools/clippy/tests/ui/empty_enums.rs index 0deb0f57b0e4a..dc8549f52fdc8 100644 --- a/src/tools/clippy/tests/ui/empty_enums.rs +++ b/src/tools/clippy/tests/ui/empty_enums.rs @@ -1,6 +1,5 @@ #![warn(clippy::empty_enums)] // Enable never type to test empty enum lint -#![feature(never_type)] enum Empty {} //~^ empty_enums diff --git a/src/tools/clippy/tests/ui/empty_enums.stderr b/src/tools/clippy/tests/ui/empty_enums.stderr index 5aa2347b4ae08..231d68a21c258 100644 --- a/src/tools/clippy/tests/ui/empty_enums.stderr +++ b/src/tools/clippy/tests/ui/empty_enums.stderr @@ -1,5 +1,5 @@ error: enum with no variants - --> tests/ui/empty_enums.rs:5:1 + --> tests/ui/empty_enums.rs:4:1 | LL | enum Empty {} | ^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/empty_enums_without_never_type.rs b/src/tools/clippy/tests/ui/empty_enums_without_never_type.rs deleted file mode 100644 index 17ccac83ce98e..0000000000000 --- a/src/tools/clippy/tests/ui/empty_enums_without_never_type.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ check-pass - -#![warn(clippy::empty_enums)] - -// `never_type` is not enabled; this test has no stderr file -enum Empty {} - -fn main() {} diff --git a/src/tools/clippy/tests/ui/infallible_destructuring_match.fixed b/src/tools/clippy/tests/ui/infallible_destructuring_match.fixed index 2af4c577278b2..c799d7cf4940b 100644 --- a/src/tools/clippy/tests/ui/infallible_destructuring_match.fixed +++ b/src/tools/clippy/tests/ui/infallible_destructuring_match.fixed @@ -1,4 +1,4 @@ -#![feature(exhaustive_patterns, never_type)] +#![feature(exhaustive_patterns)] #![expect(clippy::let_and_return, clippy::uninhabited_references)] enum SingleVariantEnum { diff --git a/src/tools/clippy/tests/ui/infallible_destructuring_match.rs b/src/tools/clippy/tests/ui/infallible_destructuring_match.rs index 87b36bb1babda..2e06df30484c8 100644 --- a/src/tools/clippy/tests/ui/infallible_destructuring_match.rs +++ b/src/tools/clippy/tests/ui/infallible_destructuring_match.rs @@ -1,4 +1,4 @@ -#![feature(exhaustive_patterns, never_type)] +#![feature(exhaustive_patterns)] #![expect(clippy::let_and_return, clippy::uninhabited_references)] enum SingleVariantEnum { diff --git a/src/tools/clippy/tests/ui/infallible_try_from.rs b/src/tools/clippy/tests/ui/infallible_try_from.rs index 6a1f12f824f55..6545a54980ae9 100644 --- a/src/tools/clippy/tests/ui/infallible_try_from.rs +++ b/src/tools/clippy/tests/ui/infallible_try_from.rs @@ -1,4 +1,3 @@ -#![feature(never_type)] #![warn(clippy::infallible_try_from)] use std::convert::Infallible; diff --git a/src/tools/clippy/tests/ui/infallible_try_from.stderr b/src/tools/clippy/tests/ui/infallible_try_from.stderr index d1e0d9e7d3bb7..d4774b2430e4a 100644 --- a/src/tools/clippy/tests/ui/infallible_try_from.stderr +++ b/src/tools/clippy/tests/ui/infallible_try_from.stderr @@ -1,5 +1,5 @@ error: infallible TryFrom impl; consider implementing From instead - --> tests/ui/infallible_try_from.rs:8:1 + --> tests/ui/infallible_try_from.rs:7:1 | LL | impl TryFrom for MyStruct { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -11,7 +11,7 @@ LL | type Error = !; = help: to override `-D warnings` add `#[allow(clippy::infallible_try_from)]` error: infallible TryFrom impl; consider implementing From instead - --> tests/ui/infallible_try_from.rs:16:1 + --> tests/ui/infallible_try_from.rs:15:1 | LL | impl TryFrom for MyStruct { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/must_use_candidates.fixed b/src/tools/clippy/tests/ui/must_use_candidates.fixed index 8aac045cad089..66d7fc5325abf 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.fixed +++ b/src/tools/clippy/tests/ui/must_use_candidates.fixed @@ -1,4 +1,3 @@ -#![feature(never_type)] #![warn(clippy::must_use_candidate)] use std::rc::Rc; use std::sync::Arc; diff --git a/src/tools/clippy/tests/ui/must_use_candidates.rs b/src/tools/clippy/tests/ui/must_use_candidates.rs index d0e2dbd3d62de..79edb4f2be19b 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.rs +++ b/src/tools/clippy/tests/ui/must_use_candidates.rs @@ -1,4 +1,3 @@ -#![feature(never_type)] #![warn(clippy::must_use_candidate)] use std::rc::Rc; use std::sync::Arc; diff --git a/src/tools/clippy/tests/ui/must_use_candidates.stderr b/src/tools/clippy/tests/ui/must_use_candidates.stderr index 9f6beaf19595d..d7ce0f91a3330 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.stderr +++ b/src/tools/clippy/tests/ui/must_use_candidates.stderr @@ -1,5 +1,5 @@ error: this function could have a `#[must_use]` attribute - --> tests/ui/must_use_candidates.rs:10:8 + --> tests/ui/must_use_candidates.rs:9:8 | LL | pub fn pure(i: u8) -> u8 { | ^^^^ @@ -13,7 +13,7 @@ LL | pub fn pure(i: u8) -> u8 { | error: this method could have a `#[must_use]` attribute - --> tests/ui/must_use_candidates.rs:16:12 + --> tests/ui/must_use_candidates.rs:15:12 | LL | pub fn inherent_pure(&self) -> u8 { | ^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL ~ pub fn inherent_pure(&self) -> u8 { | error: this function could have a `#[must_use]` attribute - --> tests/ui/must_use_candidates.rs:48:8 + --> tests/ui/must_use_candidates.rs:47:8 | LL | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool { | ^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool { | error: this function could have a `#[must_use]` attribute - --> tests/ui/must_use_candidates.rs:61:8 + --> tests/ui/must_use_candidates.rs:60:8 | LL | pub fn rcd(_x: Rc) -> bool { | ^^^ @@ -49,7 +49,7 @@ LL | pub fn rcd(_x: Rc) -> bool { | error: this function could have a `#[must_use]` attribute - --> tests/ui/must_use_candidates.rs:70:8 + --> tests/ui/must_use_candidates.rs:69:8 | LL | pub fn arcd(_x: Arc) -> bool { | ^^^^ @@ -61,7 +61,7 @@ LL | pub fn arcd(_x: Arc) -> bool { | error: this function could have a `#[must_use]` attribute - --> tests/ui/must_use_candidates.rs:102:8 + --> tests/ui/must_use_candidates.rs:101:8 | LL | pub fn result_uninhabited_1() -> Result { | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/redundant_else.fixed b/src/tools/clippy/tests/ui/redundant_else.fixed index 328fb8d7a900f..d0e8ffc8de188 100644 --- a/src/tools/clippy/tests/ui/redundant_else.fixed +++ b/src/tools/clippy/tests/ui/redundant_else.fixed @@ -1,6 +1,5 @@ //@aux-build:proc_macros.rs -#![feature(never_type)] #![warn(clippy::redundant_else)] #![expect(clippy::unnecessary_operation)] diff --git a/src/tools/clippy/tests/ui/redundant_else.rs b/src/tools/clippy/tests/ui/redundant_else.rs index 478b6277dbfc3..dd9c8348e690e 100644 --- a/src/tools/clippy/tests/ui/redundant_else.rs +++ b/src/tools/clippy/tests/ui/redundant_else.rs @@ -1,6 +1,5 @@ //@aux-build:proc_macros.rs -#![feature(never_type)] #![warn(clippy::redundant_else)] #![expect(clippy::unnecessary_operation)] diff --git a/src/tools/clippy/tests/ui/redundant_else.stderr b/src/tools/clippy/tests/ui/redundant_else.stderr index 01112d5e0ea15..31a8f45599ec0 100644 --- a/src/tools/clippy/tests/ui/redundant_else.stderr +++ b/src/tools/clippy/tests/ui/redundant_else.stderr @@ -1,5 +1,5 @@ error: redundant else block - --> tests/ui/redundant_else.rs:19:10 + --> tests/ui/redundant_else.rs:18:10 | LL | } else { | __________^ @@ -18,7 +18,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:27:14 + --> tests/ui/redundant_else.rs:26:14 | LL | } else { | ______________^ @@ -35,7 +35,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:36:14 + --> tests/ui/redundant_else.rs:35:14 | LL | } else { | ______________^ @@ -52,7 +52,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:47:10 + --> tests/ui/redundant_else.rs:46:10 | LL | } else { | __________^ @@ -69,7 +69,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:55:14 + --> tests/ui/redundant_else.rs:54:14 | LL | } else { | ______________^ @@ -86,7 +86,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:61:14 + --> tests/ui/redundant_else.rs:60:14 | LL | } else { | ______________^ @@ -103,7 +103,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:72:10 + --> tests/ui/redundant_else.rs:71:10 | LL | } else { | __________^ @@ -120,7 +120,7 @@ LL ~ black_box(()); | error: redundant else block - --> tests/ui/redundant_else.rs:79:10 + --> tests/ui/redundant_else.rs:78:10 | LL | } else { | __________^ @@ -137,7 +137,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:86:10 + --> tests/ui/redundant_else.rs:85:10 | LL | } else { | __________^ @@ -154,7 +154,7 @@ LL ~ black_box(0i32); | error: redundant else block - --> tests/ui/redundant_else.rs:96:10 + --> tests/ui/redundant_else.rs:95:10 | LL | } else { | __________^ @@ -171,7 +171,7 @@ LL + black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:103:10 + --> tests/ui/redundant_else.rs:102:10 | LL | } else { | __________^ @@ -190,7 +190,7 @@ LL + black_box(()); | error: redundant else block - --> tests/ui/redundant_else.rs:111:10 + --> tests/ui/redundant_else.rs:110:10 | LL | } else { | __________^ @@ -207,7 +207,7 @@ LL + { black_box(()) } | error: redundant else block - --> tests/ui/redundant_else.rs:118:10 + --> tests/ui/redundant_else.rs:117:10 | LL | } else { | __________^ @@ -228,7 +228,7 @@ LL + } | error: redundant else block - --> tests/ui/redundant_else.rs:127:10 + --> tests/ui/redundant_else.rs:126:10 | LL | } else { | __________^ @@ -250,7 +250,7 @@ LL + } | error: redundant else block - --> tests/ui/redundant_else.rs:138:10 + --> tests/ui/redundant_else.rs:137:10 | LL | } else { | __________^ @@ -275,7 +275,7 @@ LL + } | error: redundant else block - --> tests/ui/redundant_else.rs:151:10 + --> tests/ui/redundant_else.rs:150:10 | LL | } else { | __________^ @@ -298,7 +298,7 @@ LL + } | error: redundant else block - --> tests/ui/redundant_else.rs:162:10 + --> tests/ui/redundant_else.rs:161:10 | LL | } else { | __________^ @@ -321,7 +321,7 @@ LL + } | error: redundant else block - --> tests/ui/redundant_else.rs:173:10 + --> tests/ui/redundant_else.rs:172:10 | LL | } else { | __________^ @@ -344,7 +344,7 @@ LL + }; | error: redundant else block - --> tests/ui/redundant_else.rs:184:10 + --> tests/ui/redundant_else.rs:183:10 | LL | } else { | __________^ @@ -361,7 +361,7 @@ LL + black_box(1) | error: redundant else block - --> tests/ui/redundant_else.rs:197:10 + --> tests/ui/redundant_else.rs:196:10 | LL | } else { | __________^ @@ -378,7 +378,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:207:10 + --> tests/ui/redundant_else.rs:206:10 | LL | } else { | __________^ @@ -395,7 +395,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:223:14 + --> tests/ui/redundant_else.rs:222:14 | LL | } else { | ______________^ @@ -412,7 +412,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:236:10 + --> tests/ui/redundant_else.rs:235:10 | LL | } else { | __________^ @@ -429,7 +429,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:232:14 + --> tests/ui/redundant_else.rs:231:14 | LL | } else { | ______________^ @@ -446,7 +446,7 @@ LL + return; | error: redundant else block - --> tests/ui/redundant_else.rs:252:10 + --> tests/ui/redundant_else.rs:251:10 | LL | } else { | __________^ @@ -463,7 +463,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:290:10 + --> tests/ui/redundant_else.rs:289:10 | LL | } else { | __________^ @@ -480,7 +480,7 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:305:10 + --> tests/ui/redundant_else.rs:304:10 | LL | } else { | __________^ @@ -497,13 +497,13 @@ LL ~ black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:326:42 + --> tests/ui/redundant_else.rs:325:42 | LL | if black_box(true) { return } else { black_box(0) } | ^^^^^^^^^^^^^^^^^^^^^^ help: remove the `else` block and move the contents out: `black_box(0)` error: redundant else block - --> tests/ui/redundant_else.rs:426:14 + --> tests/ui/redundant_else.rs:425:14 | LL | } else { | ______________^ @@ -521,7 +521,7 @@ LL + black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:433:14 + --> tests/ui/redundant_else.rs:432:14 | LL | } else { | ______________^ @@ -539,7 +539,7 @@ LL + black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:446:14 + --> tests/ui/redundant_else.rs:445:14 | LL | } else { | ______________^ @@ -557,7 +557,7 @@ LL + black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:441:18 + --> tests/ui/redundant_else.rs:440:18 | LL | } else { | __________________^ @@ -577,7 +577,7 @@ LL + return | error: redundant else block - --> tests/ui/redundant_else.rs:459:14 + --> tests/ui/redundant_else.rs:458:14 | LL | } else { | ______________^ @@ -595,7 +595,7 @@ LL + black_box(0); | error: redundant else block - --> tests/ui/redundant_else.rs:473:14 + --> tests/ui/redundant_else.rs:472:14 | LL | } else { | ______________^ @@ -613,7 +613,7 @@ LL + inline!({ black_box(()); }); | error: redundant else block - --> tests/ui/redundant_else.rs:481:14 + --> tests/ui/redundant_else.rs:480:14 | LL | } else { | ______________^ diff --git a/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.rs b/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.rs index 8453e57d43fba..d83ab1d9f05d9 100644 --- a/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.rs +++ b/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.rs @@ -1,6 +1,5 @@ //@no-rustfix #![warn(clippy::result_map_unit_fn)] -#![feature(never_type)] #![expect(clippy::unnecessary_map_on_constructor)] struct HasResult { diff --git a/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.stderr b/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.stderr index c7bca9e9e02b3..5b808fd383f98 100644 --- a/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.stderr +++ b/src/tools/clippy/tests/ui/result_map_unit_fn_unfixable.stderr @@ -1,5 +1,5 @@ error: called `map(f)` on a `Result` value where `f` is a closure that returns the unit type `()` - --> tests/ui/result_map_unit_fn_unfixable.rs:24:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:23:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL + if let Ok(value) = x.field { ... } | error: called `map(f)` on a `Result` value where `f` is a closure that returns the unit type `()` - --> tests/ui/result_map_unit_fn_unfixable.rs:29:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:28:5 | LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + if let Ok(value) = x.field { ... } | error: called `map(f)` on a `Result` value where `f` is a closure that returns the unit type `()` - --> tests/ui/result_map_unit_fn_unfixable.rs:35:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:34:5 | LL | / x.field.map(|value| { LL | | @@ -47,7 +47,7 @@ LL + if let Ok(value) = x.field { ... } | error: called `map(f)` on a `Result` value where `f` is a closure that returns the unit type `()` - --> tests/ui/result_map_unit_fn_unfixable.rs:41:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:40:5 | LL | x.field.map(|value| { do_nothing(value); do_nothing(value); }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL + if let Ok(value) = x.field { ... } | error: called `map(f)` on a `Result` value where `f` is a function that returns the unit type `()` - --> tests/ui/result_map_unit_fn_unfixable.rs:47:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:46:5 | LL | "12".parse::().map(diverge); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -71,7 +71,7 @@ LL + if let Ok(a) = "12".parse::() { diverge(a) } | error: called `map(f)` on a `Result` value where `f` is a function that returns the unit type `()` - --> tests/ui/result_map_unit_fn_unfixable.rs:55:5 + --> tests/ui/result_map_unit_fn_unfixable.rs:54:5 | LL | y.map(do_nothing); | ^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/uninhabited_references.rs b/src/tools/clippy/tests/ui/uninhabited_references.rs index 2351fb6a2c4e6..a5052ecbb42cd 100644 --- a/src/tools/clippy/tests/ui/uninhabited_references.rs +++ b/src/tools/clippy/tests/ui/uninhabited_references.rs @@ -1,5 +1,4 @@ #![warn(clippy::uninhabited_references)] -#![feature(never_type)] fn ret_uninh_ref() -> &'static std::convert::Infallible { //~^ uninhabited_references diff --git a/src/tools/clippy/tests/ui/uninhabited_references.stderr b/src/tools/clippy/tests/ui/uninhabited_references.stderr index 0d29816fc51d9..a76782086d8bc 100644 --- a/src/tools/clippy/tests/ui/uninhabited_references.stderr +++ b/src/tools/clippy/tests/ui/uninhabited_references.stderr @@ -1,5 +1,5 @@ error: dereferencing a reference to an uninhabited type would be undefined behavior - --> tests/ui/uninhabited_references.rs:4:23 + --> tests/ui/uninhabited_references.rs:3:23 | LL | fn ret_uninh_ref() -> &'static std::convert::Infallible { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn ret_uninh_ref() -> &'static std::convert::Infallible { = help: to override `-D warnings` add `#[allow(clippy::uninhabited_references)]` error: dereferencing a reference to an uninhabited type would be undefined behavior - --> tests/ui/uninhabited_references.rs:11:30 + --> tests/ui/uninhabited_references.rs:10:30 | LL | fn $name(x: &$ty) -> &$ty { | ^^^^ @@ -19,7 +19,7 @@ LL | ret_something!(id_never, !); = note: this error originates in the macro `ret_something` (in Nightly builds, run with -Z macro-backtrace for more info) error: dereferencing a reference to an uninhabited type is undefined behavior - --> tests/ui/uninhabited_references.rs:13:14 + --> tests/ui/uninhabited_references.rs:12:14 | LL | &*x | ^^ @@ -30,7 +30,7 @@ LL | ret_something!(id_never, !); = note: this error originates in the macro `ret_something` (in Nightly builds, run with -Z macro-backtrace for more info) error: dereferencing a reference to an uninhabited type is undefined behavior - --> tests/ui/uninhabited_references.rs:24:13 + --> tests/ui/uninhabited_references.rs:23:13 | LL | let _ = *x; | ^^ diff --git a/src/tools/clippy/tests/ui/unused_unit.edition2021.fixed b/src/tools/clippy/tests/ui/unused_unit.edition2021.fixed index b6e3753d9ee4d..37c50cd78a94c 100644 --- a/src/tools/clippy/tests/ui/unused_unit.edition2021.fixed +++ b/src/tools/clippy/tests/ui/unused_unit.edition2021.fixed @@ -126,7 +126,6 @@ mod issue14577 { trait Unit {} impl Unit for () {} - #[allow(dependency_on_unit_never_type_fallback)] fn bar() { //~[edition2021]^ unused_unit panic!() diff --git a/src/tools/clippy/tests/ui/unused_unit.edition2021.stderr b/src/tools/clippy/tests/ui/unused_unit.edition2021.stderr index a6b9fa70d6cf8..8a1ab2ef65813 100644 --- a/src/tools/clippy/tests/ui/unused_unit.edition2021.stderr +++ b/src/tools/clippy/tests/ui/unused_unit.edition2021.stderr @@ -116,7 +116,7 @@ LL | fn test3()-> (){} | ^^^^^ help: remove the `-> ()` error: unneeded unit return type - --> tests/ui/unused_unit.rs:130:13 + --> tests/ui/unused_unit.rs:129:13 | LL | fn bar() -> () { | ^^^^^^ help: remove the `-> ()` diff --git a/src/tools/clippy/tests/ui/unused_unit.edition2024.fixed b/src/tools/clippy/tests/ui/unused_unit.edition2024.fixed index f389b833310a1..5e77094cc0c81 100644 --- a/src/tools/clippy/tests/ui/unused_unit.edition2024.fixed +++ b/src/tools/clippy/tests/ui/unused_unit.edition2024.fixed @@ -126,7 +126,6 @@ mod issue14577 { trait Unit {} impl Unit for () {} - #[allow(dependency_on_unit_never_type_fallback)] fn bar() -> () { //~[edition2021]^ unused_unit panic!() diff --git a/src/tools/clippy/tests/ui/unused_unit.rs b/src/tools/clippy/tests/ui/unused_unit.rs index b70d7bf18ac84..156f038cbedf5 100644 --- a/src/tools/clippy/tests/ui/unused_unit.rs +++ b/src/tools/clippy/tests/ui/unused_unit.rs @@ -126,7 +126,6 @@ mod issue14577 { trait Unit {} impl Unit for () {} - #[allow(dependency_on_unit_never_type_fallback)] fn bar() -> () { //~[edition2021]^ unused_unit panic!() diff --git a/src/tools/clippy/tests/ui/unwrap_expect_used.rs b/src/tools/clippy/tests/ui/unwrap_expect_used.rs index ef638bf0e9c9a..3fb1c8d838106 100644 --- a/src/tools/clippy/tests/ui/unwrap_expect_used.rs +++ b/src/tools/clippy/tests/ui/unwrap_expect_used.rs @@ -1,6 +1,5 @@ #![warn(clippy::expect_used, clippy::unwrap_used)] #![expect(clippy::unnecessary_literal_unwrap)] -#![feature(never_type)] use std::convert::Infallible; diff --git a/src/tools/clippy/tests/ui/unwrap_expect_used.stderr b/src/tools/clippy/tests/ui/unwrap_expect_used.stderr index b9a2844b284c8..6c8c16c2c1967 100644 --- a/src/tools/clippy/tests/ui/unwrap_expect_used.stderr +++ b/src/tools/clippy/tests/ui/unwrap_expect_used.stderr @@ -1,5 +1,5 @@ error: used `unwrap()` on an `Option` value - --> tests/ui/unwrap_expect_used.rs:27:5 + --> tests/ui/unwrap_expect_used.rs:26:5 | LL | Some(3).unwrap(); | ^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | Some(3).unwrap(); = help: to override `-D warnings` add `#[allow(clippy::unwrap_used)]` error: used `expect()` on an `Option` value - --> tests/ui/unwrap_expect_used.rs:30:5 + --> tests/ui/unwrap_expect_used.rs:29:5 | LL | Some(3).expect("Hello world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | Some(3).expect("Hello world!"); = help: to override `-D warnings` add `#[allow(clippy::expect_used)]` error: used `unwrap()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:46:5 + --> tests/ui/unwrap_expect_used.rs:45:5 | LL | a.unwrap(); | ^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | a.unwrap(); = note: if this value is an `Err`, it will panic error: used `expect()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:49:5 + --> tests/ui/unwrap_expect_used.rs:48:5 | LL | a.expect("Hello world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | a.expect("Hello world!"); = note: if this value is an `Err`, it will panic error: used `unwrap_err()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:52:5 + --> tests/ui/unwrap_expect_used.rs:51:5 | LL | a.unwrap_err(); | ^^^^^^^^^^^^^^ @@ -43,7 +43,7 @@ LL | a.unwrap_err(); = note: if this value is an `Ok`, it will panic error: used `expect_err()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:55:5 + --> tests/ui/unwrap_expect_used.rs:54:5 | LL | a.expect_err("Hello error!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -51,7 +51,7 @@ LL | a.expect_err("Hello error!"); = note: if this value is an `Ok`, it will panic error: used `unwrap()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:80:17 + --> tests/ui/unwrap_expect_used.rs:79:17 | LL | let _ = open!(file).unwrap(); | ^^^^^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | let _ = open!(file).unwrap(); = note: if this value is an `Err`, it will panic error: used `expect()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:81:17 + --> tests/ui/unwrap_expect_used.rs:80:17 | LL | let _ = open!(file).expect("can open"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | let _ = open!(file).expect("can open"); = note: if this value is an `Err`, it will panic error: used `unwrap_err()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:82:17 + --> tests/ui/unwrap_expect_used.rs:81:17 | LL | let _ = open!(file).unwrap_err(); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -75,7 +75,7 @@ LL | let _ = open!(file).unwrap_err(); = note: if this value is an `Ok`, it will panic error: used `expect_err()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:83:17 + --> tests/ui/unwrap_expect_used.rs:82:17 | LL | let _ = open!(file).expect_err("can open"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ LL | let _ = open!(file).expect_err("can open"); = note: if this value is an `Ok`, it will panic error: used `unwrap()` on an `Option` value - --> tests/ui/unwrap_expect_used.rs:89:5 + --> tests/ui/unwrap_expect_used.rs:88:5 | LL | Option::unwrap(opt); | ^^^^^^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | Option::unwrap(opt); = note: if this value is `None`, it will panic error: used `expect()` on an `Option` value - --> tests/ui/unwrap_expect_used.rs:90:5 + --> tests/ui/unwrap_expect_used.rs:89:5 | LL | Option::expect(opt, "error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -99,7 +99,7 @@ LL | Option::expect(opt, "error message"); = note: if this value is `None`, it will panic error: used `unwrap()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:93:5 + --> tests/ui/unwrap_expect_used.rs:92:5 | LL | Result::unwrap(res); | ^^^^^^^^^^^^^^^^^^^ @@ -107,7 +107,7 @@ LL | Result::unwrap(res); = note: if this value is an `Err`, it will panic error: used `expect()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:94:5 + --> tests/ui/unwrap_expect_used.rs:93:5 | LL | Result::expect(res, "error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -115,7 +115,7 @@ LL | Result::expect(res, "error message"); = note: if this value is an `Err`, it will panic error: used `unwrap_err()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:95:5 + --> tests/ui/unwrap_expect_used.rs:94:5 | LL | Result::unwrap_err(res); | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,7 +123,7 @@ LL | Result::unwrap_err(res); = note: if this value is an `Ok`, it will panic error: used `expect_err()` on a `Result` value - --> tests/ui/unwrap_expect_used.rs:96:5 + --> tests/ui/unwrap_expect_used.rs:95:5 | LL | Result::expect_err(res, "error message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/zero_repeat_side_effects.fixed b/src/tools/clippy/tests/ui/zero_repeat_side_effects.fixed index 27adfadcf19a0..b05d4b85ee780 100644 --- a/src/tools/clippy/tests/ui/zero_repeat_side_effects.fixed +++ b/src/tools/clippy/tests/ui/zero_repeat_side_effects.fixed @@ -149,3 +149,11 @@ fn issue_15824() { _ => {}, } } + +#[allow(clippy::diverging_sub_expression)] // only fires *before* the fix +fn diverging() { + // Used to not be fixable when `!` wasn't stable yet and thus not nameable + panic!(); + let _data: [!; 0] = []; + //~^ zero_repeat_side_effects +} diff --git a/src/tools/clippy/tests/ui/zero_repeat_side_effects.rs b/src/tools/clippy/tests/ui/zero_repeat_side_effects.rs index 292387bb36e88..479cf20cff55e 100644 --- a/src/tools/clippy/tests/ui/zero_repeat_side_effects.rs +++ b/src/tools/clippy/tests/ui/zero_repeat_side_effects.rs @@ -126,3 +126,10 @@ fn issue_15824() { _ => {}, } } + +#[allow(clippy::diverging_sub_expression)] // only fires *before* the fix +fn diverging() { + // Used to not be fixable when `!` wasn't stable yet and thus not nameable + let _data = [panic!(); 0]; + //~^ zero_repeat_side_effects +} diff --git a/src/tools/clippy/tests/ui/zero_repeat_side_effects.stderr b/src/tools/clippy/tests/ui/zero_repeat_side_effects.stderr index 5560f4855c75c..276f1cdae6be2 100644 --- a/src/tools/clippy/tests/ui/zero_repeat_side_effects.stderr +++ b/src/tools/clippy/tests/ui/zero_repeat_side_effects.stderr @@ -166,5 +166,17 @@ LL + a = [] as [(); 0] LL ~ }, | -error: aborting due to 13 previous errors +error: expression with side effects as the initial value in a zero-sized array initializer + --> tests/ui/zero_repeat_side_effects.rs:133:5 + | +LL | let _data = [panic!(); 0]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: consider performing the side effect separately + | +LL ~ panic!(); +LL + let _data: [!; 0] = []; + | + +error: aborting due to 14 previous errors diff --git a/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.fixed b/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.fixed index 3d037516f75c8..e6faf115de545 100644 --- a/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.fixed +++ b/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.fixed @@ -1,6 +1,5 @@ #![warn(clippy::zero_repeat_side_effects)] #![allow(clippy::diverging_sub_expression)] -#![feature(never_type)] fn issue_14998() { // nameable type thanks to `never_type` being enabled, suggest diff --git a/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.rs b/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.rs index 3dc1929bcdc76..2fec6b1d26ab2 100644 --- a/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.rs +++ b/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.rs @@ -1,6 +1,5 @@ #![warn(clippy::zero_repeat_side_effects)] #![allow(clippy::diverging_sub_expression)] -#![feature(never_type)] fn issue_14998() { // nameable type thanks to `never_type` being enabled, suggest diff --git a/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.stderr b/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.stderr index 280955740cc4c..df2c26bda7971 100644 --- a/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.stderr +++ b/src/tools/clippy/tests/ui/zero_repeat_side_effects_never_pattern.stderr @@ -1,5 +1,5 @@ error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects_never_pattern.rs:7:5 + --> tests/ui/zero_repeat_side_effects_never_pattern.rs:6:5 | LL | let _data = [panic!(); 0]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/zero_repeat_side_effects_unfixable.rs b/src/tools/clippy/tests/ui/zero_repeat_side_effects_unfixable.rs index 82f0884056ab0..834b8640cad05 100644 --- a/src/tools/clippy/tests/ui/zero_repeat_side_effects_unfixable.rs +++ b/src/tools/clippy/tests/ui/zero_repeat_side_effects_unfixable.rs @@ -1,13 +1,8 @@ //@no-rustfix #![warn(clippy::zero_repeat_side_effects)] -#![expect(clippy::diverging_sub_expression)] fn issue_14998() { // unnameable types, don't suggest let _data = [|| 3i32; 0]; //~^ zero_repeat_side_effects - - // unnameable type because `never_type` is not enabled, don't suggest - let _data = [panic!(); 0]; - //~^ zero_repeat_side_effects } diff --git a/src/tools/clippy/tests/ui/zero_repeat_side_effects_unfixable.stderr b/src/tools/clippy/tests/ui/zero_repeat_side_effects_unfixable.stderr index 450617f3782c4..24cba6e3932fe 100644 --- a/src/tools/clippy/tests/ui/zero_repeat_side_effects_unfixable.stderr +++ b/src/tools/clippy/tests/ui/zero_repeat_side_effects_unfixable.stderr @@ -1,5 +1,5 @@ error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects_unfixable.rs:7:5 + --> tests/ui/zero_repeat_side_effects_unfixable.rs:6:5 | LL | let _data = [|| 3i32; 0]; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,13 +8,5 @@ LL | let _data = [|| 3i32; 0]; = note: `-D clippy::zero-repeat-side-effects` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::zero_repeat_side_effects)]` -error: expression with side effects as the initial value in a zero-sized array initializer - --> tests/ui/zero_repeat_side_effects_unfixable.rs:11:5 - | -LL | let _data = [panic!(); 0]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider performing the side effect separately - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index a2b6108882df3..4cd7475f62915 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -14,7 +14,7 @@ #![feature(float_gamma)] #![feature(float_erf)] #![feature(map_try_insert)] -#![feature(never_type)] +#![cfg_attr(bootstrap, feature(never_type))] #![feature(try_blocks)] #![feature(io_error_more)] #![feature(io_error_inprogress)] diff --git a/src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_deref_match_never.rs b/src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_deref_match_never.rs index e77c8e06a0f9e..890f194180dbb 100644 --- a/src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_deref_match_never.rs +++ b/src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_deref_match_never.rs @@ -2,7 +2,6 @@ //@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation #![allow(unreachable_code)] -#![feature(never_type)] fn main() { let p = { diff --git a/src/tools/miri/tests/fail/erroneous_const.rs b/src/tools/miri/tests/fail/erroneous_const.rs index 6e126ed701f88..736a881749c6d 100644 --- a/src/tools/miri/tests/fail/erroneous_const.rs +++ b/src/tools/miri/tests/fail/erroneous_const.rs @@ -1,6 +1,5 @@ //! Make sure we detect erroneous constants post-monomorphization even when they are unused. //! (https://github.com/rust-lang/miri/issues/1382) -#![feature(never_type)] struct PrintName(T); impl PrintName { diff --git a/src/tools/miri/tests/fail/intrinsics/uninit_uninhabited_type.rs b/src/tools/miri/tests/fail/intrinsics/uninit_uninhabited_type.rs index 34fef6b9ee556..2d7f8d2e46879 100644 --- a/src/tools/miri/tests/fail/intrinsics/uninit_uninhabited_type.rs +++ b/src/tools/miri/tests/fail/intrinsics/uninit_uninhabited_type.rs @@ -1,5 +1,3 @@ -#![feature(never_type)] - #[allow(deprecated, invalid_value)] fn main() { let _ = unsafe { std::mem::uninitialized::() }; //~ERROR: constructing invalid value diff --git a/src/tools/miri/tests/fail/match/closures/uninhabited-variant1.rs b/src/tools/miri/tests/fail/match/closures/uninhabited-variant1.rs index 0a2dfe9a7f645..4a8c28857ae46 100644 --- a/src/tools/miri/tests/fail/match/closures/uninhabited-variant1.rs +++ b/src/tools/miri/tests/fail/match/closures/uninhabited-variant1.rs @@ -1,6 +1,5 @@ // Motivated by rust-lang/rust#138961, this shows how invalid discriminants interact with // closure captures. -#![feature(never_type)] #[repr(C)] #[allow(dead_code)] diff --git a/src/tools/miri/tests/fail/match/closures/uninhabited-variant2.rs b/src/tools/miri/tests/fail/match/closures/uninhabited-variant2.rs index 050e83884d1e2..3d88798f44b18 100644 --- a/src/tools/miri/tests/fail/match/closures/uninhabited-variant2.rs +++ b/src/tools/miri/tests/fail/match/closures/uninhabited-variant2.rs @@ -3,7 +3,6 @@ // // Test case with only one inhabited variant, for which rustc used to not emit // a discriminant read in the first place. See: rust-lang/miri#4778 -#![feature(never_type)] #[repr(C)] #[allow(dead_code)] diff --git a/src/tools/miri/tests/fail/match/only_inhabited_variant.rs b/src/tools/miri/tests/fail/match/only_inhabited_variant.rs index 2be5e8083aa7f..7457481a22ca2 100644 --- a/src/tools/miri/tests/fail/match/only_inhabited_variant.rs +++ b/src/tools/miri/tests/fail/match/only_inhabited_variant.rs @@ -1,5 +1,4 @@ // rust-lang/miri#4778 -#![feature(never_type)] #[repr(C)] #[allow(dead_code)] diff --git a/src/tools/miri/tests/fail/never_match_never.rs b/src/tools/miri/tests/fail/never_match_never.rs index 5f2f471bf6098..02b3eff13a377 100644 --- a/src/tools/miri/tests/fail/never_match_never.rs +++ b/src/tools/miri/tests/fail/never_match_never.rs @@ -1,7 +1,6 @@ // This should fail even without validation //@compile-flags: -Zmiri-disable-validation -#![feature(never_type)] #![allow(unreachable_code)] fn main() { diff --git a/src/tools/miri/tests/fail/never_say_never.rs b/src/tools/miri/tests/fail/never_say_never.rs index fd082e367a83a..457005391ae80 100644 --- a/src/tools/miri/tests/fail/never_say_never.rs +++ b/src/tools/miri/tests/fail/never_say_never.rs @@ -1,7 +1,6 @@ // This should fail even without validation //@compile-flags: -Zmiri-disable-validation -#![feature(never_type)] #![allow(unreachable_code)] fn main() { diff --git a/src/tools/miri/tests/fail/never_transmute_humans.rs b/src/tools/miri/tests/fail/never_transmute_humans.rs index cba3cc0ccf17b..559eb652555ac 100644 --- a/src/tools/miri/tests/fail/never_transmute_humans.rs +++ b/src/tools/miri/tests/fail/never_transmute_humans.rs @@ -1,8 +1,6 @@ // This should fail even without validation //@compile-flags: -Zmiri-disable-validation -#![feature(never_type)] - struct Human; fn main() { diff --git a/src/tools/miri/tests/fail/never_transmute_void.rs b/src/tools/miri/tests/fail/never_transmute_void.rs index a2db2ca9db61b..bc1095c815e7f 100644 --- a/src/tools/miri/tests/fail/never_transmute_void.rs +++ b/src/tools/miri/tests/fail/never_transmute_void.rs @@ -1,7 +1,6 @@ // This should fail even without validation //@compile-flags: -Zmiri-disable-validation -#![feature(never_type)] #![allow(unused, invalid_value)] mod m { diff --git a/src/tools/miri/tests/fail/validity/invalid_enum_op_discr_uninhabited.rs b/src/tools/miri/tests/fail/validity/invalid_enum_op_discr_uninhabited.rs index 3d1ae64b57826..96c7a613378ad 100644 --- a/src/tools/miri/tests/fail/validity/invalid_enum_op_discr_uninhabited.rs +++ b/src/tools/miri/tests/fail/validity/invalid_enum_op_discr_uninhabited.rs @@ -1,6 +1,5 @@ // Make sure we find these even with many checks disabled. //@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation -#![feature(never_type)] enum Never {} diff --git a/src/tools/miri/tests/fail/validity/ref_to_uninhabited1.rs b/src/tools/miri/tests/fail/validity/ref_to_uninhabited1.rs index 25e21375cd746..1f8fc6a2ce334 100644 --- a/src/tools/miri/tests/fail/validity/ref_to_uninhabited1.rs +++ b/src/tools/miri/tests/fail/validity/ref_to_uninhabited1.rs @@ -1,4 +1,3 @@ -#![feature(never_type)] use std::mem::{forget, transmute}; fn main() { diff --git a/src/tools/miri/tests/fail/validity/uninhabited_variant.rs b/src/tools/miri/tests/fail/validity/uninhabited_variant.rs index 303584423fdcf..4d6b4b84ca53f 100644 --- a/src/tools/miri/tests/fail/validity/uninhabited_variant.rs +++ b/src/tools/miri/tests/fail/validity/uninhabited_variant.rs @@ -1,6 +1,5 @@ // NOTE: this is essentially a smoke-test, with more comprehensive tests living in the rustc // repository at tests/ui/consts/const-eval/ub-enum.rs -#![feature(never_type)] #[repr(C)] #[allow(dead_code)] diff --git a/src/tools/miri/tests/pass/async-fn.rs b/src/tools/miri/tests/pass/async-fn.rs index 42c60bb4fabdd..a20caf3d9f515 100644 --- a/src/tools/miri/tests/pass/async-fn.rs +++ b/src/tools/miri/tests/pass/async-fn.rs @@ -1,5 +1,3 @@ -#![feature(never_type)] - use std::future::Future; // See if we can run a basic `async fn` diff --git a/src/tools/miri/tests/pass/coroutine.rs b/src/tools/miri/tests/pass/coroutine.rs index 5411ee889054e..9ea2b4d2f3f77 100644 --- a/src/tools/miri/tests/pass/coroutine.rs +++ b/src/tools/miri/tests/pass/coroutine.rs @@ -1,7 +1,7 @@ //@revisions: stack tree tree_implicit_writes //@[tree_implicit_writes]compile-flags: -Zmiri-tree-borrows -Zmiri-tree-borrows-implicit-writes //@[tree]compile-flags: -Zmiri-tree-borrows -#![feature(coroutines, coroutine_trait, never_type, stmt_expr_attributes)] +#![feature(coroutines, coroutine_trait, stmt_expr_attributes)] use std::fmt::Debug; use std::mem::ManuallyDrop; diff --git a/src/tools/miri/tests/pass/function_calls/abi_compat.rs b/src/tools/miri/tests/pass/function_calls/abi_compat.rs index 56c45eb29a0bf..2f04d2c231790 100644 --- a/src/tools/miri/tests/pass/function_calls/abi_compat.rs +++ b/src/tools/miri/tests/pass/function_calls/abi_compat.rs @@ -1,5 +1,3 @@ -#![feature(never_type)] - use std::rc::Rc; use std::{mem, num, ptr}; diff --git a/src/tools/miri/tests/pass/issues/issue-120337-irrefutable-let-ice.rs b/src/tools/miri/tests/pass/issues/issue-120337-irrefutable-let-ice.rs index 5af0d0e4bbd95..7380d700ab708 100644 --- a/src/tools/miri/tests/pass/issues/issue-120337-irrefutable-let-ice.rs +++ b/src/tools/miri/tests/pass/issues/issue-120337-irrefutable-let-ice.rs @@ -1,7 +1,6 @@ // Validation stops the test before the ICE we used to hit //@compile-flags: -Zmiri-disable-validation -#![feature(never_type)] #[derive(Copy, Clone)] pub enum E { A(!), diff --git a/src/tools/miri/tests/pass/loop-break-value.rs b/src/tools/miri/tests/pass/loop-break-value.rs index 74ab487b342a1..dffbfdaf06472 100644 --- a/src/tools/miri/tests/pass/loop-break-value.rs +++ b/src/tools/miri/tests/pass/loop-break-value.rs @@ -1,4 +1,3 @@ -#![feature(never_type)] #![allow(unreachable_code)] #[allow(unused)] diff --git a/src/tools/miri/tests/pass/panic/catch_panic.rs b/src/tools/miri/tests/pass/panic/catch_panic.rs index 06d15a1a7f94e..bd26a79a0b8ec 100644 --- a/src/tools/miri/tests/pass/panic/catch_panic.rs +++ b/src/tools/miri/tests/pass/panic/catch_panic.rs @@ -1,4 +1,3 @@ -#![feature(never_type)] #![allow(unconditional_panic, non_fmt_panics)] use std::cell::Cell; diff --git a/src/tools/miri/tests/pass/underscore_pattern.rs b/src/tools/miri/tests/pass/underscore_pattern.rs index 2f203bdc01e45..44a1d02cc393e 100644 --- a/src/tools/miri/tests/pass/underscore_pattern.rs +++ b/src/tools/miri/tests/pass/underscore_pattern.rs @@ -1,5 +1,4 @@ // Various tests ensuring that underscore patterns really just construct the place, but don't check its contents. -#![feature(never_type)] use std::ptr; diff --git a/tests/codegen-llvm/enum/enum-debug-niche-2.rs b/tests/codegen-llvm/enum/enum-debug-niche-2.rs index 80a4081f15b10..fd9c18583f375 100644 --- a/tests/codegen-llvm/enum/enum-debug-niche-2.rs +++ b/tests/codegen-llvm/enum/enum-debug-niche-2.rs @@ -7,7 +7,6 @@ // CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}size: 32,{{.*}} // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Placeholder",{{.*}}extraData: i32 -1{{[,)].*}} // CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "Error",{{.*}}extraData: i32 0{{[,)].*}} -#![feature(never_type)] #[derive(Copy, Clone)] pub struct Entity { diff --git a/tests/codegen-units/item-collection/opaque-return-impls.rs b/tests/codegen-units/item-collection/opaque-return-impls.rs index 484fbe7fe62f1..d2781b356e976 100644 --- a/tests/codegen-units/item-collection/opaque-return-impls.rs +++ b/tests/codegen-units/item-collection/opaque-return-impls.rs @@ -79,7 +79,7 @@ pub fn foo3() -> Box> { //~ MONO_ITEM fn ::nth //~ MONO_ITEM fn ::size_hint //~ MONO_ITEM fn ::try_fold::, {closure@::spec_advance_by::{closure#0}}, std::option::Option>> -//~ MONO_ITEM fn > as std::ops::FromResidual>>::from_residual +//~ MONO_ITEM fn > as std::ops::FromResidual>>::from_residual //~ MONO_ITEM fn > as std::ops::Try>::branch //~ MONO_ITEM fn > as std::ops::Try>::from_output //~ MONO_ITEM fn foo3 diff --git a/tests/crashes/108428.rs b/tests/crashes/108248.rs similarity index 84% rename from tests/crashes/108428.rs rename to tests/crashes/108248.rs index b18123b6a7c40..36252e29d33f0 100644 --- a/tests/crashes/108428.rs +++ b/tests/crashes/108248.rs @@ -1,4 +1,4 @@ -//@ known-bug: #108428 +//@ known-bug: #108248 //@ needs-rustc-debug-assertions //@ compile-flags: -Wunused-lifetimes fn main() { diff --git a/tests/crashes/138262.rs b/tests/crashes/138262.rs new file mode 100644 index 0000000000000..ce5b3bb257e5d --- /dev/null +++ b/tests/crashes/138262.rs @@ -0,0 +1,12 @@ +//@ known-bug: #138262 +//@ compile-flags: -Zsanitizer=cfi -Ccodegen-units=1 -Clto -Clink-dead-code=true -Cunsafe-allow-abi-mismatch=sanitizer -Ctarget-feature=-crt-static +//@ ignore-backends: gcc +//@ needs-sanitizer-cfi +fn foo() {} + +core::arch::global_asm!("/* {} */", sym foo::<{ + || {}; + 0 +}>); + +fn main() {} diff --git a/tests/crashes/142155.rs b/tests/crashes/142155.rs new file mode 100644 index 0000000000000..8c0769bf2b586 --- /dev/null +++ b/tests/crashes/142155.rs @@ -0,0 +1,12 @@ +//@ known-bug: #142155 +//@ needs-rustc-debug-assertions +//@ edition: 2021 + +#![warn(tail_expr_drop_order)] +use core::future::Future; + +fn f() -> impl Future> { + async { Some("nope".into()) } +} + +fn main() {} diff --git a/tests/crashes/144241.rs b/tests/crashes/144241.rs new file mode 100644 index 0000000000000..3f91fcc7c6275 --- /dev/null +++ b/tests/crashes/144241.rs @@ -0,0 +1,4 @@ +//@ known-bug: #144241 +fn main() { + |_: dyn ?Sized + !Send| {} +} diff --git a/tests/crashes/149562.rs b/tests/crashes/149562.rs new file mode 100644 index 0000000000000..4d032a0af5c3e --- /dev/null +++ b/tests/crashes/149562.rs @@ -0,0 +1,10 @@ +//@ known-bug: #149562 +//@ needs-rustc-debug-assertions +fn a() -> T +where + T: ?Sized, + T: ?Sized, +{ +} + +fn main() {} diff --git a/tests/crashes/152414.rs b/tests/crashes/152414.rs new file mode 100644 index 0000000000000..226f9e29faad6 --- /dev/null +++ b/tests/crashes/152414.rs @@ -0,0 +1,6 @@ +//@ known-bug: #152414 +//@ needs-rustc-debug-assertions +#![feature(generic_assert)] +fn main() { + assert!(size_of(val, 1) >= 1); +} diff --git a/tests/crashes/152416.rs b/tests/crashes/152416.rs new file mode 100644 index 0000000000000..9ca418cce3628 --- /dev/null +++ b/tests/crashes/152416.rs @@ -0,0 +1,17 @@ +//@ known-bug: #152416 +//@ needs-rustc-debug-assertions +//@ compile-flags: -Zunstable-options + +trait AssetID {} +trait Archive { + fn name(&self); +} +struct NorthlightAssetID; +impl AssetID for NorthlightAssetID {} +fn get() -> Box> { + let x: Box> = todo!(); + x +} +fn main() { + get().name(); +} diff --git a/tests/crashes/152626.rs b/tests/crashes/152626.rs new file mode 100644 index 0000000000000..eafb714c2f5c2 --- /dev/null +++ b/tests/crashes/152626.rs @@ -0,0 +1,7 @@ +//@ known-bug: #152626 +//@ needs-rustc-debug-assertions +struct A>(T); +fn f() -> A<&'static ()> { + todo!() +} +fn main() {} diff --git a/tests/crashes/154903.rs b/tests/crashes/154903.rs new file mode 100644 index 0000000000000..63e80d8f9e251 --- /dev/null +++ b/tests/crashes/154903.rs @@ -0,0 +1,7 @@ +//@ known-bug: #154903 +//@ compile-flags: -Zlint-mir +#![feature(guard_patterns)] + +fn a(((x if true, _) | (_, x)): (i32, i32)) {} + +fn main() {} diff --git a/tests/crashes/154963.rs b/tests/crashes/154963.rs new file mode 100644 index 0000000000000..8fafc29c48342 --- /dev/null +++ b/tests/crashes/154963.rs @@ -0,0 +1,10 @@ +//@ known-bug: #154963 +#![feature(extern_types, negative_impls)] + +unsafe extern "C" { + type ExternType; +} + +impl !Unpin for ExternType {} + +fn main() {} diff --git a/tests/crashes/155053.rs b/tests/crashes/155053.rs new file mode 100644 index 0000000000000..31b9ccaf20540 --- /dev/null +++ b/tests/crashes/155053.rs @@ -0,0 +1,11 @@ +//@ known-bug: #155053 +#![feature(pin_ergonomics)] +#![feature(extern_types)] + +unsafe extern "C" { + type ExternType; +} + +impl Unpin for ExternType {} + +fn main() {} diff --git a/tests/crashes/156101.rs b/tests/crashes/156101.rs new file mode 100644 index 0000000000000..c95361fab2ecc --- /dev/null +++ b/tests/crashes/156101.rs @@ -0,0 +1,4 @@ +//@ known-bug: #156101 +fn main() { + format_args!(concat!("𐏿", "{f:?#}")); +} diff --git a/tests/crashes/156288.rs b/tests/crashes/156288.rs new file mode 100644 index 0000000000000..b745cfe063dda --- /dev/null +++ b/tests/crashes/156288.rs @@ -0,0 +1,3 @@ +//@ known-bug: #156288 +#[warn(rust_2021_incompatible_closure_captures)] +const _: () = |b| move || b; diff --git a/tests/mir-opt/building/eq_never_type._f.built.after.mir b/tests/mir-opt/building/eq_never_type._f.built.after.mir index 4711af46f1c8c..7a4bb2df7a007 100644 --- a/tests/mir-opt/building/eq_never_type._f.built.after.mir +++ b/tests/mir-opt/building/eq_never_type._f.built.after.mir @@ -6,11 +6,9 @@ fn _f(_1: !, _2: !) -> () { let mut _0: (); let mut _3: !; let _4: bool; - let mut _5: &(); + let mut _5: &!; let mut _6: !; - let mut _7: &(); - let _8: (); - let mut _9: !; + let mut _7: &!; bb0: { StorageLive(_4); @@ -23,31 +21,22 @@ fn _f(_1: !, _2: !) -> () { bb1: { StorageDead(_6); StorageLive(_7); - StorageLive(_8); - StorageLive(_9); - _9 = copy _2; - unreachable; + _7 = &_2; + _4 = ::eq(move _5, move _7) -> [return: bb2, unwind: bb4]; } bb2: { - _7 = &_8; - StorageDead(_9); - _4 = <() as PartialEq>::eq(move _5, move _7) -> [return: bb3, unwind: bb5]; - } - - bb3: { StorageDead(_7); StorageDead(_5); - StorageDead(_8); StorageDead(_4); unreachable; } - bb4: { + bb3: { return; } - bb5 (cleanup): { + bb4 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/eq_never_type.rs b/tests/mir-opt/building/eq_never_type.rs index 762f20ee1e104..b805904b4f379 100644 --- a/tests/mir-opt/building/eq_never_type.rs +++ b/tests/mir-opt/building/eq_never_type.rs @@ -1,6 +1,5 @@ //@ compile-flags: -Zmir-opt-level=0 //@ skip-filecheck -#![feature(never_type)] #![allow(unreachable_code)] // EMIT_MIR eq_never_type._f.built.after.mir diff --git a/tests/mir-opt/building/fallible_struct_drop.build.ElaborateDrops.diff b/tests/mir-opt/building/fallible_struct_drop.build.ElaborateDrops.diff index b0db5ea383919..b6085e6c9b23b 100644 --- a/tests/mir-opt/building/fallible_struct_drop.build.ElaborateDrops.diff +++ b/tests/mir-opt/building/fallible_struct_drop.build.ElaborateDrops.diff @@ -6,54 +6,54 @@ let mut _0: std::result::Result; let mut _2: Big; let mut _3: std::string::String; - let mut _4: std::ops::ControlFlow, std::string::String>; + let mut _4: std::ops::ControlFlow, std::string::String>; let mut _5: std::result::Result; let mut _6: u64; let mut _7: u64; let mut _8: isize; - let _9: std::result::Result; + let _9: std::result::Result; let mut _10: !; - let mut _11: std::result::Result; + let mut _11: std::result::Result; let _12: std::string::String; let mut _13: std::string::String; - let mut _14: std::ops::ControlFlow, std::string::String>; + let mut _14: std::ops::ControlFlow, std::string::String>; let mut _15: std::result::Result; let mut _16: u64; let mut _17: u64; let mut _18: isize; - let _19: std::result::Result; + let _19: std::result::Result; let mut _20: !; - let mut _21: std::result::Result; + let mut _21: std::result::Result; let _22: std::string::String; let mut _23: std::string::String; - let mut _24: std::ops::ControlFlow, std::string::String>; + let mut _24: std::ops::ControlFlow, std::string::String>; let mut _25: std::result::Result; let mut _26: u64; let mut _27: u64; let mut _28: isize; - let _29: std::result::Result; + let _29: std::result::Result; let mut _30: !; - let mut _31: std::result::Result; + let mut _31: std::result::Result; let _32: std::string::String; let mut _33: std::string::String; - let mut _34: std::ops::ControlFlow, std::string::String>; + let mut _34: std::ops::ControlFlow, std::string::String>; let mut _35: std::result::Result; let mut _36: u64; let mut _37: u64; let mut _38: isize; - let _39: std::result::Result; + let _39: std::result::Result; let mut _40: !; - let mut _41: std::result::Result; + let mut _41: std::result::Result; let _42: std::string::String; let mut _43: std::string::String; - let mut _44: std::ops::ControlFlow, std::string::String>; + let mut _44: std::ops::ControlFlow, std::string::String>; let mut _45: std::result::Result; let mut _46: u64; let mut _47: u64; let mut _48: isize; - let _49: std::result::Result; + let _49: std::result::Result; let mut _50: !; - let mut _51: std::result::Result; + let mut _51: std::result::Result; let _52: std::string::String; + let mut _53: bool; + let mut _54: bool; @@ -154,10 +154,10 @@ bb5: { StorageLive(_9); - _9 = copy ((_4 as Break).0: std::result::Result); + _9 = copy ((_4 as Break).0: std::result::Result); StorageLive(_11); _11 = copy _9; - _0 = as FromResidual>>::from_residual(move _11) -> [return: bb6, unwind: bb90]; + _0 = as FromResidual>>::from_residual(move _11) -> [return: bb6, unwind: bb90]; } bb6: { @@ -204,10 +204,10 @@ bb11: { StorageLive(_19); - _19 = copy ((_14 as Break).0: std::result::Result); + _19 = copy ((_14 as Break).0: std::result::Result); StorageLive(_21); _21 = copy _19; - _0 = as FromResidual>>::from_residual(move _21) -> [return: bb12, unwind: bb86]; + _0 = as FromResidual>>::from_residual(move _21) -> [return: bb12, unwind: bb86]; } bb12: { @@ -253,10 +253,10 @@ bb17: { StorageLive(_29); - _29 = copy ((_24 as Break).0: std::result::Result); + _29 = copy ((_24 as Break).0: std::result::Result); StorageLive(_31); _31 = copy _29; - _0 = as FromResidual>>::from_residual(move _31) -> [return: bb18, unwind: bb81]; + _0 = as FromResidual>>::from_residual(move _31) -> [return: bb18, unwind: bb81]; } bb18: { @@ -302,10 +302,10 @@ bb23: { StorageLive(_39); - _39 = copy ((_34 as Break).0: std::result::Result); + _39 = copy ((_34 as Break).0: std::result::Result); StorageLive(_41); _41 = copy _39; - _0 = as FromResidual>>::from_residual(move _41) -> [return: bb24, unwind: bb75]; + _0 = as FromResidual>>::from_residual(move _41) -> [return: bb24, unwind: bb75]; } bb24: { @@ -350,10 +350,10 @@ bb29: { StorageLive(_49); - _49 = copy ((_44 as Break).0: std::result::Result); + _49 = copy ((_44 as Break).0: std::result::Result); StorageLive(_51); _51 = copy _49; - _0 = as FromResidual>>::from_residual(move _51) -> [return: bb30, unwind: bb68]; + _0 = as FromResidual>>::from_residual(move _51) -> [return: bb30, unwind: bb68]; } bb30: { diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir index 70f602aa236e8..de33a7ebeac3e 100644 --- a/tests/mir-opt/building/issue_101867.main.built.after.mir +++ b/tests/mir-opt/building/issue_101867.main.built.after.mir @@ -8,14 +8,13 @@ fn main() -> () { let mut _0: (); let _1: std::option::Option as UserTypeProjection { base: UserType(0), projs: [] }; let mut _2: !; - let _3: (); - let mut _4: !; - let mut _6: isize; + let _3: !; + let mut _5: isize; scope 1 { debug x => _1; - let _5: u8; + let _4: u8; scope 2 { - debug y => _5; + debug y => _4; } } @@ -25,18 +24,16 @@ fn main() -> () { FakeRead(ForLet(None), _1); AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); PlaceMention(_1); - _6 = discriminant(_1); - switchInt(move _6) -> [1: bb4, otherwise: bb3]; + _5 = discriminant(_1); + switchInt(move _5) -> [1: bb4, otherwise: bb3]; } bb1: { StorageLive(_3); - StorageLive(_4); - _4 = std::rt::begin_panic::<&str>(const "explicit panic") -> [return: bb2, unwind: bb8]; + _3 = std::rt::begin_panic::<&str>(const "explicit panic") -> [return: bb2, unwind: bb8]; } bb2: { - StorageDead(_4); StorageDead(_3); unreachable; } @@ -54,10 +51,10 @@ fn main() -> () { } bb6: { - StorageLive(_5); - _5 = copy ((_1 as Some).0: u8); + StorageLive(_4); + _4 = copy ((_1 as Some).0: u8); _0 = const (); - StorageDead(_5); + StorageDead(_4); StorageDead(_1); return; } diff --git a/tests/mir-opt/coroutine/coroutine_tiny.main-{closure#0}.StateTransform.diff b/tests/mir-opt/coroutine/coroutine_tiny.main-{closure#0}.StateTransform.diff index b84e55cac4616..dc8d51f618dbd 100644 --- a/tests/mir-opt/coroutine/coroutine_tiny.main-{closure#0}.StateTransform.diff +++ b/tests/mir-opt/coroutine/coroutine_tiny.main-{closure#0}.StateTransform.diff @@ -1,10 +1,10 @@ - // MIR for `main::{closure#0}` before StateTransform + // MIR for `main::{closure#0}` after StateTransform -- fn main::{closure#0}(_1: {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}, _2: u8) -> () +- fn main::{closure#0}(_1: {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}, _2: u8) -> ! - yields () - { -+ fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}>, _2: u8) -> CoroutineState<(), ()> { ++ fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}>, _2: u8) -> CoroutineState<(), !> { + coroutine layout { + field _s0: HasDrop; + variant_fields = { @@ -16,68 +16,63 @@ + storage_conflicts = BitMatrix(1x1) {(_s0, _s0)} + } debug _x => _2; -- let mut _0: (); +- let mut _0: !; + coroutine debug _d => _s0; -+ let mut _0: std::ops::CoroutineState<(), ()>; ++ let mut _0: std::ops::CoroutineState<(), !>; let _3: HasDrop; - let mut _4: !; - let mut _5: (); - let _6: u8; - let mut _7: (); - let _8: (); -+ let mut _9: (); -+ let mut _10: u32; -+ let mut _11: &mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}; + let mut _4: (); + let _5: u8; + let mut _6: (); + let _7: (); ++ let mut _8: !; ++ let mut _9: u32; ++ let mut _10: &mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}; scope 1 { - debug _d => _3; -+ debug _d => (((*_11) as variant#3).0: HasDrop); ++ debug _d => (((*_10) as variant#3).0: HasDrop); } bb0: { - StorageLive(_3); - _3 = HasDrop; -- StorageLive(_4); - goto -> bb1; -+ _11 = copy (_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}); -+ _10 = discriminant((*_11)); -+ switchInt(move _10) -> [0: bb6, 3: bb4, otherwise: bb5]; ++ _10 = copy (_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:20:5: 20:13}); ++ _9 = discriminant((*_10)); ++ switchInt(move _9) -> [0: bb6, 3: bb4, otherwise: bb5]; } bb1: { + StorageLive(_5); StorageLive(_6); - StorageLive(_7); - _7 = (); -- _6 = yield(move _7) -> [resume: bb2, drop: bb4]; -+ _0 = CoroutineState::<(), ()>::Yielded(move _7); -+ StorageDead(_4); + _6 = (); +- _5 = yield(move _6) -> [resume: bb2, drop: bb4]; ++ _0 = CoroutineState::<(), !>::Yielded(move _6); ++ StorageDead(_5); + StorageDead(_6); -+ StorageDead(_7); -+ discriminant((*_11)) = 3; ++ discriminant((*_10)) = 3; + return; } bb2: { - StorageDead(_7); StorageDead(_6); - StorageLive(_8); - _8 = callee() -> [return: bb3, unwind unreachable]; + StorageDead(_5); + StorageLive(_7); + _7 = callee() -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); - _5 = const (); + StorageDead(_7); + _4 = const (); goto -> bb1; } bb4: { -- StorageDead(_7); - StorageDead(_6); -- StorageDead(_4); +- StorageDead(_5); - drop(_3) -> [return: bb5, unwind unreachable]; -+ StorageLive(_4); ++ StorageLive(_5); + StorageLive(_6); -+ StorageLive(_7); -+ _6 = move _2; ++ _5 = move _2; + goto -> bb2; } @@ -90,8 +85,7 @@ bb6: { - coroutine_drop; + nop; -+ (((*_11) as variant#3).0: HasDrop) = HasDrop; -+ StorageLive(_4); ++ (((*_10) as variant#3).0: HasDrop) = HasDrop; + goto -> bb1; } } diff --git a/tests/mir-opt/gvn_uninhabited.rs b/tests/mir-opt/gvn_uninhabited.rs index 78afc0efef900..106d7862471a5 100644 --- a/tests/mir-opt/gvn_uninhabited.rs +++ b/tests/mir-opt/gvn_uninhabited.rs @@ -3,8 +3,6 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //@ skip-filecheck -#![feature(never_type)] - #[derive(Copy, Clone)] pub enum E { A(!, u32), diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff index 66b1bc29877ab..8d7a32322ad93 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff @@ -10,7 +10,7 @@ let mut _5: !; let _6: !; + scope 1 (inlined panic) { -+ let mut _7: !; ++ let _7: !; + } bb0: { diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff index 68dd9530137d5..11a9ae601fb50 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff @@ -10,7 +10,7 @@ let mut _5: !; let _6: !; + scope 1 (inlined panic) { -+ let mut _7: !; ++ let _7: !; + } bb0: { diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-abort.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-abort.mir index 968334753db40..afee76707e8a4 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-abort.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-abort.mir @@ -6,12 +6,12 @@ fn test() -> Option> { let mut _2: std::boxed::Box>; let mut _3: std::boxed::Box>; let mut _4: u32; - let mut _5: std::ops::ControlFlow, u32>; + let mut _5: std::ops::ControlFlow, u32>; let mut _6: std::option::Option; let mut _7: isize; - let _8: std::option::Option; + let _8: std::option::Option; let mut _9: !; - let mut _10: std::option::Option; + let mut _10: std::option::Option; let _11: u32; scope 1 { debug residual => _8; @@ -63,10 +63,10 @@ fn test() -> Option> { bb5: { StorageLive(_8); - _8 = copy ((_5 as Break).0: std::option::Option); + _8 = copy ((_5 as Break).0: std::option::Option); StorageLive(_10); _10 = copy _8; - _0 = > as FromResidual>>::from_residual(move _10) -> [return: bb6, unwind: bb13]; + _0 = > as FromResidual>>::from_residual(move _10) -> [return: bb6, unwind: bb13]; } bb6: { diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-unwind.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-unwind.mir index 1fc75018c8625..d44db1eb1c8c6 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-unwind.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.after.panic-unwind.mir @@ -6,12 +6,12 @@ fn test() -> Option> { let mut _2: std::boxed::Box>; let mut _3: std::boxed::Box>; let mut _4: u32; - let mut _5: std::ops::ControlFlow, u32>; + let mut _5: std::ops::ControlFlow, u32>; let mut _6: std::option::Option; let mut _7: isize; - let _8: std::option::Option; + let _8: std::option::Option; let mut _9: !; - let mut _10: std::option::Option; + let mut _10: std::option::Option; let _11: u32; scope 1 { debug residual => _8; @@ -63,10 +63,10 @@ fn test() -> Option> { bb5: { StorageLive(_8); - _8 = copy ((_5 as Break).0: std::option::Option); + _8 = copy ((_5 as Break).0: std::option::Option); StorageLive(_10); _10 = copy _8; - _0 = > as FromResidual>>::from_residual(move _10) -> [return: bb6, unwind: bb13]; + _0 = > as FromResidual>>::from_residual(move _10) -> [return: bb6, unwind: bb13]; } bb6: { diff --git a/tests/mir-opt/issue_72181_1.main.built.after.mir b/tests/mir-opt/issue_72181_1.main.built.after.mir index 977d48d6d25f0..07763e0e176ec 100644 --- a/tests/mir-opt/issue_72181_1.main.built.after.mir +++ b/tests/mir-opt/issue_72181_1.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty(Void), max_universe: U0, var_kinds: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void -| 1: user_ty: Canonical { value: Ty(Void), max_universe: U0, var_kinds: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void +| 0: user_ty: Canonical { value: Ty(Void), max_universe: U0, var_kinds: [] }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void +| 1: user_ty: Canonical { value: Ty(Void), max_universe: U0, var_kinds: [] }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/issue_72181_1.rs b/tests/mir-opt/issue_72181_1.rs index 1e7c70c449d98..c20ae49c75bb0 100644 --- a/tests/mir-opt/issue_72181_1.rs +++ b/tests/mir-opt/issue_72181_1.rs @@ -2,7 +2,6 @@ //@ compile-flags: -Z mir-opt-level=1 // Regression test for #72181, this ICE requires `-Z mir-opt-level=1` flags. -#![feature(never_type)] #![allow(unused, invalid_value)] enum Void {} diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff index ec4a93c9a4e17..a822ca20a8e80 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff @@ -5,17 +5,17 @@ debug x => _1; let mut _0: std::result::Result; let mut _2: i32; - let mut _3: std::ops::ControlFlow, i32>; + let mut _3: std::ops::ControlFlow, i32>; let mut _4: std::result::Result; let mut _5: isize; - let _6: std::result::Result; + let _6: std::result::Result; let mut _7: !; - let mut _8: std::result::Result; + let mut _8: std::result::Result; let _9: i32; scope 1 { debug residual => _6; scope 2 { - scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { + scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { let mut _14: isize; let _15: i32; let mut _16: i32; @@ -36,7 +36,7 @@ let mut _10: isize; let _11: i32; let _12: i32; - let mut _13: std::result::Result; + let mut _13: std::result::Result; scope 6 { } scope 7 { @@ -70,7 +70,7 @@ bb3: { StorageLive(_6); - _6 = copy ((_3 as Break).0: std::result::Result); + _6 = copy ((_3 as Break).0: std::result::Result); StorageLive(_8); _8 = copy _6; StorageLive(_14); @@ -109,8 +109,8 @@ StorageLive(_12); _12 = move ((_4 as Err).0: i32); StorageLive(_13); - _13 = Result::::Err(copy _12); - _3 = ControlFlow::, i32>::Break(move _13); + _13 = Result::::Err(copy _12); + _3 = ControlFlow::, i32>::Break(move _13); StorageDead(_13); StorageDead(_12); - goto -> bb5; @@ -120,7 +120,7 @@ bb7: { StorageLive(_11); _11 = move ((_4 as Ok).0: i32); - _3 = ControlFlow::, i32>::Continue(copy _11); + _3 = ControlFlow::, i32>::Continue(copy _11); StorageDead(_11); - goto -> bb5; + goto -> bb9; diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff index ec4a93c9a4e17..a822ca20a8e80 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff @@ -5,17 +5,17 @@ debug x => _1; let mut _0: std::result::Result; let mut _2: i32; - let mut _3: std::ops::ControlFlow, i32>; + let mut _3: std::ops::ControlFlow, i32>; let mut _4: std::result::Result; let mut _5: isize; - let _6: std::result::Result; + let _6: std::result::Result; let mut _7: !; - let mut _8: std::result::Result; + let mut _8: std::result::Result; let _9: i32; scope 1 { debug residual => _6; scope 2 { - scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { + scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { let mut _14: isize; let _15: i32; let mut _16: i32; @@ -36,7 +36,7 @@ let mut _10: isize; let _11: i32; let _12: i32; - let mut _13: std::result::Result; + let mut _13: std::result::Result; scope 6 { } scope 7 { @@ -70,7 +70,7 @@ bb3: { StorageLive(_6); - _6 = copy ((_3 as Break).0: std::result::Result); + _6 = copy ((_3 as Break).0: std::result::Result); StorageLive(_8); _8 = copy _6; StorageLive(_14); @@ -109,8 +109,8 @@ StorageLive(_12); _12 = move ((_4 as Err).0: i32); StorageLive(_13); - _13 = Result::::Err(copy _12); - _3 = ControlFlow::, i32>::Break(move _13); + _13 = Result::::Err(copy _12); + _3 = ControlFlow::, i32>::Break(move _13); StorageDead(_13); StorageDead(_12); - goto -> bb5; @@ -120,7 +120,7 @@ bb7: { StorageLive(_11); _11 = move ((_4 as Ok).0: i32); - _3 = ControlFlow::, i32>::Continue(copy _11); + _3 = ControlFlow::, i32>::Continue(copy _11); StorageDead(_11); - goto -> bb5; + goto -> bb9; diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs index e4942a5c173fd..b480bc097b99f 100644 --- a/tests/mir-opt/jump_threading.rs +++ b/tests/mir-opt/jump_threading.rs @@ -59,7 +59,7 @@ fn identity(x: Result) -> Result { // CHECK: _0 = Result::::Ok( // CHECK: goto -> bb4; // CHECK: bb3: { - // CHECK: {{_.*}} = copy (([[controlflow]] as Break).0: std::result::Result); + // CHECK: {{_.*}} = copy (([[controlflow]] as Break).0: std::result::Result); // CHECK: _0 = Result::::Err( // CHECK: goto -> bb4; // CHECK: bb4: { @@ -68,11 +68,11 @@ fn identity(x: Result) -> Result { // CHECK: switchInt(move _5) -> [0: bb2, 1: bb3, otherwise: bb1]; // CHECK: bb6: { // CHECK: {{_.*}} = move (([[x]] as Err).0: i32); - // CHECK: [[controlflow]] = ControlFlow::, i32>::Break( + // CHECK: [[controlflow]] = ControlFlow::, i32>::Break( // CHECK: goto -> bb8; // CHECK: bb7: { // CHECK: {{_.*}} = move (([[x]] as Ok).0: i32); - // CHECK: [[controlflow]] = ControlFlow::, i32>::Continue( + // CHECK: [[controlflow]] = ControlFlow::, i32>::Continue( // CHECK: goto -> bb9; // CHECK: bb8: { // CHECK: goto -> bb3; diff --git a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.panic-abort.diff b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.panic-abort.diff index 2b715ac1d635b..a4be4617b9370 100644 --- a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.panic-abort.diff +++ b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.panic-abort.diff @@ -3,13 +3,11 @@ fn unreachable() -> ! { let mut _0: !; - let _1: (); - let mut _2: !; + let _1: !; bb0: { StorageLive(_1); - StorageLive(_2); -- _2 = std::intrinsics::unreachable() -> unwind unreachable; +- _1 = std::intrinsics::unreachable() -> unwind unreachable; + unreachable; } } diff --git a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.panic-unwind.diff b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.panic-unwind.diff index 2b715ac1d635b..a4be4617b9370 100644 --- a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.panic-unwind.diff +++ b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.panic-unwind.diff @@ -3,13 +3,11 @@ fn unreachable() -> ! { let mut _0: !; - let _1: (); - let mut _2: !; + let _1: !; bb0: { StorageLive(_1); - StorageLive(_2); -- _2 = std::intrinsics::unreachable() -> unwind unreachable; +- _1 = std::intrinsics::unreachable() -> unwind unreachable; + unreachable; } } diff --git a/tests/mir-opt/pre-codegen/option_bubble_debug.option_traits.runtime-optimized.after.panic-abort.mir b/tests/mir-opt/pre-codegen/option_bubble_debug.option_traits.runtime-optimized.after.panic-abort.mir index 26ccbb7d89fd1..5a9f8b2cc466b 100644 --- a/tests/mir-opt/pre-codegen/option_bubble_debug.option_traits.runtime-optimized.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/option_bubble_debug.option_traits.runtime-optimized.after.panic-abort.mir @@ -3,12 +3,12 @@ fn option_traits(_1: Option) -> Option { debug x => _1; let mut _0: std::option::Option; - let mut _2: std::ops::ControlFlow, u32>; + let mut _2: std::ops::ControlFlow, u32>; let mut _3: isize; let _4: u32; let mut _5: u32; scope 1 { - debug residual => const Option::::None; + debug residual => const Option::::None; scope 2 { } } @@ -34,7 +34,7 @@ fn option_traits(_1: Option) -> Option { } bb3: { - _0 = ops::try_trait::residual_into_try_type::, u32>(const Option::::None) -> [return: bb4, unwind unreachable]; + _0 = ops::try_trait::residual_into_try_type::, u32>(const Option::::None) -> [return: bb4, unwind unreachable]; } bb4: { diff --git a/tests/mir-opt/pre-codegen/option_bubble_debug.option_traits.runtime-optimized.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/option_bubble_debug.option_traits.runtime-optimized.after.panic-unwind.mir index c9cb25b647ef5..8d272ac3485f1 100644 --- a/tests/mir-opt/pre-codegen/option_bubble_debug.option_traits.runtime-optimized.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/option_bubble_debug.option_traits.runtime-optimized.after.panic-unwind.mir @@ -3,12 +3,12 @@ fn option_traits(_1: Option) -> Option { debug x => _1; let mut _0: std::option::Option; - let mut _2: std::ops::ControlFlow, u32>; + let mut _2: std::ops::ControlFlow, u32>; let mut _3: isize; let _4: u32; let mut _5: u32; scope 1 { - debug residual => const Option::::None; + debug residual => const Option::::None; scope 2 { } } @@ -34,7 +34,7 @@ fn option_traits(_1: Option) -> Option { } bb3: { - _0 = ops::try_trait::residual_into_try_type::, u32>(const Option::::None) -> [return: bb4, unwind continue]; + _0 = ops::try_trait::residual_into_try_type::, u32>(const Option::::None) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.runtime-optimized.after.mir index 26648a3173d67..3c559614e9863 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.map_via_question_mark.runtime-optimized.after.mir @@ -3,14 +3,14 @@ fn map_via_question_mark(_1: Option) -> Option { debug x => _1; let mut _0: std::option::Option; - let mut _4: std::option::Option; - let mut _7: std::ops::ControlFlow, i32>; + let mut _4: std::option::Option; + let mut _7: std::ops::ControlFlow, i32>; let _8: i32; let mut _9: i32; scope 1 { - debug residual => const Option::::None; + debug residual => const Option::::None; scope 2 { - scope 7 (inlined as FromResidual>>::from_residual) { + scope 7 (inlined as FromResidual>>::from_residual) { let mut _3: isize; let mut _5: bool; } @@ -54,7 +54,7 @@ fn map_via_question_mark(_1: Option) -> Option { bb2: { StorageLive(_6); _6 = copy ((_1 as Some).0: i32); - _7 = ControlFlow::, i32>::Continue(copy _6); + _7 = ControlFlow::, i32>::Continue(copy _6); StorageDead(_6); StorageDead(_2); _8 = copy ((_7 as Continue).0: i32); diff --git a/tests/mir-opt/pre-codegen/simple_option_map.rs b/tests/mir-opt/pre-codegen/simple_option_map.rs index 8f3ea6f0ae280..42d42bac835dd 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.rs +++ b/tests/mir-opt/pre-codegen/simple_option_map.rs @@ -29,7 +29,7 @@ pub fn map_via_question_mark(x: Option) -> Option { // CHECK-LABEL: fn map_via_question_mark // CHECK: [[INNER:_.+]] = copy ((_1 as Some).0: i32); - // CHECK: [[TEMP1:_.+]] = ControlFlow::, i32>::Continue(copy [[INNER]]); + // CHECK: [[TEMP1:_.+]] = ControlFlow::, i32>::Continue(copy [[INNER]]); // CHECK: [[TEMP2:_.+]] = copy (([[TEMP1]] as Continue).0: i32); // CHECK: [[SUCC:_.+]] = Add({{copy|move}} [[TEMP2]], const 1_i32); // CHECK: _0 = Option::::Some({{copy|move}} [[SUCC]]); diff --git a/tests/mir-opt/remove_never_const.rs b/tests/mir-opt/remove_never_const.rs index ab7f369e68029..4c5470f568125 100644 --- a/tests/mir-opt/remove_never_const.rs +++ b/tests/mir-opt/remove_never_const.rs @@ -3,8 +3,6 @@ // consts in codegen. We also have tests for this that catches the error, see // tests/ui/consts/const-eval/index-out-of-bounds-never-type.rs. -#![feature(never_type)] - struct PrintName(T); impl PrintName { diff --git a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff index 5bc79f76b3706..be29296044837 100644 --- a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff +++ b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff @@ -4,14 +4,14 @@ fn identity(_1: Result) -> Result { debug x => _1; let mut _0: std::result::Result; - let mut _2: std::ops::ControlFlow, i32>; + let mut _2: std::ops::ControlFlow, i32>; let mut _3: isize; - let _4: std::result::Result; + let _4: std::result::Result; let _5: i32; scope 1 { debug residual => _4; scope 2 { - scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { + scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { let mut _10: isize; let _11: i32; let mut _12: bool; @@ -31,7 +31,7 @@ let mut _6: isize; let _7: i32; let _8: i32; - let mut _9: std::result::Result; + let mut _9: std::result::Result; scope 6 { } scope 7 { @@ -58,7 +58,7 @@ bb3: { StorageLive(_4); - _4 = copy ((_2 as Break).0: std::result::Result); + _4 = copy ((_2 as Break).0: std::result::Result); StorageLive(_10); StorageLive(_12); _10 = discriminant(_4); @@ -85,8 +85,8 @@ StorageLive(_8); _8 = copy ((_1 as Err).0: i32); StorageLive(_9); - _9 = Result::::Err(copy _8); - _2 = ControlFlow::, i32>::Break(move _9); + _9 = Result::::Err(copy _8); + _2 = ControlFlow::, i32>::Break(move _9); StorageDead(_9); StorageDead(_8); - goto -> bb4; @@ -96,7 +96,7 @@ bb6: { StorageLive(_7); _7 = copy ((_1 as Ok).0: i32); - _2 = ControlFlow::, i32>::Continue(copy _7); + _2 = ControlFlow::, i32>::Continue(copy _7); StorageDead(_7); - goto -> bb4; + goto -> bb8; diff --git a/tests/mir-opt/ssa_unreachable_116212.rs b/tests/mir-opt/ssa_unreachable_116212.rs index f8550556f54d0..14a2195275f7b 100644 --- a/tests/mir-opt/ssa_unreachable_116212.rs +++ b/tests/mir-opt/ssa_unreachable_116212.rs @@ -1,8 +1,6 @@ //@ skip-filecheck // Regression test for issue #116212. -#![feature(never_type)] - use std::mem::MaybeUninit; struct Foo { diff --git a/tests/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir b/tests/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir index 02e1f4be15e2e..dced13df2ea38 100644 --- a/tests/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir +++ b/tests/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir @@ -4,7 +4,7 @@ fn process_never(_1: *const !) -> () { debug input => _1; let mut _0: (); scope 1 { - debug _input => const (); + debug _input => const ZeroSized: !; } bb0: { diff --git a/tests/mir-opt/uninhabited_enum.rs b/tests/mir-opt/uninhabited_enum.rs index 2ef76449e3cc3..4dc05eb8edd99 100644 --- a/tests/mir-opt/uninhabited_enum.rs +++ b/tests/mir-opt/uninhabited_enum.rs @@ -2,7 +2,6 @@ // // check that we mark blocks with `!` locals as unreachable. // (and currently don't do the same for other uninhabited types) -#![feature(never_type)] #[derive(Copy, Clone)] pub enum Void {} diff --git a/tests/mir-opt/uninhabited_not_read.rs b/tests/mir-opt/uninhabited_not_read.rs index c1598d0301f67..526849cfc612e 100644 --- a/tests/mir-opt/uninhabited_not_read.rs +++ b/tests/mir-opt/uninhabited_not_read.rs @@ -5,8 +5,6 @@ // This would introduce a `! -> ()` coercion which would // be UB if we didn't disallow this explicitly. -#![feature(never_type)] - // EMIT_MIR uninhabited_not_read.main.SimplifyLocals-final.after.mir fn main() { // With a type annotation diff --git a/tests/pretty/never-pattern.pp b/tests/pretty/never-pattern.pp index bb95a1ed442a4..133a636ecdc40 100644 --- a/tests/pretty/never-pattern.pp +++ b/tests/pretty/never-pattern.pp @@ -6,7 +6,6 @@ #![allow(incomplete_features)] #![feature(never_patterns)] -#![feature(never_type)] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/never-pattern.rs b/tests/pretty/never-pattern.rs index fe170bafc666a..ea9aaaa10514f 100644 --- a/tests/pretty/never-pattern.rs +++ b/tests/pretty/never-pattern.rs @@ -4,7 +4,6 @@ #![allow(incomplete_features)] #![feature(never_patterns)] -#![feature(never_type)] fn f(x: Result) { _ = match x { diff --git a/tests/rustdoc-html/intra-doc/prim-associated-traits.rs b/tests/rustdoc-html/intra-doc/prim-associated-traits.rs index 41a3931222fc1..12fe8b9d41bfd 100644 --- a/tests/rustdoc-html/intra-doc/prim-associated-traits.rs +++ b/tests/rustdoc-html/intra-doc/prim-associated-traits.rs @@ -1,4 +1,3 @@ -#![feature(never_type)] use std::str::FromStr; //@ has 'prim_associated_traits/struct.Number.html' '//a[@href="{{channel}}/std/primitive.f64.html#method.from_str"]' 'f64::from_str()' diff --git a/tests/rustdoc-js/hof.rs b/tests/rustdoc-js/hof.rs index e4d550250e8ad..375d12e1adf78 100644 --- a/tests/rustdoc-js/hof.rs +++ b/tests/rustdoc-js/hof.rs @@ -1,5 +1,3 @@ -#![feature(never_type)] - pub struct First(T); pub struct Second(T); pub struct Third(T); diff --git a/tests/rustdoc-js/never-search.rs b/tests/rustdoc-js/never-search.rs index 800f9ead8b35f..57175bc1a2a6d 100644 --- a/tests/rustdoc-js/never-search.rs +++ b/tests/rustdoc-js/never-search.rs @@ -1,5 +1,3 @@ -#![feature(never_type)] - #[allow(nonstandard_style)] pub struct never; diff --git a/tests/rustdoc-json/blanket_impls.rs b/tests/rustdoc-json/blanket_impls.rs index 2def2c2c5a956..e15848cdaddbb 100644 --- a/tests/rustdoc-json/blanket_impls.rs +++ b/tests/rustdoc-json/blanket_impls.rs @@ -3,5 +3,5 @@ #![no_std] //@ jq_is '[.index[] | select(.name == "Error").inner | has("assoc_type")]' '[true, true]' -//@ jq_has '.index[] | select(.name == "Error").inner.assoc_type.type.resolved_path.path' '"Infallible"' +//@ jq_has '.index[] | select(.name == "Error").inner.assoc_type.type.primitive' '"never"' pub struct ForBlanketTryFromImpl; diff --git a/tests/rustdoc-json/primitives/primitive_type.rs b/tests/rustdoc-json/primitives/primitive_type.rs index a0d34218b805d..ff9bdc0c173bf 100644 --- a/tests/rustdoc-json/primitives/primitive_type.rs +++ b/tests/rustdoc-json/primitives/primitive_type.rs @@ -1,5 +1,3 @@ -#![feature(never_type)] - //@ is "$.index[?(@.name=='PrimNever')].visibility" \"public\" //@ is "$.index[?(@.name=='PrimNever')].inner.type_alias.type.primitive" \"never\" pub type PrimNever = !; diff --git a/tests/rustdoc-ui/lints/invalid-html-tags.rs b/tests/rustdoc-ui/lints/invalid-html-tags.rs index d0aa97c9e4074..7a244e6cc58f5 100644 --- a/tests/rustdoc-ui/lints/invalid-html-tags.rs +++ b/tests/rustdoc-ui/lints/invalid-html-tags.rs @@ -1,5 +1,6 @@ #![deny(rustdoc::invalid_html_tags)] //~^ NOTE the lint level is defined here +#![allow(rustdoc::invalid_markdown_table)] //!

💩

//~^ ERROR unclosed HTML tag `p` diff --git a/tests/rustdoc-ui/lints/invalid-html-tags.stderr b/tests/rustdoc-ui/lints/invalid-html-tags.stderr index 15b88496b7557..d0830321536dd 100644 --- a/tests/rustdoc-ui/lints/invalid-html-tags.stderr +++ b/tests/rustdoc-ui/lints/invalid-html-tags.stderr @@ -1,5 +1,5 @@ error: unclosed HTML tag `p` - --> $DIR/invalid-html-tags.rs:4:5 + --> $DIR/invalid-html-tags.rs:5:5 | LL | //!

💩

| ^^^ @@ -11,115 +11,115 @@ LL | #![deny(rustdoc::invalid_html_tags)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unclosed HTML tag `p` - --> $DIR/invalid-html-tags.rs:4:9 + --> $DIR/invalid-html-tags.rs:5:9 | LL | //!

💩

| ^^^ error: unclosed HTML tag `unknown` - --> $DIR/invalid-html-tags.rs:12:5 + --> $DIR/invalid-html-tags.rs:13:5 | LL | /// | ^^^^^^^^^ error: unclosed HTML tag `script` - --> $DIR/invalid-html-tags.rs:15:5 + --> $DIR/invalid-html-tags.rs:16:5 | LL | ///