Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E0700 does not point to where the captured lifetime is #68604

Open
Nokel81 opened this issue Jan 28, 2020 · 5 comments
Open

E0700 does not point to where the captured lifetime is #68604

Nokel81 opened this issue Jan 28, 2020 · 5 comments
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Nokel81
Copy link
Contributor

Nokel81 commented Jan 28, 2020

The error message

error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds

does not point to where in the block the captured lifetime is (which makes debugging it difficult).

It does, however, point to the scope:

note: hidden type `impl futures::Future` captures the scope of call-site for function at 48:40
  --> rs/agent-updater/src/fetcher.rs:48:40
   |
48 |       ) -> Result<PathBuf, FetcherError> {
   |  ________________________________________^
49 | |         let checksum = m.get_valid_checksum()?;
51 | |
...  |
72 | |         Ok(folder)
73 | |     }
   | |_____^
@Centril
Copy link
Contributor

Centril commented Jan 28, 2020

@Nokel81 Do you have / could you make a small self-contained example we could use when trying to improve the diagnostics?

@Centril Centril added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jan 28, 2020
@estebank estebank added A-async-await Area: Async & Await D-papercut Diagnostics: An error or lint that needs small tweaks. labels Jan 28, 2020
@Nokel81
Copy link
Contributor Author

Nokel81 commented Jan 28, 2020

Yes, here is a minimal example. (cannot be a playground link since the playground doesn't have slog.

Example:

use std::{
    collections::HashMap, 
    io,
    sync::Mutex, 
    path::PathBuf
};
use reqwest::Response;
use hyper;
use slog::Logger;

pub struct Module;
pub struct DownloaderError;

pub trait Downloader {
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        url: &'life1 str,
    ) -> ::core::pin::Pin<
        Box<
            dyn ::core::future::Future<Output = Result<Response, DownloaderError>>
                + ::core::marker::Send
                + 'async_trait,
        >,
    >
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait;
}

pub struct Fetcher<T>
where
    T: Downloader,
{
    downloader: T,
    storage_folder: PathBuf,
    download_cache: Mutex<HashMap<[u8; 32], Vec<u8>>>,
}

impl<T> Fetcher<T>
where
    T: Downloader,
{
    pub fn new(downloader: T, storage_folder: PathBuf) -> Fetcher<T> {
        Self {
            downloader,
            storage_folder,
            download_cache: Mutex::new(HashMap::new()),
        }
    }

    pub async fn fetch_module(
        &self,
        logger: Logger,
        m: &Module,
    ) -> Result<PathBuf, DownloaderError> {
        Ok(PathBuf::new())
    }
}

This is compiled on stable 1.40.

If you remove the line logger: Logger, from the fetch_module method then the compiler error goes away.

@skeet70
Copy link

skeet70 commented Jan 31, 2020

This may be related to #63033.

@tmandry tmandry added the AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. label Feb 11, 2020
@tmandry
Copy link
Member

tmandry commented Feb 11, 2020

Marking as triaged. This issue would benefit from a more minimized example.

@Nokel81
Copy link
Contributor Author

Nokel81 commented Feb 11, 2020

I try and get a smaller one tomorrow.

@JohnTitor JohnTitor added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Apr 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-enhancement Category: An issue proposing an enhancement or a PR with one. D-papercut Diagnostics: An error or lint that needs small tweaks. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants