Commit a28d221
committed
Auto merge of #120730 - estebank:confusable-api, r=oli-obk
Provide suggestions through `rustc_confusables` annotations
Help with common API confusion, like asking for `push` when the data structure really has `append`.
```
error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope
--> $DIR/rustc_confusables_std_cases.rs:17:7
|
LL | x.size();
| ^^^^
|
help: you might have meant to use `len`
|
LL | x.len();
| ~~~
help: there is a method with a similar name
|
LL | x.resize();
| ~~~~~~
```
Fix #59450 (we can open subsequent tickets for specific cases).
Fix #108437:
```
error[E0599]: `Option<{integer}>` is not an iterator
--> f101.rs:3:9
|
3 | opt.flat_map(|val| Some(val));
| ^^^^^^^^ `Option<{integer}>` is not an iterator
|
::: /home/gh-estebank/rust/library/core/src/option.rs:571:1
|
571 | pub enum Option<T> {
| ------------------ doesn't satisfy `Option<{integer}>: Iterator`
|
= note: the following trait bounds were not satisfied:
`Option<{integer}>: Iterator`
which is required by `&mut Option<{integer}>: Iterator`
help: you might have meant to use `and_then`
|
3 | opt.and_then(|val| Some(val));
| ~~~~~~~~
```
On type error of method call arguments, look at confusables for suggestion. Fix #87212:
```
error[E0308]: mismatched types
--> f101.rs:8:18
|
8 | stuff.append(Thing);
| ------ ^^^^^ expected `&mut Vec<Thing>`, found `Thing`
| |
| arguments to this method are incorrect
|
= note: expected mutable reference `&mut Vec<Thing>`
found struct `Thing`
note: method defined here
--> /home/gh-estebank/rust/library/alloc/src/vec/mod.rs:2025:12
|
2025 | pub fn append(&mut self, other: &mut Self) {
| ^^^^^^
help: you might have meant to use `push`
|
8 | stuff.push(Thing);
| ~~~~
```File tree
72 files changed
+833
-196
lines changed- compiler
- rustc_hir_typeck/src
- fn_ctxt
- method
- rustc_middle/src/ty/print
- library
- alloc/src
- collections
- binary_heap
- btree
- map
- vec_deque
- vec
- core/src
- proc_macro/src/bridge
- std/src
- collections/hash
- ffi
- thread
- tests/ui
- associated-item
- async-await/in-trait
- attributes
- block-result
- coherence
- confuse-field-and-method
- hygiene
- impl-trait
- imports
- issues
- methods
- issues
- parser
- resolve
- rust-2018
- uniform-paths
- rust-2021
- self
- shadowed
- suggestions
- traits
- trait-upcasting
- typeck
- ufcs
- underscore-imports
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
72 files changed
+833
-196
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
451 | 455 | | |
452 | 456 | | |
453 | 457 | | |
454 | | - | |
| 458 | + | |
455 | 459 | | |
456 | 460 | | |
457 | 461 | | |
| |||
463 | 467 | | |
464 | 468 | | |
465 | 469 | | |
466 | | - | |
| 470 | + | |
467 | 471 | | |
468 | | - | |
| 472 | + | |
469 | 473 | | |
470 | 474 | | |
471 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
472 | 478 | | |
473 | 479 | | |
474 | 480 | | |
475 | 481 | | |
476 | 482 | | |
477 | 483 | | |
478 | 484 | | |
479 | | - | |
| 485 | + | |
480 | 486 | | |
481 | 487 | | |
482 | 488 | | |
| |||
530 | 536 | | |
531 | 537 | | |
532 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
533 | 637 | | |
534 | 638 | | |
535 | 639 | | |
| |||
694 | 798 | | |
695 | 799 | | |
696 | 800 | | |
| 801 | + | |
697 | 802 | | |
698 | 803 | | |
699 | 804 | | |
| |||
718 | 823 | | |
719 | 824 | | |
720 | 825 | | |
721 | | - | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
722 | 830 | | |
723 | 831 | | |
724 | 832 | | |
| |||
733 | 841 | | |
734 | 842 | | |
735 | 843 | | |
736 | | - | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
737 | 847 | | |
738 | 848 | | |
739 | 849 | | |
| |||
802 | 912 | | |
803 | 913 | | |
804 | 914 | | |
| 915 | + | |
805 | 916 | | |
806 | 917 | | |
807 | 918 | | |
| |||
829 | 940 | | |
830 | 941 | | |
831 | 942 | | |
| 943 | + | |
832 | 944 | | |
833 | 945 | | |
834 | 946 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
| 358 | + | |
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| |||
1750 | 1750 | | |
1751 | 1751 | | |
1752 | 1752 | | |
1753 | | - | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
1754 | 1756 | | |
1755 | 1757 | | |
1756 | 1758 | | |
| |||
1766 | 1768 | | |
1767 | 1769 | | |
1768 | 1770 | | |
| 1771 | + | |
1769 | 1772 | | |
1770 | 1773 | | |
1771 | 1774 | | |
| |||
1775 | 1778 | | |
1776 | 1779 | | |
1777 | 1780 | | |
| 1781 | + | |
1778 | 1782 | | |
1779 | 1783 | | |
1780 | 1784 | | |
| |||
1942 | 1946 | | |
1943 | 1947 | | |
1944 | 1948 | | |
1945 | | - | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
1946 | 1964 | | |
1947 | 1965 | | |
1948 | 1966 | | |
| |||
0 commit comments