A Rust compiler front-end for IDEs
Find a file
Matthias Krüger 7c4b2b92c2
Rollup merge of #144200 - estebank:dont-point-at-closure, r=lcnr
Tweak output for non-`Clone` values moved into closures

When we encounter a non-`Clone` value being moved into a closure, try to find the corresponding type of the binding being moved, if it is a `let`-binding or a function parameter. If any of those cases, we point at them with the note explaining that the type is not `Copy`, instead of giving that label to the place where it is captured. When it is a `let`-binding with no explicit type, we point at the initializer (if it fits in a single line).

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             ---  ----------- move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
   |             |
   |             captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            --- variable moved due to use in coroutine
```

instead of

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             --- captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            ---
   |            |
   |            variable moved due to use in coroutine
   |            move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
```
2025-07-25 11:16:36 +02:00
.cargo fix: Fix generated markers not being patchable in package.json 2024-06-08 12:54:43 +02:00
.github ci: Fix up release workflow 2025-06-28 11:35:55 +02:00
.vscode feat: use vscode log format for client logs 2024-07-27 21:43:35 -07:00
assets Automatically change text color in logo based on dark mode 2022-03-06 23:06:53 +11:00
bench_data chore: Bump Edition::CURRENT to 2024 2025-03-17 12:29:19 +01:00
crates Revert "Bump rustc-literal-escaper" 2025-07-21 09:31:28 +03:00
docs/book remove syntaxTree from docs 2025-07-04 14:27:03 -03:00
editors/code Merge pull request #20104 from Veykril/push-nqnmmlvksyty 2025-06-26 08:44:57 +00:00
lib examples: add minimal_lsp.rs and FIFO test script. 2025-07-17 11:04:14 +02:00
xtask Differentiate between asm!(), global_asm!() and naked_asm!(), and make only asm!() unsafe 2025-07-09 17:37:27 +03:00
.editorconfig fix: do not apply editorconfig to git commit msg 2025-03-08 01:44:27 +05:30
.git-blame-ignore-revs Fix some mir eval/lowerings 2025-02-03 14:42:41 +01:00
.gitattributes Fix .gitattributes for test_data 2022-07-24 14:05:35 +02:00
.gitignore manual: Convert to mdbook 2025-01-24 13:23:22 -08:00
.typos.toml Ignore ast id hashes in typos check 2025-06-12 08:50:43 +03:00
Cargo.lock Downgrade ra-ap-rustc_parse_format 2025-07-21 09:46:53 +03:00
Cargo.toml Downgrade ra-ap-rustc_parse_format 2025-07-21 09:46:53 +03:00
clippy.toml Enforce a current directory being set for spawned commands 2024-12-29 12:51:13 +01:00
CONTRIBUTING.md move dev docs to manual 2025-02-17 10:47:27 -08:00
LICENSE-APACHE Drop Apache license appendices 2024-08-27 14:52:34 +03:00
LICENSE-MIT Licenses 2018-01-10 22:47:04 +03:00
PRIVACY.md Update PRIVACY.md 2025-02-07 20:18:21 +01:00
README.md move dev docs to manual 2025-02-17 10:47:27 -08:00
rust-version Preparing for merge from rust-lang/rust 2025-07-21 09:17:54 +03:00
rustfmt.toml Shuffle hir-expand things around 2024-01-26 19:28:39 +01:00
triagebot.toml Enable [canonicalize-issue-links] and [no-mentions] in triagebot 2025-04-09 22:15:51 +02:00

rust-analyzer logo

rust-analyzer is a modular compiler frontend for the Rust language. It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust.

Quick Start

https://rust-analyzer.github.io/book/installation.html

Documentation

If you want to contribute to rust-analyzer check out the CONTRIBUTING.md or if you are just curious about how things work under the hood, see the Contributing section of the manual.

If you want to use rust-analyzer's language server with your editor of choice, check the manual. It also contains some tips & tricks to help you be more productive when using rust-analyzer.

Security and Privacy

See the security and privacy sections of the manual.

Communication

For usage and troubleshooting requests, please use "IDEs and Editors" category of the Rust forum:

https://users.rust-lang.org/c/ide/14

For questions about development and implementation, join rust-analyzer working group on Zulip:

https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer

License

rust-analyzer is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.