clean up handling of paths in mgca - #160216
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
8dda2c6 to
5b41ff7
Compare
| } | ||
|
|
||
| fn can_lower_path_to_const_arg_direct( | ||
| &mut self, |
There was a problem hiding this comment.
nit:
| &mut self, | |
| &self, |
There was a problem hiding this comment.
thanks! I also removed the mut from can_lower_expr_to_const_arg_direct :3
| TyKind::DirectConstArg(expr) => self.resolve_anon_const_manual( | ||
| true, | ||
| AnonConstKind::ConstArg(IsRepeatExpr::No), | ||
| |this| this.resolve_expr(&expr, None), |
There was a problem hiding this comment.
nit:
| |this| this.resolve_expr(&expr, None), | |
| |this| this.resolve_expr(expr, None), |
There was a problem hiding this comment.
out of curiosity, how did you spot this? just a good eye, or do you have some sort of setup where you can run clippy locally or something, and you checked out my code?
There was a problem hiding this comment.
Nothing really. I was reading through the code, fiddling around, and somehow stumbled 😄.
| { | ||
| let ct = | ||
| self.lower_const_path_to_const_arg(&None, path, res, ty.id, ty.span); | ||
| let ct = self.arena.alloc(ct); |
There was a problem hiding this comment.
Curious why we do arena alloc here?
There was a problem hiding this comment.
GenericArg::Const(&'hir ConstArg<..>)is arena'd, so it needs an arena alloc somewherelower_anon_const_to_const_argreturns ConstArg by value (this has been the case since before I started working on this code)- there's a
lower_anon_const_to_const_arg_and_allocwrapper, fwiw
- there's a
- which requires
lower_expr_to_const_arg_directto return it by value - which requires
lower_path_to_const_arg_directto do the same - and then I said shrug, make
lower_const_path_to_const_argdo the same, since it's a parallel tolower_anon_const_to_const_arg - so we arena alloc in the caller of
lower_const_path_to_const_arg, here
there's no particular reason why this whole set of functions (lower_anon_const_to_const_arg/lower_expr_to_const_arg_direct/lower_const_path_to_const_arg/lower_path_to_const_arg_direct) returns by value instead of by &'hir, could go the other way around, but they should all be consistently the same IMO.
There was a problem hiding this comment.
I guess in other words:
the diff adds an arena alloc here, because I removed it from lower_const_path_to_const_arg, because I wanted lower_const_path_to_const_arg to be more parallel to lower_anon_const_to_const_arg: they are conceptually extremely similar functions (take an X, attempt to lower it to a direct const arg, and fall back to anon const if that fails), just X is a path for one, and an AST anon const in the other.
There was a problem hiding this comment.
Makes sense. Thanks for detailed explanation. 😄
5b41ff7 to
2f54b38
Compare
|
@bors r=BoxyUwU,bit-aloo |
…uwer Rollup of 10 pull requests Successful merges: - #160841 (`rust-analyzer` subtree update) - #160253 (Add CI job for checking stdlib semver compatibility) - #160216 (clean up handling of paths in mgca) - #160832 (Fix funding link) - #160833 (Remove `analysis` arg from `ResultsVisitor` methods) - #160834 (Update Enzyme submodule) - #160836 (Fix swapped documentation lines on `io::Read`) - #160839 (Stop updating npm lockfile by Renovatebot) - #160840 (Rename `SmallCopyList` to `SmallCopySet`) - #160846 (use rustc_attr_ir imports more)
Rollup merge of #160216 - khyperia:gca-path-cleanup, r=BoxyUwU,bit-aloo clean up handling of paths in mgca related tracking issue: #132980 Handling of ambiguous type-or-constant argument paths was really wonky and distinct from the regular `can_lower_expr_to_const_arg_direct` lowering paths. Clean that up and unify it, as discussed here #158479 (comment) Also, do a bunch of other little cleanups at the same time while I'm here: - add support for parens to the inside of direct_const_arg! and macroless_generic_const_args (idk why this wasn't a thing before) - add constant and lifetime ribs when resolving TyKind::DirectConstArg - note the TyKind, not ExprKind (~~I am unsure if/how this changes behavior~~ added a test, `direct-const-arg-correct-rib.rs`) - this was discussed here #158617 (comment) - minor debug logging change - various minor code shuffles/cleanups - add test for `direct_const_arg!(_)` inferring to a type - this test should have been added in #159058 which added this behavior (well, changed the behavior from an ICE to inferring to a type) - add a test asserting the current behavior of parens/braces/underscores on stable - one or two of these cases already have tests elsewhere, but it's nice to assert the whole set, and also assert the whole set in the same place so it's easily visible to be able to give me confidence the whole set actually is tested (both positives and negatives are important here) - add a test similar to the previous one, but with mgca enabled, asserting all combinations now compile successfully r? @BoxyUwU
related tracking issue: #132980
Handling of ambiguous type-or-constant argument paths was really wonky and distinct from the regular
can_lower_expr_to_const_arg_directlowering paths. Clean that up and unify it, as discussed here #158479 (comment)Also, do a bunch of other little cleanups at the same time while I'm here:
I am unsure if/how this changes behavioradded a test,direct-const-arg-correct-rib.rs) - this was discussed here allow mGCA const arguments to fall back to anon consts #158617 (comment)direct_const_arg!(_)inferring to a type - this test should have been added in implement #![feature(macroless_generic_const_args)] #159058 which added this behavior (well, changed the behavior from an ICE to inferring to a type)r? @BoxyUwU