Skip to content

Recursive type with Cow, 'static and slice triggers "overflow evaluating the requirement" #47032

Closed as not planned
@m-ou-se

Description

@m-ou-se

The following compiles with rustc 1.7.0 and earlier, but not in 1.8.0 and later:

use std::borrow::Cow;

#[derive(Clone)]
pub struct Node {
	// ...
	pub children_a: &'static [Node], // Works
	pub children_b: Vec<Node>, // Works
	pub children_c: Cow<'static, [Node]> // Doesn't compile
}

The errors:

error[E0275]: overflow evaluating the requirement `<[Node] as std::borrow::ToOwned>::Owned`
 --> src/lib.rs:6:2
  |
6 |     pub children_a: &'static [Node],
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: required because it appears within the type `Node`
  = note: required because of the requirements on the impl of `std::borrow::ToOwned` for `[Node]`
  = note: required because it appears within the type `Node`
  = note: slice and array elements must have `Sized` type

Since it compiles fine with the first two members (reference to slice, and Vec), I'd expect a Cow of a slice to also work. Is this a regression, or is this supposed to not compile?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions