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

confusing error with 'extern crate' #13672

Closed
comex opened this issue Apr 22, 2014 · 4 comments
Closed

confusing error with 'extern crate' #13672

comex opened this issue Apr 22, 2014 · 4 comments
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically

Comments

@comex
Copy link
Contributor

comex commented Apr 22, 2014

a.rs:

#![crate_type = "dylib"]
pub trait Foo {}

b.rs:

mod c;
fn main() {}

c.rs:

extern crate a;
use a::Foo;

Ran rustc a.rs, then rustc b.rs -L.. The result is a confusing error:

c.rs:2:9: 2:10 error: unresolved import. maybe a missing `extern crate a`?
c.rs:2     use a::Foo;

rustc 0.11-pre-nightly (d35804e 2014-04-18 00:01:22 -0700)

@SiegeLord
Copy link
Contributor

It's unclear what you mean by 'useless'. You seem to imply that it is unusable, which is not the case (to use from it you need to do, e.g., use self::a::Foo in c.rs). It is, however, unused if you uncomment the use statement, but I imagine you could want to link to a crate for some side-effect (e.g. the other crate could bring some C libraries which are used in a way invisible to rustc).

The wrong use error is bizarre though in this case.

@comex
Copy link
Contributor Author

comex commented Apr 22, 2014

I see. Some people in #rust seemed to think that it was unusable, but I guess that's wrong. I've edited the bug to refer to the confusing error.

@comex comex changed the title no complaint about useless 'extern crate' confusing error with 'extern crate' Apr 22, 2014
@frewsxcv
Copy link
Member

frewsxcv commented Feb 3, 2015

visiting for triage

The error message is slightly different now with the latest rust

/t/triage $ cat a.rs
#![crate_type = "dylib"]
pub trait Foo {}
/t/triage $ cat b.rs
mod c;
fn main() {}
/t/triage $ cat c.rs
extern crate a;
use a::Foo;
/t/triage $ rustc a.rs
/t/triage $ rustc b.rs -L.
c.rs:2:5: 2:6 error: unresolved import `a::Foo`. Did you mean `self::a`?
c.rs:2 use a::Foo;
           ^
error: aborting due to previous error
/t/triage $ rustc --version
rustc 1.0.0-nightly (1d00c545e 2015-01-30 19:56:34 +0000)

@Gankra
Copy link
Contributor

Gankra commented Feb 3, 2015

Looks fixed to me.

@Gankra Gankra closed this as completed Feb 3, 2015
flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 14, 2024
…ments (rust-lang#13672)

Fixes rust-lang#13670.

Bug was that I forgot to add the comparison with the included file
content length...

changelog: Fix `large_include_file` lint being triggered all the time by
doc comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically
Projects
None yet
Development

No branches or pull requests

5 participants