Rollup merge of #61333 - varkor:apit-const-param-ice, r=estebank

Fix ICE with APIT in a function with a const parameter

Fixes https://github.com/rust-lang/rust/issues/60953.
This commit is contained in:
Mazdak Farrokhzad 2019-05-30 10:53:07 +02:00 committed by GitHub
commit 528972a28a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 0 deletions

View File

@ -1083,6 +1083,18 @@ impl<'a> LoweringContext<'a> {
.chain(in_band_defs)
.collect();
// FIXME(const_generics): the compiler doesn't always cope with
// unsorted generic parameters at the moment, so we make sure
// that they're ordered correctly here for now. (When we chain
// the `in_band_defs`, we might make the order unsorted.)
lowered_generics.params.sort_by_key(|param| {
match param.kind {
hir::GenericParamKind::Lifetime { .. } => ParamKindOrd::Lifetime,
hir::GenericParamKind::Type { .. } => ParamKindOrd::Type,
hir::GenericParamKind::Const { .. } => ParamKindOrd::Const,
}
});
(lowered_generics, res)
}

View File

@ -0,0 +1,10 @@
// run-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
trait Trait {}
fn f<const N: usize>(_: impl Trait) {}
fn main() {}

View File

@ -0,0 +1,6 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/apit-with-const-param.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^