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

Poor error message for unconstrained bounds #17849

Closed
aturon opened this issue Oct 7, 2014 · 4 comments
Closed

Poor error message for unconstrained bounds #17849

aturon opened this issue Oct 7, 2014 · 4 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-typesystem Area: The type system

Comments

@aturon
Copy link
Member

aturon commented Oct 7, 2014

The following program:

#![allow(dead_code)]

fn foo() -> Result<(), ()> {
    Ok(());  // Note the stray semicolon
}

fn main() {}

generates the following error:

not-infer-sized.rs:4:5: 4:7 error: unable to infer enough type information to locate the impl of the trait `core::kinds::Sized` for the type `<generic #1>`; type annotations required
not-infer-sized.rs:4     Ok(());
                         ^~
not-infer-sized.rs:4:5: 4:7 note: the trait `core::kinds::Sized` must be implemented because it is required by `core::result::Ok`
not-infer-sized.rs:4     Ok(());
@aturon aturon added A-typesystem Area: The type system A-DSTs Area: Dynamically-sized types (DSTs) labels Oct 7, 2014
@aturon
Copy link
Member Author

aturon commented Oct 7, 2014

cc @nick29581 @nikomatsakis

@aturon aturon changed the title Strange error about inferring Sized Poor error message for unconstrained bounds Oct 7, 2014
@aturon
Copy link
Member Author

aturon commented Oct 7, 2014

This is happening because, due to the semicolon, the type arguments for Ok are completely unconstrained. However, this is an easy mistake to make (especially for newcomers) so it would be good to provide a better error message here.

@nrc
Copy link
Member

nrc commented Oct 7, 2014

This is the same problem as #17567, although a different example. Not sure if we can fix with the same fix, so I'll leave this open for now.

@nikomatsakis
Copy link
Contributor

As I wrote in #17567, it's probably easiest to just update the error message to change its emphasis in cases like this. I think it's just a dup of #17567, hence closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

3 participants