Skip to content

Commit

Permalink
Add new tests, fix up old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jan 12, 2022
1 parent 9bf9fe0 commit 7bf0cb7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/ui/autoref-autoderef/deref-into-array.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 27 additions & 0 deletions src/test/ui/const-generics/deref-into-array-generic.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 7bf0cb7

Please sign in to comment.