Description
Code
I tried this code:
#![allow(unused)]
#[derive(Clone)] // nothing substantial changes if this is replaced with a manual impl Clone for Test
struct Hello {
a: std::borrow::Cow<'static, [Self]>,
}
fn main(){}
I expected to see this happen: On 1.78 and below, this fails to compile with several E0277s (trait bound not satisfied)
full error message
error[E0277]: the trait bound `[Hello]: ToOwned` is not satisfied in `Hello`
--> src/main.rs:4:32
|
4 | a: std::borrow::Cow<'static, [Self]>,
| ^^^^^^ within `Hello`, the trait `ToOwned` is not implemented for `[Hello]`, which is required by `Hello: Sized`
|
= help: the trait `ToOwned` is implemented for `[T]`
note: required because it appears within the type `Hello`
--> src/main.rs:3:8
|
3 | struct Hello {
| ^^^^^
= note: slice and array elements must have `Sized` type
error[E0277]: the trait bound `[Hello]: ToOwned` is not satisfied in `Hello`
--> src/main.rs:2:10
|
2 | #[derive(Clone)]
| ^^^^^ within `Hello`, the trait `ToOwned` is not implemented for `[Hello]`, which is required by `Hello: Sized`
|
= help: the trait `ToOwned` is implemented for `[T]`
note: required because it appears within the type `Hello`
--> src/main.rs:3:8
|
3 | struct Hello {
| ^^^^^
note: required by a bound in `Clone`
--> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/clone.rs:147:1
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `[Hello]: ToOwned` is not satisfied in `Hello`
--> src/main.rs:2:10
|
2 | #[derive(Clone)]
| ^^^^^ within `Hello`, the trait `ToOwned` is not implemented for `[Hello]`, which is required by `Hello: Sized`
|
= help: the trait `ToOwned` is implemented for `[T]`
note: required because it appears within the type `Hello`
--> src/main.rs:3:8
|
3 | struct Hello {
| ^^^^^
= note: the return type of a function must have a statically known size
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `[Hello]: ToOwned` is not satisfied in `Cow<'_, [Hello]>`
--> src/main.rs:4:3
|
2 | #[derive(Clone)]
| ----- in this derive macro expansion
3 | struct Hello {
4 | a: std::borrow::Cow<'static, [Self]>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `Cow<'_, [Hello]>`, the trait `ToOwned` is not implemented for `[Hello]`, which is required by `Cow<'_, [Hello]>: Sized`
|
= help: the trait `ToOwned` is implemented for `[T]`
note: required because it appears within the type `Cow<'_, [Hello]>`
--> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/borrow.rs:180:10
note: required by a bound in `clone`
--> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/clone.rs:160:5
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0277`.
error: could not compile `bisectee` (bin "bisectee") due to 4 previous errors
Instead, this happened: On Rust 1.79 and above, it compiles without error
Version it didn't work on
It most recently didn't work on: Rust 1.78.0
Version with anti-regression
rustc --version --verbose
:
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-unknown-linux-gnu
release: 1.79.0
LLVM version: 18.1.7
Bisection:
searched nightlies: from nightly-2024-03-16 to nightly-2024-04-28
regressed nightly: nightly-2024-03-20
searched commit range: 3c85e56...a7e4de1
regressed commit: 196ff44
bisected with cargo-bisect-rustc v0.6.9
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc --start=1.78.0 --end=1.79.0 --regress success --preserve
cc @lukas-code The description of #122493 says "This should not make more or less code compile, but it can change error output in some rare cases."
Probably nothing to do but add a test to make sure this keeps compiling in the future?
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Relevant to the types team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.Untriaged performance or correctness regression.