Skip to content

Use impl's generics when suggesting fix on bad impl Copy - #99741

Merged
bors merged 1 commit into
rust-lang:masterfrom
compiler-errors:copy-impl-impl-generics
Jul 31, 2022
Merged

Use impl's generics when suggesting fix on bad impl Copy#99741
bors merged 1 commit into
rust-lang:masterfrom
compiler-errors:copy-impl-impl-generics

Conversation

@compiler-errors

@compiler-errorscompiler-errors commented Jul 26, 2022

Copy link
Copy Markdown
Contributor

See the UI test for a more complicated example, but we weren't correctly suggesting to add bounds given a manual impl whose generics didn't match the struct generics.

#[derive(Clone)]structWrapper<T>(T);impl<S>CopyforWrapper<S>{}

Coincidentally this fix didn't cause any regressions for derive(Copy) impls, I think because those use the same spans in the impl generics as the struct generics, so the machinery still applies the same change.

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 26, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @fee1-dead

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 26, 2022
@compiler-errors
compiler-errorsforce-pushed the copy-impl-impl-generics branch from eb74e15 to 1390220CompareJuly 26, 2022 01:48
Comment on lines +10 to +14
note: the `Copy` impl for `OnlyCopyIfDisplay<S>` requires that `S: std::fmt::Display`
--> $DIR/missing-bound-in-manual-copy-impl-2.rs:4:19
|
LL | struct Wrapper<T>(T);
| ^

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the late review. This span could be better but we can leave it as followup.

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.

Thanks. You're right, this is super misleading. I'll fix it.

@fee1-dead

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Jul 31, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 1390220 has been approved by fee1-dead

It is now in the queue for this repository.

@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 Jul 31, 2022
@Dylan-DPCDylan-DPC mentioned this pull request Jul 31, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 31, 2022
Rollup of 5 pull requests
Successful merges:
- rust-lang#99186 (Use LocalDefId for closures more)
- rust-lang#99741 (Use `impl`'s generics when suggesting fix on bad `impl Copy`)
- rust-lang#99844 (Introduce an ArchiveBuilderBuilder)
- rust-lang#99921 (triagebot.yml: CC Enselic when rustdoc-json-types changes)
- rust-lang#99974 (Suggest removing a semicolon and boxing the expressions for if-else)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 2c14bc3 into rust-lang:masterJul 31, 2022
@rustbotrustbot added this to the 1.64.0 milestone Jul 31, 2022
@compiler-errors
compiler-errors deleted the copy-impl-impl-generics branch August 11, 2023 19:57
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

@compiler-errors@rust-highfive@fee1-dead@bors@rustbot