-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Bug in import #16217
Comments
Do you have a standalone example of your code that could be tested? |
On my repo if you want : https://github.com/GuillaumeGomez/rust-GSL . The file is vector.rs (like said in the errors). |
I actually think that the problem is the following : inside a module, this is a different scope (right ?) so what you import inside is only for inside functions, not inside struct and their methods. That's my opinion. However, I found out that it's possible to not import ffi and use it like this : pub mod Gsl {
pub struct SomeStruct {
...
}
impl SomeStruct {
pub fn however() {
::ffi::some_function();
}
}
} But once again, is that normal ? PS: my compiler version is the following : > rustc --version
rustc 0.12.0-pre-nightly (4d4eb1023 2014-08-02 23:36:09 +0000) |
I tried checking our your repo, but I see no |
Yes, sorry, I updated and I forgot to create a branch to keep this bug in sight. The "good" version is the following one : > git checkout 0166fde6730730145b226305750566106b536781 |
At that commit there are two imports of |
I can't find the good commit... I think it's an error of mine... Sorry for making you losing your time. I updated the rust compiler yesterday and today so maybe it's why we can't see the bug but I think I just didn't see the bad import. It seems kinda strange but it doesn't matter, even if it was a bug, now it doesn't appear anymore. |
No problem! I'm going to close for now and feel free to reopen if you run across it in the future! |
I've just encountered this same bug. Reproduced here: https://github.com/ajprax/rust_imports_bug (run |
@ajprax what you see is related to the fact that I think the normal approach here is to move the #[test]
fn it_works() {
use std::thread;
thread::spawn(|| {
println!("Hello from a thread!");
});
} or to make it dependent on #[cfg(test)]
use std::thread;
#[test]
fn it_works() {
thread::spawn(|| {
println!("Hello from a thread!");
});
} |
Presumably this is the result of A suggestion from the book, which seems appropriate here is to encapsulate the tests in a separate module: #[cfg(tests)]
pub mod tests {
use std::thread;
#[test]
fn it_works() {
thread::spawn(|| {
println!("Hello from a thread!");
});
}
} |
…icola internal: Simplify implementation of apply_document_changes While reading through the code base, I stumbled across a piece of code that I found hard to read despite its simple purpose. This is my attempt at making the code easier to understand for future readers. I won't be offended if this is too minor and not worth your time.
Hey, here's the problem :
When I compile it, the compiler says :
So I remove the import and then I get :
Is that normal ? Since the ffi import is used, I'm not supposed to have a unused warning, am I ?
The text was updated successfully, but these errors were encountered: