]> git.proxmox.com Git - rustc.git/blob - src/test/ui/issues/issue-6898.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / issues / issue-6898.rs
1 // check-pass
2 // pretty-expanded FIXME #23616
3
4 use std::mem;
5
6 /// Returns the size of a type
7 pub fn size_of<T>() -> usize {
8 TypeInfo::size_of(None::<T>)
9 }
10
11 /// Returns the size of the type that `val` points to
12 pub fn size_of_val<T>(val: &T) -> usize {
13 val.size_of_val()
14 }
15
16 pub trait TypeInfo: Sized {
17 fn size_of(_lame_type_hint: Option<Self>) -> usize;
18 fn size_of_val(&self) -> usize;
19 }
20
21 impl<T> TypeInfo for T {
22 /// The size of the type in bytes.
23 fn size_of(_lame_type_hint: Option<T>) -> usize {
24 mem::size_of::<T>()
25 }
26
27 /// Returns the size of the type of `self` in bytes.
28 fn size_of_val(&self) -> usize {
29 TypeInfo::size_of(None::<T>)
30 }
31 }
32
33 pub fn main() {}