correctly handle const params in type_of

This commit is contained in:
Bastian Kauschke 2020-03-22 22:29:54 +01:00
parent 1902d1e0de
commit 645fedd183
7 changed files with 73 additions and 15 deletions

View file

@ -0,0 +1,17 @@
// check-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
trait T<const A: usize> {
fn f();
}
struct S;
impl T<0usize> for S {
fn f() {}
}
fn main() {
let _err = <S as T<0usize>>::f();
}

View file

@ -0,0 +1,8 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/issue70273-assoc-fn.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default

View file

@ -0,0 +1,21 @@
// run-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
trait T<const A: usize> {
fn l<const N: bool>() -> usize;
fn r<const N: bool>() -> bool;
}
struct S;
impl<const N: usize> T<N> for S {
fn l<const M: bool>() -> usize { N }
fn r<const M: bool>() -> bool { M }
}
fn main() {
assert_eq!(<S as T<123>>::l::<true>(), 123);
assert!(<S as T<123>>::r::<true>());
}

View file

@ -0,0 +1,8 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/type_of_anon_const.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default