Skip to content

Commit eafa3a8

Browse files
committed
Sort in-band generic parameter definitions from APIT
1 parent 7212685 commit eafa3a8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustc/hir/lowering.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,18 @@ impl<'a> LoweringContext<'a> {
10831083
.chain(in_band_defs)
10841084
.collect();
10851085

1086+
// FIXME(const_generics): the compiler doesn't always cope with
1087+
// unsorted generic parameters at the moment, so we make sure
1088+
// that they're ordered correctly here for now. (When we chain
1089+
// the `in_band_defs`, we might make the order unsorted.)
1090+
lowered_generics.params.sort_by_key(|param| {
1091+
match param.kind {
1092+
hir::GenericParamKind::Lifetime { .. } => ParamKindOrd::Lifetime,
1093+
hir::GenericParamKind::Type { .. } => ParamKindOrd::Type,
1094+
hir::GenericParamKind::Const { .. } => ParamKindOrd::Const,
1095+
}
1096+
});
1097+
10861098
(lowered_generics, res)
10871099
}
10881100

0 commit comments

Comments
 (0)