module-linker
module-linker copied to clipboard
Fails on some rust imports
Chrome or Firefox?
Chrome at least.
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?
It's not that important, I can wait :) (#27 is my main issue atm.)
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.)
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.
Not the same bug. But I think I know how to fix this.
Nice, thanks for taking a look. I really love this extension!
Btw, Rust is getting nested group imports: https://github.com/rust-lang/rfcs/pull/2128
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?
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::*;
Someone wrote a guide:
https://dev.to/hertz4/rust-module-essentials-12oi