Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

save-analysis doesn't dump information about glob imports #33213

Closed
aochagavia opened this issue Apr 26, 2016 · 10 comments · Fixed by #33248
Closed

save-analysis doesn't dump information about glob imports #33213

aochagavia opened this issue Apr 26, 2016 · 10 comments · Fixed by #33248

Comments

@aochagavia
Copy link
Contributor

Running rustc foo.rs -Z save-analysis on the following code:

use self::foo::*;
mod foo {
    pub struct Bar;
    pub enum Baz {}
}

fn new_bar() -> Bar { Bar }
fn new_baz() -> Baz { panic!() }
fn main() {}

The output is:

crate,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,1,file_col,0,extent_start,0,extent_start_bytes,0,file_line_end,9,file_col_end,11,extent_end,151,extent_end_bytes,151,name,"globs1",crate_root,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code"
external_crate,name,"alloc",crate,"5",file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs"
external_crate,name,"libc",crate,"7",file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs"
external_crate,name,"std",crate,"1",file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs"
external_crate,name,"collections",crate,"3",file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs"
external_crate,name,"rustc_unicode",crate,"4",file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs"
external_crate,name,"rand",crate,"6",file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs"
external_crate,name,"core",crate,"2",file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs"
external_crate,name,"alloc_system",crate,"8",file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs"
end_external_crates
mod_ref,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,1,file_col,4,extent_start,4,extent_start_bytes,4,file_line_end,1,file_col_end,8,extent_end,8,extent_end_bytes,8,refid,"0",refidcrate,"0",qualname,"::self",scopeid,"0"
mod_ref,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,1,file_col,10,extent_start,10,extent_start_bytes,10,file_line_end,1,file_col_end,13,extent_end,13,extent_end_bytes,13,refid,"0",refidcrate,"0",qualname,"self::foo",scopeid,"0"
module,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,2,file_col,4,extent_start,23,extent_start_bytes,23,file_line_end,2,file_col_end,7,extent_end,26,extent_end_bytes,26,id,"5",qualname,"::foo",scopeid,"0",def_file,"globs1.rs"
struct,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,3,file_col,15,extent_start,45,extent_start_bytes,45,file_line_end,3,file_col_end,18,extent_end,48,extent_end_bytes,48,id,"7",ctor_id,"8",qualname,"::foo::Bar",scopeid,"5",value,"pub struct Bar;"
enum,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,4,file_col,13,extent_start,64,extent_start_bytes,64,file_line_end,4,file_col_end,16,extent_end,67,extent_end_bytes,67,id,"9",qualname,"::foo::Baz",scopeid,"5",value,"pub enum Baz {}"
function,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,7,file_col,3,extent_start,80,extent_start_bytes,80,file_line_end,7,file_col_end,10,extent_end,87,extent_end_bytes,87,id,"10",qualname,"::new_bar",declid,"",declidcrate,"",scopeid,"0"
type_ref,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,7,file_col,16,extent_start,93,extent_start_bytes,93,file_line_end,7,file_col_end,19,extent_end,96,extent_end_bytes,96,refid,"7",refidcrate,"0",qualname,"",scopeid,"0"
type_ref,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,7,file_col,22,extent_start,99,extent_start_bytes,99,file_line_end,7,file_col_end,25,extent_end,102,extent_end_bytes,102,refid,"8",refidcrate,"0",qualname,"",scopeid,"29"
function,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,8,file_col,3,extent_start,109,extent_start_bytes,109,file_line_end,8,file_col_end,10,extent_end,116,extent_end_bytes,116,id,"11",qualname,"::new_baz",declid,"",declidcrate,"",scopeid,"0"
type_ref,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,8,file_col,16,extent_start,122,extent_start_bytes,122,file_line_end,8,file_col_end,19,extent_end,125,extent_end_bytes,125,refid,"9",refidcrate,"0",qualname,"",scopeid,"0"
macro_use,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,8,file_col,22,extent_start,128,extent_start_bytes,128,file_line_end,8,file_col_end,27,extent_end,133,extent_end_bytes,133,callee_name,"panic",qualname,"panic::10335926828616349768",scopeid,"34"
function,file_name,"D:\Computer Science\Thesis\rrt\components\compiler\tests\code\globs1.rs",file_line,9,file_col,3,extent_start,143,extent_start_bytes,143,file_line_end,9,file_col_end,7,extent_end,147,extent_end_bytes,147,id,"13",qualname,"::main",declid,"",declidcrate,"",scopeid,"0"

I would expect a line containing information about the imports inserted by the compiler, namely self::foo::Bar and self::foo::Baz. This used to work in the past.

@aochagavia
Copy link
Contributor Author

cc @nrc

@nrc
Copy link
Member

nrc commented Apr 26, 2016

cc @jseyfried I wonder if one of the changes to name resolution could have caused this? I can't really imagine how, but it seems the most likely candidate.

@nrc nrc changed the title save-analysis doesn't dump information about global imports save-analysis doesn't dump information about glob imports Apr 26, 2016
@nrc nrc added the A-tools label Apr 26, 2016
@jseyfried
Copy link
Contributor

This was caused by #33044, which (correctly) changed the span of the path in a glob import to not include the ::* suffix.
The span change caused sub_span to be None so that the call to filter_generated on the following line always returned true.

@jseyfried
Copy link
Contributor

Unrelated to this issue, but we currently only dump glob-imported names that end up getting used.
@aochagavia, would you prefer we dump all glob imported names, even if they are not used?

@nrc
Copy link
Member

nrc commented Apr 28, 2016

Thanks @jseyfried ! The intended behviour is just to have the used names, i.e., the list of names one would use if you wanted to replace the glob import with a list import.

@jseyfried
Copy link
Contributor

jseyfried commented Apr 28, 2016

the list of names one would use if you wanted to replace the glob import with a list import.

Ah, that makes sense.

I was thinking more along the lines of refactoring away a needless qualification or moving a path from one module to another, in which we would want to know about unused names as well.

jseyfried added a commit to jseyfried/rust that referenced this issue Apr 28, 2016
Manishearth added a commit to Manishearth/rust that referenced this issue Apr 29, 2016
rustc_save_analysis: fix a bug in which glob imports are not dumped

This fixes rust-lang#33213, a bug that prevents glob imports from being included in the save-analysis data.
r? @nrc
@aochagavia
Copy link
Contributor Author

aochagavia commented Apr 30, 2016

After the changes, I still can reproduce the issue 😞

@jseyfried
Copy link
Contributor

jseyfried commented Apr 30, 2016

@aochagavia the changes haven't made it into the nighties yet (the current nightly is still 2016-04-28).

If you can reproduce on a more up-to-date local build, could you include the rustc --version and the emitted json?

@aochagavia
Copy link
Contributor Author

Oops... Sorry, I thought the changes were already in nightly. My bad.

@jseyfried
Copy link
Contributor

No problem!

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

Successfully merging a pull request may close this issue.

4 participants