-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit 4a4dd8e
authored
Auto merge of #143629 - oli-obk:limited-nonzero-coercion, r=<try>
Limited nonzero coercion
coercing `NonZero<T>` to `T` if all the types are available at the cast site.
This is fairly limited, as (as the tests show), this does not allow "reborrowing" `&NonZero<T>` as `&T`. It also fails quickly if the types aren't fully clear at the coercion site, but only resolved later.
Also cannot aid in trait selection or similar, even if there is clearly only one option.
Related:
* #143594
* rust-lang/rfcs#3786
cc `@traviscross`File tree
27 files changed
+663
-17
lines changed- compiler
- rustc_hir_typeck/src
- fn_ctxt
- rustc_hir/src
- rustc_lint/src
- rustc_middle/src/ty
- rustc_mir_build/src/thir/cx
- library/core/src/num
- src/tools/clippy/clippy_lints/src
- methods
- operators
- transmute
- tests/ui/mismatched_types
27 files changed
+663
-17
lines changedLines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
426 | 426 |
| |
427 | 427 |
| |
428 | 428 |
| |
429 | + | ||
430 | + | ||
429 | 431 |
| |
430 | 432 |
| |
431 | 433 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
263 | 263 |
| |
264 | 264 |
| |
265 | 265 |
| |
266 | + | ||
267 | + | ||
268 | + | ||
266 | 269 |
| |
267 | 270 |
| |
268 | 271 |
| |
| |||
827 | 830 |
| |
828 | 831 |
| |
829 | 832 |
| |
833 | + | ||
834 | + | ||
835 | + | ||
836 | + | ||
837 | + | ||
838 | + | ||
839 | + | ||
840 | + | ||
841 | + | ||
842 | + | ||
843 | + | ||
844 | + | ||
845 | + | ||
830 | 846 |
| |
831 | 847 |
| |
832 | 848 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
854 | 854 |
| |
855 | 855 |
| |
856 | 856 |
| |
857 | + | ||
858 | + | ||
857 | 859 |
| |
858 | 860 |
| |
859 | 861 |
| |
| |||
1336 | 1338 |
| |
1337 | 1339 |
| |
1338 | 1340 |
| |
1341 | + | ||
1339 | 1342 |
| |
1340 | 1343 |
| |
1341 | 1344 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
290 | 290 |
| |
291 | 291 |
| |
292 | 292 |
| |
293 | - | ||
293 | + | ||
294 | 294 |
| |
295 | 295 |
| |
296 | 296 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2487 | 2487 |
| |
2488 | 2488 |
| |
2489 | 2489 |
| |
2490 | - | ||
2490 | + | ||
2491 | 2491 |
| |
2492 | 2492 |
| |
2493 | 2493 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
171 | 171 |
| |
172 | 172 |
| |
173 | 173 |
| |
174 | + | ||
174 | 175 |
| |
175 | 176 |
| |
176 | 177 |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
108 | + | ||
109 | + | ||
110 | + | ||
108 | 111 |
| |
109 | 112 |
| |
110 | 113 |
| |
|
Lines changed: 28 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
239 | 239 |
| |
240 | 240 |
| |
241 | 241 |
| |
242 | + | ||
243 | + | ||
244 | + | ||
245 | + | ||
246 | + | ||
247 | + | ||
248 | + | ||
249 | + | ||
250 | + | ||
251 | + | ||
252 | + | ||
253 | + | ||
254 | + | ||
255 | + | ||
256 | + | ||
257 | + | ||
258 | + | ||
259 | + | ||
260 | + | ||
261 | + | ||
262 | + | ||
263 | + | ||
264 | + | ||
265 | + | ||
266 | + | ||
267 | + | ||
268 | + | ||
269 | + | ||
242 | 270 |
| |
243 | 271 |
| |
244 | 272 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
126 | - | ||
126 | + | ||
127 | 127 |
| |
128 | 128 |
| |
129 | 129 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
5 | - | ||
5 | + | ||
6 | 6 |
| |
7 | - | ||
7 | + | ||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 | - | ||
18 | + | ||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
|
0 commit comments