os-rust/tests/ui/impl-trait/in-trait/foreign.rs

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

59 lines
1.4 KiB
Rust
Raw Normal View History

2022-09-23 00:56:55 +00:00
//@ check-pass
//@ aux-build: rpitit.rs
extern crate rpitit;
2023-04-30 21:52:35 +00:00
use rpitit::{Foo, Foreign};
use std::sync::Arc;
// Implement an RPITIT from another crate.
pub struct Local;
2023-04-30 21:52:35 +00:00
impl Foo for Local {
#[expect(refining_impl_trait)]
fn bar(self) -> Arc<String> {
Arc::new(String::new())
}
}
struct LocalOnlyRefiningA;
impl Foo for LocalOnlyRefiningA {
#[warn(refining_impl_trait)]
fn bar(self) -> Arc<String> {
//~^ WARN impl method signature does not match trait method signature
Arc::new(String::new())
}
}
struct LocalOnlyRefiningB;
impl Foo for LocalOnlyRefiningB {
#[warn(refining_impl_trait)]
#[allow(refining_impl_trait_reachable)]
fn bar(self) -> Arc<String> {
//~^ WARN impl method signature does not match trait method signature
Arc::new(String::new())
}
}
struct LocalOnlyRefiningC;
impl Foo for LocalOnlyRefiningC {
#[warn(refining_impl_trait)]
#[allow(refining_impl_trait_internal)]
fn bar(self) -> Arc<String> {
Arc::new(String::new())
}
}
fn generic(f: impl Foo) {
let x = &*f.bar();
}
2022-09-23 00:56:55 +00:00
fn main() {
// Witness an RPITIT from another crate.
2023-04-30 21:52:35 +00:00
let &() = Foreign.bar();
2023-04-30 21:52:35 +00:00
let x: Arc<String> = Local.bar();
let x: Arc<String> = LocalOnlyRefiningA.bar();
let x: Arc<String> = LocalOnlyRefiningB.bar();
let x: Arc<String> = LocalOnlyRefiningC.bar();
2022-09-23 00:56:55 +00:00
}