Skip to content

invalid suggestion for trait from extern crate if trait reexported #32938

@KalitaAlexey

Description

@KalitaAlexey
extern crate iron;

use iron::{IronResult, Request, Response};

fn handler(req: &mut Request) -> IronResult<Response> {
    req.get_ref::<i32>();
    Ok(Response::new())
}

fn main() {
    println!("Hello, world!");
}

Error in

req.get_ref::<i32>();

It is defined in plugin::Plugin and reexported in iron/lib.rs:

pub use plugin::Pluggable as Plugin;

https://github.com/iron/iron/blob/master/src/lib.rs#L95

The compiler says

src/main.rs:6:9: 6:16 error: no method named `get_ref` found for type `&mut iron::Request<'_, '_>` in the current scope
src/main.rs:6     req.get_ref::<i32>();
                      ^~~~~~~
src/main.rs:6:9: 6:16 help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
src/main.rs:6:9: 6:16 help: candidate #1: `use iron::Pluggable`

Of course if I add use iron::Pluggable then the compiler says

src/main.rs:4:5: 4:20 error: unresolved import `iron::Pluggable`. There is no `Pluggable` in `iron` [E0432]
src/main.rs:4 use iron::Pluggable;

Reproduced in

$ rustc --version
rustc 1.9.0-nightly (a43eb4e77 2016-04-12)
$ cargo --version
cargo 0.10.0-nightly (88e3081 2016-04-12)
$ rustc --version
rustc 1.7.0 (a5d1e7a59 2016-02-29)
$ cargo --version
cargo 0.8.0-nightly (28a0cbb 2016-01-17)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-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