Skip to content

Loop evaluating Cow<'a, T>: Sized in recursive structure #23714

Closed as not planned
@ghost

Description

The example causes the checker to loop with build rustc 1.0.0-dev (81938ec58 2015-03-25) (built 2015-03-25):

src/lib.rs:1:1: 1:1 error: overflow evaluating the requirement `collections::borrow::Cow<'static, Foo> : core::marker::Sized` [E0275]

It does still work using the Rust playpen here. I'm not sure if something changed in the API or if it's a bug or something else. The docs show ToOwned::Owned: Sized so the requirement should be satisfied. /cc @aturon

use std::borrow::*;

enum Foo {
    Bar,
    Baz { cow: Cow<'static, Foo> }
}

impl ToOwned for Foo {
    type Owned = Box<Foo>;
    fn to_owned(&self) -> Box<Foo> {
        let res = match self {
            &Foo::Bar => {
                Foo::Bar
            },
            &Foo::Baz { ref cow } => {
                Foo::Baz { cow: cow.to_owned() }
            }
        };
        Box::new(res)
    }
}

impl Borrow<Foo> for Box<Foo> {
    fn borrow(&self) -> &Foo {
        &**self
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-borrow-checkerArea: The borrow checkerC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions