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.

39 lines
731 B
Rust
Raw Normal View History

2022-09-22 19:56:55 -05:00
// check-pass
// aux-build: rpitit.rs
#![feature(lint_reasons)]
2022-09-22 19:56:55 -05:00
extern crate rpitit;
2023-04-30 16:52:35 -05:00
use rpitit::{Foo, Foreign};
use std::sync::Arc;
// Implement an RPITIT from another crate.
pub struct Local;
2023-04-30 16:52:35 -05:00
impl Foo for Local {
#[expect(refining_impl_trait)]
fn bar(self) -> Arc<String> {
Arc::new(String::new())
}
}
struct LocalIgnoreRefining;
impl Foo for LocalIgnoreRefining {
#[deny(refining_impl_trait)]
fn bar(self) -> Arc<String> {
Arc::new(String::new())
}
}
fn generic(f: impl Foo) {
let x = &*f.bar();
}
2022-09-22 19:56:55 -05:00
fn main() {
// Witness an RPITIT from another crate.
2023-04-30 16:52:35 -05:00
let &() = Foreign.bar();
2023-04-30 16:52:35 -05:00
let x: Arc<String> = Local.bar();
let x: Arc<String> = LocalIgnoreRefining.bar();
2022-09-22 19:56:55 -05:00
}