Skip to content

No error despite of multiple applicable methods in scope #26080

Open
@michas2

Description

@michas2

Given the following code:

extern crate mio;
use mio::buf::RingBuf;
use mio::buf::Buf;
use std::io::Read;

fn main() {
    let buf = RingBuf::new(10);
    let bytes = buf.bytes();
    println!("{:?}", bytes);
}

buf is of type RingBuf. RingBuf does not provide .bytes(), but it implements both Buf and Read, which both provide a .bytes() implementation.

According to https://doc.rust-lang.org/book/ufcs.html the compiler should complain. But it simply chooses to take the implementation of Read, which return the "wrong" result type.

(Without the "use Read" line rust chooses the implementation of Buf, which return the "correct" type.)

(I am using Rust 1.0.0.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions