Skip to content

Trait object coercions do not distribute over pattern bindings #9951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kimundi opened this issue Oct 19, 2013 · 3 comments
Closed

Trait object coercions do not distribute over pattern bindings #9951

Kimundi opened this issue Oct 19, 2013 · 3 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@Kimundi
Copy link
Member

Kimundi commented Oct 19, 2013

This works:

trait Bar{} 
impl Bar for uint {}; 
let (a, b) = (~5u as ~Bar, ~9u as ~Bar); 

let c: &Bar = a; 
let d: &Bar = b; 

This doesn't:

trait Bar{} 
impl Bar for uint {}

fn main() {
    let (a, b) = (~5u as ~Bar, ~9u as ~Bar); 
    let (c, d): (&Bar, &Bar) = (a, b);
}


error: mismatched types: expected `(&main::Bar<no-bounds>,&main::Bar<no-bounds>)` but found `(~main::Bar:Send,~main::Bar:Send)` (trait storage differs: expected & but found ~)
@nikomatsakis
Copy link
Contributor

This is not specific to trait coercions, but rather any coercion. We could make this work with mild effort. See also #8783, which is related in that it touches same parts of the compiler.

@flaper87
Copy link
Contributor

flaper87 commented Apr 7, 2014

Visiting for triage. Still valid.

@flaper87
Copy link
Contributor

Triage bump:

This seems to be fixed now:

trait Bar{} 
impl Bar for usize {}
impl Bar for i32 {}

fn main() {
    let (a, b) = (&5u as &Bar, &9u as &Bar); 
    let (c, d): (&Bar, &Bar) = (a, b);


    let (a, b) = (Box::new(5u) as Box<Bar>, Box::new(9u) as Box<Bar>); 
    let (c, d): (&Bar, &Bar) = (&*a, &*b);


    let (c, d): (&Bar, &Bar) = (&5, &9);
}

@flaper87 flaper87 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 19, 2015
@bors bors closed this as completed in a17f061 Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

3 participants