Skip to content

Require generic params for const generic params #142449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
ty_id,
&None,
path,
ParamMode::Optional,
ParamMode::Explicit,
AllowReturnTypeNotation::No,
// FIXME(mgca): update for `fn foo() -> Bar<FOO<impl Trait>>` support
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
Expand Down Expand Up @@ -2219,7 +2219,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
expr.id,
qself,
path,
ParamMode::Optional,
ParamMode::Explicit,
AllowReturnTypeNotation::No,
// FIXME(mgca): update for `fn foo() -> Bar<FOO<impl Trait>>` support
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
Expand Down
6 changes: 0 additions & 6 deletions tests/crashes/137188.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/crashes/138166.rs

This file was deleted.

9 changes: 0 additions & 9 deletions tests/crashes/138240.rs

This file was deleted.

7 changes: 0 additions & 7 deletions tests/crashes/138266.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/crashes/138359.rs

This file was deleted.

16 changes: 16 additions & 0 deletions tests/ui/const-generics/mgca/missing_generic_params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This used to ICE: #137188
// The missing parameter list on `N` was set to
// "infer from use site" in ast lowering, which
// caused later code to not emit a missing generic
// param error. The missing param was then attempted
// to be inferred, but inference of generic params
// is only possible within bodies. So a delayed
// bug was generated with no error ever reported.

#![feature(min_generic_const_args)]
#![allow(incomplete_features)]
trait Trait {}
impl Trait for [(); N] {}
//~^ ERROR: missing generics for function `N`
fn N<T>() {}
pub fn main() {}
19 changes: 19 additions & 0 deletions tests/ui/const-generics/mgca/missing_generic_params.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0107]: missing generics for function `N`
--> $DIR/missing_generic_params.rs:13:21
|
LL | impl Trait for [(); N] {}
| ^ expected 1 generic argument
|
note: function defined here, with 1 generic parameter: `T`
--> $DIR/missing_generic_params.rs:15:4
|
LL | fn N<T>() {}
| ^ -
help: add missing generic argument
|
LL | impl Trait for [(); N<T>] {}
| +++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0107`.
Loading