Skip to content

Potentially misleading compiler error for unfinished line with Option<T> #25133

Closed
@DoumanAsh

Description

@DoumanAsh

Next code:

use std::io::{Read, stdin};

fn main() {
    stdin().bytes().next()
}

Gives this compile error:

E:\Downloads\Git\collectionScripts\rust
 [master +2 ~1 -0 !] > rustc.exe .\temp.rs
.\temp.rs:4:5: 4:27 error: mismatched types:
 expected `()`,
    found `core::option::Option<core::result::Result<u8, std::io::error::Error>>`
(expected (),
    found enum `core::option::Option`) [E0308]
.\temp.rs:4     stdin().bytes().next()
                ^~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Which is a bit misleading as there is actually we're missing either ; or unwrap() i think?

Rust version:

rustc 1.0.0-beta.4 (850151a75 2015-04-30) (built 2015-05-01)
binary: rustc
commit-hash: 850151a75709f146addd30bbbf1f23d384f0b381
commit-date: 2015-04-30
build-date: 2015-05-01
host: x86_64-pc-windows-gnu
release: 1.0.0-beta.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions