Skip to content

Supertrait loops are (still) unsound #43784

Closed
@arielb1

Description

First reported in https://users.rust-lang.org/t/unexpected-behaviors-of-trait-bounds/12286/3

STR

pub trait Partial: Copy {
}

pub trait Complete: Partial {
}

impl<T> Partial for T where T: Complete {}
impl<T> Complete for T {}

fn copy<P: Partial>(p: P) -> (P, P) {
    (p, p)
}

fn main() {
    let (p, q) = copy("hello".to_string());
    drop(p);
    println!("{}", q);
}

cc @nikomatsakis - let's discuss this when you are back from vacation (unless @aturon can come up with a solution?)

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-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