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

Comments

@Nokel81
Copy link
Contributor

@Nokel81 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

This comment has been minimized.

Copy link
Member

@Centril 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?

@Nokel81

This comment has been minimized.

Copy link
Contributor Author

@Nokel81 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

This comment has been minimized.

Copy link

@skeet70 skeet70 commented Jan 31, 2020

This may be related to #63033.

@tmandry

This comment has been minimized.

Copy link
Contributor

@tmandry tmandry commented Feb 11, 2020

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

@Nokel81

This comment has been minimized.

Copy link
Contributor Author

@Nokel81 Nokel81 commented Feb 11, 2020

I try and get a smaller one tomorrow.

@tmandry tmandry added this to Low priority in wg-async-foundations triage Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.