Skip to content
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

Borrowed ptr to boxed trait exposes "uniq" type #4972

Closed
jbclements opened this issue Feb 15, 2013 · 5 comments
Closed

Borrowed ptr to boxed trait exposes "uniq" type #4972

jbclements opened this issue Feb 15, 2013 · 5 comments
Labels
A-traits Area: Trait system

Comments

@jbclements
Copy link
Contributor

This isn't quite an ICE, but I think it probably should be; the following program

trait MyTrait { }

pub enum TraitWrapper {
    A(~MyTrait),
}

fn get_tw_map(tw: &lt/TraitWrapper) -> &lt/MyTrait {
    match *tw {
        A(~ref map) => map,
    }
}

... signals the error

Running /usr/local/bin/rustc:
./foo.rs:9:10: 9:19 error: mismatched types: expected `~MyTrait` found uniq
./foo.rs:9         A(~ref map) => map,
                     ^~~~~~~~~

It appears that "uniq" is the name used in midle/trans/reflect.rs for ty::vstore_uniq, in vstore_name_and_extra.

I'm guessing this isn't the desired behavior?

@ghost ghost assigned catamorphism Feb 21, 2013
@catamorphism
Copy link
Contributor

This has to do with the typechecking for patterns being top-down rather than bottom-up, so right now, that code just prints a hard-wired string for the actual type of the pattern, since the type isn't known yet.

I have a patch in progress that improves the error messages here, but it probably won't be done for 0.6. De-milestoning.

@catamorphism
Copy link
Contributor

This is fixed. Checking in a test case.

@emberian
Copy link
Member

Indeed fixed and checked in, closing.

@emberian
Copy link
Member

(src/test/compile-fail/issue-4972.rs, for posterity)

@edwardw
Copy link
Contributor

edwardw commented Jun 21, 2014

I don't think the error classification in src/test/compile-fail/issue-4972.rs very accurate. It isn't a type mismatch error, but a trying to deref non-derefable type one, i.e. Box<MyTrait>. Found this when assessing #15031.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system
Projects
None yet
Development

No branches or pull requests

4 participants