diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index 4fc7c7475d757..ed78b6d93bcd8 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -6,6 +6,7 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc( html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/", test(attr(deny(warnings))) @@ -14,7 +15,6 @@ #![feature(array_windows)] #![feature(associated_type_defaults)] #![feature(box_patterns)] -#![feature(if_let_guard)] #![feature(macro_metavar_expr)] #![feature(negative_impls)] #![feature(never_type)] diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 422e79ca82ffd..b75c7ac302bae 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -32,11 +32,11 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(exact_size_is_empty)] -#![feature(if_let_guard)] #![feature(rustdoc_internals)] // tidy-alphabetical-end diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 915613a391374..b88868d72270a 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -454,11 +454,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) { } }; } - gate_all!( - if_let_guard, - "`if let` guards are experimental", - "you can write `if matches!(, )` instead of `if let = `" - ); gate_all!(let_chains, "`let` expressions in this position are unstable"); gate_all!( async_trait_bounds, diff --git a/compiler/rustc_ast_passes/src/lib.rs b/compiler/rustc_ast_passes/src/lib.rs index 6517fdb55bd3f..abd897d3ed2ae 100644 --- a/compiler/rustc_ast_passes/src/lib.rs +++ b/compiler/rustc_ast_passes/src/lib.rs @@ -4,9 +4,9 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(rust_logo)] #![feature(box_patterns)] -#![feature(if_let_guard)] #![feature(iter_is_partitioned)] #![feature(rustdoc_internals)] // tidy-alphabetical-end diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs index 676cb618b725b..f2e9c40a86fab 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(if_let_guard))] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(file_buffered)] -#![feature(if_let_guard)] #![feature(negative_impls)] #![feature(never_type)] #![feature(rustc_attrs)] diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 9cd4d17059a0f..edac286491814 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -5,13 +5,13 @@ #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(autodiff)] #![feature(box_patterns)] #![feature(decl_macro)] -#![feature(if_let_guard)] #![feature(proc_macro_internals)] #![feature(proc_macro_quote)] #![feature(rustdoc_internals)] diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index 5736314b96a36..2f4890641613a 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -6,13 +6,13 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(exact_size_is_empty)] #![feature(extern_types)] #![feature(file_buffered)] -#![feature(if_let_guard)] #![feature(impl_trait_in_assoc_type)] #![feature(iter_intersperse)] #![feature(rustdoc_internals)] diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index 84919645cf071..44e01eb2cc2bb 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -2,12 +2,12 @@ #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(file_buffered)] -#![feature(if_let_guard)] #![feature(negative_impls)] #![feature(rustdoc_internals)] #![feature(string_from_utf8_lossy_owned)] diff --git a/compiler/rustc_const_eval/src/lib.rs b/compiler/rustc_const_eval/src/lib.rs index bf7a79dcb20f0..1ec12cf6d4a66 100644 --- a/compiler/rustc_const_eval/src/lib.rs +++ b/compiler/rustc_const_eval/src/lib.rs @@ -1,11 +1,11 @@ // tidy-alphabetical-start #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(decl_macro)] -#![feature(if_let_guard)] #![feature(never_type)] #![feature(rustdoc_internals)] #![feature(slice_ptr_get)] diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index f8e19e5077893..525124ebf22e7 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -7,6 +7,7 @@ #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(array_windows)] @@ -16,7 +17,6 @@ #![feature(box_patterns)] #![feature(default_field_values)] #![feature(error_reporter)] -#![feature(if_let_guard)] #![feature(negative_impls)] #![feature(never_type)] #![feature(rustc_attrs)] diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs index cd744977bb323..ccf34c16347f2 100644 --- a/compiler/rustc_expand/src/lib.rs +++ b/compiler/rustc_expand/src/lib.rs @@ -1,10 +1,10 @@ // tidy-alphabetical-start #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(rust_logo)] #![feature(array_windows)] #![feature(associated_type_defaults)] -#![feature(if_let_guard)] #![feature(macro_metavar_expr)] #![feature(map_try_insert)] #![feature(proc_macro_diagnostic)] diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 820af9ac84b2c..fee2f0c2c9973 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -234,6 +234,8 @@ declare_features! ( (accepted, i128_type, "1.26.0", Some(35118)), /// Allows the use of `if let` expressions. (accepted, if_let, "1.0.0", None), + /// Allows `if let` guard in match arms. + (accepted, if_let_guard, "CURRENT_RUSTC_VERSION", Some(51114)), /// Rescoping temporaries in `if let` to align with Rust 2024. (accepted, if_let_rescope, "1.84.0", Some(124085)), /// Allows top level or-patterns (`p | q`) in `if let` and `while let`. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 6cdcf451f37e3..9f91c0a91bd87 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -530,8 +530,6 @@ declare_features! ( (incomplete, guard_patterns, "1.85.0", Some(129967)), /// Allows using `..=X` as a patterns in slices. (unstable, half_open_range_patterns_in_slices, "1.66.0", Some(67264)), - /// Allows `if let` guard in match arms. - (unstable, if_let_guard, "1.47.0", Some(51114)), /// Allows `impl Trait` to be used inside associated types (RFC 2515). (unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063)), /// Allows `impl Trait` in bindings (`let`). diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 010c6c376fe3d..11138ae21cc03 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -59,12 +59,12 @@ This API is completely unstable and subject to change. #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(coroutines)] #![feature(debug_closure_helpers)] -#![feature(if_let_guard)] #![feature(iter_from_coroutine)] #![feature(iter_intersperse)] #![feature(never_type)] diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 161f5e981d430..02c9b8f6e4dfb 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -1,9 +1,9 @@ // tidy-alphabetical-start #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(array_windows)] #![feature(box_patterns)] -#![feature(if_let_guard)] #![feature(iter_intersperse)] #![feature(never_type)] #![feature(try_blocks)] diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 4ff586a79a6ec..1f3818fc852ed 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -21,12 +21,12 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(array_windows)] #![feature(assert_matches)] #![feature(box_patterns)] -#![feature(if_let_guard)] #![feature(iter_order_by)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index 81817018cb14d..52072f429969b 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -1,6 +1,6 @@ // tidy-alphabetical-start #![allow(rustc::default_hash_types)] -#![feature(if_let_guard)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(never_type)] #![feature(proc_macro_diagnostic)] #![feature(proc_macro_span)] diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 97b67140fa2d4..702baa15f26b3 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -1,12 +1,12 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(coroutines)] #![feature(decl_macro)] #![feature(error_iter)] #![feature(file_buffered)] -#![feature(if_let_guard)] #![feature(iter_from_coroutine)] #![feature(macro_metavar_expr)] #![feature(min_specialization)] diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index cb3fdd4d3f76e..110e59c0a883e 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -28,6 +28,7 @@ #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(allocator_api)] @@ -44,7 +45,6 @@ #![feature(discriminant_kind)] #![feature(extern_types)] #![feature(file_buffered)] -#![feature(if_let_guard)] #![feature(intra_doc_pointers)] #![feature(iter_from_coroutine)] #![feature(min_specialization)] diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index 8c7003b778761..20fa2f7817846 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -3,9 +3,9 @@ // tidy-alphabetical-start #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(assert_matches)] #![feature(box_patterns)] -#![feature(if_let_guard)] #![feature(try_blocks)] // tidy-alphabetical-end diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 10dbb3437dcbf..2cd78a8ca5a61 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -1,11 +1,11 @@ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(array_windows)] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(const_type_name)] #![feature(cow_is_borrowed)] #![feature(file_buffered)] -#![feature(if_let_guard)] #![feature(impl_trait_in_assoc_type)] #![feature(map_try_insert)] #![feature(never_type)] diff --git a/compiler/rustc_monomorphize/src/lib.rs b/compiler/rustc_monomorphize/src/lib.rs index 5c66017bc6113..28bef8465dd90 100644 --- a/compiler/rustc_monomorphize/src/lib.rs +++ b/compiler/rustc_monomorphize/src/lib.rs @@ -1,7 +1,7 @@ // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(array_windows)] #![feature(file_buffered)] -#![feature(if_let_guard)] #![feature(impl_trait_in_assoc_type)] #![feature(once_cell_get_mut)] // tidy-alphabetical-end diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 3ab726d9d9d64..a4e08749a4fd8 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -4,10 +4,10 @@ #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(assert_matches)] #![feature(box_patterns)] #![feature(debug_closure_helpers)] -#![feature(if_let_guard)] #![feature(iter_intersperse)] #![feature(string_from_utf8_lossy_owned)] #![recursion_limit = "256"] diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 2a7910a6af4dd..bd04abb3535d5 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -3407,31 +3407,15 @@ impl<'a> Parser<'a> { fn parse_match_arm_guard(&mut self) -> PResult<'a, Option>> { // Used to check the `if_let_guard` feature mostly by scanning // `&&` tokens. - fn has_let_expr(expr: &Expr) -> bool { - match &expr.kind { - ExprKind::Binary(BinOp { node: BinOpKind::And, .. }, lhs, rhs) => { - let lhs_rslt = has_let_expr(lhs); - let rhs_rslt = has_let_expr(rhs); - lhs_rslt || rhs_rslt - } - ExprKind::Let(..) => true, - _ => false, - } - } if !self.eat_keyword(exp!(If)) { // No match arm guard present. return Ok(None); } - let if_span = self.prev_token.span; let mut cond = self.parse_match_guard_condition()?; CondChecker::new(self, LetChainsPolicy::AlwaysAllowed).visit_expr(&mut cond); - if has_let_expr(&cond) { - let span = if_span.to(cond.span); - self.psess.gated_spans.gate(sym::if_let_guard, span); - } Ok(Some(cond)) } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 9ba70abd4d933..d4e7620df5438 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -10,11 +10,11 @@ #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(box_patterns)] -#![feature(if_let_guard)] #![feature(iter_intersperse)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 22ca8accf9fde..0ec15405885b3 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -17,13 +17,13 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(array_windows)] #![feature(cfg_match)] #![feature(core_io_borrowed_buf)] #![feature(hash_set_entry)] -#![feature(if_let_guard)] #![feature(map_try_insert)] #![feature(negative_impls)] #![feature(read_buf)] diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 67328defe36b5..1d93953addb65 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -14,13 +14,13 @@ #![allow(internal_features)] #![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::untranslatable_diagnostic)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(associated_type_defaults)] #![feature(box_patterns)] #![feature(cfg_version)] -#![feature(if_let_guard)] #![feature(iter_intersperse)] #![feature(iterator_try_reduce)] #![feature(never_type)] diff --git a/compiler/rustc_ty_utils/src/lib.rs b/compiler/rustc_ty_utils/src/lib.rs index 929cc074bdac7..0125b66ab0e6d 100644 --- a/compiler/rustc_ty_utils/src/lib.rs +++ b/compiler/rustc_ty_utils/src/lib.rs @@ -6,12 +6,12 @@ // tidy-alphabetical-start #![allow(internal_features)] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(rust_logo)] #![feature(assert_matches)] #![feature(associated_type_defaults)] #![feature(box_patterns)] -#![feature(if_let_guard)] #![feature(iterator_try_collect)] #![feature(never_type)] #![feature(rustdoc_internals)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index e605d7e0d7844..9d58e59aa5bba 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -95,6 +95,7 @@ // // Library features: // tidy-alphabetical-start +#![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(array_ptr_get)] #![feature(asm_experimental_arch)] #![feature(bigint_helper_methods)] @@ -143,6 +144,7 @@ #![feature(cfg_ub_checks)] #![feature(const_precise_live_drops)] #![feature(const_trait_impl)] +#![feature(core_float_math)] #![feature(decl_macro)] #![feature(deprecated_suggestion)] #![feature(doc_cfg)] @@ -154,7 +156,6 @@ #![feature(freeze_impls)] #![feature(fundamental)] #![feature(generic_arg_infer)] -#![feature(if_let_guard)] #![feature(intra_doc_pointers)] #![feature(intrinsics)] #![feature(lang_items)] @@ -182,6 +183,7 @@ #![feature(transparent_unions)] #![feature(try_blocks)] #![feature(unboxed_closures)] +#![feature(unsigned_signed_diff)] #![feature(unsized_fn_params)] #![feature(with_negative_coherence)] // tidy-alphabetical-end diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index ef41b47384d61..3dc5e9ff2f6fb 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -268,6 +268,7 @@ all(target_vendor = "fortanix", target_env = "sgx"), feature(slice_index_methods, coerce_unsized, sgx_platform) )] +#![cfg_attr(bootstrap, feature(if_let_guard))] #![cfg_attr(any(windows, target_os = "uefi"), feature(round_char_boundary))] #![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))] #![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))] @@ -300,11 +301,11 @@ #![feature(f16)] #![feature(ffi_const)] #![feature(formatting_options)] -#![feature(if_let_guard)] #![feature(intra_doc_pointers)] #![feature(iter_advance_by)] #![feature(iter_next_chunk)] #![feature(lang_items)] +#![feature(let_chains)] #![feature(link_cfg)] #![feature(linkage)] #![feature(macro_metavar_expr_concat)] @@ -325,7 +326,6 @@ #![feature(try_blocks)] #![feature(try_trait_v2)] #![feature(type_alias_impl_trait)] -#![feature(unsigned_signed_diff)] // tidy-alphabetical-end // // Library features (core): @@ -373,6 +373,7 @@ #![feature(sync_unsafe_cell)] #![feature(temporary_niche_types)] #![feature(ub_checks)] +#![feature(unsigned_signed_diff)] #![feature(used_with_arg)] // tidy-alphabetical-end // @@ -719,6 +720,7 @@ pub use core::todo; // Re-export built-in macros defined through core. #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[allow(deprecated)] +#[cfg_attr(bootstrap, allow(deprecated_in_future))] pub use core::{ assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args, env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax, diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 001668c54a745..7fb2f3b79c861 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -1,3 +1,4 @@ +#![cfg_attr(bootstrap, feature(if_let_guard))] #![doc( html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/" @@ -8,7 +9,6 @@ #![feature(debug_closure_helpers)] #![feature(file_buffered)] #![feature(format_args_nl)] -#![feature(if_let_guard)] #![feature(impl_trait_in_assoc_type)] #![feature(iter_intersperse)] #![feature(never_type)] diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index ff028713bf049..d73c73b7fa722 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -1,9 +1,9 @@ +#![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(array_windows)] #![feature(box_patterns)] #![feature(macro_metavar_expr_concat)] #![feature(f128)] #![feature(f16)] -#![feature(if_let_guard)] #![feature(iter_intersperse)] #![feature(iter_partition_in_place)] #![feature(never_type)] diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 4fb608a64828a..35223a5268b84 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -1,5 +1,5 @@ +#![cfg_attr(bootstrap, feature(if_let_guard))] #![feature(box_patterns)] -#![feature(if_let_guard)] #![feature(macro_metavar_expr)] #![feature(never_type)] #![feature(rustc_private)] diff --git a/src/tools/clippy/tests/ui/redundant_guards.fixed b/src/tools/clippy/tests/ui/redundant_guards.fixed index 9dd9d341db2ef..f433d8263023a 100644 --- a/src/tools/clippy/tests/ui/redundant_guards.fixed +++ b/src/tools/clippy/tests/ui/redundant_guards.fixed @@ -1,5 +1,4 @@ //@aux-build:proc_macros.rs -#![feature(if_let_guard)] #![allow(clippy::no_effect, unused, clippy::single_match, invalid_nan_comparisons)] #![warn(clippy::redundant_guards)] diff --git a/src/tools/clippy/tests/ui/redundant_guards.rs b/src/tools/clippy/tests/ui/redundant_guards.rs index e9950d3bbd1d2..02115af75ed06 100644 --- a/src/tools/clippy/tests/ui/redundant_guards.rs +++ b/src/tools/clippy/tests/ui/redundant_guards.rs @@ -1,5 +1,4 @@ //@aux-build:proc_macros.rs -#![feature(if_let_guard)] #![allow(clippy::no_effect, unused, clippy::single_match, invalid_nan_comparisons)] #![warn(clippy::redundant_guards)] diff --git a/src/tools/clippy/tests/ui/redundant_guards.stderr b/src/tools/clippy/tests/ui/redundant_guards.stderr index cb7b9b119e20f..c889d5a5697d9 100644 --- a/src/tools/clippy/tests/ui/redundant_guards.stderr +++ b/src/tools/clippy/tests/ui/redundant_guards.stderr @@ -1,5 +1,5 @@ error: redundant guard - --> tests/ui/redundant_guards.rs:22:14 + --> tests/ui/redundant_guards.rs:21:14 | LL | x if x == 0.0 => todo!(), | ^^^^^^^^ @@ -13,7 +13,7 @@ LL + 0.0 => todo!(), | error: redundant guard - --> tests/ui/redundant_guards.rs:29:14 + --> tests/ui/redundant_guards.rs:28:14 | LL | x if x == FloatWrapper(0.0) => todo!(), | ^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL + FloatWrapper(0.0) => todo!(), | error: redundant guard - --> tests/ui/redundant_guards.rs:45:20 + --> tests/ui/redundant_guards.rs:44:20 | LL | C(x, y) if let 1 = y => .., | ^^^^^^^^^ @@ -37,7 +37,7 @@ LL + C(x, 1) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:52:20 + --> tests/ui/redundant_guards.rs:51:20 | LL | Some(x) if matches!(x, Some(1) if true) => .., | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL + Some(Some(1)) if true => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:54:20 + --> tests/ui/redundant_guards.rs:53:20 | LL | Some(x) if matches!(x, Some(1)) => { | ^^^^^^^^^^^^^^^^^^^^ @@ -61,7 +61,7 @@ LL + Some(Some(1)) => { | error: redundant guard - --> tests/ui/redundant_guards.rs:59:20 + --> tests/ui/redundant_guards.rs:58:20 | LL | Some(x) if let Some(1) = x => .., | ^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL + Some(Some(1)) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:61:20 + --> tests/ui/redundant_guards.rs:60:20 | LL | Some(x) if x == Some(2) => .., | ^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + Some(Some(2)) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:63:20 + --> tests/ui/redundant_guards.rs:62:20 | LL | Some(x) if Some(2) == x => .., | ^^^^^^^^^^^^ @@ -97,7 +97,7 @@ LL + Some(Some(2)) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:89:20 + --> tests/ui/redundant_guards.rs:88:20 | LL | B { e } if matches!(e, Some(A(2))) => .., | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL + B { e: Some(A(2)) } => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:127:20 + --> tests/ui/redundant_guards.rs:126:20 | LL | E::A(y) if y == "not from an or pattern" => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL + E::A("not from an or pattern") => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:135:14 + --> tests/ui/redundant_guards.rs:134:14 | LL | x if matches!(x, Some(0)) => .., | ^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL + Some(0) => .., | error: redundant guard - --> tests/ui/redundant_guards.rs:143:14 + --> tests/ui/redundant_guards.rs:142:14 | LL | i if i == -1 => {}, | ^^^^^^^ @@ -145,7 +145,7 @@ LL + -1 => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:145:14 + --> tests/ui/redundant_guards.rs:144:14 | LL | i if i == 1 => {}, | ^^^^^^ @@ -157,7 +157,7 @@ LL + 1 => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:208:28 + --> tests/ui/redundant_guards.rs:207:28 | LL | Some(ref x) if x == &1 => {}, | ^^^^^^^ @@ -169,7 +169,7 @@ LL + Some(1) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:210:28 + --> tests/ui/redundant_guards.rs:209:28 | LL | Some(ref x) if &1 == x => {}, | ^^^^^^^ @@ -181,7 +181,7 @@ LL + Some(1) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:212:28 + --> tests/ui/redundant_guards.rs:211:28 | LL | Some(ref x) if let &2 = x => {}, | ^^^^^^^^^^ @@ -193,7 +193,7 @@ LL + Some(2) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:214:28 + --> tests/ui/redundant_guards.rs:213:28 | LL | Some(ref x) if matches!(x, &3) => {}, | ^^^^^^^^^^^^^^^ @@ -205,7 +205,7 @@ LL + Some(3) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:235:32 + --> tests/ui/redundant_guards.rs:234:32 | LL | B { ref c, .. } if c == &1 => {}, | ^^^^^^^ @@ -217,7 +217,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:237:32 + --> tests/ui/redundant_guards.rs:236:32 | LL | B { ref c, .. } if &1 == c => {}, | ^^^^^^^ @@ -229,7 +229,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:239:32 + --> tests/ui/redundant_guards.rs:238:32 | LL | B { ref c, .. } if let &1 = c => {}, | ^^^^^^^^^^ @@ -241,7 +241,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:241:32 + --> tests/ui/redundant_guards.rs:240:32 | LL | B { ref c, .. } if matches!(c, &1) => {}, | ^^^^^^^^^^^^^^^ @@ -253,7 +253,7 @@ LL + B { c: 1, .. } => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:252:26 + --> tests/ui/redundant_guards.rs:251:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -265,7 +265,7 @@ LL + Some(Some("")) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:264:26 + --> tests/ui/redundant_guards.rs:263:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -277,7 +277,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:270:26 + --> tests/ui/redundant_guards.rs:269:26 | LL | Some(Some(x)) if x.is_empty() => {}, | ^^^^^^^^^^^^ @@ -289,7 +289,7 @@ LL + Some(Some([])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:282:26 + --> tests/ui/redundant_guards.rs:281:26 | LL | Some(Some(x)) if x.starts_with(&[]) => {}, | ^^^^^^^^^^^^^^^^^^ @@ -301,7 +301,7 @@ LL + Some(Some([..])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:288:26 + --> tests/ui/redundant_guards.rs:287:26 | LL | Some(Some(x)) if x.starts_with(&[1]) => {}, | ^^^^^^^^^^^^^^^^^^^ @@ -313,7 +313,7 @@ LL + Some(Some([1, ..])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:294:26 + --> tests/ui/redundant_guards.rs:293:26 | LL | Some(Some(x)) if x.starts_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^^^ @@ -325,7 +325,7 @@ LL + Some(Some([1, 2, ..])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:300:26 + --> tests/ui/redundant_guards.rs:299:26 | LL | Some(Some(x)) if x.ends_with(&[1, 2]) => {}, | ^^^^^^^^^^^^^^^^^^^^ @@ -337,7 +337,7 @@ LL + Some(Some([.., 1, 2])) => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:323:18 + --> tests/ui/redundant_guards.rs:322:18 | LL | y if y.is_empty() => {}, | ^^^^^^^^^^^^ @@ -349,7 +349,7 @@ LL + "" => {}, | error: redundant guard - --> tests/ui/redundant_guards.rs:342:22 + --> tests/ui/redundant_guards.rs:341:22 | LL | y if y.is_empty() => {}, | ^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/redundant_pattern_matching_option.fixed b/src/tools/clippy/tests/ui/redundant_pattern_matching_option.fixed index dc9d6491691f3..376b120dcc260 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_option.fixed +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_option.fixed @@ -1,4 +1,3 @@ -#![feature(if_let_guard)] #![warn(clippy::redundant_pattern_matching)] #![allow( clippy::needless_bool, diff --git a/src/tools/clippy/tests/ui/redundant_pattern_matching_option.rs b/src/tools/clippy/tests/ui/redundant_pattern_matching_option.rs index 2e9714ad8e75f..83f9f284df733 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_option.rs +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_option.rs @@ -1,4 +1,3 @@ -#![feature(if_let_guard)] #![warn(clippy::redundant_pattern_matching)] #![allow( clippy::needless_bool, diff --git a/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr b/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr index e5a6598898aa1..1998278fa9455 100644 --- a/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr +++ b/src/tools/clippy/tests/ui/redundant_pattern_matching_option.stderr @@ -1,5 +1,5 @@ error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:12:5 + --> tests/ui/redundant_pattern_matching_option.rs:11:5 | LL | matches!(maybe_some, None if !boolean) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `maybe_some.is_none() && (!boolean)` @@ -8,55 +8,55 @@ LL | matches!(maybe_some, None if !boolean) = help: to override `-D warnings` add `#[allow(clippy::redundant_pattern_matching)]` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:17:13 + --> tests/ui/redundant_pattern_matching_option.rs:16:13 | LL | let _ = matches!(maybe_some, None if boolean || boolean2); // guard needs parentheses | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `maybe_some.is_none() && (boolean || boolean2)` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:33:12 + --> tests/ui/redundant_pattern_matching_option.rs:32:12 | LL | if let None = None::<()> {} | -------^^^^------------- help: try: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:36:12 + --> tests/ui/redundant_pattern_matching_option.rs:35:12 | LL | if let Some(_) = Some(42) {} | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:39:12 + --> tests/ui/redundant_pattern_matching_option.rs:38:12 | LL | if let Some(_) = Some(42) { | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:46:15 + --> tests/ui/redundant_pattern_matching_option.rs:45:15 | LL | while let Some(_) = Some(42) {} | ----------^^^^^^^----------- help: try: `while Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:49:15 + --> tests/ui/redundant_pattern_matching_option.rs:48:15 | LL | while let None = Some(42) {} | ----------^^^^----------- help: try: `while Some(42).is_none()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:52:15 + --> tests/ui/redundant_pattern_matching_option.rs:51:15 | LL | while let None = None::<()> {} | ----------^^^^------------- help: try: `while None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:56:15 + --> tests/ui/redundant_pattern_matching_option.rs:55:15 | LL | while let Some(_) = v.pop() { | ----------^^^^^^^---------- help: try: `while v.pop().is_some()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:65:5 + --> tests/ui/redundant_pattern_matching_option.rs:64:5 | LL | / match Some(42) { LL | | @@ -66,7 +66,7 @@ LL | | }; | |_____^ help: try: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:71:5 + --> tests/ui/redundant_pattern_matching_option.rs:70:5 | LL | / match None::<()> { LL | | @@ -76,7 +76,7 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:77:13 + --> tests/ui/redundant_pattern_matching_option.rs:76:13 | LL | let _ = match None::<()> { | _____________^ @@ -87,55 +87,55 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:84:20 + --> tests/ui/redundant_pattern_matching_option.rs:83:20 | LL | let _ = if let Some(_) = opt { true } else { false }; | -------^^^^^^^------ help: try: `if opt.is_some()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:91:20 + --> tests/ui/redundant_pattern_matching_option.rs:90:20 | LL | let _ = if let Some(_) = gen_opt() { | -------^^^^^^^------------ help: try: `if gen_opt().is_some()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:94:19 + --> tests/ui/redundant_pattern_matching_option.rs:93:19 | LL | } else if let None = gen_opt() { | -------^^^^------------ help: try: `if gen_opt().is_none()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:101:12 + --> tests/ui/redundant_pattern_matching_option.rs:100:12 | LL | if let Some(..) = gen_opt() {} | -------^^^^^^^^------------ help: try: `if gen_opt().is_some()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:117:12 + --> tests/ui/redundant_pattern_matching_option.rs:116:12 | LL | if let Some(_) = Some(42) {} | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:120:12 + --> tests/ui/redundant_pattern_matching_option.rs:119:12 | LL | if let None = None::<()> {} | -------^^^^------------- help: try: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:123:15 + --> tests/ui/redundant_pattern_matching_option.rs:122:15 | LL | while let Some(_) = Some(42) {} | ----------^^^^^^^----------- help: try: `while Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:126:15 + --> tests/ui/redundant_pattern_matching_option.rs:125:15 | LL | while let None = None::<()> {} | ----------^^^^------------- help: try: `while None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:129:5 + --> tests/ui/redundant_pattern_matching_option.rs:128:5 | LL | / match Some(42) { LL | | @@ -145,7 +145,7 @@ LL | | }; | |_____^ help: try: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:135:5 + --> tests/ui/redundant_pattern_matching_option.rs:134:5 | LL | / match None::<()> { LL | | @@ -155,19 +155,19 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:144:12 + --> tests/ui/redundant_pattern_matching_option.rs:143:12 | LL | if let None = *(&None::<()>) {} | -------^^^^----------------- help: try: `if (&None::<()>).is_none()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:146:12 + --> tests/ui/redundant_pattern_matching_option.rs:145:12 | LL | if let None = *&None::<()> {} | -------^^^^--------------- help: try: `if (&None::<()>).is_none()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:153:5 + --> tests/ui/redundant_pattern_matching_option.rs:152:5 | LL | / match x { LL | | @@ -177,7 +177,7 @@ LL | | }; | |_____^ help: try: `x.is_some()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:159:5 + --> tests/ui/redundant_pattern_matching_option.rs:158:5 | LL | / match x { LL | | @@ -187,7 +187,7 @@ LL | | }; | |_____^ help: try: `x.is_none()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:165:5 + --> tests/ui/redundant_pattern_matching_option.rs:164:5 | LL | / match x { LL | | @@ -197,7 +197,7 @@ LL | | }; | |_____^ help: try: `x.is_none()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:171:5 + --> tests/ui/redundant_pattern_matching_option.rs:170:5 | LL | / match x { LL | | @@ -207,19 +207,19 @@ LL | | }; | |_____^ help: try: `x.is_some()` error: redundant pattern matching, consider using `is_some()` - --> tests/ui/redundant_pattern_matching_option.rs:187:13 + --> tests/ui/redundant_pattern_matching_option.rs:186:13 | LL | let _ = matches!(x, Some(_)); | ^^^^^^^^^^^^^^^^^^^^ help: try: `x.is_some()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:190:13 + --> tests/ui/redundant_pattern_matching_option.rs:189:13 | LL | let _ = matches!(x, None); | ^^^^^^^^^^^^^^^^^ help: try: `x.is_none()` error: redundant pattern matching, consider using `is_none()` - --> tests/ui/redundant_pattern_matching_option.rs:201:17 + --> tests/ui/redundant_pattern_matching_option.rs:200:17 | LL | let _ = matches!(*p, None); | ^^^^^^^^^^^^^^^^^^ help: try: `(*p).is_none()` diff --git a/tests/ui/async-await/issues/issue-66695-static-refs.rs b/tests/ui/async-await/issues/issue-66695-static-refs.rs index 5bf92f966f429..aafdca8327e87 100644 --- a/tests/ui/async-await/issues/issue-66695-static-refs.rs +++ b/tests/ui/async-await/issues/issue-66695-static-refs.rs @@ -1,7 +1,6 @@ //@ build-pass //@ edition:2018 -#![feature(if_let_guard)] static A: [i32; 5] = [1, 2, 3, 4, 5]; diff --git a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs index 547c7414526c2..04958352d3f2e 100644 --- a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs +++ b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs @@ -1,7 +1,6 @@ //@ build-pass //@ edition:2018 -#![feature(if_let_guard)] // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] diff --git a/tests/ui/async-await/missed-capture-issue-107414.rs b/tests/ui/async-await/missed-capture-issue-107414.rs index 0249fd9bbb0f2..ed5ae80c8f74d 100644 --- a/tests/ui/async-await/missed-capture-issue-107414.rs +++ b/tests/ui/async-await/missed-capture-issue-107414.rs @@ -1,7 +1,6 @@ //@ check-pass //@ edition:2018 -#![feature(if_let_guard)] fn main() {} diff --git a/tests/ui/binding/match-beginning-vert.rs b/tests/ui/binding/match-beginning-vert.rs index ac07181e06330..c13431cf668c2 100644 --- a/tests/ui/binding/match-beginning-vert.rs +++ b/tests/ui/binding/match-beginning-vert.rs @@ -1,6 +1,5 @@ //@ run-pass -#![feature(if_let_guard)] enum Foo { A, diff --git a/tests/ui/borrowck/borrowck-drop-from-guard.rs b/tests/ui/borrowck/borrowck-drop-from-guard.rs index 0f320af265760..6d1b4a7a3f5bc 100644 --- a/tests/ui/borrowck/borrowck-drop-from-guard.rs +++ b/tests/ui/borrowck/borrowck-drop-from-guard.rs @@ -1,5 +1,3 @@ -#![feature(if_let_guard)] - fn foo(_:String) {} fn main() diff --git a/tests/ui/borrowck/borrowck-drop-from-guard.stderr b/tests/ui/borrowck/borrowck-drop-from-guard.stderr index 9fa28efd8554d..b14a00df9815f 100644 --- a/tests/ui/borrowck/borrowck-drop-from-guard.stderr +++ b/tests/ui/borrowck/borrowck-drop-from-guard.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `my_str` - --> $DIR/borrowck-drop-from-guard.rs:11:23 + --> $DIR/borrowck-drop-from-guard.rs:9:23 | LL | let my_str = "hello".to_owned(); | ------ move occurs because `my_str` has type `String`, which does not implement the `Copy` trait @@ -16,7 +16,7 @@ LL | Some(_) if { drop(my_str.clone()); false } => {} | ++++++++ error[E0382]: use of moved value: `my_str` - --> $DIR/borrowck-drop-from-guard.rs:18:23 + --> $DIR/borrowck-drop-from-guard.rs:16:23 | LL | let my_str = "hello".to_owned(); | ------ move occurs because `my_str` has type `String`, which does not implement the `Copy` trait diff --git a/tests/ui/borrowck/borrowck-mutate-in-guard.rs b/tests/ui/borrowck/borrowck-mutate-in-guard.rs index d80a9e81576f4..3295229bd0479 100644 --- a/tests/ui/borrowck/borrowck-mutate-in-guard.rs +++ b/tests/ui/borrowck/borrowck-mutate-in-guard.rs @@ -1,5 +1,3 @@ -#![feature(if_let_guard)] - enum Enum<'a> { A(&'a isize), B(bool), diff --git a/tests/ui/borrowck/borrowck-mutate-in-guard.stderr b/tests/ui/borrowck/borrowck-mutate-in-guard.stderr index dbb3272fdc351..797827141272c 100644 --- a/tests/ui/borrowck/borrowck-mutate-in-guard.stderr +++ b/tests/ui/borrowck/borrowck-mutate-in-guard.stderr @@ -1,5 +1,5 @@ error[E0510]: cannot assign `x` in match guard - --> $DIR/borrowck-mutate-in-guard.rs:12:25 + --> $DIR/borrowck-mutate-in-guard.rs:10:25 | LL | match x { | - value is immutable in match guard @@ -7,7 +7,7 @@ LL | Enum::A(_) if { x = Enum::B(false); false } => 1, | ^^^^^^^^^^^^^^^^^^ cannot assign error[E0510]: cannot mutably borrow `x` in match guard - --> $DIR/borrowck-mutate-in-guard.rs:14:33 + --> $DIR/borrowck-mutate-in-guard.rs:12:33 | LL | match x { | - value is immutable in match guard @@ -16,7 +16,7 @@ LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, | ^^^^^^ cannot mutably borrow error[E0510]: cannot assign `x` in match guard - --> $DIR/borrowck-mutate-in-guard.rs:25:40 + --> $DIR/borrowck-mutate-in-guard.rs:23:40 | LL | match x { | - value is immutable in match guard @@ -24,7 +24,7 @@ LL | Enum::A(_) if let Some(()) = { x = Enum::B(false); None } => 1, | ^^^^^^^^^^^^^^^^^^ cannot assign error[E0510]: cannot mutably borrow `x` in match guard - --> $DIR/borrowck-mutate-in-guard.rs:27:48 + --> $DIR/borrowck-mutate-in-guard.rs:25:48 | LL | match x { | - value is immutable in match guard diff --git a/tests/ui/borrowck/issue-31287-drop-in-guard.rs b/tests/ui/borrowck/issue-31287-drop-in-guard.rs index 5b824adc6e273..fff181597d944 100644 --- a/tests/ui/borrowck/issue-31287-drop-in-guard.rs +++ b/tests/ui/borrowck/issue-31287-drop-in-guard.rs @@ -1,5 +1,3 @@ -#![feature(if_let_guard)] - fn main() { let a = Some("...".to_owned()); let b = match a { diff --git a/tests/ui/borrowck/issue-31287-drop-in-guard.stderr b/tests/ui/borrowck/issue-31287-drop-in-guard.stderr index 18f371c20735a..f61bca650a4b3 100644 --- a/tests/ui/borrowck/issue-31287-drop-in-guard.stderr +++ b/tests/ui/borrowck/issue-31287-drop-in-guard.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `a` - --> $DIR/issue-31287-drop-in-guard.rs:7:9 + --> $DIR/issue-31287-drop-in-guard.rs:5:9 | LL | let a = Some("...".to_owned()); | - move occurs because `a` has type `Option`, which does not implement the `Copy` trait @@ -15,7 +15,7 @@ LL | Some(_) if { drop(a.clone()); false } => None, | ++++++++ error[E0382]: use of moved value: `a` - --> $DIR/issue-31287-drop-in-guard.rs:13:9 + --> $DIR/issue-31287-drop-in-guard.rs:11:9 | LL | let a = Some("...".to_owned()); | - move occurs because `a` has type `Option`, which does not implement the `Copy` trait diff --git a/tests/ui/closures/2229_closure_analysis/issue-88118-2.rs b/tests/ui/closures/2229_closure_analysis/issue-88118-2.rs index 27c1eac88e573..f8583da30463a 100644 --- a/tests/ui/closures/2229_closure_analysis/issue-88118-2.rs +++ b/tests/ui/closures/2229_closure_analysis/issue-88118-2.rs @@ -1,6 +1,5 @@ //@ edition:2021 //@ run-pass -#![feature(if_let_guard)] #[allow(unused_must_use)] #[allow(dead_code)] diff --git a/tests/ui/closures/2229_closure_analysis/issue-88118-2.stderr b/tests/ui/closures/2229_closure_analysis/issue-88118-2.stderr index 34b3eab2345bd..f8141a595850b 100644 --- a/tests/ui/closures/2229_closure_analysis/issue-88118-2.stderr +++ b/tests/ui/closures/2229_closure_analysis/issue-88118-2.stderr @@ -1,5 +1,5 @@ warning: irrefutable `if let` guard pattern - --> $DIR/issue-88118-2.rs:10:25 + --> $DIR/issue-88118-2.rs:9:25 | LL | Registry if let _ = registry.try_find_description() => { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2018.stderr b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2018.stderr index 394629c000136..66e651661e4fb 100644 --- a/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2018.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2018.stderr @@ -1,5 +1,5 @@ error[E0505]: cannot move out of `value` because it is borrowed - --> $DIR/if-let-guards-errors.rs:16:13 + --> $DIR/if-let-guards-errors.rs:15:13 | LL | let f = |x: &E| { | ------- borrow of `value` occurs here @@ -14,7 +14,7 @@ LL | drop(f); | - borrow later used here error[E0382]: use of moved value: `value` - --> $DIR/if-let-guards-errors.rs:28:13 + --> $DIR/if-let-guards-errors.rs:27:13 | LL | fn if_let_move(value: Box) { | ----- move occurs because `value` has type `Box`, which does not implement the `Copy` trait diff --git a/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2021.stderr b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2021.stderr index 5672845019b8f..00e501a29fb79 100644 --- a/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2021.stderr +++ b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.e2021.stderr @@ -1,5 +1,5 @@ error[E0505]: cannot move out of `value` because it is borrowed - --> $DIR/if-let-guards-errors.rs:16:13 + --> $DIR/if-let-guards-errors.rs:15:13 | LL | let f = |x: &E| { | ------- borrow of `*value` occurs here @@ -14,7 +14,7 @@ LL | drop(f); | - borrow later used here error[E0382]: use of moved value: `value` - --> $DIR/if-let-guards-errors.rs:28:13 + --> $DIR/if-let-guards-errors.rs:27:13 | LL | fn if_let_move(value: Box) { | ----- move occurs because `value` has type `Box`, which does not implement the `Copy` trait diff --git a/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.rs b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.rs index e19838995eecc..d2bc20ba766f5 100644 --- a/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.rs +++ b/tests/ui/closures/2229_closure_analysis/match/if-let-guards-errors.rs @@ -3,7 +3,6 @@ //@[e2018] edition:2018 //@[e2021] edition:2021 -#![feature(if_let_guard)] #![allow(irrefutable_let_patterns)] fn if_let_ref_mut(mut value: Box) { diff --git a/tests/ui/closures/2229_closure_analysis/match/if-let-guards.rs b/tests/ui/closures/2229_closure_analysis/match/if-let-guards.rs index a629a91bb9062..612a32f35fd52 100644 --- a/tests/ui/closures/2229_closure_analysis/match/if-let-guards.rs +++ b/tests/ui/closures/2229_closure_analysis/match/if-let-guards.rs @@ -4,7 +4,6 @@ //@[e2018] edition:2018 //@[e2021] edition:2021 -#![feature(if_let_guard)] #![allow(irrefutable_let_patterns)] fn if_let_underscore(value: Box) { diff --git a/tests/ui/coroutine/yielding-in-match-guards.rs b/tests/ui/coroutine/yielding-in-match-guards.rs index 6f074188728ef..39e85077c02f9 100644 --- a/tests/ui/coroutine/yielding-in-match-guards.rs +++ b/tests/ui/coroutine/yielding-in-match-guards.rs @@ -10,7 +10,6 @@ // Thus, `&'_ u8` should be included in type signature // of the underlying coroutine. -#![feature(if_let_guard)] async fn f() -> u8 { 1 } async fn foo() -> [bool; 10] { [false; 10] } diff --git a/tests/ui/drop/drop-order-comparisons.e2021.fixed b/tests/ui/drop/drop-order-comparisons.e2021.fixed index 6c8d2d3fa9c12..93539638f666a 100644 --- a/tests/ui/drop/drop-order-comparisons.e2021.fixed +++ b/tests/ui/drop/drop-order-comparisons.e2021.fixed @@ -24,7 +24,6 @@ //@ [e2024] edition: 2024 //@ run-pass -#![feature(if_let_guard)] #![cfg_attr(e2021, feature(let_chains))] #![cfg_attr(e2021, warn(rust_2024_compatibility))] diff --git a/tests/ui/drop/drop-order-comparisons.e2021.stderr b/tests/ui/drop/drop-order-comparisons.e2021.stderr index 8b93376cc0d05..a286f7e97a2e7 100644 --- a/tests/ui/drop/drop-order-comparisons.e2021.stderr +++ b/tests/ui/drop/drop-order-comparisons.e2021.stderr @@ -1,5 +1,5 @@ warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:77:9 + --> $DIR/drop-order-comparisons.rs:76:9 | LL | _ = ({ | _________- @@ -29,35 +29,35 @@ LL | | }, e.mark(3), e.ok(4)); = warning: this changes meaning in Rust 2024 = note: for more information, see note: `#3` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `_v` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages note: the lint level is defined here - --> $DIR/drop-order-comparisons.rs:29:25 + --> $DIR/drop-order-comparisons.rs:28:25 | LL | #![cfg_attr(e2021, warn(rust_2024_compatibility))] | ^^^^^^^^^^^^^^^^^^^^^^^ = note: `#[warn(tail_expr_drop_order)]` implied by `#[warn(rust_2024_compatibility)]` warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:101:45 + --> $DIR/drop-order-comparisons.rs:100:45 | LL | _ = ({ | _________- @@ -77,19 +77,19 @@ LL | | }, e.mark(1), e.ok(4)); = warning: this changes meaning in Rust 2024 = note: for more information, see note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:101:19 + --> $DIR/drop-order-comparisons.rs:100:19 | LL | _ = ({ | _________- @@ -109,19 +109,19 @@ LL | | }, e.mark(1), e.ok(4)); = warning: this changes meaning in Rust 2024 = note: for more information, see note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:222:24 + --> $DIR/drop-order-comparisons.rs:221:24 | LL | _ = ({ | _________- @@ -141,19 +141,19 @@ LL | | }, e.mark(2), e.ok(3)); = warning: this changes meaning in Rust 2024 = note: for more information, see note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:248:24 + --> $DIR/drop-order-comparisons.rs:247:24 | LL | _ = ({ | _________- @@ -173,19 +173,19 @@ LL | | }, e.mark(2), e.ok(3)); = warning: this changes meaning in Rust 2024 = note: for more information, see note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:124:13 + --> $DIR/drop-order-comparisons.rs:123:13 | LL | _ = (if let Ok(_) = e.ok(4).as_ref() { | ^^^^^^^^^^^^-------^^^^^^^^^ @@ -195,12 +195,12 @@ LL | _ = (if let Ok(_) = e.ok(4).as_ref() { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:128:5 + --> $DIR/drop-order-comparisons.rs:127:5 | LL | }, e.mark(2), e.ok(3)); | ^ @@ -215,7 +215,7 @@ LL ~ } _ => {}}, e.mark(2), e.ok(3)); | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:146:13 + --> $DIR/drop-order-comparisons.rs:145:13 | LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -225,12 +225,12 @@ LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:146:44 + --> $DIR/drop-order-comparisons.rs:145:44 | LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { | ^ @@ -244,7 +244,7 @@ LL ~ }}, e.mark(2), e.ok(3)); | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:248:12 + --> $DIR/drop-order-comparisons.rs:247:12 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -254,12 +254,12 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:248:43 + --> $DIR/drop-order-comparisons.rs:247:43 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^ @@ -273,7 +273,7 @@ LL ~ }} | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:372:12 + --> $DIR/drop-order-comparisons.rs:371:12 | LL | if let true = e.err(9).is_ok() {} else { | ^^^^^^^^^^^--------^^^^^^^^ @@ -283,12 +283,12 @@ LL | if let true = e.err(9).is_ok() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:372:41 + --> $DIR/drop-order-comparisons.rs:371:41 | LL | if let true = e.err(9).is_ok() {} else { | ^ @@ -302,7 +302,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:375:12 + --> $DIR/drop-order-comparisons.rs:374:12 | LL | if let Ok(_v) = e.err(8) {} else { | ^^^^^^^^^^^^^-------- @@ -312,12 +312,12 @@ LL | if let Ok(_v) = e.err(8) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:375:35 + --> $DIR/drop-order-comparisons.rs:374:35 | LL | if let Ok(_v) = e.err(8) {} else { | ^ @@ -331,7 +331,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:378:12 + --> $DIR/drop-order-comparisons.rs:377:12 | LL | if let Ok(_) = e.err(7) {} else { | ^^^^^^^^^^^^-------- @@ -341,12 +341,12 @@ LL | if let Ok(_) = e.err(7) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:378:34 + --> $DIR/drop-order-comparisons.rs:377:34 | LL | if let Ok(_) = e.err(7) {} else { | ^ @@ -360,7 +360,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:381:12 + --> $DIR/drop-order-comparisons.rs:380:12 | LL | if let Ok(_) = e.err(6).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -370,12 +370,12 @@ LL | if let Ok(_) = e.err(6).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:381:43 + --> $DIR/drop-order-comparisons.rs:380:43 | LL | if let Ok(_) = e.err(6).as_ref() {} else { | ^ @@ -389,7 +389,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:385:12 + --> $DIR/drop-order-comparisons.rs:384:12 | LL | if let Ok(_v) = e.err(5) {} else { | ^^^^^^^^^^^^^-------- @@ -399,12 +399,12 @@ LL | if let Ok(_v) = e.err(5) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:385:35 + --> $DIR/drop-order-comparisons.rs:384:35 | LL | if let Ok(_v) = e.err(5) {} else { | ^ @@ -418,7 +418,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:388:12 + --> $DIR/drop-order-comparisons.rs:387:12 | LL | if let Ok(_) = e.err(4) {} else { | ^^^^^^^^^^^^-------- @@ -428,12 +428,12 @@ LL | if let Ok(_) = e.err(4) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:388:34 + --> $DIR/drop-order-comparisons.rs:387:34 | LL | if let Ok(_) = e.err(4) {} else { | ^ @@ -447,7 +447,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:424:12 + --> $DIR/drop-order-comparisons.rs:423:12 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -457,12 +457,12 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:611:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:424:43 + --> $DIR/drop-order-comparisons.rs:423:43 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^ diff --git a/tests/ui/drop/drop-order-comparisons.rs b/tests/ui/drop/drop-order-comparisons.rs index 9a10a08a3ff74..dba4dc73a870f 100644 --- a/tests/ui/drop/drop-order-comparisons.rs +++ b/tests/ui/drop/drop-order-comparisons.rs @@ -24,7 +24,6 @@ //@ [e2024] edition: 2024 //@ run-pass -#![feature(if_let_guard)] #![cfg_attr(e2021, feature(let_chains))] #![cfg_attr(e2021, warn(rust_2024_compatibility))] diff --git a/tests/ui/drop/dynamic-drop.rs b/tests/ui/drop/dynamic-drop.rs index b695b5702d943..5cad16c748164 100644 --- a/tests/ui/drop/dynamic-drop.rs +++ b/tests/ui/drop/dynamic-drop.rs @@ -2,7 +2,6 @@ //@ needs-unwind #![feature(coroutines, coroutine_trait, stmt_expr_attributes)] -#![feature(if_let_guard)] #![allow(unused_assignments)] #![allow(unused_variables)] diff --git a/tests/ui/issues/issue-29723.rs b/tests/ui/issues/issue-29723.rs index 399e9ba0df730..4ff43fa231d55 100644 --- a/tests/ui/issues/issue-29723.rs +++ b/tests/ui/issues/issue-29723.rs @@ -1,6 +1,5 @@ // test for https://github.com/rust-lang/rust/issues/29723 -#![feature(if_let_guard)] fn main() { let s = String::new(); diff --git a/tests/ui/issues/issue-29723.stderr b/tests/ui/issues/issue-29723.stderr index 044d8a9b5dd1d..9d4210f78a0e7 100644 --- a/tests/ui/issues/issue-29723.stderr +++ b/tests/ui/issues/issue-29723.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `s` - --> $DIR/issue-29723.rs:12:13 + --> $DIR/issue-29723.rs:11:13 | LL | let s = String::new(); | - move occurs because `s` has type `String`, which does not implement the `Copy` trait @@ -16,7 +16,7 @@ LL | 0 if { drop(s.clone()); false } => String::from("oops"), | ++++++++ error[E0382]: use of moved value: `s` - --> $DIR/issue-29723.rs:20:14 + --> $DIR/issue-29723.rs:19:14 | LL | let s = String::new(); | - move occurs because `s` has type `String`, which does not implement the `Copy` trait diff --git a/tests/ui/lint/lint-match-arms-2.rs b/tests/ui/lint/lint-match-arms-2.rs index 0c1146339c45f..d8d52c130759f 100644 --- a/tests/ui/lint/lint-match-arms-2.rs +++ b/tests/ui/lint/lint-match-arms-2.rs @@ -1,4 +1,3 @@ -#![feature(if_let_guard)] #![allow(unused, non_snake_case)] enum E { diff --git a/tests/ui/lint/lint-match-arms-2.stderr b/tests/ui/lint/lint-match-arms-2.stderr index 5e803ef193480..b308a9ee4ef38 100644 --- a/tests/ui/lint/lint-match-arms-2.stderr +++ b/tests/ui/lint/lint-match-arms-2.stderr @@ -1,17 +1,17 @@ error[E0170]: pattern binding `A` is named the same as one of the variants of the type `E` - --> $DIR/lint-match-arms-2.rs:12:9 + --> $DIR/lint-match-arms-2.rs:11:9 | LL | A => {} | ^ help: to match on the variant, qualify the path: `E::A` | note: the lint level is defined here - --> $DIR/lint-match-arms-2.rs:11:16 + --> $DIR/lint-match-arms-2.rs:10:16 | LL | #[deny(bindings_with_variant_name)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: irrefutable `if let` guard pattern - --> $DIR/lint-match-arms-2.rs:18:14 + --> $DIR/lint-match-arms-2.rs:17:14 | LL | a if let b = a => {} | ^^^^^^^^^ @@ -19,7 +19,7 @@ LL | a if let b = a => {} = note: this pattern will always match, so the guard is useless = help: consider removing the guard and adding a `let` inside the match arm note: the lint level is defined here - --> $DIR/lint-match-arms-2.rs:17:16 + --> $DIR/lint-match-arms-2.rs:16:16 | LL | #[deny(irrefutable_let_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/unused/issue-119383-if-let-guard.rs b/tests/ui/lint/unused/issue-119383-if-let-guard.rs index 71197444f45c3..7c54ce5e61912 100644 --- a/tests/ui/lint/unused/issue-119383-if-let-guard.rs +++ b/tests/ui/lint/unused/issue-119383-if-let-guard.rs @@ -1,4 +1,3 @@ -#![feature(if_let_guard)] #![deny(unused_variables)] fn main() { diff --git a/tests/ui/lint/unused/issue-119383-if-let-guard.stderr b/tests/ui/lint/unused/issue-119383-if-let-guard.stderr index 5bf48bb80a8f6..f95b3193e57cf 100644 --- a/tests/ui/lint/unused/issue-119383-if-let-guard.stderr +++ b/tests/ui/lint/unused/issue-119383-if-let-guard.stderr @@ -1,11 +1,11 @@ error: unused variable: `b` - --> $DIR/issue-119383-if-let-guard.rs:6:24 + --> $DIR/issue-119383-if-let-guard.rs:5:24 | LL | () if let Some(b) = Some(()) => {} | ^ help: if this is intentional, prefix it with an underscore: `_b` | note: the lint level is defined here - --> $DIR/issue-119383-if-let-guard.rs:2:9 + --> $DIR/issue-119383-if-let-guard.rs:1:9 | LL | #![deny(unused_variables)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 3f3d9252adbe8..46312250cc37a 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -9,7 +9,6 @@ #![feature(coroutines)] #![feature(decl_macro)] #![feature(explicit_tail_calls)] -#![feature(if_let_guard)] #![feature(let_chains)] #![feature(more_qualified_paths)] #![feature(never_patterns)] diff --git a/tests/ui/mir/mir_match_guard_let_chains_drop_order.rs b/tests/ui/mir/mir_match_guard_let_chains_drop_order.rs index e98d57d1154c4..df0affc80d036 100644 --- a/tests/ui/mir/mir_match_guard_let_chains_drop_order.rs +++ b/tests/ui/mir/mir_match_guard_let_chains_drop_order.rs @@ -6,7 +6,7 @@ // See `mir_drop_order.rs` for more information -#![feature(if_let_guard)] +#![cfg_attr(edition2021, feature(let_chains))] #![allow(irrefutable_let_patterns)] use std::cell::RefCell; diff --git a/tests/ui/nll/issue-24535-allow-mutable-borrow-in-match-guard.rs b/tests/ui/nll/issue-24535-allow-mutable-borrow-in-match-guard.rs index 4e4278820f1af..f2e229a169c8a 100644 --- a/tests/ui/nll/issue-24535-allow-mutable-borrow-in-match-guard.rs +++ b/tests/ui/nll/issue-24535-allow-mutable-borrow-in-match-guard.rs @@ -5,7 +5,6 @@ // See further discussion on rust-lang/rust#24535, // rust-lang/rfcs#1006, and rust-lang/rfcs#107 -#![feature(if_let_guard)] fn main() { rust_issue_24535(); diff --git a/tests/ui/nll/issue-27282-move-match-input-into-guard.rs b/tests/ui/nll/issue-27282-move-match-input-into-guard.rs index 85feda5824b40..ede1ecf47e9b3 100644 --- a/tests/ui/nll/issue-27282-move-match-input-into-guard.rs +++ b/tests/ui/nll/issue-27282-move-match-input-into-guard.rs @@ -7,7 +7,6 @@ // reaches the panic code when executed, despite the compiler warning // about that match arm being unreachable. -#![feature(if_let_guard)] fn main() { let b = &mut true; diff --git a/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr b/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr index ae7978004576b..a6c6a5572e24f 100644 --- a/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr +++ b/tests/ui/nll/issue-27282-move-match-input-into-guard.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `b` - --> $DIR/issue-27282-move-match-input-into-guard.rs:14:5 + --> $DIR/issue-27282-move-match-input-into-guard.rs:13:5 | LL | let b = &mut true; | - move occurs because `b` has type `&mut bool`, which does not implement the `Copy` trait @@ -12,7 +12,7 @@ LL | _ if { (|| { let bar = b; *bar = false; })(); | value moved into closure here error[E0382]: use of moved value: `b` - --> $DIR/issue-27282-move-match-input-into-guard.rs:24:5 + --> $DIR/issue-27282-move-match-input-into-guard.rs:23:5 | LL | let b = &mut true; | - move occurs because `b` has type `&mut bool`, which does not implement the `Copy` trait diff --git a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs index c3b19886a5078..85aeb6f0279f8 100644 --- a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs +++ b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.rs @@ -2,7 +2,6 @@ // mutable borrows in match guards by hiding the mutable borrow in a // guard behind a move (of the ref mut pattern id) within a closure. -#![feature(if_let_guard)] fn main() { match Some(&4) { diff --git a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr index e790fda4d7ca7..b257b3cd3a6fd 100644 --- a/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr +++ b/tests/ui/nll/issue-27282-move-ref-mut-into-guard.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/issue-27282-move-ref-mut-into-guard.rs:11:19 + --> $DIR/issue-27282-move-ref-mut-into-guard.rs:10:19 | LL | if { (|| { let mut bar = foo; bar.take() })(); false } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait @@ -9,7 +9,7 @@ LL | if { (|| { let mut bar = foo; bar.take() })(); false } => {}, = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/issue-27282-move-ref-mut-into-guard.rs:19:34 + --> $DIR/issue-27282-move-ref-mut-into-guard.rs:18:34 | LL | if let Some(()) = { (|| { let mut bar = foo; bar.take() })(); None } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait diff --git a/tests/ui/nll/issue-27282-mutation-in-guard.rs b/tests/ui/nll/issue-27282-mutation-in-guard.rs index 4f41fc23fc34b..a37b4f3fc1468 100644 --- a/tests/ui/nll/issue-27282-mutation-in-guard.rs +++ b/tests/ui/nll/issue-27282-mutation-in-guard.rs @@ -1,5 +1,3 @@ -#![feature(if_let_guard)] - fn main() { match Some(&4) { None => {}, diff --git a/tests/ui/nll/issue-27282-mutation-in-guard.stderr b/tests/ui/nll/issue-27282-mutation-in-guard.stderr index 0b5d723172c76..bd531eb6d0199 100644 --- a/tests/ui/nll/issue-27282-mutation-in-guard.stderr +++ b/tests/ui/nll/issue-27282-mutation-in-guard.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/issue-27282-mutation-in-guard.rs:8:18 + --> $DIR/issue-27282-mutation-in-guard.rs:6:18 | LL | (|| { let bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait @@ -9,7 +9,7 @@ LL | (|| { let bar = foo; bar.take() })(); = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/issue-27282-mutation-in-guard.rs:20:18 + --> $DIR/issue-27282-mutation-in-guard.rs:18:18 | LL | (|| { let bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait diff --git a/tests/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs b/tests/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs index ac06b2b01028f..ef15c2f4365cd 100644 --- a/tests/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs +++ b/tests/ui/nll/issue-27282-reborrow-ref-mut-in-guard.rs @@ -5,7 +5,6 @@ // reject it. But I want to make sure that we continue to reject it // (under NLL) even when that conservative check goes away. -#![feature(if_let_guard)] fn main() { let mut b = &mut true; diff --git a/tests/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr b/tests/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr index 5eb7a25bf9f50..fca07d06dd2e4 100644 --- a/tests/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr +++ b/tests/ui/nll/issue-27282-reborrow-ref-mut-in-guard.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `r` as mutable, as it is immutable for the pattern guard - --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:14:25 + --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:13:25 | LL | ref mut r if { (|| { let bar = &mut *r; **bar = false; })(); | ^^ -- mutable borrow occurs due to use of `r` in closure @@ -9,7 +9,7 @@ LL | ref mut r if { (|| { let bar = &mut *r; **bar = false; })(); = note: variables bound in patterns are immutable until the end of the pattern guard error[E0596]: cannot borrow `r` as mutable, as it is immutable for the pattern guard - --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:24:40 + --> $DIR/issue-27282-reborrow-ref-mut-in-guard.rs:23:40 | LL | ref mut r if let Some(()) = { (|| { let bar = &mut *r; **bar = false; })(); | ^^ -- mutable borrow occurs due to use of `r` in closure diff --git a/tests/ui/nll/match-cfg-fake-edges.rs b/tests/ui/nll/match-cfg-fake-edges.rs index e349c2c8e2a5f..fe96df12b1c28 100644 --- a/tests/ui/nll/match-cfg-fake-edges.rs +++ b/tests/ui/nll/match-cfg-fake-edges.rs @@ -1,7 +1,6 @@ // Test that we have enough false edges to avoid exposing the exact matching // algorithm in borrow checking. -#![feature(if_let_guard)] #[rustfmt::skip] fn all_patterns_are_tested() { diff --git a/tests/ui/nll/match-cfg-fake-edges.stderr b/tests/ui/nll/match-cfg-fake-edges.stderr index 066e77b17fc7b..865e46e2d6f8e 100644 --- a/tests/ui/nll/match-cfg-fake-edges.stderr +++ b/tests/ui/nll/match-cfg-fake-edges.stderr @@ -1,5 +1,5 @@ warning: irrefutable `if let` pattern - --> $DIR/match-cfg-fake-edges.rs:19:8 + --> $DIR/match-cfg-fake-edges.rs:18:8 | LL | if let _ = true { | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | if let _ = true { = note: `#[warn(irrefutable_let_patterns)]` on by default error[E0382]: use of moved value: `x` - --> $DIR/match-cfg-fake-edges.rs:16:10 + --> $DIR/match-cfg-fake-edges.rs:15:10 | LL | let x = String::new(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait @@ -26,7 +26,7 @@ LL | _ => drop(x.clone()), | ++++++++ error[E0382]: use of moved value: `x` - --> $DIR/match-cfg-fake-edges.rs:24:10 + --> $DIR/match-cfg-fake-edges.rs:23:10 | LL | let x = String::new(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait @@ -43,7 +43,7 @@ LL | drop(x.clone()) | ++++++++ error[E0382]: borrow of moved value: `x.0` - --> $DIR/match-cfg-fake-edges.rs:30:5 + --> $DIR/match-cfg-fake-edges.rs:29:5 | LL | (y, _) | (_, y) => (), | - value moved here @@ -58,7 +58,7 @@ LL | (ref y, _) | (_, y) => (), | +++ error[E0382]: borrow of moved value: `x.1` - --> $DIR/match-cfg-fake-edges.rs:32:5 + --> $DIR/match-cfg-fake-edges.rs:31:5 | LL | (y, _) | (_, y) => (), | - value moved here @@ -73,7 +73,7 @@ LL | (y, _) | (_, ref y) => (), | +++ error[E0382]: borrow of moved value: `x.0` - --> $DIR/match-cfg-fake-edges.rs:36:5 + --> $DIR/match-cfg-fake-edges.rs:35:5 | LL | let ((y, _) | (_, y)) = x; | - value moved here @@ -87,7 +87,7 @@ LL | let ((ref y, _) | (_, y)) = x; | +++ error[E0382]: borrow of moved value: `x.1` - --> $DIR/match-cfg-fake-edges.rs:38:5 + --> $DIR/match-cfg-fake-edges.rs:37:5 | LL | let ((y, _) | (_, y)) = x; | - value moved here @@ -102,7 +102,7 @@ LL | let ((y, _) | (_, ref y)) = x; | +++ error[E0381]: used binding `x` is possibly-uninitialized - --> $DIR/match-cfg-fake-edges.rs:72:19 + --> $DIR/match-cfg-fake-edges.rs:71:19 | LL | let x; | - binding declared here but left uninitialized @@ -113,7 +113,7 @@ LL | _ => drop(x), | if this pattern is matched, `x` is not initialized error[E0381]: used binding `x` isn't initialized - --> $DIR/match-cfg-fake-edges.rs:79:16 + --> $DIR/match-cfg-fake-edges.rs:78:16 | LL | let x; | - binding declared here but left uninitialized @@ -130,7 +130,7 @@ LL | let x = 42; | ++++ error[E0381]: used binding `x` isn't initialized - --> $DIR/match-cfg-fake-edges.rs:86:31 + --> $DIR/match-cfg-fake-edges.rs:85:31 | LL | let x; | - binding declared here but left uninitialized @@ -146,7 +146,7 @@ LL | let x = 42; | ++++ error[E0382]: use of moved value: `x` - --> $DIR/match-cfg-fake-edges.rs:99:22 + --> $DIR/match-cfg-fake-edges.rs:98:22 | LL | let x = String::new(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait @@ -163,7 +163,7 @@ LL | false if { drop(x.clone()); true } => {}, | ++++++++ error[E0382]: use of moved value: `x` - --> $DIR/match-cfg-fake-edges.rs:114:22 + --> $DIR/match-cfg-fake-edges.rs:113:22 | LL | let x = String::new(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait diff --git a/tests/ui/nll/match-guards-always-borrow.rs b/tests/ui/nll/match-guards-always-borrow.rs index 5271e3cfc6655..c8aa9686156c8 100644 --- a/tests/ui/nll/match-guards-always-borrow.rs +++ b/tests/ui/nll/match-guards-always-borrow.rs @@ -1,4 +1,3 @@ -#![feature(if_let_guard)] #![allow(unused_mut)] // Here is arielb1's basic example from rust-lang/rust#27282 diff --git a/tests/ui/nll/match-guards-always-borrow.stderr b/tests/ui/nll/match-guards-always-borrow.stderr index 71977bd84721b..e48e5224c6fbb 100644 --- a/tests/ui/nll/match-guards-always-borrow.stderr +++ b/tests/ui/nll/match-guards-always-borrow.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/match-guards-always-borrow.rs:11:14 + --> $DIR/match-guards-always-borrow.rs:10:14 | LL | (|| { let mut bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait @@ -9,7 +9,7 @@ LL | (|| { let mut bar = foo; bar.take() })(); = note: variables bound in patterns cannot be moved from until after the end of the pattern guard error[E0507]: cannot move out of `foo` in pattern guard - --> $DIR/match-guards-always-borrow.rs:20:14 + --> $DIR/match-guards-always-borrow.rs:19:14 | LL | (|| { let mut bar = foo; bar.take() })(); | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait diff --git a/tests/ui/nll/match-guards-partially-borrow.rs b/tests/ui/nll/match-guards-partially-borrow.rs index 3a9e1654b1c2d..f0f4682206c89 100644 --- a/tests/ui/nll/match-guards-partially-borrow.rs +++ b/tests/ui/nll/match-guards-partially-borrow.rs @@ -5,7 +5,6 @@ // Test that we don't allow mutating the value being matched on in a way that // changes which patterns it matches, until we have chosen an arm. -#![feature(if_let_guard)] fn ok_mutation_in_if_guard(mut q: i32) { match q { @@ -15,7 +14,7 @@ fn ok_mutation_in_if_guard(mut q: i32) { } } -fn ok_mutation_in_if_let_guard(mut q: i32) { +fn ok_mutation_in_(mut q: i32) { match q { // OK, mutation doesn't change which patterns g matches _ if let Some(()) = { q = 1; None } => (), @@ -35,7 +34,7 @@ fn ok_mutation_in_if_guard2(mut u: bool) { } } -fn ok_mutation_in_if_let_guard2(mut u: bool) { +fn ok_mutation_in_2(mut u: bool) { // OK value of u is unused before modification match u { _ => (), @@ -59,7 +58,7 @@ fn ok_mutation_in_if_guard4(mut w: (&mut bool,)) { } } -fn ok_mutation_in_if_let_guard4(mut w: (&mut bool,)) { +fn ok_mutation_in_4(mut w: (&mut bool,)) { // OK value of u is unused before modification match w { _ => (), @@ -82,7 +81,7 @@ fn ok_indirect_mutation_in_if_guard(mut p: &bool) { } } -fn ok_indirect_mutation_in_if_let_guard(mut p: &bool) { +fn ok_indirect_mutation_in_(mut p: &bool) { match *p { // OK, mutation doesn't change which patterns s matches _ if let Some(()) = { @@ -104,7 +103,7 @@ fn mutation_invalidates_pattern_in_if_guard(mut q: bool) { } } -fn mutation_invalidates_pattern_in_if_let_guard(mut q: bool) { +fn mutation_invalidates_pattern_in_(mut q: bool) { match q { // q doesn't match the pattern with the guard by the end of the guard. false if let Some(()) = { @@ -127,7 +126,7 @@ fn mutation_invalidates_previous_pattern_in_if_guard(mut r: bool) { } } -fn mutation_invalidates_previous_pattern_in_if_let_guard(mut r: bool) { +fn mutation_invalidates_previous_pattern_in_(mut r: bool) { match r { // r matches a previous pattern by the end of the guard. true => (), @@ -152,7 +151,7 @@ fn match_on_borrowed_early_end_if_guard(mut s: bool) { } } -fn match_on_borrowed_early_end_if_let_guard(mut s: bool) { +fn match_on_borrowed_early_end_(mut s: bool) { let h = &mut s; // OK value of s is unused before modification. match s { @@ -176,7 +175,7 @@ fn bad_mutation_in_if_guard(mut t: bool) { } } -fn bad_mutation_in_if_let_guard(mut t: bool) { +fn bad_mutation_in_(mut t: bool) { match t { true => (), false if let Some(()) = { @@ -203,7 +202,7 @@ fn bad_mutation_in_if_guard2(mut x: Option>) { } } -fn bad_mutation_in_if_let_guard2(mut x: Option>) { +fn bad_mutation_in_2(mut x: Option>) { // Check that nested patterns are checked. match x { None => (), @@ -229,7 +228,7 @@ fn bad_mutation_in_if_guard3(mut t: bool) { } } -fn bad_mutation_in_if_let_guard3(mut t: bool) { +fn bad_mutation_in_3(mut t: bool) { match t { s if let Some(()) = { t = !t; //~ ERROR @@ -250,7 +249,7 @@ fn bad_indirect_mutation_in_if_guard(mut y: &bool) { } } -fn bad_indirect_mutation_in_if_let_guard(mut y: &bool) { +fn bad_indirect_mutation_in_(mut y: &bool) { match *y { true => (), false if let Some(()) = { @@ -272,7 +271,7 @@ fn bad_indirect_mutation_in_if_guard2(mut z: &bool) { } } -fn bad_indirect_mutation_in_if_let_guard2(mut z: &bool) { +fn bad_indirect_mutation_in_2(mut z: &bool) { match z { &true => (), &false if let Some(()) = { @@ -295,7 +294,7 @@ fn bad_indirect_mutation_in_if_guard3(mut a: &bool) { } } -fn bad_indirect_mutation_in_if_let_guard3(mut a: &bool) { +fn bad_indirect_mutation_in_3(mut a: &bool) { // Same as bad_indirect_mutation_in_if_guard2, but using match ergonomics match a { true => (), @@ -318,7 +317,7 @@ fn bad_indirect_mutation_in_if_guard4(mut b: &bool) { } } -fn bad_indirect_mutation_in_if_let_guard4(mut b: &bool) { +fn bad_indirect_mutation_in_4(mut b: &bool) { match b { &_ => (), &_ if let Some(()) = { diff --git a/tests/ui/nll/match-guards-partially-borrow.stderr b/tests/ui/nll/match-guards-partially-borrow.stderr index 7bdcbcb9c6ef6..429e7767665f3 100644 --- a/tests/ui/nll/match-guards-partially-borrow.stderr +++ b/tests/ui/nll/match-guards-partially-borrow.stderr @@ -1,5 +1,5 @@ error[E0510]: cannot assign `q` in match guard - --> $DIR/match-guards-partially-borrow.rs:100:13 + --> $DIR/match-guards-partially-borrow.rs:99:13 | LL | match q { | - value is immutable in match guard @@ -8,7 +8,7 @@ LL | q = true; | ^^^^^^^^ cannot assign error[E0510]: cannot assign `q` in match guard - --> $DIR/match-guards-partially-borrow.rs:111:13 + --> $DIR/match-guards-partially-borrow.rs:110:13 | LL | match q { | - value is immutable in match guard @@ -17,7 +17,7 @@ LL | q = true; | ^^^^^^^^ cannot assign error[E0510]: cannot assign `r` in match guard - --> $DIR/match-guards-partially-borrow.rs:123:13 + --> $DIR/match-guards-partially-borrow.rs:122:13 | LL | match r { | - value is immutable in match guard @@ -26,7 +26,7 @@ LL | r = true; | ^^^^^^^^ cannot assign error[E0510]: cannot assign `r` in match guard - --> $DIR/match-guards-partially-borrow.rs:135:13 + --> $DIR/match-guards-partially-borrow.rs:134:13 | LL | match r { | - value is immutable in match guard @@ -35,7 +35,7 @@ LL | r = true; | ^^^^^^^^ cannot assign error[E0510]: cannot assign `t` in match guard - --> $DIR/match-guards-partially-borrow.rs:172:13 + --> $DIR/match-guards-partially-borrow.rs:171:13 | LL | match t { | - value is immutable in match guard @@ -44,7 +44,7 @@ LL | t = true; | ^^^^^^^^ cannot assign error[E0510]: cannot assign `t` in match guard - --> $DIR/match-guards-partially-borrow.rs:183:13 + --> $DIR/match-guards-partially-borrow.rs:182:13 | LL | match t { | - value is immutable in match guard @@ -53,7 +53,7 @@ LL | t = true; | ^^^^^^^^ cannot assign error[E0510]: cannot mutably borrow `x.0` in match guard - --> $DIR/match-guards-partially-borrow.rs:197:22 + --> $DIR/match-guards-partially-borrow.rs:196:22 | LL | match x { | - value is immutable in match guard @@ -62,7 +62,7 @@ LL | Some(ref mut r) => *r = None, | ^^^^^^^^^ cannot mutably borrow error[E0510]: cannot mutably borrow `x.0` in match guard - --> $DIR/match-guards-partially-borrow.rs:213:22 + --> $DIR/match-guards-partially-borrow.rs:212:22 | LL | match x { | - value is immutable in match guard @@ -71,7 +71,7 @@ LL | Some(ref mut r) => *r = None, | ^^^^^^^^^ cannot mutably borrow error[E0506]: cannot assign to `t` because it is borrowed - --> $DIR/match-guards-partially-borrow.rs:225:13 + --> $DIR/match-guards-partially-borrow.rs:224:13 | LL | s if { | - `t` is borrowed here @@ -82,7 +82,7 @@ LL | } => (), // What value should `s` have in the arm? | - borrow later used here error[E0506]: cannot assign to `t` because it is borrowed - --> $DIR/match-guards-partially-borrow.rs:235:13 + --> $DIR/match-guards-partially-borrow.rs:234:13 | LL | s if let Some(()) = { | - `t` is borrowed here @@ -93,7 +93,7 @@ LL | } => (), // What value should `s` have in the arm? | - borrow later used here error[E0510]: cannot assign `y` in match guard - --> $DIR/match-guards-partially-borrow.rs:246:13 + --> $DIR/match-guards-partially-borrow.rs:245:13 | LL | match *y { | -- value is immutable in match guard @@ -102,7 +102,7 @@ LL | y = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `y` in match guard - --> $DIR/match-guards-partially-borrow.rs:257:13 + --> $DIR/match-guards-partially-borrow.rs:256:13 | LL | match *y { | -- value is immutable in match guard @@ -111,7 +111,7 @@ LL | y = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `z` in match guard - --> $DIR/match-guards-partially-borrow.rs:268:13 + --> $DIR/match-guards-partially-borrow.rs:267:13 | LL | match z { | - value is immutable in match guard @@ -120,7 +120,7 @@ LL | z = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `z` in match guard - --> $DIR/match-guards-partially-borrow.rs:279:13 + --> $DIR/match-guards-partially-borrow.rs:278:13 | LL | match z { | - value is immutable in match guard @@ -129,7 +129,7 @@ LL | z = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `a` in match guard - --> $DIR/match-guards-partially-borrow.rs:291:13 + --> $DIR/match-guards-partially-borrow.rs:290:13 | LL | match a { | - value is immutable in match guard @@ -138,7 +138,7 @@ LL | a = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `a` in match guard - --> $DIR/match-guards-partially-borrow.rs:303:13 + --> $DIR/match-guards-partially-borrow.rs:302:13 | LL | match a { | - value is immutable in match guard @@ -147,7 +147,7 @@ LL | a = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `b` in match guard - --> $DIR/match-guards-partially-borrow.rs:314:13 + --> $DIR/match-guards-partially-borrow.rs:313:13 | LL | match b { | - value is immutable in match guard @@ -156,7 +156,7 @@ LL | b = &true; | ^^^^^^^^^ cannot assign error[E0510]: cannot assign `b` in match guard - --> $DIR/match-guards-partially-borrow.rs:325:13 + --> $DIR/match-guards-partially-borrow.rs:324:13 | LL | match b { | - value is immutable in match guard diff --git a/tests/ui/parser/struct-literal-in-match-guard.rs b/tests/ui/parser/struct-literal-in-match-guard.rs index ced01e08621a6..55b1737eb0338 100644 --- a/tests/ui/parser/struct-literal-in-match-guard.rs +++ b/tests/ui/parser/struct-literal-in-match-guard.rs @@ -3,7 +3,6 @@ // Unlike `if` condition, `match` guards accept struct literals. // This is detected in . -#![feature(if_let_guard)] #[derive(PartialEq)] struct Foo { diff --git a/tests/ui/pattern/usefulness/conflicting_bindings.stderr b/tests/ui/pattern/usefulness/conflicting_bindings.edition2021.stderr similarity index 75% rename from tests/ui/pattern/usefulness/conflicting_bindings.stderr rename to tests/ui/pattern/usefulness/conflicting_bindings.edition2021.stderr index 6f6504e6f6442..a71ea489ee140 100644 --- a/tests/ui/pattern/usefulness/conflicting_bindings.stderr +++ b/tests/ui/pattern/usefulness/conflicting_bindings.edition2021.stderr @@ -1,5 +1,5 @@ error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:5:9 + --> $DIR/conflicting_bindings.rs:9:9 | LL | let ref mut y @ ref mut z = x; | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -7,7 +7,7 @@ LL | let ref mut y @ ref mut z = x; | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:7:14 + --> $DIR/conflicting_bindings.rs:11:14 | LL | let Some(ref mut y @ ref mut z) = x else { return }; | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -15,7 +15,7 @@ LL | let Some(ref mut y @ ref mut z) = x else { return }; | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:9:17 + --> $DIR/conflicting_bindings.rs:13:17 | LL | if let Some(ref mut y @ ref mut z) = x {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -23,7 +23,7 @@ LL | if let Some(ref mut y @ ref mut z) = x {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:11:17 + --> $DIR/conflicting_bindings.rs:15:17 | LL | if let Some(ref mut y @ ref mut z) = x && true {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -31,7 +31,7 @@ LL | if let Some(ref mut y @ ref mut z) = x && true {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:13:43 + --> $DIR/conflicting_bindings.rs:17:43 | LL | if let Some(_) = Some(()) && let Some(ref mut y @ ref mut z) = x && true {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -39,7 +39,7 @@ LL | if let Some(_) = Some(()) && let Some(ref mut y @ ref mut z) = x && tru | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:15:20 + --> $DIR/conflicting_bindings.rs:19:20 | LL | while let Some(ref mut y @ ref mut z) = x {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -47,7 +47,7 @@ LL | while let Some(ref mut y @ ref mut z) = x {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:17:20 + --> $DIR/conflicting_bindings.rs:21:20 | LL | while let Some(ref mut y @ ref mut z) = x && true {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -55,7 +55,7 @@ LL | while let Some(ref mut y @ ref mut z) = x && true {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:20:9 + --> $DIR/conflicting_bindings.rs:24:9 | LL | ref mut y @ ref mut z => {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -63,12 +63,20 @@ LL | ref mut y @ ref mut z => {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:23:24 + --> $DIR/conflicting_bindings.rs:27:24 | LL | () if let Some(ref mut y @ ref mut z) = x => {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here | | | value is mutably borrowed by `y` here -error: aborting due to 9 previous errors +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:31:51 + | +LL | () if let Some(()) = Some(()) && let Some(ref mut y @ ref mut z) = x && true => {} + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: aborting due to 10 previous errors diff --git a/tests/ui/pattern/usefulness/conflicting_bindings.edition2024.stderr b/tests/ui/pattern/usefulness/conflicting_bindings.edition2024.stderr new file mode 100644 index 0000000000000..a71ea489ee140 --- /dev/null +++ b/tests/ui/pattern/usefulness/conflicting_bindings.edition2024.stderr @@ -0,0 +1,82 @@ +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:9:9 + | +LL | let ref mut y @ ref mut z = x; + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:11:14 + | +LL | let Some(ref mut y @ ref mut z) = x else { return }; + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:13:17 + | +LL | if let Some(ref mut y @ ref mut z) = x {} + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:15:17 + | +LL | if let Some(ref mut y @ ref mut z) = x && true {} + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:17:43 + | +LL | if let Some(_) = Some(()) && let Some(ref mut y @ ref mut z) = x && true {} + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:19:20 + | +LL | while let Some(ref mut y @ ref mut z) = x {} + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:21:20 + | +LL | while let Some(ref mut y @ ref mut z) = x && true {} + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:24:9 + | +LL | ref mut y @ ref mut z => {} + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:27:24 + | +LL | () if let Some(ref mut y @ ref mut z) = x => {} + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: cannot borrow value as mutable more than once at a time + --> $DIR/conflicting_bindings.rs:31:51 + | +LL | () if let Some(()) = Some(()) && let Some(ref mut y @ ref mut z) = x && true => {} + | ^^^^^^^^^ --------- value is mutably borrowed by `z` here + | | + | value is mutably borrowed by `y` here + +error: aborting due to 10 previous errors + diff --git a/tests/ui/pattern/usefulness/conflicting_bindings.rs b/tests/ui/pattern/usefulness/conflicting_bindings.rs index 16737e0a8946b..9c64390ef1293 100644 --- a/tests/ui/pattern/usefulness/conflicting_bindings.rs +++ b/tests/ui/pattern/usefulness/conflicting_bindings.rs @@ -1,4 +1,8 @@ -#![feature(if_let_guard, let_chains)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 + +#![cfg_attr(edition2021, feature(let_chains))] fn main() { let mut x = Some(String::new()); @@ -23,4 +27,9 @@ fn main() { () if let Some(ref mut y @ ref mut z) = x => {} //~ ERROR: mutable more than once _ => {} } + match () { + () if let Some(()) = Some(()) && let Some(ref mut y @ ref mut z) = x && true => {} + //~^ ERROR: mutable more than once + _ => {} + } } diff --git a/tests/ui/pattern/usefulness/deny-irrefutable-let-patterns.rs b/tests/ui/pattern/usefulness/deny-irrefutable-let-patterns.rs index c85af7f3bcc79..9eb5f6e5f2756 100644 --- a/tests/ui/pattern/usefulness/deny-irrefutable-let-patterns.rs +++ b/tests/ui/pattern/usefulness/deny-irrefutable-let-patterns.rs @@ -1,5 +1,3 @@ -#![feature(if_let_guard)] - #![deny(irrefutable_let_patterns)] fn main() { diff --git a/tests/ui/pattern/usefulness/deny-irrefutable-let-patterns.stderr b/tests/ui/pattern/usefulness/deny-irrefutable-let-patterns.stderr index e8b7f40c70e48..5e79e9e76ea1e 100644 --- a/tests/ui/pattern/usefulness/deny-irrefutable-let-patterns.stderr +++ b/tests/ui/pattern/usefulness/deny-irrefutable-let-patterns.stderr @@ -1,5 +1,5 @@ error: irrefutable `if let` pattern - --> $DIR/deny-irrefutable-let-patterns.rs:6:8 + --> $DIR/deny-irrefutable-let-patterns.rs:4:8 | LL | if let _ = 5 {} | ^^^^^^^^^ @@ -7,13 +7,13 @@ LL | if let _ = 5 {} = note: this pattern will always match, so the `if let` is useless = help: consider replacing the `if let` with a `let` note: the lint level is defined here - --> $DIR/deny-irrefutable-let-patterns.rs:3:9 + --> $DIR/deny-irrefutable-let-patterns.rs:1:9 | LL | #![deny(irrefutable_let_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: irrefutable `while let` pattern - --> $DIR/deny-irrefutable-let-patterns.rs:8:11 + --> $DIR/deny-irrefutable-let-patterns.rs:6:11 | LL | while let _ = 5 { | ^^^^^^^^^ @@ -22,7 +22,7 @@ LL | while let _ = 5 { = help: consider instead using a `loop { ... }` with a `let` inside it error: irrefutable `if let` guard pattern - --> $DIR/deny-irrefutable-let-patterns.rs:13:14 + --> $DIR/deny-irrefutable-let-patterns.rs:11:14 | LL | _ if let _ = 2 => {} | ^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs index 6f0d2b045918d..5eefbc65fc52e 100644 --- a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs @@ -1,5 +1,3 @@ -#![feature(if_let_guard)] - enum VecWrapper { A(Vec) } fn if_guard(x: VecWrapper) -> usize { diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr index 0ab70c5ae8ab2..6de9627a14c18 100644 --- a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-across-arms.rs:7:36 + --> $DIR/rfc-reject-double-move-across-arms.rs:5:36 | LL | VecWrapper::A(v) if { drop(v); false } => 1, | ^ move occurs because `v` has type `Vec`, which does not implement the `Copy` trait @@ -11,7 +11,7 @@ LL | VecWrapper::A(v) if { drop(v.clone()); false } => 1, | ++++++++ error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-across-arms.rs:15:51 + --> $DIR/rfc-reject-double-move-across-arms.rs:13:51 | LL | VecWrapper::A(v) if let Some(()) = { drop(v); None } => 1, | ^ move occurs because `v` has type `Vec`, which does not implement the `Copy` trait diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs index 827335f6a8494..de3f23830d870 100644 --- a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs @@ -1,5 +1,3 @@ -#![feature(if_let_guard)] - struct A { a: Box } fn if_guard(n: i32) { diff --git a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr index c261f9942838a..b78649f9174a1 100644 --- a/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr +++ b/tests/ui/rfcs/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-in-first-arm.rs:8:30 + --> $DIR/rfc-reject-double-move-in-first-arm.rs:6:30 | LL | A { a: v } if { drop(v); true } => v, | ^ move occurs because `v` has type `Box`, which does not implement the `Copy` trait @@ -11,7 +11,7 @@ LL | A { a: v } if { drop(v.clone()); true } => v, | ++++++++ error[E0507]: cannot move out of `v` in pattern guard - --> $DIR/rfc-reject-double-move-in-first-arm.rs:17:45 + --> $DIR/rfc-reject-double-move-in-first-arm.rs:15:45 | LL | A { a: v } if let Some(()) = { drop(v); Some(()) } => v, | ^ move occurs because `v` has type `Box`, which does not implement the `Copy` trait diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.rs index 1f32e4af121f2..1cef8b02e8d02 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.rs @@ -1,5 +1,3 @@ -#![feature(if_let_guard)] - fn main() { match Some(None) { Some(x) if let Some(y) = x => (x, y), diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.stderr index 2463b7f3eacc7..acedbf966ae69 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/bindings.stderr @@ -1,11 +1,11 @@ error[E0425]: cannot find value `y` in this scope - --> $DIR/bindings.rs:6:14 + --> $DIR/bindings.rs:4:14 | LL | _ => y, | ^ not found in this scope error[E0425]: cannot find value `y` in this scope - --> $DIR/bindings.rs:8:5 + --> $DIR/bindings.rs:6:5 | LL | y | ^ not found in this scope diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/compare-drop-order.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/compare-drop-order.rs new file mode 100644 index 0000000000000..bffa0b1b75b4c --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/compare-drop-order.rs @@ -0,0 +1,60 @@ +//@ run-pass +//@revisions: edition2015 edition2018 edition2021 edition2024 +//@[edition2015] edition:2015 +//@[edition2018] edition:2018 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 + +#![allow(irrefutable_let_patterns)] + +use std::sync::Mutex; + +static A: Mutex> = Mutex::new(Vec::new()); + +struct D(i32); + +fn make_d(x: i32) -> D { + A.lock().unwrap().push(x); + D(x) +} + +impl Drop for D { + fn drop(&mut self) { + A.lock().unwrap().push(!self.0); + } +} + +fn if_let_guard(num: i32) { + let _d = make_d(1); + match num { + 1 | 2 if let D(ref _x) = make_d(2) => { + make_d(3); + } + _ => {} + } +} + +fn if_let(num: i32) { + let _d = make_d(1); + match num { + 1 | 2 => { + if let D(ref _x) = make_d(2) { + make_d(3); + } + } + _ => {} + } +} + +fn main() { + if_let(1); + if_let(2); + if_let_guard(1); + if_let_guard(2); + let expected = + [1, 2, 3, !3, !2, !1, 1, 2, 3, !3, !2, !1, + // Here is two parts, first one is for basic if let inside the match arm + // And second part is for if let guard + 1, 2, 3, !3, !2, !1, 1, 2, 3, !3, !2, !1]; + assert_eq!(*A.lock().unwrap(), expected); +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/const-expr.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/const-expr.rs index e5078bacb932d..c4f0891ddce14 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/const-expr.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/const-expr.rs @@ -1,7 +1,9 @@ // Ensure if let guards can be used in constant expressions. -//@ build-pass -#![feature(if_let_guard)] +//@ build-pass +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 const fn match_if_let(x: Option, y: Option) -> i32 { match x { diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs index 801329bcc5afd..de8fea3d26a75 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-order.rs @@ -3,8 +3,10 @@ // For let guards temporaries live until the end of the arm. //@ run-pass +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 -#![feature(if_let_guard)] #![allow(irrefutable_let_patterns)] use std::sync::Mutex; @@ -49,11 +51,7 @@ fn main() { if_guard(2); if_let_guard(1); if_let_guard(2); - let expected = [ - 1, 2, !2, 3, !3, !1, - 1, 2, !2, 3, !3, !1, - 1, 2, 3, !3, !2, !1, - 1, 2, 3, !3, !2, !1, - ]; + let expected = + [1, 2, !2, 3, !3, !1, 1, 2, !2, 3, !3, !1, 1, 2, 3, !3, !2, !1, 1, 2, 3, !3, !2, !1]; assert_eq!(*A.lock().unwrap(), expected); } diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs index 0578b827a47a0..25e824d07cfea 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs @@ -2,8 +2,10 @@ // regression test for #118593 //@ check-pass +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 -#![feature(if_let_guard)] #![feature(let_chains)] fn get_temp() -> Option { diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.edition2021.stderr similarity index 94% rename from tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.stderr rename to tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.edition2021.stderr index ddd08854ff77f..52800e2f6e5b9 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.edition2021.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `None` not covered - --> $DIR/exhaustive.rs:5:11 + --> $DIR/exhaustive.rs:8:11 | LL | match x { | ^ pattern `None` not covered @@ -17,7 +17,7 @@ LL + None => todo!() | error[E0004]: non-exhaustive patterns: `()` not covered - --> $DIR/exhaustive.rs:14:11 + --> $DIR/exhaustive.rs:17:11 | LL | match x { | ^ pattern `()` not covered diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.edition2024.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.edition2024.stderr new file mode 100644 index 0000000000000..52800e2f6e5b9 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.edition2024.stderr @@ -0,0 +1,35 @@ +error[E0004]: non-exhaustive patterns: `None` not covered + --> $DIR/exhaustive.rs:8:11 + | +LL | match x { + | ^ pattern `None` not covered + | +note: `Option` defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + ::: $SRC_DIR/core/src/option.rs:LL:COL + | + = note: not covered + = note: the matched value is of type `Option` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ None if let y = x => {}, +LL + None => todo!() + | + +error[E0004]: non-exhaustive patterns: `()` not covered + --> $DIR/exhaustive.rs:17:11 + | +LL | match x { + | ^ pattern `()` not covered + | + = note: the matched value is of type `()` + = note: match arms with guards don't count towards exhaustivity +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ y if let z = y => {}, +LL + () => todo!() + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.rs index b4eb541398cfa..13e42eab841a3 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/exhaustive.rs @@ -1,6 +1,9 @@ -#![feature(if_let_guard)] #![allow(irrefutable_let_patterns)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 + fn match_option(x: Option) { match x { //~^ ERROR non-exhaustive patterns: `None` not covered diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs deleted file mode 100644 index b1e305834cb2e..0000000000000 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.rs +++ /dev/null @@ -1,71 +0,0 @@ -// gate-test-if_let_guard - -use std::ops::Range; - -fn _if_let_guard() { - match () { - () if let 0 = 1 => {} - //~^ ERROR `if let` guards are experimental - - () if (let 0 = 1) => {} - //~^ ERROR expected expression, found `let` statement - - () if (((let 0 = 1))) => {} - //~^ ERROR expected expression, found `let` statement - - () if true && let 0 = 1 => {} - //~^ ERROR `if let` guards are experimental - - () if let 0 = 1 && true => {} - //~^ ERROR `if let` guards are experimental - - () if (let 0 = 1) && true => {} - //~^ ERROR expected expression, found `let` statement - - () if true && (let 0 = 1) => {} - //~^ ERROR expected expression, found `let` statement - - () if (let 0 = 1) && (let 0 = 1) => {} - //~^ ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - - () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - //~^ ERROR `if let` guards are experimental - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - - - () if let Range { start: _, end: _ } = (true..true) && false => {} - //~^ ERROR `if let` guards are experimental - - _ => {} - } -} - -fn _macros() { - macro_rules! use_expr { - ($e:expr) => { - match () { - () if $e => {} - _ => {} - } - } - } - use_expr!((let 0 = 1 && 0 == 0)); - //~^ ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - use_expr!((let 0 = 1)); - //~^ ERROR expected expression, found `let` statement - //~| ERROR expected expression, found `let` statement - match () { - #[cfg(false)] - () if let 0 = 1 => {} - //~^ ERROR `if let` guards are experimental - _ => {} - } - use_expr!(let 0 = 1); - //~^ ERROR no rules expected keyword `let` -} - -fn main() {} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr deleted file mode 100644 index 19d1f4b0a573b..0000000000000 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/feature-gate.stderr +++ /dev/null @@ -1,235 +0,0 @@ -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:10:16 - | -LL | () if (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:10:16 - | -LL | () if (let 0 = 1) => {} - | ^^^^^^^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:13:18 - | -LL | () if (((let 0 = 1))) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:13:18 - | -LL | () if (((let 0 = 1))) => {} - | ^^^^^^^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:22:16 - | -LL | () if (let 0 = 1) && true => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:22:16 - | -LL | () if (let 0 = 1) && true => {} - | ^^^^^^^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:25:24 - | -LL | () if true && (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:25:24 - | -LL | () if true && (let 0 = 1) => {} - | ^^^^^^^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:28:16 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:28:16 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:28:31 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:28:31 - | -LL | () if (let 0 = 1) && (let 0 = 1) => {} - | ^^^^^^^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:32:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:32:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:32:55 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:32:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:32:68 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions -note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/feature-gate.rs:32:42 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:55:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:55:16 - | -LL | use_expr!((let 0 = 1 && 0 == 0)); - | ^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:58:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:58:16 - | -LL | use_expr!((let 0 = 1)); - | ^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: no rules expected keyword `let` - --> $DIR/feature-gate.rs:67:15 - | -LL | macro_rules! use_expr { - | --------------------- when calling this macro -... -LL | use_expr!(let 0 = 1); - | ^^^ no rules expected this token in macro call - | -note: while trying to match meta-variable `$e:expr` - --> $DIR/feature-gate.rs:48:10 - | -LL | ($e:expr) => { - | ^^^^^^^ - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:7:12 - | -LL | () if let 0 = 1 => {} - | ^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:16:12 - | -LL | () if true && let 0 = 1 => {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:19:12 - | -LL | () if let 0 = 1 && true => {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:32:12 - | -LL | () if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:39:12 - | -LL | () if let Range { start: _, end: _ } = (true..true) && false => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = help: you can write `if matches!(, )` instead of `if let = ` - -error[E0658]: `if let` guards are experimental - --> $DIR/feature-gate.rs:63:12 - | -LL | () if let 0 = 1 => {} - | ^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = help: you can write `if matches!(, )` instead of `if let = ` - -error: aborting due to 20 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.edition2021.stderr similarity index 92% rename from tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.stderr rename to tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.edition2021.stderr index 741ae7c92d78b..d6db1c75a5fed 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.edition2021.stderr @@ -1,5 +1,5 @@ error[E0505]: cannot move out of `x.0` because it is borrowed - --> $DIR/guard-lifetime-1.rs:8:14 + --> $DIR/guard-lifetime-1.rs:10:14 | LL | Some(mut y) if let Some(ref z) = y => { | ^^^^^ diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.edition2024.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.edition2024.stderr new file mode 100644 index 0000000000000..d6db1c75a5fed --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.edition2024.stderr @@ -0,0 +1,15 @@ +error[E0505]: cannot move out of `x.0` because it is borrowed + --> $DIR/guard-lifetime-1.rs:10:14 + | +LL | Some(mut y) if let Some(ref z) = y => { + | ^^^^^ + | | + | move out of `x.0` occurs here + | borrow of `x.0` occurs here +LL | +LL | let _z: &String = z; + | - borrow later used here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0505`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs index 792225e656f42..fc589e8f2e113 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-1.rs @@ -1,6 +1,8 @@ // References to by-move bindings in an if-let guard *cannot* be used after the guard. -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 fn main() { let x: Option> = Some(Some(String::new())); diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-2.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-2.rs index 09dc4bfde35f3..5009aaee53e5a 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-2.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-lifetime-2.rs @@ -1,8 +1,9 @@ // References to by-mutable-ref bindings in an if-let guard *can* be used after the guard. //@ check-pass - -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 fn main() { let mut x: Option> = Some(Some(String::new())); diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.edition2021.stderr similarity index 91% rename from tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.stderr rename to tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.edition2021.stderr index 98285f5c3e1c8..989967e0262f1 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.edition2021.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `y.0` as mutable, as it is immutable for the pattern guard - --> $DIR/guard-mutability-1.rs:8:33 + --> $DIR/guard-mutability-1.rs:10:33 | LL | Some(mut y) if let Some(ref mut z) = y => { | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.edition2024.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.edition2024.stderr new file mode 100644 index 0000000000000..989967e0262f1 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.edition2024.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `y.0` as mutable, as it is immutable for the pattern guard + --> $DIR/guard-mutability-1.rs:10:33 + | +LL | Some(mut y) if let Some(ref mut z) = y => { + | ^^^^^^^^^ cannot borrow as mutable + | + = note: variables bound in patterns are immutable until the end of the pattern guard + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.rs index 9353c9d92f89b..1f01a714ee379 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-1.rs @@ -1,6 +1,8 @@ // Check mutable bindings cannot be mutated by an if-let guard. -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 fn main() { let x: Option> = Some(Some(6)); diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.edition2021.stderr similarity index 91% rename from tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.stderr rename to tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.edition2021.stderr index 31df8a922ace2..1118a2a0f9164 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.edition2021.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `y.0` as mutable, as it is immutable for the pattern guard - --> $DIR/guard-mutability-2.rs:8:37 + --> $DIR/guard-mutability-2.rs:10:37 | LL | Some(ref mut y) if let Some(ref mut z) = *y => { | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.edition2024.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.edition2024.stderr new file mode 100644 index 0000000000000..1118a2a0f9164 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.edition2024.stderr @@ -0,0 +1,11 @@ +error[E0596]: cannot borrow `y.0` as mutable, as it is immutable for the pattern guard + --> $DIR/guard-mutability-2.rs:10:37 + | +LL | Some(ref mut y) if let Some(ref mut z) = *y => { + | ^^^^^^^^^ cannot borrow as mutable + | + = note: variables bound in patterns are immutable until the end of the pattern guard + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.rs index 4efa02f57a6c7..63f99e2fe2af0 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/guard-mutability-2.rs @@ -1,6 +1,8 @@ // Check mutable reference bindings cannot be mutated by an if-let guard. -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 fn main() { let mut x: Option> = Some(Some(6)); diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs index c13804e4534ea..6af36f3e3718e 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/loop-mutability.rs @@ -1,6 +1,7 @@ //@ check-pass - -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 fn split_last(_: &()) -> Option<(&i32, &i32)> { None diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.edition2021.stderr similarity index 93% rename from tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.stderr rename to tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.edition2021.stderr index 921cd083fffd7..6c543ec258584 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.edition2021.stderr @@ -1,5 +1,5 @@ error: expected expression, found `let` statement - --> $DIR/macro-expanded.rs:6:20 + --> $DIR/macro-expanded.rs:8:20 | LL | ($e:expr) => { let Some(x) = $e } | ^^^ diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.edition2024.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.edition2024.stderr new file mode 100644 index 0000000000000..6c543ec258584 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.edition2024.stderr @@ -0,0 +1,14 @@ +error: expected expression, found `let` statement + --> $DIR/macro-expanded.rs:8:20 + | +LL | ($e:expr) => { let Some(x) = $e } + | ^^^ +... +LL | () if m!(Some(5)) => {} + | ----------- in this macro invocation + | + = note: only supported directly in conditions of `if` and `while` expressions + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.rs index e1138835006b9..11fba2c018542 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/macro-expanded.rs @@ -1,6 +1,8 @@ // Expression macros can't expand to a let match guard. -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 macro_rules! m { ($e:expr) => { let Some(x) = $e } diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.edition2021.stderr similarity index 92% rename from tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.stderr rename to tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.edition2021.stderr index 123c5f1943024..d526cc05dece7 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.edition2021.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `x` - --> $DIR/move-guard-if-let-chain.rs:12:23 + --> $DIR/move-guard-if-let-chain.rs:15:23 | LL | let x: Box<_> = Box::new(1); | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait @@ -15,7 +15,7 @@ LL | (1, 2) if let ref y = x && c => (), | +++ error[E0382]: use of moved value: `x` - --> $DIR/move-guard-if-let-chain.rs:36:23 + --> $DIR/move-guard-if-let-chain.rs:39:23 | LL | let x: Box<_> = Box::new(1); | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait @@ -31,7 +31,7 @@ LL | (1, _) if let ref y = x && c => (), | +++ error[E0382]: use of moved value: `x` - --> $DIR/move-guard-if-let-chain.rs:59:32 + --> $DIR/move-guard-if-let-chain.rs:62:32 | LL | let x: Box<_> = Box::new(1); | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait @@ -45,7 +45,7 @@ LL | (1, _) | (_, 2) if let ref y = x && c => (), | +++ error[E0382]: use of moved value: `x` - --> $DIR/move-guard-if-let-chain.rs:82:16 + --> $DIR/move-guard-if-let-chain.rs:85:16 | LL | let x: Box<_> = Box::new(1); | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait @@ -61,7 +61,7 @@ LL | (1, 2) if let ref y = x && c => false, | +++ error[E0382]: use of moved value: `x` - --> $DIR/move-guard-if-let-chain.rs:103:41 + --> $DIR/move-guard-if-let-chain.rs:106:41 | LL | let x: Box<_> = Box::new(1); | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.edition2024.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.edition2024.stderr new file mode 100644 index 0000000000000..d526cc05dece7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.edition2024.stderr @@ -0,0 +1,81 @@ +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-if-let-chain.rs:15:23 + | +LL | let x: Box<_> = Box::new(1); + | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait +... +LL | (1, 2) if let y = x && c => (), + | - value moved here +LL | (1, 2) if let z = x => (), + | ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | (1, 2) if let ref y = x && c => (), + | +++ + +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-if-let-chain.rs:39:23 + | +LL | let x: Box<_> = Box::new(1); + | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait +... +LL | (1, _) if let y = x && c => (), + | - value moved here +LL | (_, 2) if let z = x => (), + | ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | (1, _) if let ref y = x && c => (), + | +++ + +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-if-let-chain.rs:62:32 + | +LL | let x: Box<_> = Box::new(1); + | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait +... +LL | (1, _) | (_, 2) if let y = x && c => (), + | ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | (1, _) | (_, 2) if let ref y = x && c => (), + | +++ + +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-if-let-chain.rs:85:16 + | +LL | let x: Box<_> = Box::new(1); + | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait +... +LL | (1, 2) if let y = x && c => false, + | - value moved here +LL | _ => { *x == 1 }, + | ^^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | (1, 2) if let ref y = x && c => false, + | +++ + +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-if-let-chain.rs:106:41 + | +LL | let x: Box<_> = Box::new(1); + | - move occurs because `x` has type `Box`, which does not implement the `Copy` trait +... +LL | (1, 2) if let y = x && c && let z = x => false, + | - ^ value used here after move + | | + | value moved here + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | (1, 2) if let ref y = x && c && let z = x => false, + | +++ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.rs index 29f529a30c2ff..0ae45de11e71c 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.rs @@ -1,5 +1,8 @@ -//@ edition: 2024 -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 + +#![cfg_attr(edition2021, feature(let_chains))] #![allow(irrefutable_let_patterns)] fn same_pattern(c: bool) { diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let.rs index 73bee8a6c68e0..9f1197f983200 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let.rs @@ -2,8 +2,10 @@ // only happen when the pattern is matched. //@ build-pass +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 -#![feature(if_let_guard)] #![allow(irrefutable_let_patterns)] fn same_pattern() { @@ -36,6 +38,6 @@ fn main() { match v { (1, 2) if let y = x => false, - _ => { *x == 1 }, + _ => *x == 1, }; } diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/parens.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.edition2021.stderr similarity index 87% rename from tests/ui/rfcs/rfc-2294-if-let-guard/parens.stderr rename to tests/ui/rfcs/rfc-2294-if-let-guard/parens.edition2021.stderr index 0c16d9c5442b0..ba526bad8cbc3 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/parens.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.edition2021.stderr @@ -1,51 +1,51 @@ error: expected expression, found `let` statement - --> $DIR/parens.rs:10:16 + --> $DIR/parens.rs:11:16 | LL | () if (let 0 = 1) => {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/parens.rs:10:16 + --> $DIR/parens.rs:11:16 | LL | () if (let 0 = 1) => {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/parens.rs:12:18 + --> $DIR/parens.rs:13:18 | LL | () if (((let 0 = 1))) => {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/parens.rs:12:18 + --> $DIR/parens.rs:13:18 | LL | () if (((let 0 = 1))) => {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/parens.rs:20:16 + --> $DIR/parens.rs:21:16 | LL | () if (let 0 = 1) => {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/parens.rs:20:16 + --> $DIR/parens.rs:21:16 | LL | () if (let 0 = 1) => {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/parens.rs:22:18 + --> $DIR/parens.rs:23:18 | LL | () if (((let 0 = 1))) => {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/parens.rs:22:18 + --> $DIR/parens.rs:23:18 | LL | () if (((let 0 = 1))) => {} | ^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/parens.edition2024.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.edition2024.stderr new file mode 100644 index 0000000000000..ba526bad8cbc3 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.edition2024.stderr @@ -0,0 +1,54 @@ +error: expected expression, found `let` statement + --> $DIR/parens.rs:11:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/parens.rs:11:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + +error: expected expression, found `let` statement + --> $DIR/parens.rs:13:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/parens.rs:13:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + +error: expected expression, found `let` statement + --> $DIR/parens.rs:21:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/parens.rs:21:16 + | +LL | () if (let 0 = 1) => {} + | ^^^^^^^^^ + +error: expected expression, found `let` statement + --> $DIR/parens.rs:23:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions +note: `let`s wrapped in parentheses are not supported in a context with let chains + --> $DIR/parens.rs:23:18 + | +LL | () if (((let 0 = 1))) => {} + | ^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/parens.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.rs index a4cb73c650835..14f61cdc56d91 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/parens.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/parens.rs @@ -1,7 +1,8 @@ -//@ edition: 2024 // Parenthesised let "expressions" are not allowed in guards -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 #[cfg(false)] fn un_cfged() { diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs index e836b0b88ffc7..ee9e215fe0ba2 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs @@ -1,8 +1,8 @@ // Macros can be used for (parts of) the pattern and expression in an if let guard //@ check-pass - -#![feature(if_let_guard)] -#![feature(let_chains)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 macro_rules! m { (pattern $i:ident) => { Some($i) }; diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/run-pass.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/run-pass.rs index e8a74a4ac34bc..1850352475807 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/run-pass.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/run-pass.rs @@ -1,6 +1,7 @@ //@ run-pass - -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 enum Foo { Bar, diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/scope.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/scope.rs index 56a6fb5bfa3ff..ef7c708670aba 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/scope.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/scope.rs @@ -1,9 +1,10 @@ // Tests for #88015 when using if let chains in match guards -//@run-pass +//@ run-pass +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 -#![feature(if_let_guard)] -#![feature(let_chains)] #![allow(irrefutable_let_patterns)] fn lhs_let(opt: Option) { diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs index 00eb952635a99..af2b278d472bc 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency-async.rs @@ -2,11 +2,12 @@ // Regression test for #116079. //@ build-pass -//@ edition:2018 +//@revisions: edition2021 edition2024 edition2018 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 +//@[edition2018] edition:2018 // -Zvalidate-mir -#![feature(if_let_guard)] - static mut A: [i32; 5] = [1, 2, 3, 4, 5]; async fn fun() { diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs index 1a36bc5b372f7..9a4b7c4df3338 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/scoping-consistency.rs @@ -1,10 +1,11 @@ // Check that temporaries in if-let guards are correctly scoped. //@ build-pass +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 // -Zvalidate-mir -#![feature(if_let_guard)] - fn fun() { match 0 { _ => (), diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/shadowing.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/shadowing.rs index e7946a2a23b11..57972f63f6892 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/shadowing.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/shadowing.rs @@ -1,8 +1,11 @@ // Check shadowing in if let guards works as expected. + //@ check-pass -//@ edition: 2024 +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 -#![feature(if_let_guard)] +#![cfg_attr(edition2021, feature(let_chains))] fn main() { let x: Option> = Some(Some(6)); diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/temporary-early-drop.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/temporary-early-drop.rs index 9edbc3243c716..15a3e4cda26e0 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/temporary-early-drop.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/temporary-early-drop.rs @@ -4,8 +4,8 @@ //@ [edition2024] edition: 2024 //@ check-pass -#![feature(if_let_guard)] #![allow(irrefutable_let_patterns)] +#![cfg_attr(edition2021, feature(let_chains))] struct Pd; diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/type-inference.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/type-inference.rs index 9d20709ee9baa..3a626db5d4fa0 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/type-inference.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/type-inference.rs @@ -1,6 +1,7 @@ //@ check-pass - -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 struct S; diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.edition2021.stderr similarity index 96% rename from tests/ui/rfcs/rfc-2294-if-let-guard/typeck.stderr rename to tests/ui/rfcs/rfc-2294-if-let-guard/typeck.edition2021.stderr index 4ce97a68a911a..1dfa11115c079 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.edition2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/typeck.rs:9:22 + --> $DIR/typeck.rs:11:22 | LL | Ok(x) if let Err(_) = x => {}, | ^^^^^^ - this expression has type `Option` @@ -10,7 +10,7 @@ LL | Ok(x) if let Err(_) = x => {}, found enum `Result<_, _>` error[E0308]: mismatched types - --> $DIR/typeck.rs:11:22 + --> $DIR/typeck.rs:13:22 | LL | Ok(x) if let 0 = x => {}, | ^ - this expression has type `Option` diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.edition2024.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.edition2024.stderr new file mode 100644 index 0000000000000..1dfa11115c079 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.edition2024.stderr @@ -0,0 +1,25 @@ +error[E0308]: mismatched types + --> $DIR/typeck.rs:11:22 + | +LL | Ok(x) if let Err(_) = x => {}, + | ^^^^^^ - this expression has type `Option` + | | + | expected `Option`, found `Result<_, _>` + | + = note: expected enum `Option` + found enum `Result<_, _>` + +error[E0308]: mismatched types + --> $DIR/typeck.rs:13:22 + | +LL | Ok(x) if let 0 = x => {}, + | ^ - this expression has type `Option` + | | + | expected `Option`, found integer + | + = note: expected enum `Option` + found type `{integer}` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.rs index ad178dfa43947..349f84a0a250e 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/typeck.rs @@ -1,4 +1,6 @@ -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 fn ok() -> Result, ()> { Ok(Some(true)) diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.edition2021.stderr similarity index 88% rename from tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr rename to tests/ui/rfcs/rfc-2294-if-let-guard/warns.edition2021.stderr index 693a06a229786..8bf4886fe5fc7 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.stderr +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.edition2021.stderr @@ -1,5 +1,5 @@ error: irrefutable `if let` guard pattern - --> $DIR/warns.rs:6:20 + --> $DIR/warns.rs:8:20 | LL | Some(x) if let () = x => {} | ^^^^^^^^^^ @@ -7,13 +7,13 @@ LL | Some(x) if let () = x => {} = note: this pattern will always match, so the guard is useless = help: consider removing the guard and adding a `let` inside the match arm note: the lint level is defined here - --> $DIR/warns.rs:3:8 + --> $DIR/warns.rs:5:8 | LL | #[deny(irrefutable_let_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/warns.rs:15:25 + --> $DIR/warns.rs:17:25 | LL | x if let None | None = x => {} | ---- ^^^^ no value can reach this @@ -21,7 +21,7 @@ LL | x if let None | None = x => {} | matches all the relevant values | note: the lint level is defined here - --> $DIR/warns.rs:12:8 + --> $DIR/warns.rs:14:8 | LL | #[deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.edition2024.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.edition2024.stderr new file mode 100644 index 0000000000000..8bf4886fe5fc7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.edition2024.stderr @@ -0,0 +1,30 @@ +error: irrefutable `if let` guard pattern + --> $DIR/warns.rs:8:20 + | +LL | Some(x) if let () = x => {} + | ^^^^^^^^^^ + | + = note: this pattern will always match, so the guard is useless + = help: consider removing the guard and adding a `let` inside the match arm +note: the lint level is defined here + --> $DIR/warns.rs:5:8 + | +LL | #[deny(irrefutable_let_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/warns.rs:17:25 + | +LL | x if let None | None = x => {} + | ---- ^^^^ no value can reach this + | | + | matches all the relevant values + | +note: the lint level is defined here + --> $DIR/warns.rs:14:8 + | +LL | #[deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs index 3ad1a50c61f83..eedcb7d162717 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/warns.rs @@ -1,4 +1,6 @@ -#![feature(if_let_guard)] +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 #[deny(irrefutable_let_patterns)] fn irrefutable_let_guard() { diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs index e7d69f89773ee..252a543c1f4c7 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs @@ -1,7 +1,7 @@ //@ revisions: allowed disallowed //@[allowed] check-pass -#![feature(if_let_guard, let_chains)] +#![feature(let_chains)] #![cfg_attr(allowed, allow(irrefutable_let_patterns))] #![cfg_attr(disallowed, deny(irrefutable_let_patterns))] diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs index f6de37867d855..9c9d1b9f1350a 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.rs @@ -1,7 +1,9 @@ +// https://github.com/rust-lang/rust/issues/93150 +//@ run-pass + fn main() { match true { _ if let true = true && true => {} - //~^ ERROR `if let` guards are _ => {} } } diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.stderr deleted file mode 100644 index 17fa37d2df322..0000000000000 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/issue-93150.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0658]: `if let` guards are experimental - --> $DIR/issue-93150.rs:3:11 - | -LL | _ if let true = true && true => {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #51114 for more information - = help: add `#![feature(if_let_guard)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = help: you can write `if matches!(, )` instead of `if let = ` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs index 6d307be90c121..c36c47a546dc0 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs @@ -1,6 +1,9 @@ //@ run-pass +//@revisions: edition2021 edition2024 +//@[edition2021] edition:2021 +//@[edition2024] edition:2024 -#![feature(if_let_guard, let_chains)] +#![cfg_attr(edition2021, feature(let_chains))] fn check_if_let(opt: Option>>, value: i32) -> bool { if let Some(first) = opt diff --git a/tests/ui/unpretty/interpolation-expanded.rs b/tests/ui/unpretty/interpolation-expanded.rs index 95280f97dac14..ab5c72e4ffc78 100644 --- a/tests/ui/unpretty/interpolation-expanded.rs +++ b/tests/ui/unpretty/interpolation-expanded.rs @@ -8,7 +8,6 @@ // Rust syntax. We also test negative cases: the pretty-printer should not be // synthesizing parentheses indiscriminately; only where necessary. -#![feature(if_let_guard)] macro_rules! expr { ($expr:expr) => { $expr }; diff --git a/tests/ui/unpretty/interpolation-expanded.stdout b/tests/ui/unpretty/interpolation-expanded.stdout index d46b46b67f41f..b29d0447653cc 100644 --- a/tests/ui/unpretty/interpolation-expanded.stdout +++ b/tests/ui/unpretty/interpolation-expanded.stdout @@ -1,4 +1,8 @@ #![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2024::*; +#[macro_use] +extern crate std; //@ compile-flags: -Zunpretty=expanded //@ edition:2024 //@ check-pass @@ -9,11 +13,6 @@ // Rust syntax. We also test negative cases: the pretty-printer should not be // synthesizing parentheses indiscriminately; only where necessary. -#![feature(if_let_guard)] -#[prelude_import] -use std::prelude::rust_2024::*; -#[macro_use] -extern crate std; macro_rules! expr { ($expr:expr) => { $expr }; } diff --git a/tests/ui/unreachable-code.rs b/tests/ui/unreachable-code.rs index 0c46a38d73f35..5894c0f3188b0 100644 --- a/tests/ui/unreachable-code.rs +++ b/tests/ui/unreachable-code.rs @@ -5,7 +5,6 @@ #![allow(path_statements)] #![allow(unreachable_code)] #![allow(unused_variables)] -#![feature(if_let_guard)] fn id(x: bool) -> bool { x