-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add JSON AST dumping #12387
Add JSON AST dumping #12387
Conversation
io::println(json); | ||
} | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compile_input
function has managed to remain pretty clean since it was created, perhaps the json emission would be better suited inside of the phases themselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't possible without exiting the entire process in the phases, which they avoid by having compile_input return early for them if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(That was the first thing I implemented, before noticing that issue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you leave the modifications to stop_after_phase_X
and then move the emission logic to the end of the phases themselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, duh. will-do
On Wed, Feb 19, 2014 at 2:52 AM, Alex Crichton notifications@github.comwrote:
In src/librustc/driver/driver.rs:
@@ -531,7 +541,13 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
write_out_deps(sess, input, &outputs, &expanded_crate).unwrap();
if stop_after_phase_2(sess) { return; }
if stop_after_phase_2(sess) {
if sess.opts.debugging_opts & session::AST_JSON != 0 {
let json = json::PrettyEncoder::str_encode(&expanded_crate);
io::println(json);
}
return;
}
Couldn't you leave the modifications to stop_after_phase_X and then move
the emission logic to the end of the phases themselves?—
Reply to this email directly or view it on GitHubhttps://github.com//pull/12387/files#r9856752
.
This is mostly useful for working on rustc, when one is unfamiliar with the AST a particular construct will produce. It's a -Z flag as it's very much for debugging. Closes #10485
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate)); | ||
|
||
if sess.opts.debugging_opts & session::AST_JSON != 0 { | ||
let mut stdout = io::stdout(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be buffered? (Otherwise every single write, including each and every :
separator, will be a syscall.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't stdout line buffered by default?
On Wed, Feb 19, 2014 at 7:39 PM, Huon Wilson notifications@github.comwrote:
In src/librustc/driver/driver.rs:
@@ -220,8 +231,16 @@ pub fn phase_2_configure_and_expand(sess: Session,
krate = time(time_passes, "prelude injection", krate, |krate|
front::std_inject::maybe_inject_prelude(sess, krate));
- time(time_passes, "assinging node ids and indexing ast", krate, |krate|
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate))
- let (krate, map) = time(time_passes, "assinging node ids and indexing ast", krate, |krate|
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate));
- if sess.opts.debugging_opts & session::AST_JSON != 0 {
let mut stdout = io::stdout();
Shouldn't this be buffered? (Otherwise every single write, including each
and every : separator will be a syscall.)—
Reply to this email directly or view it on GitHubhttps://github.com//pull/12387/files#r9890950
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The task-local stdout handle is line-buffered by default, but those created through io::stdout()
are not buffered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feh.
On Wed, Feb 19, 2014 at 7:55 PM, Alex Crichton notifications@github.comwrote:
In src/librustc/driver/driver.rs:
@@ -220,8 +231,16 @@ pub fn phase_2_configure_and_expand(sess: Session,
krate = time(time_passes, "prelude injection", krate, |krate|
front::std_inject::maybe_inject_prelude(sess, krate));
- time(time_passes, "assinging node ids and indexing ast", krate, |krate|
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate))
- let (krate, map) = time(time_passes, "assinging node ids and indexing ast", krate, |krate|
front::assign_node_ids_and_map::assign_node_ids_and_map(sess, krate));
- if sess.opts.debugging_opts & session::AST_JSON != 0 {
let mut stdout = io::stdout();
The task-local stdout handle is line-buffered by default, but those
created through io::stdout() are not buffered.—
Reply to this email directly or view it on GitHubhttps://github.com//pull/12387/files#r9891396
.
@cmr, also, while you're fixing the buffering ;), it would be good to add a simple run-make test, to ensure the flags keep doing something approximately sane. |
Awesome! |
fix(ide-db): correct single-file module rename Fixes a bug where rust-analyzer would emit `WorkspaceEdit`s with paths to dirs instead of files for the following project layout. lib.rs ```rust mod foo; ``` foo.rs ```rust mod bar { struct Bar; } ``` Also fixes emitted paths for modules with mod.rs. The bug resulted in panic in helix editor when attempting to rename a module.
See the commits