Code change:
GenericArg::Const(self.parse_const_arg()?) } else if self.check_type() { // Parse type argument. <del> let is_const_fn = self.look_ahead(1, |t| t.kind == token::OpenDelim(Delimiter::Parenthesis)); let mut snapshot = self.create_snapshot_for_diagnostic(); </del> <ins> // Proactively create a parser snapshot enabling us to rewind and try to reparse the // input as a const expression in case we fail to parse a type. If we successfully // do so, we will report an error that it needs to be wrapped in braces. let mut snapshot = None; if self.may_recover() && self.token.can_begin_expr() { snapshot = Some(self.create_snapshot_for_diagnostic()); } </ins> match self.parse_ty() { <del> Ok(ty) => GenericArg::Type(ty), </del> <ins> Ok(ty) => { // Since the type parser recovers from some malformed slice and array types and // successfully returns a type, we need to look for `TyKind::Err`s in the // type to determine if error recovery has occurred and if the input is not a // syntactically valid type after all. if let ast::TyKind::Slice(inner_ty) | ast::TyKind::Array(inner_ty, _) = &ty.kind && let ast::TyKind::Err = inner_ty.kind && let Some(snapshot) = snapshot && let Some(expr) = self.recover_unbraced_const_arg_that_can_begin_ty(snapshot) { return Ok(Some(self.dummy_const_arg_needs_braces( self.struct_span_err(expr.span, "invalid const generic expression"), expr.span, ))); } GenericArg::Type(ty) } </ins> Err(err) => { <del> if is_const_fn { match (*snapshot).parse_expr_res(Restrictions::CONST_EXPR, None) { Ok(expr) => { self.restore_snapshot(snapshot); return Ok(Some(self.dummy_const_arg_needs_braces(err, expr.span))); } Err(err) => { err.cancel(); } } </del> <ins> if let Some(snapshot) = snapshot && let Some(expr) = self.recover_unbraced_const_arg_that_can_begin_ty(snapshot) { return Ok(Some(self.dummy_const_arg_needs_braces( err, expr.span, ))); </ins> } // Try to recover from possible `const` arg without braces. return self.recover_const_arg(start, err).map(Some);

Related discussion:
text: <!-- Thank you for filing a bug report! Please provide a short summary of the bug, along with any information you feel relevant to replicating the bug. --This is a much abbreviated version of the code from my experiments with adding a shuffle API to the stdsimd repo, it probably needs further reduction but I wanted to file this before I forgot: I expected to see this happen: it works, provides a useful error, or even just ICEs. Instead, this happened: I got a request to input a type instead! And no, that doesn't work either if you put it in, because instead you get: : <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
The fix is Due to parsing ambiguities generic arguments currently need to be put into braces, unless they are really simple (like or ), is not simple enough.
Oh, cool! That does compile! I knew about that but wasn't sure if that was the problem because I thought that was just for expressions? I guess that's technically an array expression? That is none of the errors I was presented with, though, which makes this a diagnostics problem I suppose?
I believe diagnostic for const generic (example taken from ) needs to be improved too before release, at least I thought that can be used instead, if one didn't know about then they need to search it up.
Arrays as const parameters still have bad error messages. same with tuples
claim