Skip to content

Conversation

@lcnr
Copy link
Contributor

@lcnr lcnr commented Nov 11, 2020

blocked on the stabilization of min_const_generics.

@ehuss ehuss added the S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository label Nov 11, 2020
@shirshak55
Copy link

Its merged in rust-lang/rust#79135

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm confused, but it seems like the grammar for GenericArgs needs to be updated for expressions?

Also, overall I feel like this is missing a lot of content. There seems to be a large amount of information in the stabilization report that would be good to carry over. There are a lot of details that seem to be missing (like const parameters don't have to be used unlike types and lifetimes). I also see a number of things in the RFC that don't seem to be mentioned.

I appreciate the effort for adding this documentation, but I would like to see a bit more detail if possible.

Comment on lines +9 to +10
> &nbsp;&nbsp; | ( _LifetimeParam_ `,` )<sup>\*</sup> _TypeParams_\
> &nbsp;&nbsp; | ( _LifetimeParam_ `,` )<sup>\*</sup> ( _TypeParam_ `,` )<sup>\*</sup> _ConstParams_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this grammar is no longer correct (see #785). The order of the parameters doesn't matter syntactically.

You don't have to fix it if you don't want to (although that would be nice), I just wanted to make a note of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't do this in that PR, as I don't know what it's expected to look like now.

Comment on lines 39 to 41
Const parameters may only be be used as standalone arguments inside
of [types] and [repeat expressions].
They can be used freely outside of [const contexts].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find these sentences a little difficult to understand. Can you add more detail, along with some examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extended this a bit, it feels weird to go more in depth here as the explanation for types and lifetimes are also fairly short

@lcnr
Copy link
Contributor Author

lcnr commented Dec 29, 2020

there is still a lot we could add about const generics or generics in general.

I am not able to spend a lot of time on rust in the near future so I would prefer merging this without adding too much more

src/paths.md Outdated
Comment on lines 72 to 73
> _GenericArgsConsts_ :\
> &nbsp;&nbsp; [_Expression_] (`,` [_Expression_])<sup>\*</sup>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the actual grammar for arguments is it? According to parse_generic_arg I believe it is something like this:

diff --git a/src/paths.md b/src/paths.md
index 9126e5b..47a14ee 100644
--- a/src/paths.md
+++ b/src/paths.md
@@ -70,7 +70,13 @@ mod m {
 > &nbsp;&nbsp; [_Type_] (`,` [_Type_])<sup>\*</sup>
 >
 > _GenericArgsConsts_ :\
-> &nbsp;&nbsp; [_Expression_] (`,` [_Expression_])<sup>\*</sup>
+> &nbsp;&nbsp; _GenericArgsConst_ (`,` _GenericArgsConst_)<sup>\*</sup>
+>
+> _GenericArgsConst_ :\
+> &nbsp;&nbsp; &nbsp;&nbsp; [_BlockExpression_]\
+> &nbsp;&nbsp; | [_LiteralExpression_]\
+> &nbsp;&nbsp; | `-` [_LiteralExpression_]\
+> &nbsp;&nbsp; | [_SimplePathSegment_]
 >
 > _GenericArgsBindings_ :\
 > &nbsp;&nbsp; _GenericArgsBinding_ (`,` _GenericArgsBinding_)<sup>\*</sup>
@@ -375,10 +381,13 @@ mod without { // ::without
 # fn main() {}
 ```

+[_BlockExpression_]: expressions/block-expr.md
+[_Expression_]: expressions.md
 [_GenericArgs_]: #paths-in-expressions
 [_Lifetime_]: trait-bounds.md
+[_LiteralExpression_]: expressions/literal-expr.md
+[_SimplePathSegment_]: #simple-paths
 [_Type_]: types.md#type-expressions
-[_Expression_]: expressions.md
 [literal]: expressions/literal-expr.md
 [item]: items.md
 [variable]: variables.md

Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that looks right to me

@ehuss
Copy link
Contributor

ehuss commented Dec 30, 2020

I am not able to spend a lot of time on rust in the near future so I would prefer merging this without adding too much more

No worries, if you can confirm the comment above about the grammar, I can probably merge this and work on extending it.

```

Const arguments must be surrounded by braces unless they are a
[literal] or a single segment path.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case this section might not be needed

@ehuss ehuss removed the S-waiting-on-stabilization Waiting for a stabilization PR to be merged in the main Rust repository label Jan 6, 2021
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and pushed the fix for the grammar. I'll follow up with other PRs.

@ehuss ehuss merged commit c81cd07 into rust-lang:master Jan 6, 2021
@lcnr lcnr deleted the const-generics branch January 6, 2021 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants