Commit Graph

14 Commits

Author SHA1 Message Date
Esteban Küber
11061831f7 Mention type that could be Clone but isn't in more cases
When encountering a moved value of a type that isn't `Clone` because of unmet obligations, but where all the unmet predicates reference crate-local types, mention them and suggest cloning, as we do in other cases already:

```
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
   |
note: if `Foo` implemented `Clone`, you could clone the value
  --> f111.rs:4:1
   |
4  | struct Foo;
   | ^^^^^^^^^^ consider implementing `Clone` for this type
...
15 |         if foo.map_or(false, |f| f.foo()) {
   |            --- you could clone this value
```
2025-07-25 18:34:10 +00:00
Matthew Jasper
4a1843924e Fix spans for unsafe binders 2025-05-30 16:58:48 +00:00
Michael Goulet
3a736e2726 Handle e2021 precise capturing of unsafe binder 2025-05-28 12:17:18 +00:00
许杰友 Jieyou Xu (Joe)
9f93c48ddc Rollup merge of #141433 - compiler-errors:unsafe-binder-captures, r=oli-obk
Properly analyze captures from unsafe binders

We need to represent the unsafe binder unwrap as an adjustment in HIR. Pretty straightforward b/c we already represent it as a projection elem in MIR.

Fixes #141418
Fixes #141417

r? oli-obk
2025-05-27 01:29:18 +08:00
Michael Goulet
04ddafc53c Properly analyze captures from unsafe binders 2025-05-23 10:43:13 +00:00
Michael Goulet
46606a3f81 Dont walk into unsafe binders when emiting error for non-structural type match 2025-05-23 10:10:50 +00:00
Vadim Petrochenkov
b3f75353a2 UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
Michael Goulet
83fa2faf23 Fix pretty printing of unsafe binders 2025-03-03 01:34:09 +00:00
Michael Goulet
b67b6c0503 Fix sized constraint for unsafe binder 2025-02-28 03:17:36 +00:00
Michael Goulet
d0564fda65 Use BikeshedGuaranteedNotDrop in unsafe binder type WF too 2025-02-13 03:45:07 +00:00
Michael Goulet
b63341e892 Enforce unsafe binders must be Copy (for now) 2025-01-31 17:40:28 +00:00
Michael Goulet
fc1a9186dc Implement MIR, CTFE, and codegen for unsafe binders 2025-01-31 17:19:53 +00:00
Michael Goulet
9a1c5eb5b3 Begin to implement type system layer of unsafe binders 2024-12-22 21:57:57 +00:00
Michael Goulet
c5d02237d3 Add tests 2024-12-12 16:29:40 +00:00