-
Notifications
You must be signed in to change notification settings - Fork 13.3k
graphviz drawing of constraints for region inference #19892
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
visualization of region inference constraint graph. Optionally uses environment variables `RUST_REGION_GRAPH=<path_template>` and `RUST_REGION_GRAPH_NODE=<node-id>` to select which file to output to and which AST node to print. Note that in some cases of method AST's, the identification of AST node is based on the id for the *body* of the method; this is largely due to having the body node-id already available at the relevant point in the control-flow of rustc in its current incarnation. Ideally we would handle identifying AST's by name in addition to node-id, e.g. the same way that the pretty-printer supports path suffixes as well as node-ids for identifying subtrees to print.
(in hindsight we might want the graph to include edges for the |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this pull request
Dec 17, 2014
Added -Z print-region-graph debugging option; produces graphviz visualization of region inference constraint graph. Optionally uses environment variables `RUST_REGION_GRAPH=<path_template>` and `RUST_REGION_GRAPH_NODE=<node-id>` to select which file to output to and which AST node to print.
bors
added a commit
that referenced
this pull request
Dec 22, 2014
…ichton NOTE: Not yet ready for merge; see my first comment below. I will remove this note after I post the appropriate follow-on commit to get `run-make` working too. This PR adds a new pretty printing mode, `everybody_loops`, which replaces every function body in the input with `loop { }`. I have found this to be useful for building narrow test cases starting from bugs in static analyses like typeck and borrowck that are only exposed initially from complex input source crates like `librustc`. The process to follow is: 1. You first generate the new input with every function body replaced with `loop { }`, then 2. you cut-and-paste the original function body that exposes the error, 3. re-run the compiler on the modified output, to confirm you still see the bug -- but now you should get results faster and with much narrower debug output, since all the other function bodies are trivial. 4., optional you iteratively delete all the other items that are now found to be no longer necessary since all of the function bodies are now just `loop { }`. (Strictly speaking, there are bugs in the pretty printer and/or parser that make the process above not as seamless as described. For example, it seems that `use super::{A, B};` can in some contexts be pretty-printed with whitespace separating `super` and `::` and `{A, B};`, which the parser then errors on. But that is not an argument against the overall technique, which still appears pretty effective, though perhaps it would be even better if combined with macro-expansion in some way.) ---- Up front: I do believe this sort of local development hack should not want this option to be part of the stable public interface for `rustc`. So while I could make a `-Z` flag just for this, I am worried that our `-Z` infrastructure is generally too weak to express the kinds of options I want to add (see e.g. #19892 where I use the hack of employing environment variables, when I really would have preferred to leverage `libgetopts`). Thus, this PR incorporates what I believe to be a reasonable compromise: Add a single new `-Z` flag, `-Z unstable-options`, which expands the set of valid options to `rustc`. This way, we still leverage all of the `getopts` infrastructure: for example, `rustc -Z unstable-options --help` prints out information about both the stable and unstable options (while `rustc --help` without the `-Z unstable-options` flag just prints out information about the stable options. The main drawback that I can see is that processing such options is a little bit awkward, since you need to make sure that you check `sess.debugging_opt(config::UNSTABLE_OPTIONS)` before querying the `getopts` matches for the option in question. But it really is not that bad; all of the ugliest stuff is paid for up front in this PR (e.g. the way I try to ensure that we do not waste time parsing the options twice in the common case where all the provided options are stable). ---- With `-Z unstable-options` in place, it is clear that pretty-print modes like `everybody_loops` belongs under an unstable option, as does the control flow graph visualizing pretty printer. To deal with that, I added a new unstable-option, `--xpretty` and moved the latter two pretty print modes there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added -Z print-region-graph debugging option; produces graphviz visualization of region inference constraint graph.
Optionally uses environment variables
RUST_REGION_GRAPH=<path_template>
andRUST_REGION_GRAPH_NODE=<node-id>
to select which file to output to and which AST node to print.