Skip to content

Pointer type inference fails with 'unconstrained type' error #14861

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
bnoordhuis opened this issue Jun 12, 2014 · 3 comments
Closed

Pointer type inference fails with 'unconstrained type' error #14861

bnoordhuis opened this issue Jun 12, 2014 · 3 comments

Comments

@bnoordhuis
Copy link
Contributor

$ cat t.rs 
struct A<T> { inner: *T }
struct B;

fn main() {
    // works
    let _: A<B> = A::<B> { inner: std::ptr::null() };
    // works
    let _ = A::<B> { inner: std::ptr::null::<B>() };
    // cannot determine a type for this local variable: unconstrained type
    let _ = A::<B> { inner: std::ptr::null() };
}

$ rustc -v
rustc 0.11.0-pre (3a9228b 2014-06-12 19:36:53 +0000)
host: x86_64-unknown-linux-gnu

$ rustc t.rs 
t.rs:10:9: 10:47 error: cannot determine a type for this local variable: unconstrained type
t.rs:10     let _ = A::<B> { inner: std::ptr::null() };
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

The third assignment seems unambiguous but the compiler won't accept it.

@alexcrichton
Copy link
Member

This is very related to, if possibly a dupe, of #9620

@ghost
Copy link

ghost commented Oct 1, 2014

All good now and #9620 included a test so we can close this.

@alexcrichton
Copy link
Member

Always with the sharp eye @jakub-, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants