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

On E0204 suggest missing type param bounds #97664

Merged
merged 2 commits into from
Jun 3, 2022

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jun 2, 2022

error[E0204]: the trait `Copy` may not be implemented for this type
  --> f42.rs:9:17
   |
9  | #[derive(Debug, Copy, Clone)]
   |                 ^^^^
10 | pub struct AABB<K>{
11 |     pub loc: Vector2<K>,
   |     ------------------- this field does not implement `Copy`
12 |     pub size: Vector2<K>
   |     -------------------- this field does not implement `Copy`
   |
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
  --> f42.rs:11:5
   |
11 |     pub loc: Vector2<K>,
   |     ^^^^^^^^^^^^^^^^^^^
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
  --> f42.rs:12:5
   |
12 |     pub size: Vector2<K>
   |     ^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `K`
   |
10 | pub struct AABB<K: Debug>{
   |                  +++++++

Fix #89137.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 2, 2022
@rust-highfive
Copy link
Collaborator

r? @lcnr

(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 Jun 2, 2022
@estebank
Copy link
Contributor Author

estebank commented Jun 2, 2022

r? @compiler-errors

@rust-highfive rust-highfive assigned compiler-errors and unassigned lcnr Jun 2, 2022
@compiler-errors
Copy link
Member

This is very cool

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 2, 2022

📌 Commit cba4868d5e78227104fcba48f3e24c62596e9f1e has been approved by compiler-errors

@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 Jun 2, 2022
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

compiler-errors commented Jun 2, 2022

@bors r-

r=me with the tests blessed 😺

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 2, 2022
```
error[E0204]: the trait `Copy` may not be implemented for this type
  --> f42.rs:9:17
   |
9  | #[derive(Debug, Copy, Clone)]
   |                 ^^^^
10 | pub struct AABB<K>{
11 |     pub loc: Vector2<K>,
   |     ------------------- this field does not implement `Copy`
12 |     pub size: Vector2<K>
   |     -------------------- this field does not implement `Copy`
   |
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
  --> f42.rs:11:5
   |
11 |     pub loc: Vector2<K>,
   |     ^^^^^^^^^^^^^^^^^^^
note: the `Copy` impl for `Vector2<K>` requires that `K: Debug`
  --> f42.rs:12:5
   |
12 |     pub size: Vector2<K>
   |     ^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `K`
   |
10 | pub struct AABB<K: Debug>{
   |                  +++++++
```

Fix rust-lang#89137.
@estebank
Copy link
Contributor Author

estebank commented Jun 2, 2022

@compiler-errors added another commit with a small, hopefully uncontroversial change.

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Jun 2, 2022

📌 Commit 9bfd3dd3794ab6a66140ef871fbf6171e3eef44f has been approved by compiler-errors

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 2, 2022
@compiler-errors
Copy link
Member

Looks good to me, other than if the usage of FxHashMap there is going to cause hash instability in diagnostics. Maybe we should stringify first?

@estebank
Copy link
Contributor Author

estebank commented Jun 2, 2022

I think that the only issue is not with hashes but with inconsistent output in the .stderr tests, but there's a single one where there aren't multiple notes being emitted, so it should be fine for now.

@compiler-errors
Copy link
Member

oh... stable_map? Did you mean to use this one? https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_data_structures/stable_map.rs.html#7

@estebank
Copy link
Contributor Author

estebank commented Jun 2, 2022

Changed :)

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Jun 2, 2022

📌 Commit 6f832eaea5b0b43264a0b17161f43d58ea5fffbb has been approved by compiler-errors

@compiler-errors
Copy link
Member

Not sure what changed: https://github.com/rust-lang/rust/compare/9bfd3dd3794ab6a66140ef871fbf6171e3eef44f..6f832eaea5b0b43264a0b17161f43d58ea5fffbb

Anyways, I can follow up in a quick PR later. Sorry for the back and forth.

@estebank
Copy link
Contributor Author

estebank commented Jun 2, 2022

🤦 I'd failed to push -f

@compiler-errors
Copy link
Member

There we go. Thanks 👍

@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 2, 2022

📌 Commit 184576cd368c5b28192eff02bbbc88ca3a255968 has been approved by compiler-errors

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

Oh no, haha. @bors r-

I think it's best to just .to_string() on the two keys for the map and use something sorted like a BTreeMap?

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 2, 2022
@estebank
Copy link
Contributor Author

estebank commented Jun 2, 2022

🤦

@estebank
Copy link
Contributor Author

estebank commented Jun 2, 2022

I'll make it a string in a bit

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

Something like:

Comment on lines 132 to 133
errors
.entry((ty, error_predicate))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
errors
.entry((ty, error_predicate))
errors
.entry((ty.to_string(), error_predicate.to_string()))

generics = self_item.kind.generics();
}
}
let mut errors: StableMap<_, Vec<_>> = Default::default();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let mut errors: StableMap<_, Vec<_>> = Default::default();
let mut errors: BTreeMap<_, Vec<_>> = Default::default();

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

CI seems happy!

@bors r+

@bors
Copy link
Contributor

bors commented Jun 2, 2022

📌 Commit f9aa2e0 has been approved by compiler-errors

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 2, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 3, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#97366 (Stabilize `{slice,array}::from_ref`)
 - rust-lang#97653 (add cast kind of from_exposed_addr (int-to-ptr casts))
 - rust-lang#97663 (take back half-baked noaliasing check in Assignment)
 - rust-lang#97664 (On E0204 suggest missing type param bounds)
 - rust-lang#97668 (rustdoc: clean up primitive.slice.html links)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b71ddd6 into rust-lang:master Jun 3, 2022
@rustbot rustbot added this to the 1.63.0 milestone Jun 3, 2022
@estebank estebank deleted the suggest-bound-derive-copy branch November 9, 2023 05:14
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.

Show error E0277 when the trait bound of a struct's member's type is unsatisfied even if E0204 is also present
7 participants