-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Fixed quote_method!() implementation #17409
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @huonw (or someone else) soon. |
@@ -465,8 +465,12 @@ pub fn expand_quote_method(cx: &mut ExtCtxt, | |||
tts: &[ast::TokenTree]) | |||
-> Box<base::MacResult+'static> { | |||
let e_param_colons = cx.expr_none(sp); | |||
let e_visibility = cx.expr_path(cx.path(syntax::codemap::DUMMY_SP, vec!( |
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.
unnecessary syntax::
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 actually be sp
.
Thanks! Could you also add a testcase? E.g. just putting (Be sure to comment once you update the PR, since GitHub doesn't provide notifications.) |
Fixed the |
Parser.parse_method now has a second argument, I assume ast::Inherited is the correct visibility in this case.
Sorry, I'm kind of fixing this without verifying that it actually compiles as I don't have a rustc at hand at the moment to bootstrap the build. I've fixed the first argument as well (was |
Ok, I've verified that it works now. Is it r? or should I squash commits first? |
Parser.parse_method now has a second argument, I assume ast::Inherited is the correct visibility in this case.
Parser.parse_method now has a second argument, I assume ast::Inherited is the correct visibility in this case.
…=Veykril fix: add a breaker to avoid infinite loops from source root cycles See rust-lang#17409 This patch prevents infinite looping from cycles by giving up if the number of source roots checked for a config value reaches the total number of source roots. Alternative more precise options include creating a set of all source roots visited and giving up as soon as a cycle is encountered, but I wasn't sure how costly an allocation would be here for performance. Can confirm that locally this fixes the problem for me.
fix: ensure there are no cycles in the source_root_parent_map See rust-lang#17409 We can view the connections between roots as a graph. The problem is that this graph may contain cycles, so when adding edges, it is necessary to check whether it will lead to a cycle. Since we ensure that each node has at most one outgoing edge (because each SourceRoot can have only one parent), we can use a disjoint-set to maintain the connectivity between nodes. If an edge’s two nodes belong to the same set, they are already connected. Additionally, this PR includes the following three changes: 1. Removed the workaround from rust-lang#17409. 2. Added an optimization: If `map.contains_key(&SourceRootId(*root_id as u32))`, we can skip the current loop iteration since we have already found its parent. 3. Modified the inner loop to iterate in reverse order with `roots[..idx].iter().rev()` at line 319. This ensures that if we are looking for the parent of `a/b/c`, and both `a` and `a/b` meet the criteria, we will choose the longer match (`a/b`).
Parser.parse_method now has a second argument, I assume ast::Inherited is the correct visibility in this case.