Add support for macro default value generics#522
Conversation
| buf.write('&'); | ||
| } | ||
| self.visit_path(buf, path); | ||
| self.visit_macro_path(buf, path); |
There was a problem hiding this comment.
I'm wondering if I should allow TyGenerics to have path with generics in them... No limit to generics recursion. =D
| } | ||
| // We special-case "askama::get_value". | ||
| Expr::Path(path) if path == &["askama", "get_value"] => { | ||
| Expr::Path(path) if matches!(path.as_slice(), [part1, part2] if part1.generics.is_empty() && part1.name == "askama" && part2.name == "get_value") => |
There was a problem hiding this comment.
if let is not supported as pattern guard. :'(
There was a problem hiding this comment.
Yeah, I hope this restriction is lifted in the future.
| buf, | ||
| args, | ||
| generics, | ||
| &path[1].generics, |
There was a problem hiding this comment.
Should I use path.last().unwrap().generics instead?
There was a problem hiding this comment.
Maybe you could add a comment that this is the "get_value" part?
There was a problem hiding this comment.
Added the code comment.
| } | ||
|
|
||
| pub(super) fn visit_path(&mut self, buf: &mut Buffer, path: &[&str]) -> DisplayWrap { | ||
| pub(super) fn visit_macro_path(&mut self, buf: &mut Buffer, path: &[&str]) -> DisplayWrap { |
There was a problem hiding this comment.
It's the same as visit_path except it's only a list of strings, no generics in there.
| return self.visit_custom_filter_with_path(ctx, buf, path, args, generics, node); | ||
| } | ||
| PathOrIdentifier::Identifier(name) => *name, | ||
| let (name, generics): (&str, &[WithSpan<'_, TyGenerics<'_>>]) = match name { |
There was a problem hiding this comment.
We could cheat here and skip all ensure_no_generics calls (which would be nice) but it would require a small refactor of this code, increasing the diff. I suppose it's better as a follow-up?
dddac55 to
592cac9
Compare
|
Fixed merge conflicts as well. :) |
Fixes #513.