rust/tests/ui/delegation/glob-override.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
526 B
Rust
Raw Permalink Normal View History

2024-03-15 06:21:03 -05:00
//@ check-pass
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
fn foo(&self) -> u8;
fn bar(&self) -> u8;
}
impl Trait for u8 {
fn foo(&self) -> u8 { 0 }
fn bar(&self) -> u8 { 1 }
}
struct S(u8);
struct Z(u8);
impl Trait for S {
reuse Trait::* { &self.0 }
fn bar(&self) -> u8 { 2 }
}
impl Trait for Z {
reuse Trait::* { &self.0 }
reuse Trait::bar { &self.0 }
}
fn main() {
let s = S(2);
s.foo();
s.bar();
let z = Z(2);
z.foo();
z.bar();
}