Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/mutable_ref.rs')
-rw-r--r--crates/ide-diagnostics/src/handlers/mutable_ref.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/crates/ide-diagnostics/src/handlers/mutable_ref.rs b/crates/ide-diagnostics/src/handlers/mutable_ref.rs
index 14734564b7..b56619612d 100644
--- a/crates/ide-diagnostics/src/handlers/mutable_ref.rs
+++ b/crates/ide-diagnostics/src/handlers/mutable_ref.rs
@@ -10,7 +10,7 @@ pub(crate) fn mutable_ref_binding(
Diagnostic::new_with_syntax_node_ptr(
ctx,
DiagnosticCode::RustcHardError("E0658"),
- "`mut` bindings cannot also be `ref` by default in 2024 edition",
+ "bindings cannot be both mutable and by-reference by default in 2024 edition. add experimental #![feature(mut_ref)] for this functionality",
d.pat.map(Into::into),
)
.stable()
@@ -26,12 +26,15 @@ mod tests {
r#"
//- minicore: option
#![feature(ref_pat_eat_one_layer_2024)]
+struct TestStruct {
+ val: i32
+}
fn main() {
- let opt_ref = &Some(42);
+ let opt_ref = &Some(TestStruct {val: 1});
if let Some(mut x) = opt_ref {
- //^^^^^ error: `mut` bindings cannot also be `ref` by default in 2024 edition
- x = &5;
+ //^^^^^ error: bindings cannot be both mutable and by-reference by default in 2024 edition. add experimental #![feature(mut_ref)] for this functionality
+ x = &TestStruct{val: 5};
}
}
"#,
@@ -45,11 +48,14 @@ fn main() {
//- minicore: option
#![feature(ref_pat_eat_one_layer_2024)]
#![feature(mut_ref)]
+struct TestStruct {
+ val: i32
+}
fn main() {
- let opt_ref = &Some(42);
+ let opt_ref = &Some(TestStruct{val: 1});
if let Some(mut x) = opt_ref {
- x = &5;
+ x = &TestStruct{val: 5};
}
}
"#,