-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Consider the following program:
impl<T: std::future::Future> FutureExt for T {}
pub trait FutureExt: Sized {
fn with_props<I: IntoIterator<Item = &'static str>>(self, props: I) -> FutureWithProps<I> {
FutureWithProps { props }
}
}
pub struct FutureWithProps<I: IntoIterator<Item = &'static str>> {
props: I,
}
impl<I: IntoIterator<Item = &'static str>> std::future::Future for FutureWithProps<I> {
type Output = ();
fn poll(self: std::pin::Pin<&mut Self>, _: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
std::task::Poll::Pending
}
}
unsafe impl<I: IntoIterator<Item = &'static str> + Send> Send for FutureWithProps<I> {}
pub async fn foo() -> Box<dyn std::future::Future<Output = ()> + Send> {
Box::new(async move { async {}.with_props(vec!["foo"]).await })
}This results in the following compiler error, using version 1.56.0:
error[E0308]: mismatched types
--> src/main.rs:33:9
|
33 | Box::pin(async move { async {}.with_properties(vec!["foo"]).await })
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected reference `&str`
found reference `&'static str`
The code compiles fine with any of the following modifications:
- Changing
&'static strinto aString; or - Removing the type parameter
Iand usingVec<&'static str>; or - Removing the
Sendimpl forFutureWithProps; or - Removing the
Sendbound infoo().
Not sure if this is a known issue, but it seems to happen with this particular mix of features.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.