Skip to content

Commit 528972a

Browse files
authored
Rollup merge of rust-lang#61333 - varkor:apit-const-param-ice, r=estebank
Fix ICE with APIT in a function with a const parameter Fixes rust-lang#60953.
2 parents 6282fae + 998ef68 commit 528972a

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// run-pass
2+
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
6+
trait Trait {}
7+
8+
fn f<const N: usize>(_: impl Trait) {}
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/apit-with-const-param.rs:3:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+

0 commit comments

Comments
 (0)