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.rs19
1 files changed, 17 insertions, 2 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 7d0f10983d..780271361d 100644
--- a/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
+++ b/crates/ide-diagnostics/src/handlers/moved_out_of_ref.rs
@@ -18,7 +18,22 @@ pub(crate) fn moved_out_of_ref(ctx: &DiagnosticsContext<'_>, d: &hir::MovedOutOf
mod tests {
use crate::tests::check_diagnostics;
- // FIXME: spans are broken
+ #[test]
+ fn operand_field_span_respected() {
+ check_diagnostics(
+ r#"
+struct NotCopy;
+struct S {
+ field: NotCopy,
+}
+
+fn f(s: &S) -> S {
+ S { field: s.field }
+ //^^^^^^^ error: cannot move `NotCopy` out of reference
+}
+ "#,
+ );
+ }
#[test]
fn move_by_explicit_deref() {
@@ -85,7 +100,7 @@ fn consume<T>(_: X<T>) {
fn main() {
let a = &X(Y);
consume(*a);
- //^^^^^^^^^^^ error: cannot move `X<Y>` out of reference
+ //^^ error: cannot move `X<Y>` out of reference
let a = &X(5);
consume(*a);
}