2023-11-26 06:57:31 -06:00
|
|
|
#![feature(fn_delegation)]
|
2024-03-26 10:59:03 -05:00
|
|
|
#![allow(incomplete_features)]
|
2023-11-26 06:57:31 -06:00
|
|
|
|
|
|
|
trait Trait {
|
2024-03-26 10:59:03 -05:00
|
|
|
fn foo1(&self, x: i32) -> i32 { x }
|
|
|
|
fn foo2(x: i32) -> i32 { x }
|
2023-11-26 06:57:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
struct F;
|
|
|
|
impl Trait for F {}
|
|
|
|
struct S(F);
|
|
|
|
|
2024-03-26 10:59:03 -05:00
|
|
|
pub mod to_reuse {
|
|
|
|
pub fn foo3() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl F {
|
|
|
|
fn foo4(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod fn_to_other {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
reuse Trait::foo1;
|
|
|
|
//~^ ERROR delegation to a trait method from a free function is not supported yet
|
|
|
|
reuse <S as Trait>::foo2;
|
|
|
|
//~^ ERROR delegation to a trait method from a free function is not supported yet
|
|
|
|
reuse to_reuse::foo3;
|
|
|
|
reuse S::foo4;
|
|
|
|
//~^ ERROR cannot find function `foo4` in `S`
|
|
|
|
}
|
|
|
|
|
|
|
|
mod inherent_impl_assoc_fn_to_other {
|
|
|
|
use crate::*;
|
|
|
|
|
|
|
|
impl S {
|
|
|
|
reuse Trait::foo1 { &self.0 }
|
|
|
|
reuse <S as Trait>::foo2;
|
|
|
|
reuse to_reuse::foo3;
|
|
|
|
reuse F::foo4 { &self.0 }
|
|
|
|
//~^ ERROR cannot find function `foo4` in `F`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod trait_impl_assoc_fn_to_other {
|
|
|
|
use crate::*;
|
|
|
|
|
|
|
|
impl Trait for S {
|
|
|
|
reuse Trait::foo1 { &self.0 }
|
|
|
|
reuse <F as Trait>::foo2;
|
|
|
|
reuse to_reuse::foo3;
|
|
|
|
//~^ ERROR method `foo3` is not a member of trait `Trait`
|
|
|
|
reuse F::foo4 { &self.0 }
|
|
|
|
//~^ ERROR method `foo4` is not a member of trait `Trait`
|
|
|
|
//~| ERROR cannot find function `foo4` in `F`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod trait_assoc_fn_to_other {
|
|
|
|
use crate::*;
|
|
|
|
|
|
|
|
trait Trait2 : Trait {
|
|
|
|
reuse <F as Trait>::foo1 { self }
|
|
|
|
//~^ ERROR mismatched types
|
|
|
|
reuse <F as Trait>::foo2;
|
|
|
|
reuse to_reuse::foo3;
|
|
|
|
reuse F::foo4 { &F }
|
|
|
|
//~^ ERROR cannot find function `foo4` in `F`
|
|
|
|
}
|
2023-11-26 06:57:31 -06:00
|
|
|
}
|
|
|
|
|
2024-03-26 10:59:03 -05:00
|
|
|
mod type_mismatch {
|
|
|
|
use crate::*;
|
2023-11-26 06:57:31 -06:00
|
|
|
|
2024-03-26 10:59:03 -05:00
|
|
|
struct S2;
|
|
|
|
impl Trait for S {
|
|
|
|
//~^ ERROR conflicting implementations of trait `Trait` for type `S`
|
|
|
|
reuse <S2 as Trait>::foo1;
|
|
|
|
//~^ ERROR mismatched types
|
|
|
|
//~| ERROR the trait bound `S2: Trait` is not satisfied
|
|
|
|
}
|
2023-11-26 06:57:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|