about summary refs log tree commit diff
path: root/tests/ui/delegation/macro-inside-glob.rs
blob: 1d529341c5b4ba1718d807ca3e7559f9c9c2a4ca (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
//@ check-pass

#![feature(fn_delegation)]
#![allow(incomplete_features)]

trait Trait {
    fn foo(&self) -> u8 { 0 }
    fn bar(&self) -> u8 { 1 }
}

impl Trait for u8 {}

struct S(u8);

// Macro expansion works inside delegation items.
macro_rules! u8 { () => { u8 } }
macro_rules! self_0 { ($self:ident) => { &$self.0 } }
impl Trait for S {
    reuse <u8!() as Trait>::* { self_0!(self) }
}

fn main() {
    let s = S(2);
    s.foo();
    s.bar();
}