Skip to content

Make suggestion of changing mutability of arguments broader #81990

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Feb 12, 2021

Conversation

hkmatsumoto
Copy link
Member

Fix #81421

Previously rustc tries to emit the suggestion of changing mutablity unless !trait_ref.has_infer_types_or_consts() && self.predicate_can_apply(obligation.param_env, trait_ref) and this led to some false negatives to occur.

@rust-highfive
Copy link
Contributor

r? @estebank

(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 Feb 11, 2021
@hkmatsumoto hkmatsumoto force-pushed the suggest-mut-reference branch from 6f74c7d to e03f097 Compare February 11, 2021 08:03
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

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

I'm delighted that the change was this small :)

Comment on lines +28 to +30
= note: the following trait bounds were not satisfied:
`&T: std::io::Read`
which is required by `BufReader<&T>: BufRead`
Copy link
Contributor

Choose a reason for hiding this comment

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

As a separate issue, it'd be nice if we mentioned that BufReader<&mut T> would satisfy the trait bounds.

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed #82086

@estebank
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 11, 2021

📌 Commit e03f097 has been approved by estebank

@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 Feb 11, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 12, 2021
…estebank

Make suggestion of changing mutability of arguments broader

Fix rust-lang#81421

Previously rustc tries to emit the suggestion of changing mutablity unless `!trait_ref.has_infer_types_or_consts() && self.predicate_can_apply(obligation.param_env, trait_ref)` and this led to some false negatives to occur.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 12, 2021
Rollup of 16 pull requests

Successful merges:

 - rust-lang#79983 (fix indefinite article in cell.rs)
 - rust-lang#81831 (Don't display `mut` in arguments for functions documentation)
 - rust-lang#81947 (Relax ItemCtxt::to_ty lifetime)
 - rust-lang#81954 (RELEASES.md 1.50: Group platform support notes together)
 - rust-lang#81955 (bootstrap: Locate llvm-dwp based on llvm-config bindir)
 - rust-lang#81959 (Fix assosiated typo)
 - rust-lang#81964 (Fix documentation not showing on localStorage error)
 - rust-lang#81968 (bootstrap: fix wrong docs installation path)
 - rust-lang#81990 (Make suggestion of changing mutability of arguments broader)
 - rust-lang#81994 (Improve long explanation for E0542 and E0546)
 - rust-lang#81997 (dist: include src/build_helper as part of the crate graph for rustc-dev)
 - rust-lang#82003 (Stack probes: fix error message)
 - rust-lang#82004 (clean up clean::Static struct)
 - rust-lang#82011 (Fix private intra-doc warnings on associated items)
 - rust-lang#82013 (Tell user how to fix CI file being not up to date)
 - rust-lang#82017 (Fix typo in mod.rs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 46aef0e into rust-lang:master Feb 12, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 12, 2021
@hkmatsumoto hkmatsumoto deleted the suggest-mut-reference branch February 17, 2021 05:17
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider suggesting &mut TypeParam when given &TypeParam and that would fix the user's issue
5 participants