Open
Description
openedon Oct 10, 2024
Code
I tried this (reduced) code:
use tokio::sync::mpsc::{unbounded_channel,UnboundedSender};
pub trait Role: 'static + Sync + Send {
type Return : Send;
}
pub trait BasicRole: 'static + Send + Sync {}
impl Role for dyn BasicRole + '_ {
type Return = ();
}
pub struct ReturnEnvelope<R: Role + ?Sized> {
pub return_path: Option<R::Return>,
}
pub fn start() {
let (_basic_role_input, mut basic_role_output): (UnboundedSender<ReturnEnvelope<dyn BasicRole>>, _) = unbounded_channel();
let event_loop = async move {
let _ = basic_role_output.recv().await;
};
let _ = ::tokio::task::spawn(event_loop);
}
I expected to see this happen: successful compile.
Instead, this happened: I received this error:
error: implementation of `Role` is not general enough
--> src/lib.rs:22:13
|
22 | let _ = ::tokio::task::spawn(event_loop);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Role` is not general enough
|
= note: `Role` would have to be implemented for the type `(dyn BasicRole + '0)`, for any lifetime `'0`...
= note: ...but `Role` is actually implemented for the type `(dyn BasicRole + '1)`, for some specific lifetime `'1`
This can also be seen on the playground configured to use nightly.
I am aware that handling this construct correctly seems to be an outstanding issue, I'm specifically reporting the inconsistency that it does work on stable and not nightly.
Version it worked on
It most recently worked on: 1.81.0 stable (most recent)
Version with regression
rustc --version --verbose
:
rustc 1.83.0-nightly (eb4e23467 2024-10-09)
binary: rustc
commit-hash: eb4e2346748e1760f74fcaa27b42431e0b95f8f3
commit-date: 2024-10-09
host: x86_64-pc-windows-msvc
release: 1.83.0-nightly
LLVM version: 19.1.1
However, this has been an issue since at least the 2024-08-17 nightly (feeba19)
@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Category: This is a bug.Category: This is a bug.Issue: Indicates that prioritization has been requested for this issue.Issue: Indicates that prioritization has been requested for this issue.This issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.Performance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.