Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot move out of reference error has bad span #19172

Open
Veykril opened this issue Feb 18, 2025 · 2 comments · May be fixed by #19247
Open

cannot move out of reference error has bad span #19172

Veykril opened this issue Feb 18, 2025 · 2 comments · May be fixed by #19247
Assignees
Labels
A-diagnostics diagnostics / error reporting C-enhancement Category: enhancement

Comments

@Veykril
Copy link
Member

Veykril commented Feb 18, 2025

struct NotCopy;
struct S {
    field: NotCopy,
}

fn f(s: &S) -> S {
    S { field: s.field }
}

the diagnostic here highlights the entire struct constructor S { field: s.field } which makes it difficult to tell what the cause is in more complicated constructions.

@Veykril Veykril added A-diagnostics diagnostics / error reporting C-enhancement Category: enhancement labels Feb 18, 2025
@alibektas
Copy link
Member

alibektas commented Feb 18, 2025

Image

Am I misunderstanding sth or am I getting a different behavior?

rust-analyzer version: 0.0.0 (4a6ea31 2025-02-18)

@ShoyuVanilla
Copy link
Member

ShoyuVanilla commented Feb 19, 2025

Am I misunderstanding sth or am I getting a different behavior?

The span in the above screenshot seems to be from rustc. This native diagnostic(move_out_of_ref) requires turning on experimental diagnostics option.

@alibektas alibektas self-assigned this Feb 25, 2025
alibektas added a commit to alibektas/rust-analyzer that referenced this issue Feb 27, 2025
@alibektas alibektas linked a pull request Feb 27, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting C-enhancement Category: enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants