Skip to content

Commit

Permalink
Make sure refinement still works
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jan 18, 2024
1 parent 500443f commit 0f86b22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
use std::future::Future;
use std::pin::Pin;

trait MyTrait {
#[allow(async_fn_in_trait)]
pub trait MyTrait {
async fn foo(&self) -> i32;
}

impl MyTrait for i32 {
#[warn(refining_impl_trait)]
fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>> {
//~^ WARN impl trait in impl method signature does not match trait method signature
Box::pin(async { *self })
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
use std::future::Future;
use std::task::Poll;

trait MyTrait {
#[allow(async_fn_in_trait)]
pub trait MyTrait {
async fn foo(&self) -> i32;
}

struct MyFuture;
pub struct MyFuture;
impl Future for MyFuture {
type Output = i32;
fn poll(self: std::pin::Pin<&mut Self>, _: &mut std::task::Context<'_>) -> Poll<Self::Output> {
Expand All @@ -17,7 +18,9 @@ impl Future for MyFuture {
}

impl MyTrait for u32 {
#[warn(refining_impl_trait)]
fn foo(&self) -> MyFuture {
//~^ WARN impl trait in impl method signature does not match trait method signature
MyFuture
}
}
Expand Down

0 comments on commit 0f86b22

Please sign in to comment.