<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_borrowck/src/diagnostics, branch 1.78.0</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.78.0</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.78.0'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2024-03-15T20:51:56+00:00</updated>
<entry>
<title>Rollup merge of #122254 - estebank:issue-48677, r=oli-obk</title>
<updated>2024-03-15T20:51:56+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>matthias.krueger@famsik.de</email>
</author>
<published>2024-03-15T20:51:56+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=9e153ccd45d231146f79e476c9b2d5e6c45e728c'/>
<id>urn:sha1:9e153ccd45d231146f79e476c9b2d5e6c45e728c</id>
<content type='text'>
Detect calls to .clone() on T: !Clone types on borrowck errors

When encountering a lifetime error on a type that *holds* a type that doesn't implement `Clone`, explore the item's body for potential calls to `.clone()` that are only cloning the reference `&amp;T` instead of `T` because `T: !Clone`. If we find this, suggest `T: Clone`.

```
error[E0502]: cannot borrow `*list` as mutable because it is also borrowed as immutable
  --&gt; $DIR/clone-on-ref.rs:7:5
   |
LL |     for v in list.iter() {
   |              ---- immutable borrow occurs here
LL |         cloned_items.push(v.clone())
   |                             ------- this call doesn't do anything, the result is still `&amp;T` because `T` doesn't implement `Clone`
LL |     }
LL |     list.push(T::default());
   |     ^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
LL |
LL |     drop(cloned_items);
   |          ------------ immutable borrow later used here
   |
help: consider further restricting this bound
   |
LL | fn foo&lt;T: Default + Clone&gt;(list: &amp;mut Vec&lt;T&gt;) {
   |                   +++++++
```
```
error[E0505]: cannot move out of `x` because it is borrowed
  --&gt; $DIR/clone-on-ref.rs:23:10
   |
LL | fn qux(x: A) {
   |        - binding `x` declared here
LL |     let a = &amp;x;
   |             -- borrow of `x` occurs here
LL |     let b = a.clone();
   |               ------- this call doesn't do anything, the result is still `&amp;A` because `A` doesn't implement `Clone`
LL |     drop(x);
   |          ^ move out of `x` occurs here
LL |
LL |     println!("{b:?}");
   |               ----- borrow later used here
   |
help: consider annotating `A` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | struct A;
   |
```

Fix #48677.
</content>
</entry>
<entry>
<title>Rollup merge of #122513 - petrochenkov:somehir4, r=fmease</title>
<updated>2024-03-15T16:24:09+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume1.gomez@gmail.com</email>
</author>
<published>2024-03-15T16:24:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=3d4464d4d75b0693de72aad3d9eb066ad25bc912'/>
<id>urn:sha1:3d4464d4d75b0693de72aad3d9eb066ad25bc912</id>
<content type='text'>
hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`

Also replace a few `hir_node()` calls with `hir_node_by_def_id()`.

Follow up to https://github.com/rust-lang/rust/pull/120943.
</content>
</entry>
<entry>
<title>Rollup merge of #122468 - beepster4096:borrowck_prefixes_cleanup, r=Nadrieril</title>
<updated>2024-03-15T16:24:07+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume1.gomez@gmail.com</email>
</author>
<published>2024-03-15T16:24:07+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=5c0012b9536b8c226c061d41c7c18d88e3526ea2'/>
<id>urn:sha1:5c0012b9536b8c226c061d41c7c18d88e3526ea2</id>
<content type='text'>
Cleanup `MirBorrowckCtxt::prefixes`

Some of the uses of this method aren't necessary anymore and `PrefixSet::Supporting` is not used anywhere.

With `PrefixSet::Supporting` removed, this could technically be moved to an extension trait on `PlaceRef`. However, it would have to be moved back to `MirBorrowckCtxt` when the `Derefer` MIR pass is moved before borrowck so I didn't.
</content>
</entry>
<entry>
<title>hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`</title>
<updated>2024-03-14T19:34:24+00:00</updated>
<author>
<name>Vadim Petrochenkov</name>
<email>vadim.petrochenkov@gmail.com</email>
</author>
<published>2024-03-14T18:05:06+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=89b536dbc85e23275f08feaf73a7abce691bf72c'/>
<id>urn:sha1:89b536dbc85e23275f08feaf73a7abce691bf72c</id>
<content type='text'>
Also replace a few `hir_node()` calls with `hir_node_by_def_id()`
</content>
</entry>
<entry>
<title>Rename `hir::StmtKind::Local` into `hir::StmtKind::Let`</title>
<updated>2024-03-14T11:42:04+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume.gomez@huawei.com</email>
</author>
<published>2024-03-14T10:53:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a4e0e50a3fb8d8658729f2860be54871597078da'/>
<id>urn:sha1:a4e0e50a3fb8d8658729f2860be54871597078da</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Account for UnOps in borrowck message</title>
<updated>2024-03-13T23:05:17+00:00</updated>
<author>
<name>Esteban Küber</name>
<email>esteban@kuber.com.ar</email>
</author>
<published>2024-03-12T17:21:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=0953608debfa9d3df955f976e7bc857584ba1ed0'/>
<id>urn:sha1:0953608debfa9d3df955f976e7bc857584ba1ed0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Detect calls to `.clone()` on `T: !Clone` types on borrowck errors</title>
<updated>2024-03-13T23:05:11+00:00</updated>
<author>
<name>Esteban Küber</name>
<email>esteban@kuber.com.ar</email>
</author>
<published>2024-03-09T20:18:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2d3435b4df844bb0c25b86bb73519a3c867a92a0'/>
<id>urn:sha1:2d3435b4df844bb0c25b86bb73519a3c867a92a0</id>
<content type='text'>
When encountering a lifetime error on a type that *holds* a type that
doesn't implement `Clone`, explore the item's body for potential calls
to `.clone()` that are only cloning the reference `&amp;T` instead of `T`
because `T: !Clone`. If we find this, suggest `T: Clone`.

