-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
implement emit-ast option ( see issue #10485 ) #10711
Conversation
}; | ||
|
||
let mut json = ~treemap::TreeMap::new(); | ||
json.insert(~"crate", crate_json); |
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.
I think this should include the compiler version, it can be retrieved by option_env!("CFG_VERSION")
which gives Option<&'static str>
that is Some when the CFG_VERSION env var exists, and None if it doesn't.
I actually think adding a static VERSION: Option<&'static str> = option_env!("CFG_VERSION");
to the librustc/lib.rs
file, and using that in the 2 places that CFG_VERSION is currently used and here would be best (those two places are version
in the lib.rs
file, and compile_unit_metadata
in librustc/middle/trans/debuginfo.rs
; the latter would change to ::VERSION.unwrap("unknown")
).
Something like
json.insert(~"version", json::String(::VERSION.unwrap("unknown").to_owned()))
FWIW, the ::...
syntax means "from the crate root".
(Probably worth keeping that as a seperate commit for now... but I'm not particularly sure or fussed.)
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.
I removed generated string intermediate value as you suggested.
(btw, do I need to provide a patch in only on commit?)
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.
Multiple commits are fine (although you may be asked to squash commits that are not particularly distinct).
It'd be good to have a test for this, that at least makes sure that it doesn't crash the compiler, and writes valid JSON, but that really needs #10434 to be solved to have a nice method for doing so. |
@huonw how can I check for validity of generated JSON? Does simply loading that JSON data using libextra's JSON parser work? |
I was thinking something like a simple python script that shelled out to rustc and loaded the output with |
Closing this due to inactivity, but feel free to reopen with an update! |
run linkcheck in clippy ci fixes rust-lang#10711 changelog: Run [linkcheck.sh](https://github.com/rust-lang/rust/blob/master/src/tools/linkchecker/linkcheck.sh) from rustc repo in Remark.yml to check Clippy book.
First try for #10485. Unit/regression tests are missing for now.
Any comments would be appreciated.
JSON generation part is mostly copied from
librustdoc::lib::json_output
.