Include const generic arguments in metadata.
This commit is contained in:
parent
446e5e57b6
commit
eb68bbb2b0
5 changed files with 58 additions and 26 deletions
|
|
@ -0,0 +1,9 @@
|
|||
#![feature(const_generics)]
|
||||
|
||||
pub struct Struct<const N: usize>(pub [u8; N]);
|
||||
|
||||
pub type Alias = Struct<2>;
|
||||
|
||||
pub fn function(value: Struct<3>) -> u8 {
|
||||
value.0[0]
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// aux-build:const_generic_lib.rs
|
||||
|
||||
extern crate const_generic_lib;
|
||||
|
||||
fn main() {
|
||||
let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
|
||||
//~^ ERROR mismatched types
|
||||
let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/const-argument-cross-crate-mismatch.rs:6:41
|
||||
|
|
||||
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `3usize`, found `2usize`
|
||||
|
|
||||
= note: expected type `const_generic_lib::Struct<3usize>`
|
||||
found type `const_generic_lib::Struct<_: usize>`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-argument-cross-crate-mismatch.rs:8:39
|
||||
|
|
||||
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2usize`, found `3usize`
|
||||
|
|
||||
= note: expected type `const_generic_lib::Struct<2usize>`
|
||||
found type `const_generic_lib::Struct<_: usize>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
12
src/test/ui/const-generics/const-argument-cross-crate.rs
Normal file
12
src/test/ui/const-generics/const-argument-cross-crate.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// run-pass
|
||||
// aux-build:const_generic_lib.rs
|
||||
|
||||
extern crate const_generic_lib;
|
||||
|
||||
struct Container(const_generic_lib::Alias);
|
||||
|
||||
fn main() {
|
||||
let res = const_generic_lib::function(const_generic_lib::Struct([14u8, 1u8, 2u8]));
|
||||
assert_eq!(res, 14u8);
|
||||
let _ = Container(const_generic_lib::Struct([0u8, 1u8]));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue