mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Add new tests, fix up old tests
This commit is contained in:
parent
9bf9fe07dc
commit
7bf0cb7671
17
src/test/ui/autoref-autoderef/deref-into-array.rs
Normal file
17
src/test/ui/autoref-autoderef/deref-into-array.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// check-pass
|
||||
|
||||
struct Test<T>([T; 1]);
|
||||
|
||||
impl<T> std::ops::Deref for Test<T> {
|
||||
type Target = [T; 1];
|
||||
|
||||
fn deref(&self) -> &[T; 1] {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let out = Test([(); 1]);
|
||||
let blah = out.len();
|
||||
println!("{}", blah);
|
||||
}
|
27
src/test/ui/const-generics/deref-into-array-generic.rs
Normal file
27
src/test/ui/const-generics/deref-into-array-generic.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// check-pass
|
||||
|
||||
struct Test<T, const N: usize>([T; N]);
|
||||
|
||||
impl<T: Copy + Default, const N: usize> Default for Test<T, N> {
|
||||
fn default() -> Self {
|
||||
Self([T::default(); N])
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, const N: usize> std::ops::Deref for Test<T, N> {
|
||||
type Target = [T; N];
|
||||
|
||||
fn deref(&self) -> &[T; N] {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
fn test() -> Test<u64, 16> {
|
||||
let test = Test::default();
|
||||
println!("{}", test.len());
|
||||
test
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test();
|
||||
}
|
Loading…
Reference in New Issue
Block a user