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

implement emit-ast option ( see issue #10485 ) #10711

Closed
wants to merge 1 commit into from

Conversation

osa1
Copy link
Contributor

@osa1 osa1 commented Nov 29, 2013

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.

};

let mut json = ~treemap::TreeMap::new();
json.insert(~"crate", crate_json);
Copy link
Member

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.)

Copy link
Contributor Author

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?)

Copy link
Member

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).

@huonw
Copy link
Member

huonw commented Nov 29, 2013

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.

@osa1
Copy link
Contributor Author

osa1 commented Nov 29, 2013

@huonw how can I check for validity of generated JSON? Does simply loading that JSON data using libextra's JSON parser work?

@huonw
Copy link
Member

huonw commented Nov 29, 2013

I was thinking something like a simple python script that shelled out to rustc and loaded the output with json. (But, I don't think this is possible to do in a nice way without #10434.)

bors added a commit that referenced this pull request Dec 6, 2013
as recommended by @huonw on this PR #10711 , I removed intermediate step that generates a string instead of directly writing to Writer without generating intermediate string.
@emberian
Copy link
Member

#10434 has been closed! See src/test/run-make

@osa1 needs a rebase

@alexcrichton
Copy link
Member

Closing this due to inactivity, but feel free to reopen with an update!

@osa1 osa1 deleted the emit-ast branch March 2, 2021 07:02
flip1995 pushed a commit to flip1995/rust that referenced this pull request May 5, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants