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

Unclear error : unable to infer enough type information about _ #19477

Closed
BigEpsilon opened this issue Dec 2, 2014 · 2 comments · Fixed by #31045
Closed

Unclear error : unable to infer enough type information about _ #19477

BigEpsilon opened this issue Dec 2, 2014 · 2 comments · Fixed by #31045
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-type-system Area: Type system

Comments

@BigEpsilon
Copy link

This code producesses an unclear error

pub trait ValueGiver<T> {
    fn give(_: Option<Self>) -> T;
}

struct m;

impl<f64> ValueGiver<f64> for m {
    fn give(_:Option<m>) -> f64 {
        0.5f64
    } 
}

fn main() {
    let y : f64 = ValueGiver::give(None::<m>);
}

Here the error of course is the impl<f64> that should be impl, but the error message is not clear :

c.rs:64:5: 68:6 error: unable to infer enough type information about `_`; type annotations required
c.rs:64     impl<f64> ValueGiver<f64> for m {
c.rs:65         fn give(_:Option<m>) -> f64 {
c.rs:66             0.5f64
c.rs:67         } 
c.rs:68     }

Could this error message be more helpful ?

@kmcallister kmcallister added A-diagnostics Area: Messages for errors, warnings, and lints A-type-system Area: Type system labels Jan 25, 2015
@apasel422
Copy link
Contributor

This now gives the error:

foo.rs:7:6: 7:9 error: user-defined types or type parameters cannot shadow the primitive types [E0317]
foo.rs:7 impl<f64> ValueGiver<f64> for m {
              ^~~

@Manishearth
Copy link
Member

Triage: Mostly fixed, would be nice if it had a span_suggestion

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 23, 2016
…veklabnik

I tried to add an inline `span_suggestion()` to the error as well, but since generics don't have their own span it becomes too fragile/complicated to work.

r? @steveklabnik

fixes rust-lang#19477
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jan 23, 2016
…veklabnik

I tried to add an inline `span_suggestion()` to the error as well, but since generics don't have their own span it becomes too fragile/complicated to work.

r? @steveklabnik

fixes rust-lang#19477
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-type-system Area: Type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants