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

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

Merged
merged 1 commit into from
Jul 31, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 26, 2022

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)]
struct Wrapper<T>(T);

impl<S> Copy for Wrapper<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.

@rustbot rustbot 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
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 Jul 26, 2022
@compiler-errors compiler-errors force-pushed the copy-impl-impl-generics branch from eb74e15 to 1390220 Compare July 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
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
Member Author

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
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 31, 2022

📌 Commit 1390220 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 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:master Jul 31, 2022
@rustbot rustbot 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 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.

5 participants