<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/tests/ui/pattern, 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>Tweak wording</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-09T20:32:13+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b367c25367117a4ada5c9a1c807b74f0efcf6d51'/>
<id>urn:sha1:b367c25367117a4ada5c9a1c807b74f0efcf6d51</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Remove `MaybeInfiniteInt::JustAfterMax`</title>
<updated>2024-03-13T13:17:11+00:00</updated>
<author>
<name>Nadrieril</name>
<email>nadrieril+git@gmail.com</email>
</author>
<published>2024-03-13T13:17:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c4236785c72fdf04176716393c910b1fb011d15f'/>
<id>urn:sha1:c4236785c72fdf04176716393c910b1fb011d15f</id>
<content type='text'>
It was inherited from before half-open ranges, but it doesn't pull its
weight anymore. We lose a tiny bit of diagnostic precision.
</content>
</entry>
<entry>
<title>Rollup merge of #121908 - Nadrieril:dynamic-variant-collection, r=matthewjasper</title>
<updated>2024-03-13T05:41:21+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>matthias.krueger@famsik.de</email>
</author>
<published>2024-03-13T05:41:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=e6ba504029792871ce9ddc3d74e99316d7b64b5c'/>
<id>urn:sha1:e6ba504029792871ce9ddc3d74e99316d7b64b5c</id>
<content type='text'>
match lowering: don't collect test alternatives ahead of time

I'm very happy with this one. Before this, when sorting candidates into the possible test branches, we manually computed `usize` indices to determine in which branch each candidate goes. To make this work we had a first pass that collected the possible alternatives we'd have to deal with, and a second pass that actually sorts the candidates.

In this PR, I replace `usize` indices with a dedicated enum. This makes `sort_candidates` easier to follow, and we don't need the first pass anymore.

r? ``@matthewjasper``
</content>
</entry>
<entry>
<title>Lint small gaps between ranges</title>
<updated>2024-03-09T00:14:22+00:00</updated>
<author>
<name>Nadrieril</name>
<email>nadrieril+git@gmail.com</email>
</author>
<published>2024-01-14T21:24:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=8ac9a04257f73d9861625816d4c741096dd69c67'/>
<id>urn:sha1:8ac9a04257f73d9861625816d4c741096dd69c67</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Allow lint where we don't care</title>
<updated>2024-03-09T00:13:42+00:00</updated>
<author>
<name>Nadrieril</name>
<email>nadrieril+git@gmail.com</email>
</author>
<published>2024-01-17T13:50:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=f783043ebf49e3a51daf271b335a74320155f965'/>
<id>urn:sha1:f783043ebf49e3a51daf271b335a74320155f965</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #121917 - GuillaumeGomez:pattern-complexity_limit.rs, r=Nadrieril</title>
<updated>2024-03-03T13:07:43+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume1.gomez@gmail.com</email>
</author>
<published>2024-03-03T13:07:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7d8f74f8b233c5de4b3356afe57eeeb789ca146c'/>
<id>urn:sha1:7d8f74f8b233c5de4b3356afe57eeeb789ca146c</id>
<content type='text'>
Add new `pattern_complexity` attribute to add possibility to limit and check recursion in pattern matching

Needed for https://github.com/rust-lang/rust-analyzer/issues/9528.

This PR adds a new attribute only available when running rust testsuite called `pattern_complexity` which allows to set the maximum recursion for the pattern matching. It is quite useful to ensure the complexity doesn't grow, like in `tests/ui/pattern/usefulness/issue-118437-exponential-time-on-diagonal-match.rs`.

r? `@Nadrieril`
</content>
</entry>
<entry>
<title>Add and update tests to use `pattern_complexity`</title>
<updated>2024-03-03T12:10:15+00:00</updated>
<author>
<name>Guillaume Gomez</name>
<email>guillaume.gomez@huawei.com</email>
</author>
<published>2024-03-02T21:48:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=f04b7ee130b51bb6281a23788107b2df5aae283d'/>
<id>urn:sha1:f04b7ee130b51bb6281a23788107b2df5aae283d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #121716 - Nadrieril:simple-binding-order, r=matthewjasper</title>
<updated>2024-03-02T19:13:23+00:00</updated>
<author>
<name>Guillaume Boisseau</name>
<email>Nadrieril@users.noreply.github.com</email>
</author>
<published>2024-03-02T19:13:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=30976fbe2b961a0c2f13e3aeb14a1a5b28b3f882'/>
<id>urn:sha1:30976fbe2b961a0c2f13e3aeb14a1a5b28b3f882</id>
<content type='text'>
match lowering: Lower bindings in a predictable order

After the recent refactorings, we can now lower bindings in a truly predictable order. The order in https://github.com/rust-lang/rust/pull/120214 was an improvement but not very clear. With this PR, we lower bindings from left to right, with the special case that `x @ pat` is traversed as `pat @ x` (i.e. `x` is lowered after any bindings in `pat`).

This description only applies in the absence of or-patterns. Or-patterns make everything complicated, because the binding place depends on the subpattern. Until I have a better idea I leave them to be handled in whatever weird order arises from today's code.

r? `@matthewjasper`
</content>
</entry>
<entry>
<title>Fix a subtle regression</title>
<updated>2024-03-02T17:38:37+00:00</updated>
<author>
<name>Nadrieril</name>
<email>nadrieril+git@gmail.com</email>
</author>
<published>2024-03-02T01:49:33+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d46ff6415c033ccfebac3d2a757908611a67d324'/>
<id>urn:sha1:d46ff6415c033ccfebac3d2a757908611a67d324</id>
<content type='text'>
Before, the SwitchInt cases were computed in two passes: if the first
pass accepted e.g. 0..=5 and then 1, the second pass would not accept
0..=5 anymore because 1 would be listed in the SwitchInt options.

Now there's a single pass, so if we sort 0..=5 we must take care to not
sort a subsequent 1.
</content>
</entry>
</feed>
