1
Fork 0

Walk return-position impl trait in trait deeply in associated_item_def_ids

This commit is contained in:
Michael Goulet 2023-03-21 18:06:04 +00:00 committed by Santiago Pastorino
parent 478cbb42b7
commit 76b0cf812b
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
3 changed files with 36 additions and 22 deletions

View file

@ -2,12 +2,13 @@
#![feature(return_position_impl_trait_in_trait)]
use std::ops::Deref;
pub trait Foo {
fn bar() -> impl Sized;
fn bar() -> impl Deref<Target = impl Sized>;
}
pub struct Foreign;
impl Foo for Foreign {
fn bar() {}
fn bar() -> &'static () { &() }
}

View file

@ -5,7 +5,17 @@
extern crate rpitit;
fn main() {
// Witness an RPITIT from another crate
let () = <rpitit::Foreign as rpitit::Foo>::bar();
use std::sync::Arc;
// Implement an RPITIT from another crate.
struct Local;
impl rpitit::Foo for Local {
fn bar() -> Arc<String> { Arc::new(String::new()) }
}
fn main() {
// Witness an RPITIT from another crate.
let &() = <rpitit::Foreign as rpitit::Foo>::bar();
let x: Arc<String> = <Local as rpitit::Foo>::bar();
}