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

Fails on some rust imports #33

Open
Boscop opened this issue Nov 8, 2017 · 12 comments
Open

Fails on some rust imports #33

Boscop opened this issue Nov 8, 2017 · 12 comments
Labels

Comments

@Boscop
Copy link

Boscop commented Nov 8, 2017

E.g.:
use database_url::extract_database_url;

@fiatjaf
Copy link
Owner

fiatjaf commented Nov 8, 2017

Chrome or Firefox?

@Boscop
Copy link
Author

Boscop commented Nov 8, 2017

Chrome at least.

@fiatjaf
Copy link
Owner

fiatjaf commented Nov 8, 2017

I believe this has been fixed on the newest versions, which are not published on Chrome yet.

I had to change the permissions for Firefox, however, because Chrome automatically grants some permissions which we weren't asking and Firefox doesn't -- which made the extension don't work unless we've changed that. Now if I publish the latest releases to Chrome it will prompt all users to accept the new permissions, which is very annoying.

Since I'm working on a rewrite of some parts which will change the permissions anyway, I thought I would delay publishing the new Chrome versions until then, but it is taking more time than I had planned. So, what should I do?

@Boscop
Copy link
Author

Boscop commented Nov 9, 2017

It's not that important, I can wait :)
(#27 is my main issue atm.)

@fiatjaf fiatjaf added the rust label Dec 6, 2017
@fiatjaf
Copy link
Owner

fiatjaf commented Dec 6, 2017

The rewrite I mentioned earlier was completed today, but it was so much easier than i was imagining that I'm afraid I may have commited stupid mistakes, please let me know if I did.

(And please reopen this issue if it is not solved.)

@fiatjaf fiatjaf closed this as completed Dec 6, 2017
@Antelope13
Copy link

Is this fixed in the latest version for Chrome? I'm still seeing it in 2.0.2.

Here's where I first saw the issue in the exa source:

use std::io::{stderr, Write, Result as IOResult};

Made a few permutations of different ways it fails here, including if the name is in the comments.

@fiatjaf
Copy link
Owner

fiatjaf commented Dec 22, 2017

Not the same bug. But I think I know how to fix this.

@Antelope13
Copy link

Nice, thanks for taking a look. I really love this extension!

@fiatjaf fiatjaf reopened this Dec 23, 2017
@Boscop
Copy link
Author

Boscop commented Dec 23, 2017

Btw, Rust is getting nested group imports: rust-lang/rfcs#2128

@fiatjaf
Copy link
Owner

fiatjaf commented Dec 23, 2017

Such complexity. Much problem.

Is that only for local/relative modules, @Boscop, or for external crates also?
use is just for local modules, right? And std is a module local to everywhere?

What is exactly a crate, a module, whatever?

@Boscop
Copy link
Author

Boscop commented Dec 26, 2017

Basically, crates are compilation units (either lib or bin) and when you do extern crate foo; it also imports foo into the current scope, so you can use symbols from foo like foo::bar() but if you are in another scope that's not a sub-scope (e.g. in another rust file), you have to import foo first with use foo; before you can use foo::bar(). Every file creates a module, but you can also create new modules within a module by writing mod asd { .. }. But this module doesn't inherit imports from the parent module!
std is implicitly imported in every module.
If you write use foo; in a rust file it will look for foo in the crate root (main.rs for bins or lib.rs for libs), also for use {foo, bar};. This foo could have been imported by extern crate foo; or it could be a module (mod foo; or mod foo {...}) or any symbol defined in main.rs/lib.rs.
So basically extern crate foo; is similar to mod foo;, in that it makes 'foo' available in the crate root.
I hope it makes sense :)

The new nested syntax is just syntactic sugar, so you can write many imports from different submodules of a module/crate in fewer lines.

use syntax::ast::{self, *}; means use syntax::ast; use syntax::ast::*;

@Boscop
Copy link
Author

Boscop commented Jan 5, 2018

Someone wrote a guide:

https://dev.to/hertz4/rust-module-essentials-12oi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants