Change:
results in: when it should be: This should be easy to fix: just replace in the following line with an appropriate format string. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOT_END --
claim
For the record, it's not quite this simple, as doing so results in incorrect output when the parameter also has bounds. For example, it would render as because bounds are printed after the

Discussion:
/// Checks that generic parameters are in the correct order, /// which is lifetimes, then types and then consts. (`<'a, T, const N: usize>`) <del> fn validate_generic_param_order<'a>( </del> <ins> fn validate_generic_param_order( </ins> sess: &Session, handler: &rustc_errors::Handler, <del> generics: impl Iterator<Item = (ParamKindOrd, Option<&'a [GenericBound]>, Span, Option<String>)>, </del> <ins> generics: &[GenericParam], </ins> span: Span, ) { let mut max_param: Option<ParamKindOrd> = None; let mut out_of_order = FxHashMap::default(); let mut param_idents = vec![]; <del> for (kind, bounds, span, ident) in generics { </del> <ins> for param in generics { let ident = Some(param.ident.to_string()); let (kind, bounds, span) = (&param.kind, Some(&*param.bounds), param.ident.span); let (ord_kind, ident) = match &param.kind { GenericParamKind::Lifetime => (ParamKindOrd::Lifetime, ident), GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident), GenericParamKind::Const { ref ty, kw_span: _ } => { let ty = pprust::ty_to_string(ty); let unordered = sess.features_untracked().const_generics; (ParamKindOrd::Const { unordered }, Some(format!("const {}: {}", param.ident, ty))) } }; </ins> if let Some(ident) = ident { <del> param_idents.push((kind, bounds, param_idents.len(), ident)); </del> <ins> param_idents.push((kind, ord_kind, bounds, param_idents.len(), ident)); </ins> } let max_param = &mut max_param; match max_param { <del> Some(max_param) if *max_param > kind => { let entry = out_of_order.entry(kind).or_insert((*max_param, vec![])); </del> <ins> Some(max_param) if *max_param > ord_kind => { let entry = out_of_order.entry(ord_kind).or_insert((*max_param, vec![])); </ins> entry.1.push(span); } <del> Some(_) | None => *max_param = Some(kind), </del> <ins> Some(_) | None => *max_param = Some(ord_kind), </ins> }; } let mut ordered_params = "<".to_string(); if !out_of_order.is_empty() { <del> param_idents.sort_by_key(|&(po, _, i, _)| (po, i)); </del> <ins> param_idents.sort_by_key(|&(_, po, _, i, _)| (po, i)); </ins> let mut first = true; <del> for (_, bounds, _, ident) in param_idents { </del> <ins> for (kind, _, bounds, _, ident) in param_idents { </ins> if !first { ordered_params += ", "; }

ordered_params += &pprust::bounds_to_string(&bounds); } } <ins> match kind { GenericParamKind::Type { default: Some(default) } => { ordered_params += " = "; ordered_params += &pprust::ty_to_string(default); } GenericParamKind::Type { default: None } => (), GenericParamKind::Lifetime => (), // FIXME(const_generics:defaults) GenericParamKind::Const { ty: _, kw_span: _ } => (), } </ins> first = false; } }

validate_generic_param_order( self.session, self.err_handler(), <del> generics.params.iter().map(|param| { let ident = Some(param.ident.to_string()); let (kind, ident) = match &param.kind { GenericParamKind::Lifetime => (ParamKindOrd::Lifetime, ident), GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident), GenericParamKind::Const { ref ty, kw_span: _ } => { let ty = pprust::ty_to_string(ty); let unordered = self.session.features_untracked().const_generics; ( ParamKindOrd::Const { unordered }, Some(format!("const {}: {}", param.ident, ty)), ) } }; (kind, Some(&*param.bounds), param.ident.span, ident) }), </del> <ins> &generics.params, </ins> generics.span, );

--> $DIR/complex-unord-param.rs:8:41 | LL | struct NestedArrays<'a, const N: usize, A: 'a, const M: usize, T:'a =u32> { <del> |                    ---------------------^----------------------^--------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, A: 'a, T: 'a, const N: usize, const M: usize>` </del> <ins> |                    ---------------------^----------------------^--------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, A: 'a, T: 'a = u32, const N: usize, const M: usize>` </ins> error: aborting due to previous error

--> $DIR/intermixed-lifetime.rs:6:28 | LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); <del> |           -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T>` </del> <ins> |           -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>` </ins> error: lifetime parameters must be declared prior to type parameters --> $DIR/intermixed-lifetime.rs:10:37 | LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); <del> |           --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T>` </del> <ins> |           --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>` </ins> error: aborting due to 2 previous errors

--> $DIR/intermixed-lifetime.rs:6:28 | LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); <del> |           -----------------^^---------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` </del> <ins> |           -----------------^^---------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` </ins> error: type parameters must be declared prior to const parameters --> $DIR/intermixed-lifetime.rs:6:32 | LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T); <del> |           ---------------------^------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` </del> <ins> |           ---------------------^------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` </ins> error: lifetime parameters must be declared prior to const parameters --> $DIR/intermixed-lifetime.rs:10:37 | LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); <del> |           --------------------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` </del> <ins> |           --------------------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` </ins> error: type parameters must be declared prior to const parameters --> $DIR/intermixed-lifetime.rs:10:28 | LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T); <del> |           -----------------^----------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` </del> <ins> |           -----------------^----------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` </ins> error: aborting due to 4 previous errors

--> $DIR/needs-feature.rs:9:26 | LL | struct A<const N: usize, T=u32>(T); <del> |         -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>` </del> <ins> |         -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T = u32, const N: usize>` </ins> error: aborting due to previous error

--> $DIR/simple-defaults.rs:8:40 | LL | struct FixedOutput<'a, const N: usize, T=u32> { <del> |                   ---------------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, const N: usize>` </del> <ins> |                   ---------------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = u32, const N: usize>` </ins> error: aborting due to previous error

<ins> #![crate_type = "lib"] struct S<T = (), 'a>(&'a T); //~^ ERROR lifetime parameters must be declared prior to type parameters </ins>

<ins> error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-80512-param-reordering-with-defaults.rs:3:18 | LL | struct S<T = (), 'a>(&'a T); |         ---------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T = ()>` error: aborting due to previous error </ins>