implement #![feature(macroless_generic_const_args)] - #159058
Conversation
|
|
| ConstItemRhsKind::TypeConst { rhs: Some(anon) } => { | ||
| hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg_and_alloc(anon)) | ||
| hir::ConstItemRhs::TypeConst(self.arena.alloc( | ||
| match self.can_lower_expr_to_const_arg_direct( | ||
| &anon.value, | ||
| DirectConstArgContext::MacrolessMinGenericConstArgs, | ||
| ) { | ||
| Ok(()) => self.lower_expr_to_const_arg_direct(&anon.value, Some(anon.id)), | ||
| Err(err) => err.emit(self), | ||
| }, | ||
| )) | ||
| } |
There was a problem hiding this comment.
ConstItemRhsKind::TypeConst no longer needs to contain an AnonConst, it can parse identically to the rhs of a regular const, as a normal expr now.
Doing so I've left undone for now, will do so in a followup, it gets a bit more involved (and it's related to this #158617 (comment) that I might do at the same time)
This comment has been minimized.
This comment has been minimized.
925742b to
4e77ce1
Compare
|
This PR changes a file inside |
| } | ||
| ``` | ||
|
|
||
| Using `#![macroless_generic_const_args]` enables you to write the above without the macro: |
There was a problem hiding this comment.
I think this should be #![feature(macroless_generic_const_args)], as shown in the example below.
This comment has been minimized.
This comment has been minimized.
4e77ce1 to
6862ede
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
There was a problem hiding this comment.
what's the behaviour of direct!(Foo { field: T::ASSOC })? Because I dont think we wan't to accept such a thing, instead field: direct!(T::ASSOC) should be required. Ideally macroful gca should not expose macroless gca's heuristic to any extent because then it needs to be figured out for stabilization 🤔
6862ede to
a388f03
Compare
|
@bors r+ thx :3 |
…uwer Rollup of 7 pull requests Successful merges: - #155617 (Replace `jemalloc` bootstrap options with `override-allocator`) - #156225 (feat(num): improve error messages for `TryFromIntError`) - #159058 (implement #![feature(macroless_generic_const_args)]) - #159435 (core: implement `Rng` for references) - #159471 (Make `Global` and `System` allocators unstably implement `const Clone + const Default`.) - #159590 (Remove some dead code) - #159636 (Improve some comments (and an error message))
Rollup merge of #159058 - khyperia:macroless_generic_const_args, r=BoxyUwU implement #![feature(macroless_generic_const_args)] tracking issue: #159006 lots of description of what is happening here in the tracking issue, not gonna copypaste it into here :) the test situation is that after discussion with boxy of whether our mgca tests should be: - keep them under only `min_generic_const_args`, and add `direct_const_arg!()` where it's needed - keep the code contents as-is, and add `#![feature(macroless_generic_const_args)]` where it's needed the second seems more desirable, so that's what I did. There are still quite a few tests that only have `min_generic_const_args` without `macroless_generic_const_args` (140 of them, to be exact - `rg --files-without-match macroless_generic_const_args $(rg -g '*.rs' --files-with-matches min_generic_const_args tests) | wc -l`, and now 90 with `macroless_generic_const_args`) r? @BoxyUwU
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#155617 (Replace `jemalloc` bootstrap options with `override-allocator`) - rust-lang/rust#156225 (feat(num): improve error messages for `TryFromIntError`) - rust-lang/rust#159058 (implement #![feature(macroless_generic_const_args)]) - rust-lang/rust#159435 (core: implement `Rng` for references) - rust-lang/rust#159471 (Make `Global` and `System` allocators unstably implement `const Clone + const Default`.) - rust-lang/rust#159590 (Remove some dead code) - rust-lang/rust#159636 (Improve some comments (and an error message))
…wU,bit-aloo clean up handling of paths in mgca related tracking issue: rust-lang#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 rust-lang#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 rust-lang#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 rust-lang#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
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
tracking issue: #159006
lots of description of what is happening here in the tracking issue, not gonna copypaste it into here :)
the test situation is that after discussion with boxy of whether our mgca tests should be:
min_generic_const_args, and adddirect_const_arg!()where it's needed#![feature(macroless_generic_const_args)]where it's neededthe second seems more desirable, so that's what I did. There are still quite a few tests that only have
min_generic_const_argswithoutmacroless_generic_const_args(140 of them, to be exact -rg --files-without-match macroless_generic_const_args $(rg -g '*.rs' --files-with-matches min_generic_const_args tests) | wc -l, and now 90 withmacroless_generic_const_args)r? @BoxyUwU