correctly handle const params in type_of
This commit is contained in:
parent
1902d1e0de
commit
645fedd183
7 changed files with 73 additions and 15 deletions
17
src/test/ui/const-generics/issues/issue70273-assoc-fn.rs
Normal file
17
src/test/ui/const-generics/issues/issue70273-assoc-fn.rs
Normal 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();
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
21
src/test/ui/const-generics/type_of_anon_const.rs
Normal file
21
src/test/ui/const-generics/type_of_anon_const.rs
Normal 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>());
|
||||
}
|
||||
8
src/test/ui/const-generics/type_of_anon_const.stderr
Normal file
8
src/test/ui/const-generics/type_of_anon_const.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue