rust icon indicating copy to clipboard operation
rust copied to clipboard

Error message ""instantiating a type parameter with an incompatible type" should tell you the type

Open bstrie opened this issue 13 years ago • 5 comments

fn main() {
    let (port, chan) = pipes::stream();  // instantiating a type parameter with an incompatible type (needs `owned`, got `const copy owned`, missing `durable`)

    do task::spawn {
        io::println(port.recv());  // instantiating a type parameter with an incompatible type (needs `owned`, got `const copy owned`, missing `durable`)
    }

    chan.send("hello, world");  // instantiating a type parameter with an incompatible type (needs `owned`, got `const copy owned`, missing `durable`)
}

None of these three error messages mention the actual types involved.

bstrie avatar Jan 11 '13 20:01 bstrie

Some more comments from IRC:

[12:36:02] <@nmatsakis> bstrie: in any case the error message is clearly... wrong-ish, because it's saying "I needed owned and you gave me owned but not durable".  (what version of rustc are you using? durable was replaced with &static at some point)
[12:36:32] <@nmatsakis> bstrie: in any case, if it needs durable, it should say so.  This may have something to do with the fact that kinds are a kind of bit set and in fact owned should imply durable...

nikomatsakis avatar Jan 11 '13 20:01 nikomatsakis

What's happening here is that the type of the port is getting inferred to &str since it gets constrained by io::println(). The printout from the kind checker not only lacks types, but it's just kind of... wrong. It did not get a "const copy owned" type.

nikomatsakis avatar Jan 11 '13 20:01 nikomatsakis

@nikomatsakis I think this can be closed now ?

ILyoan avatar Apr 29 '13 08:04 ILyoan

assigning bug; change assignment if you disagree

graydon avatar May 01 '13 00:05 graydon

This is fixed. I'll check in a test case.

catamorphism avatar Jun 26 '13 19:06 catamorphism