Skip to content

Suggest constraining param for unary ops when missing trait impl - #95197

Merged
bors merged 1 commit into
rust-lang:masterfrom
frank-king:feat/unary_op_type_constrain
Mar 22, 2022
Merged

Suggest constraining param for unary ops when missing trait impl#95197
bors merged 1 commit into
rust-lang:masterfrom
frank-king:feat/unary_op_type_constrain

Conversation

@frank-king

Copy link
Copy Markdown
Contributor

This PR adds a suggestion of constraining param for unary ops - and ! when the corresponding trait implementation
is missing.

Fixs #94543.

BTW, this is my first time to touch rustc, please correct me if I did anything wrong.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @petrochenkov

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

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 22, 2022
@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 22, 2022
visitor.visit_ty(operand_ty);
if let [ty] = &visitor.0[..] {
if let ty::Param(p) = *operand_ty.kind() {
suggest_constraining_param(

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Here I just followed what check_overloaded_binop does, I'm not sure if the passed arguments are right.

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Mar 22, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit f28d8b1 has been approved by petrochenkov

@borsbors 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 Mar 22, 2022
@Dylan-DPCDylan-DPC mentioned this pull request Mar 22, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 22, 2022
Rollup of 5 pull requests
Successful merges:
- rust-lang#95188 ([`macro-metavar-expr`] Fix generated tokens hygiene)
- rust-lang#95196 (rename LocalState::Uninitialized to Unallocated)
- rust-lang#95197 (Suggest constraining param for unary ops when missing trait impl)
- rust-lang#95200 (Cancel a not emitted error after parsing const generic args)
- rust-lang#95207 (update Termination trait docs)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 0e80a7a into rust-lang:masterMar 22, 2022
@rustbotrustbot added this to the 1.61.0 milestone Mar 22, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

5 participants

@frank-king@rust-highfive@petrochenkov@bors@rustbot