Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention as_mut alongside as_ref in borrowck error message #100186

Merged
merged 2 commits into from
Aug 20, 2022

Conversation

compiler-errors
Copy link
Member

Kinda fixes #99426 but I guess that really might be better staying open to see if we could make it suggest as_mut in a structured way. Not sure how to change borrowck to know that info tho.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 6, 2022
@rust-highfive
Copy link
Collaborator

r? @fee1-dead

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 6, 2022
Comment on lines 1091 to 1094
fn_call_span.shrink_to_lo(),
"consider calling `.as_ref()` to borrow the type's contents",
"consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents",
"as_ref().",
Applicability::MachineApplicable,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the user has a choice. So should we be making this MachineApplicable? Thinking of it again, should it be a suggestion at all or just a span_help?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't even notice this was MachineApplicable. Yeah, it shouldn't. I could probably bump it down and make the suggestion inline, not verbose like it's rendering now

@fee1-dead fee1-dead added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 9, 2022
@compiler-errors compiler-errors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 16, 2022
Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, sorry for the late review.

@fee1-dead
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Aug 19, 2022

📌 Commit e37565d has been approved by fee1-dead

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 19, 2022
@compiler-errors
Copy link
Member Author

@bors rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 20, 2022
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#100186 (Mention `as_mut` alongside `as_ref` in borrowck error message)
 - rust-lang#100383 (Mitigate stale data reads on SGX platform)
 - rust-lang#100507 (suggest `once_cell::Lazy` for non-const statics)
 - rust-lang#100617 (Suggest the right help message for as_ref)
 - rust-lang#100667 (Migrate "invalid variable declaration" errors to SessionDiagnostic)
 - rust-lang#100709 (Migrate typeck's `used` expected symbol diagnostic to `SessionDiagnostic`)
 - rust-lang#100723 (Add the diagnostic translation lints to crates that don't emit them)
 - rust-lang#100729 (Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf`)
 - rust-lang#100750 (improved diagnostic for function defined with `def`, `fun`, `func`, or `function` instead of `fn`)
 - rust-lang#100763 (triagebot: Autolabel `A-rustdoc-json`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3cca140 into rust-lang:master Aug 20, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 20, 2022
@compiler-errors compiler-errors deleted the or-as_mut branch August 11, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid suggestion to introduce as_ref() for Option used in a place expression
5 participants