about summary refs log tree commit diff
path: root/tests/ui/traits/const-traits/enforce-deref-on-adjust.rs
blob: cba207f095309c0452cc269d57f9e9208559bb28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//@ check-pass

#![feature(const_convert)]
#![feature(const_trait_impl)]

use std::ops::Deref;

struct Wrap<T>(T);
struct Foo;

impl Foo {
    const fn call(&self) {}
}

impl<T> const Deref for Wrap<T> {
    type Target = T;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

const fn foo() {
    let x = Wrap(Foo);
    x.call();
}

fn main() {}