Skip to content

Confusing error message #36797

Closed
Closed
@jthornber

Description

@jthornber

A spurious semicolon meant this function was returning () rather than some form of io::Result. I feel the error message could have been more helpful, since the type was just plain wrong, rather than inadequately specified.

use std::fs::File;
use std::io;
use std::os::unix::io::AsRawFd;
use std::path::Path;

pub struct DMIoctl {
// FIXME: automate closing the fd
control_file: File

}

static IOCTL_CONTROL_PATH: &'static Path = Path::new("/dev/mapper/control");

impl DMIoctl {
fn new_specifying_control<P: AsRef>(path: &P) -> io::Result {
let i = DMIoctl { control_file: try!(File::open(path)) };

   // main.rs:21:9: 71:11 error: unable to infer enough type information about `_`; type annotations or generic parameter binding required\

[E0282]
//main.rs:21 Ok(i);
^~

   Ok(i);

}

fn new() -> io::Result {
Self::new_specifying_control(IOCTL_CONTROL_PATH);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions