Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs')
-rw-r--r--crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs42
1 files changed, 41 insertions, 1 deletions
diff --git a/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs b/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
index 01cf5e8fa5..1e80d02926 100644
--- a/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
+++ b/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
@@ -4,7 +4,10 @@ use hir::HirDisplay;
// Diagnostic: moved-out-of-ref
//
// This diagnostic is triggered on moving non copy things out of references.
-pub(crate) fn moved_out_of_ref(ctx: &DiagnosticsContext<'_>, d: &hir::MovedOutOfRef) -> Diagnostic {
+pub(crate) fn moved_out_of_ref(
+ ctx: &DiagnosticsContext<'_>,
+ d: &hir::MovedOutOfRef<'_>,
+) -> Diagnostic {
Diagnostic::new_with_syntax_node_ptr(
ctx,
DiagnosticCode::RustcHardError("E0507"),
@@ -217,4 +220,41 @@ fn test() {
"#,
)
}
+
+ #[test]
+ fn regression_18201() {
+ check_diagnostics(
+ r#"
+//- minicore: copy
+struct NotCopy;
+struct S(NotCopy);
+impl S {
+ fn f(&mut self) {
+ || {
+ if let ref mut _cb = self.0 {
+ }
+ };
+ }
+}
+"#,
+ )
+ }
+
+ #[test]
+ fn regression_20155() {
+ check_diagnostics(
+ r#"
+//- minicore: copy, option
+struct Box(i32);
+fn test() {
+ let b = Some(Box(0));
+ || {
+ if let Some(b) = b {
+ let _move = b;
+ }
+ };
+}
+"#,
+ )
+ }
}