Skip to content

The trait object Foo+Copy implements the trait Copy #32963

Closed

Description

@arielb1

select considers the trait object type Foo+Copy to implement the trait Copy, and therefore its supertraits Clone and Sized. This is totally bogus, as the trait object type is not Sized.

For example:

use std::{fmt, mem};

fn size_of_copy<T: Copy+?Sized>() -> usize { mem::size_of::<T>() }

fn main() {
    println!("{}", size_of_copy::<fmt::Debug+Copy>());
}

This obviously should not compile, but it does (and prints 16, because of the size_of unsized hack).

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Apr 14, 2016
  2. arielb1 commented on Apr 14, 2016

    @arielb1
    ContributorAuthor
  3. nikomatsakis commented on Apr 15, 2016

    @nikomatsakis
    Contributor

    @arielb1 indeed.

  4. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Apr 15, 2016
  5. nikomatsakis commented on Apr 15, 2016

    @nikomatsakis
    Contributor

    triage: P-high

  6. arielb1 commented on Apr 16, 2016

    @arielb1
    ContributorAuthor

    I am working on a fix.

  7. added a commit that references this issue on Apr 17, 2016
  8. nikomatsakis commented on Apr 18, 2016

    @nikomatsakis
    Contributor

    @arielb1 saw your ping on IRC; it seems like we simply should consider Copy to be object-unsafe. Ideally with a warning period.

  9. nikomatsakis commented on Apr 18, 2016

    @nikomatsakis
    Contributor

    (I've always thought that unsized types would be move-only.)

  10. added a commit that references this issue on May 6, 2016
    5158f3b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh 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