Skip to content

Copy not implemented for (u32, u32) error #88047

Closed
@leonardo-m

Description

@leonardo-m
const fn foo<T: Copy, const N: usize>(a: [T; N]) -> [T; N] {
    a
}
fn main() {
    const SPAM: [(u32, u32); 1] = foo([(1, 1)]);
}

Using the last Nightly (this error didn't happen with the Nightly of the precedent day):

rustc 1.56.0-nightly (8007b506a 2021-08-14)
binary: rustc
commit-hash: 8007b506ac5da629f223b755f5a5391edd5f6d01
commit-date: 2021-08-14
host: x86_64-pc-windows-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

Gives:

error[E0277]: the trait bound `(u32, u32): Copy` is not satisfied
 --> C:\lavoro\bugs\test.rs:5:39
  |
1 | const fn foo<T: Copy, const N: usize>(a: [T; N]) -> [T; N] {
  |                 ---- required by this bound in `foo`
...
5 |     const SPAM: [(u32, u32); 1] = foo([(1, 1)]);
  |                                       ^^^^^^^^ the trait `Copy` is not implemented for `(u32, u32)`
  |
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
  |
4 | fn main() where (u32, u32): Copy {
  |           ++++++++++++++++++++++

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions