Uh oh!
There was an error while loading. Please reload this page.
Add #[rustc_confusables] attribute to allow targeted "no method" error suggestions on standard library types - #112239
Conversation
rustbot
commented
Jun 3, 2023
(rustbot has picked a reviewer for you, use r? to override) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
407117c to
7240568Compareest31
commented
Jun 3, 2023
The suggestion made in the thread seems relevant, to use Or is it explicitly wanted that if you search for |
jieyouxu
commented
Jun 3, 2023
Oops, I have no clue how I missed that... I will close this PR then.
I think it's just so happens that Sorry about this! |
@jieyouxu note that this is only my private opinion and I don't know if others agree... :) I did not want to discourage you, and it might be too early to close this PR just yet. I think it's definitely worth to discuss having an attribute separate from I also dimly remember that either the libs (api) team or the rustdoc team expressed that they want to But on the other hand, adding a edit: the policy seems to be here. |
jieyouxu
commented
Jun 3, 2023
I suppose I will keep this PR open for now, then, in case having a separate attribute might be useful.
I think I will open a separate PR for adding a doc-alias for |
est31
commented
Jun 3, 2023
jieyouxu
commented
Jun 3, 2023
Actually, after grepping through |
Fair points... I think ultimately it's up to the libs team if they want |
Noratrieb
commented
Jun 3, 2023
I think the problem with doc aliases is that if you have too many, it becomes quite hard to navigate the docs because you search for something and get lots of random other results showing up. In the diagnostics here you don't really have that problem as its only limited to impls on the type. |
WaffleLapkin
commented
Jun 8, 2023
r? compiler |
compiler-errors
commented
Jun 23, 2023
r? compiler |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
7240568 to
a7cd813Comparerustbot
commented
Jun 24, 2023
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
a7cd813 to
dab231dComparejieyouxu
commented
Jun 24, 2023
@rustbot ready |
9f97dd8 to
410870cComparebors
commented
Jul 14, 2023
☔ The latest upstream changes (presumably #113328) made this pull request unmergeable. Please resolve the merge conflicts. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
410870c to
a06fcbaCompareThere was a problem hiding this comment.
You can remove it, it is not used any more.
Uh oh!
There was an error while loading. Please reload this page.
"no method" errors on standard library types
The standard library developer can annotate methods on e.g.
`BTreeSet::push` with `#[rustc_confusables("insert")]`. When the user
mistypes `btreeset.push()`, `BTreeSet::insert` will be suggested if
there are no other candidates to suggest.a06fcba to
08c77a6Comparecjgillot
commented
Jul 16, 2023
@bors r+ |
bors
commented
Jul 16, 2023
bors
commented
Jul 16, 2023
⌛ Testing commit 08c77a6 with merge c4b1a20fd4e7f3fa31ac9fbf4b3e8dad1f8a912b... |
rust-log-analyzer
commented
Jul 16, 2023
bors
commented
Jul 16, 2023
💔 Test failed - checks-actions |
cjgillot
commented
Jul 16, 2023
Seems spurious: |
bors
commented
Jul 16, 2023
bors
commented
Jul 16, 2023
☀️ Test successful - checks-actions |
rust-timer
commented
Jul 16, 2023
Finished benchmarking commit (11da267): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 658.073s -> 657.937s (-0.02%) |
After this PR, the standard library developer can annotate methods on e.g.
BTreeSet::pushwith#[rustc_confusables("insert")]. When the user mistypesbtreeset.push(),BTreeSet::insertwill be suggested if there are no other candidates to suggest. This PR lays the foundations for contributors to addrustc_confusablesannotations to standard library types for targeted suggestions, as specified in #59450, or to address cases such as #108437.Example
Assume
BTreeSetis the standard library type:A new suggestion (which has lower precedence than suggestions for misspellings and only is shown when there are no misspellings suggestions) will be added to hint the user maybe they intended to write
x.insert()instead: