Skip to content

Conversation

@estebank
Copy link
Contributor

@estebank estebank commented Jan 14, 2026

When a const param doesn't have a : Type, recover the parser state and provide a structured suggestion. This not only provides guidance on what was missing, but it also makes subsuequent errors to be emitted that would otherwise be silenced.

error: expected `:`, found `>`
  --> $DIR/incorrect-const-param.rs:26:16
   |
LL | impl<T, const N> From<[T; N]> for VecWrapper<T>
   |                ^ expected `:`
   |
help: you might have meant to write the type of the const parameter here
   |
LL | impl<T, const N: /* Type */> From<[T; N]> for VecWrapper<T>
   |                ++++++++++++

r? @fmease

Follow up to #151077. Fix #84327.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 14, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 14, 2026

fmease is not on the review rotation at the moment.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

When a const param doesn't have a `: Type`, recover the parser state and provide a structured suggestion. This not only provides guidance on what was missing, but it also makes subsuequent errors to be emitted that would otherwise be silenced.

```
error: expected `:`, found `>`
  --> $DIR/incorrect-const-param.rs:26:16
   |
LL | impl<T, const N> From<[T; N]> for VecWrapper<T>
   |                ^ expected `:`
   |
help: you might have meant to write the type of the const parameter here
   |
LL | impl<T, const N: /* Type */> From<[T; N]> for VecWrapper<T>
   |                ++++++++++++
```
@rustbot
Copy link
Collaborator

rustbot commented Jan 14, 2026

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.

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

Nice, thanks! r=me rollup with nitpick addressed in one way or another

View changes since this review

@@ -0,0 +1,45 @@
// #84327
Copy link
Member

@fmease fmease Jan 14, 2026

Choose a reason for hiding this comment

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

I get that it's nice to group all 3 cases from the issue but is it really necessary? We already have tests in separate files for the other 2 cases we've already addressed (in your PR: #151077, and in mine: #120570).

This doesn't increase test coverage unless I've missed sth. and the added test cases exercise things the preexisting tests don't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It exercises that the parser recovers correctly besides just providing the suggestion. I tend to group related checks either in the same file when possible, or with files with similar naming. I considered only having this case in the test and then a type error, but felt that having all of them (even if redundant because individual cases are already tested) would help in the future if someone makes changes that incidentally touches these to notice that there are similarly handled cases.

@estebank
Copy link
Contributor Author

@bors r=fmease

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 14, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 14, 2026

📌 Commit 92db7b2 has been approved by fmease

It is now in the queue for this repository.

@fmease
Copy link
Member

fmease commented Jan 14, 2026

@bors rollup

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 14, 2026
Recover parse gracefully from `<const N>`

When a const param doesn't have a `: Type`, recover the parser state and provide a structured suggestion. This not only provides guidance on what was missing, but it also makes subsuequent errors to be emitted that would otherwise be silenced.

```
error: expected `:`, found `>`
  --> $DIR/incorrect-const-param.rs:26:16
   |
LL | impl<T, const N> From<[T; N]> for VecWrapper<T>
   |                ^ expected `:`
   |
help: you might have meant to write the type of the const parameter here
   |
LL | impl<T, const N: /* Type */> From<[T; N]> for VecWrapper<T>
   |                ++++++++++++
```

r? @fmease

Follow up to rust-lang#151077. Fix rust-lang#84327.
rust-bors bot pushed a commit that referenced this pull request Jan 14, 2026
…uwer

Rollup of 16 pull requests

Successful merges:

 - #150585 (Add a context-consistency check before emitting redundant generic-argument suggestions)
 - #150586 (rustdoc: Fix intra-doc link bugs involving type aliases and associated items)
 - #150590 (Don't try to recover keyword as non-keyword identifier )
 - #150817 (cleanup: remove borrowck handling for inline const patterns)
 - #150939 (resolve: Relax some asserts in glob overwriting and add tests)
 - #150962 (Remove `FeedConstTy` and provide ty when lowering const arg)
 - #150966 (rustc_target: Remove unused Arch::PowerPC64LE)
 - #150971 (Disallow eii in statement position)
 - #151016 (fix: WASI threading regression by disabling pthread usage)
 - #151046 (compiler: Make Externally Implementable Item (eii) macros "semiopaque")
 - #151099 (Recover parse gracefully from `<const N>`)
 - #151117 (Avoid serde dependency in build_helper when not necessary)
 - #151127 (Delete `MetaItemOrLitParser::Err`)
 - #151128 (Add temporary new bors e-mail address to the mailmap)
 - #151130 (resolve: Downgrade `ambiguous_glob_imports` to warn-by-default)
 - #151138 (Rename `rust.use-lld` to `rust.bootstrap-override-lld` in INSTALL.md)

r? @ghost
rust-bors bot pushed a commit that referenced this pull request Jan 14, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #150585 (Add a context-consistency check before emitting redundant generic-argument suggestions)
 - #150586 (rustdoc: Fix intra-doc link bugs involving type aliases and associated items)
 - #150590 (Don't try to recover keyword as non-keyword identifier )
 - #150817 (cleanup: remove borrowck handling for inline const patterns)
 - #150939 (resolve: Relax some asserts in glob overwriting and add tests)
 - #150962 (Remove `FeedConstTy` and provide ty when lowering const arg)
 - #150966 (rustc_target: Remove unused Arch::PowerPC64LE)
 - #150971 (Disallow eii in statement position)
 - #151016 (fix: WASI threading regression by disabling pthread usage)
 - #151046 (compiler: Make Externally Implementable Item (eii) macros "semiopaque")
 - #151099 (Recover parse gracefully from `<const N>`)
 - #151117 (Avoid serde dependency in build_helper when not necessary)
 - #151127 (Delete `MetaItemOrLitParser::Err`)
 - #151128 (Add temporary new bors e-mail address to the mailmap)
 - #151138 (Rename `rust.use-lld` to `rust.bootstrap-override-lld` in INSTALL.md)

r? @ghost
@rust-bors rust-bors bot merged commit 00501de into rust-lang:main Jan 15, 2026
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 15, 2026
rust-timer added a commit that referenced this pull request Jan 15, 2026
Rollup merge of #151099 - issue-84327-2, r=fmease

Recover parse gracefully from `<const N>`

When a const param doesn't have a `: Type`, recover the parser state and provide a structured suggestion. This not only provides guidance on what was missing, but it also makes subsuequent errors to be emitted that would otherwise be silenced.

```
error: expected `:`, found `>`
  --> $DIR/incorrect-const-param.rs:26:16
   |
LL | impl<T, const N> From<[T; N]> for VecWrapper<T>
   |                ^ expected `:`
   |
help: you might have meant to write the type of the const parameter here
   |
LL | impl<T, const N: /* Type */> From<[T; N]> for VecWrapper<T>
   |                ++++++++++++
```

r? @fmease

Follow up to #151077. Fix #84327.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 15, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#150585 (Add a context-consistency check before emitting redundant generic-argument suggestions)
 - rust-lang/rust#150586 (rustdoc: Fix intra-doc link bugs involving type aliases and associated items)
 - rust-lang/rust#150590 (Don't try to recover keyword as non-keyword identifier )
 - rust-lang/rust#150817 (cleanup: remove borrowck handling for inline const patterns)
 - rust-lang/rust#150939 (resolve: Relax some asserts in glob overwriting and add tests)
 - rust-lang/rust#150962 (Remove `FeedConstTy` and provide ty when lowering const arg)
 - rust-lang/rust#150966 (rustc_target: Remove unused Arch::PowerPC64LE)
 - rust-lang/rust#150971 (Disallow eii in statement position)
 - rust-lang/rust#151016 (fix: WASI threading regression by disabling pthread usage)
 - rust-lang/rust#151046 (compiler: Make Externally Implementable Item (eii) macros "semiopaque")
 - rust-lang/rust#151099 (Recover parse gracefully from `<const N>`)
 - rust-lang/rust#151117 (Avoid serde dependency in build_helper when not necessary)
 - rust-lang/rust#151127 (Delete `MetaItemOrLitParser::Err`)
 - rust-lang/rust#151128 (Add temporary new bors e-mail address to the mailmap)
 - rust-lang/rust#151138 (Rename `rust.use-lld` to `rust.bootstrap-override-lld` in INSTALL.md)

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide const generics hints when a token is forgotten

4 participants