Skip to content

Nightly compiler bug: "lifetime mismatch" #94004

Closed
@annmarie-switzer

Description

@annmarie-switzer

Nightly 2022-02-13 seems to have introduced a bug. Code that compiles properly on stable and nightly-2022-02-09 does not compile with nightly-2022-02-13:

$ cargo +nightly run run
   Compiling detect_core v0.0.0 (C:\git\datadetect\core)
error[E0308]: mismatched types
   --> core\src\analysis.rs:217:17
    |
217 |                   tokio::spawn(async move {
    |                   ^^^^^^^^^^^^ lifetime mismatch       
...
395 |       reqs.then(|req| async move {
    |  ________________________________-
396 | |         let data = serde_json::to_vec(&req).unwrap();
397 | |         let subj = format!("HASH_REQ.{}", &req.connector);
398 | |
...   |
447 | |         vec![header, doc]
448 | |     })
    | |     -
    | |     |
    | |_____the expected `async` block
    |       the found `async` block
    |
   ::: core\src\reporting\scan.rs:18:59
    |
18  |   pub async fn send_report(task_type: &str, stat: ScanStat) {
    |                                                             -
    |                                                             |
    |                                                             one of the expected opaque types
    |                                                             one of the found opaque types
    |
   ::: C:\Users\aswitzer\.cargo\registry\src\github.com-1ecc6299db9ec823\nats-0.16.0\src\asynk.rs:158:74
    |
158 |       pub async fn request(&self, subject: &str, msg: impl AsRef<[u8]>) -> io::Result<Message> {
    |                                                                            -------------------
    |                                                                            |
    |                                                                            one of the expected opaque types
    |                                                                            one of the found opaque types
    |
   ::: C:\Users\aswitzer\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib/src/rust\library\core\src\future\mod.rs:65:43
    |
65  |   pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return>
    |                                             -------------------------------
    |                                             |
    |                                             one of the expected opaque types
    |                                             one of the found opaque types
    |
note: while checking the return type of the `async fn`
   --> core\src\lib.rs:101:24
    |
101 | pub async fn nats() -> &'static nats::asynk::Connection {
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, one of the expected opaque types
note: while checking the return type of the `async fn`
    |
101 | pub async fn nats() -> &'static nats::asynk::Connection {
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, one of the found opaque types
    = note: expected opaque type `impl futures::Future<Output = [async output]>`
               found opaque type `impl futures::Future<Output = [async output]>`
note: the lifetime requirement is introduced here
   --> C:\Users\aswitzer\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.15.0\src\task\spawn.rs:127:21
    |
127 |         T: Future + Send + 'static,
    |                     ^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `detect_core` due to previous error

Metadata

Metadata

Labels

C-bugCategory: This is a bug.P-highHigh priorityregression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions