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

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

Closed
KalitaAlexey opened this issue Apr 13, 2016 · 1 comment
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@KalitaAlexey
Copy link
Contributor

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)
@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Jul 25, 2016
@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum
Copy link
Member

Closing in favor of (more general) #21934.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants