Update rustc-driver related examples#1345
Merged
tshepang merged 1 commit intorust-lang:masterfrom May 30, 2022
Merged
Conversation
36 tasks
tshepang
approved these changes
May 22, 2022
jyn514
reviewed
May 23, 2022
| let def_id = tcx.hir().local_def_id(item.hir_id()); // def_id identifies the main function | ||
| let ty = tcx.typeck(def_id).node_type(hir_id); | ||
| println!("{:?}: {:?}", expr, ty); // prints expr(HirId { owner: DefIndex(3), local_id: 4 }: "Hello, world!"): &'static str | ||
| println!("{:?}: {:?}", expr, ty); // prints "`rustc_hir::Expr`: `rustc_middle::ty::Ty`" |
Member
There was a problem hiding this comment.
are you sure? that seems very strange for it to print, normally it gives details about the item itself
Member
Author
There was a problem hiding this comment.
It actually prints:
fn main() { let message = "Hello, world!"; println!("{}", message); }
Expr { hir_id: HirId { owner: DefId(0:3 ~ rust_out[a9df]::main), local_id: 2 }, kind: Lit(Spanned { node: Str("Hello, world!", Cooked), span: <main.rs>:1:27: 1:42 (#0) }), span: <main.rs>:1:27: 1:42 (#0) }: &str
Well, I remember I truncated the output because it's a bit long but... yeah it's quite different.
Any suggestions here? I feel it's verbose and would like to shorten if possible. Though I don't mind pasting it as-is if you think it's better :)
45c4156 to
920ae60
Compare
tshepang
approved these changes
May 24, 2022
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
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.
Updates rustc-driver related examples to the latest nightly (I forgot to update the references on #1330 :P).
cc #1344