Skip to content

Methods with &mut Trait and polymorphic objects can't get encoded #8401

Closed
@alexcrichton

Description

@alexcrichton

This code

#[crate_type = "lib"];
#[link(name = "foo", vers = "0.1")];

use std::cast;

trait A {}
struct B;
impl A for B {}

fn bar<T>(_: &mut A, _: &T) {}

fn foo<T>(t: &T) {
    let b = B;
    bar(unsafe { cast::transmute(&b as &A) }, t)
}

Dies with

error: internal compiler error: Cannot encode region variables

The transmute is in place to get around #8248, but I think that this may be uncovering a separate issue. Even with the transmute, I think this should compile anyway (although it's still unsafe code).

cc @msullivan

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions