Add explanation for &mut self method call when expecting -> Self#75613
Merged
bors merged 1 commit intorust-lang:masterfrom Aug 18, 2020
Merged
Add explanation for &mut self method call when expecting -> Self#75613bors merged 1 commit intorust-lang:masterfrom
&mut self method call when expecting -> Self#75613bors merged 1 commit intorust-lang:masterfrom
Conversation
When a user tries to use a method as if it returned a new value of the same type as its receiver, we will emit a type error. Try to detect this and provide extra explanation that the method modifies the receiver in-place. This has confused people in the wild, like in https://users.rust-lang.org/t/newbie-why-the-commented-line-stops-the-snippet-from-compiling/47322
Contributor
|
(rust_highfive has picked a reviewer for you, use r? to override) |
Contributor
|
If |
Collaborator
|
📌 Commit ac73474 has been approved by |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Aug 18, 2020
Rollup of 8 pull requests Successful merges: - rust-lang#75389 (attempt to improve span_label docs) - rust-lang#75392 (Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods) - rust-lang#75464 (Move to intra doc links for ascii.rs and panic.rs) - rust-lang#75578 (Allowing raw ptr dereference in const fn) - rust-lang#75613 (Add explanation for `&mut self` method call when expecting `-> Self`) - rust-lang#75626 (Clean up E0754 explanation) - rust-lang#75629 (Use intra-doc links in `std::env`, `std::alloc` and `std::error`) - rust-lang#75634 (Mark x86_64-linux-kernel as *) Failed merges: r? @ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a user tries to use a method as if it returned a new value of the
same type as its receiver, we will emit a type error. Try to detect this
and provide extra explanation that the method modifies the receiver
in-place.
This has confused people in the wild, like in
https://users.rust-lang.org/t/newbie-why-the-commented-line-stops-the-snippet-from-compiling/47322