```
error[E0502]: cannot borrow `*list` as mutable because it is also borrowed as immutable
  --&gt; $DIR/clone-on-ref.rs:7:5
   |
LL |     for v in list.iter() {
   |              ---- immutable borrow occurs here
LL |         cloned_items.push(v.clone())
   |                             ------- this call doesn't do anything, the result is still `&amp;T` because `T` doesn't implement `Clone`
LL |     }
LL |     list.push(T::default());
   |     ^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
LL |
LL |     drop(cloned_items);
   |          ------------ immutable borrow later used here
   |
help: consider further restricting this bound
   |
LL | fn foo&lt;T: Default + Clone&gt;(list: &amp;mut Vec&lt;T&gt;) {
   |                   +++++++
```
```
error[E0505]: cannot move out of `x` because it is borrowed
  --&gt; $DIR/clone-on-ref.rs:23:10
   |
LL | fn qux(x: A) {
   |        - binding `x` declared here
LL |     let a = &amp;x;
   |             -- borrow of `x` occurs here
LL |     let b = a.clone();
   |               ------- this call doesn't do anything, the result is still `&amp;A` because `A` doesn't implement `Clone`
LL |     drop(x);
   |          ^ move out of `x` occurs here
LL |
LL |     println!("{b:?}");
   |               ----- borrow later used here
   |
help: consider annotating `A` with `#[derive(Clone)]`
   |
LL + #[derive(Clone)]
LL | struct A;
   |
```
</content>
</entry>
<entry>
<title>cleanup prefixes iterator</title>
<updated>2024-03-13T19:34:58+00:00</updated>
<author>
<name>beepster4096</name>
<email>19316085+beepster4096@users.noreply.github.com</email>
</author>
<published>2024-03-13T19:34:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a5cb61d39ba92beb8b48d9b4dfe72ac06fa4503c'/>
<id>urn:sha1:a5cb61d39ba92beb8b48d9b4dfe72ac06fa4503c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rename `IntoDiagnosticArg` as `IntoDiagArg`.</title>
<updated>2024-03-10T22:12:19+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2024-03-05T05:53:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a09b1d33a703d4ed412e70d3197e73ba7e0937f9'/>
<id>urn:sha1:a09b1d33a703d4ed412e70d3197e73ba7e0937f9</id>
<content type='text'>
Also rename `into_diagnostic_arg` as `into_diag_arg`, and
`NotIntoDiagnosticArg` as `NotInotDiagArg`.
</content>
</entry>
<entry>
<title>Drive-by fix string fmt</title>
<updated>2024-03-09T20:02:47+00:00</updated>
<author>
<name>Esteban Küber</name>
<email>esteban@kuber.com.ar</email>
</author>
<published>2024-03-09T20:02:47+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7e79dcdc06a2bbd4a1d3250b23dbfc024bf0a86f'/>
<id>urn:sha1:7e79dcdc06a2bbd4a1d3250b23dbfc024bf0a86f</id>
<content type='text'>
</content>
</entry>
</feed>
