Change:
At the moment, we simply emit errors like: It would be good to suggest to the user how to fix this, like with uninferred type arguments.
cc
Stu over has picked this issue up.

Discussion:
return; } } <ins> // FIXME(const_generics): Currently, any uninferred `const` generics arguments // are handled specially, but instead they should be handled in `annotate_method_call`, // which currently doesn't work because this evaluates to `false` for const arguments. // See https://github.com/rust-lang/rust/pull/77758 for more details. </ins> if self.node_ty_contains_target(expr.hir_id).is_some() { match expr.kind { ExprKind::Closure(..) => self.found_closure = Some(&expr),

) -> DiagnosticBuilder<'tcx> { let arg = self.resolve_vars_if_possible(arg); let arg_data = self.extract_inference_diagnostics_data(arg, None); <del> let kind_str = match arg.unpack() { GenericArgKind::Type(_) => "type", GenericArgKind::Const(_) => "the value", GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"), }; </del> let mut local_visitor = FindHirNodeVisitor::new(&self, arg, span); let ty_to_string = |ty: Ty<'tcx>| -> String {

.any(|span_label| span_label.label.is_some() && span_label.span == span) && local_visitor.found_arg_pattern.is_none() { <ins> let (kind_str, const_value) = match arg.unpack() { GenericArgKind::Type(_) => ("type", None), GenericArgKind::Const(_) => ("the value", Some(())), GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"), }; // FIXME(const_generics): we would like to handle const arguments // as part of the normal diagnostics flow below, but there appear to // be subtleties in doing so, so for now we special-case const args // here. if let Some(suggestion) = const_value .and_then(|_| arg_data.parent_name.as_ref()) .map(|parent| format!("{}::<{}>", parent, arg_data.name)) { err.span_suggestion_verbose( span, "consider specifying the const argument", suggestion, Applicability::MaybeIncorrect, ); } </ins> // Avoid multiple labels pointing at `span`. err.span_label( span,

| LL |     foo(); |     ^^^ cannot infer the value of const parameter `X` declared on the function `foo` <ins> | help: consider specifying the const argument | LL |     foo::<X>(); |     ^^^^^^^^ </ins> error: aborting due to previous error

| LL |         println!("{:?}", take_array_from_mut(&mut arr, i)); |                          ^^^^^^^^^^^^^^^^^^^ cannot infer the value of const parameter `N` declared on the function `take_array_from_mut` <ins> | help: consider specifying the const argument | LL |         println!("{:?}", take_array_from_mut::<N>(&mut arr, i)); |                          ^^^^^^^^^^^^^^^^^^^^^^^^ </ins> error: aborting due to previous error

| LL |     Foo.bar().bar().bar().bar().baz(); |                                 ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz` <ins> | help: consider specifying the const argument | LL |     Foo.bar().bar().bar().bar().baz::<N>(); |                                 ^^^^^^^^ </ins> error: aborting due to previous error

<ins> error[E0282]: type annotations needed --> $DIR/one-param-uninferred.rs:15:23 | LL |     let _: [u8; 17] = foo(); |                       ^^^ cannot infer the value of const parameter `M` declared on the function `foo` | help: consider specifying the const argument | LL |     let _: [u8; 17] = foo::<M>(); |                       ^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0282`. </ins>

<ins> // Test that we emit an error if we cannot properly infer a constant. // revisions: full min #![cfg_attr(full, feature(const_generics))] #![cfg_attr(full, allow(incomplete_features))] #![cfg_attr(min, feature(min_const_generics))] fn foo<const N: usize, const M: usize>() -> [u8; N] { todo!() } fn main() { // FIXME(const_generics): Currently this only suggests one const parameter, // but instead it should suggest to provide all parameters. let _: [u8; 17] = foo(); //~^ ERROR type annotations needed } </ins>

--> $DIR/uninferred-consts.rs:14:9 | LL |     Foo.foo(); <del> |         ^^^ cannot infer the value of const parameter `N` declared on the associated function `foo` </del> <ins> |         ^^^ cannot infer the value of const parameter `A` declared on the associated function `foo` | help: consider specifying the const argument | LL |     Foo.foo::<A>(); |         ^^^^^^^^ </ins> error: aborting due to previous error

// taken from https://github.com/rust-lang/rust/issues/70507#issuecomment-615268893 struct Foo; impl Foo { <del> fn foo<const N: usize>(self) {} </del> <ins> fn foo<const A: usize, const B: usize>(self) {} </ins> } fn main() { Foo.foo();