-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
error[E0275]: "overflow evaluating the requirement" triggered by importing a path of length 2 #57854
Comments
cc @shepmaster it seems a playground issue, cannot reproduce on a local machine. |
I can reproduce it locally with Arch Linux's rustc:
I wouldn't have used Playground if I weren't having issue on a local machine. However, I did some testing with other versions, and here are some interesting results:
Looking at Arch Linux's build script for Rust, it appears to be a normal build with a custom config.toml. |
Have you added both the tokio and tar crates (based on the error messages)? |
Yes, adding just Tokio triggers this. I've updated the original comment. |
_: std::io::Read
/cc @davidtwco does this feel like anything around the external crate trait suggestions you worked on? |
I don't think so - the extern crate trait suggestions work (#55613) I've done hasn't landed (I feel like there was something like that I had done which landed, but I can't find it, so I suppose not). |
Oh, heh, then pretty unlikely to be related 😊! Sorry to drag you in! |
Looks like the bug definitely depends on a certain package (tokio) being pulled in, but does not necessarily require a non-existent import. In my original code, importing actix-web ( |
Oh, you said that in your original comment; sorry. |
I tried to minimize from my codebase while applying @zhaofengli's ideas, and came to this: [package]
name = "example"
version = "0.1.0"
authors = ["Author"]
edition = "2018"
[dependencies]
tokio-reactor = "=0.1.9" impl Foo {}
fn bar<R>(r: &R) {
std::io::Read::read_exact(&mut r, &mut [])
//std::io::copy(&mut r, unimplemented!())
//std::io::BufReader::new(r)
} Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a1e1abd1001d712519ac5f18f999bb3a. Reproducible on latest stable, beta and nightly with either of the three lines in the body of All elements in this code are required to trigger the requirement evaluation overflow:
Hope this unblocks the issue! |
Minimized even more to a standalone version, reproducible with just struct PollEvented<E> {
phantom: std::marker::PhantomData<E>,
}
impl<'a, E> std::io::Read for &'a PollEvented<E>
where
&'a E: std::io::Read,
{
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
unimplemented!()
}
}
fn bar<R>(r: &R) {
std::io::Read::read_exact(&mut r, &mut [])
//std::io::copy(&mut r, unimplemented!())
//std::io::BufReader::new(r)
} which now looks very similar to #39959 (comment). Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=f0458c4cc719dcc848c4f3cc6242afba. |
Having the same problem. It does not even say which file/line is the problem. ❯ cargo build
Compiling proj v0.2.0 (../proj)
error[E0275]: overflow evaluating the requirement `&tokio_reactor::poll_evented::PollEvented<_>: std::io::Write`
|
= help: consider adding a `#![recursion_limit="10"]` attribute to your crate
= note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<_>>`
= note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<_>>>`
= note: required because of the requirements on the impl of `std::io::Write` for `&tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<_>>>>`
= note: required because of the requirements on the impl of `tokio_io::async_write::AsyncWrite` for `&tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<_>>>>>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0275`.
error: Could not compile `proj`.
To learn more, run the command again with --verbose. |
I am also having this issue, on both stable (1.33) and nightly (1.35). error[E0275]: overflow evaluating the requirement `_: std::marker::Sized`
|
= help: consider adding a `#![recursion_limit="128"]` attribute to your crate
= note: required because of the requirements on the impl of `std::io::Read` for `&tokio_reactor::poll_evented::PollEvented<_>`
= note: required because of the requirements on the impl of `std::io::Read` for `&tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<_>>` With the following: use futures::{try_ready, Async, Future, Poll};
use serde::de::DeserializeOwned;
use tokio::io::{read_exact, AsyncRead};
use std::{io, marker::PhantomData};
#[derive(Debug)]
pub struct Bar<R> {
stream: R,
}
impl<R> Future for Bar<R>
where
R: AsyncRead,
{
type Item = Foo;
type Error = io::Error;
fn poll(&mut self) -> Poll<Self::Item, io::Error> {
let mut buf = [0_u8; 14];
// if you comment out the following line, error goes away:
let (rd, init) = try_ready!(read_exact(&self.stream, &mut buf).poll());
Ok(Async::Ready(Foo { }))
}
}
pub struct Foo {} It appears to be Is there anyway to get around this? The API of what I'm trying to build gets pretty gross if I can't use a generic type param. edit: playground link https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7817e212b23d8618e9e42e4cd9061109 |
@leshow the problem is that there is no The solution is to use |
We can't read from the original file, because we want to be able to use that as the writer in `apply()`. Previously, this would result in the original file simply being truncated, as we weren't reading from the correct file. To fix this, we need to give `apply_to()` both a reader and a writer. Now, in `apply()`, we can pass it the temporary file to read, and the original to write to. Used a `Path` as an input to `apply_to()` instead of a `Read`er because I got an error that didn't really make sense to me when I did so: error[E0275]: overflow evaluating the requirement `&tokio_reactor::poll_evented::PollEvented<_>: std::io::Read` | = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`git_suggested_patch`) = note: required because of the requirements on the impl of `std::io::Read` for `&tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<_>>` = note: required because of the requirements on the impl of `std::io::Read` for `&tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<tokio_reactor::poll_evented::PollEvented<_>>>` A search for the error message turned up a few active issues: - rust-lang/rust#57854 - rust-lang/rust#62755 - rust-lang/rust#39959 The above issues indicate that this could come from having a variable with an inferred type. However, for the moment the issue isn't resolved, and the error message doesn't indicate where the problem is actually coming from. As I was unable to track down the source of the problem, I decided not to bother using a `Read` argument.
The original report no longer emits E0275, it only complains about the invalid
The minimized report now looks like this:
If we apply the suggestions naively, we get further errors:
But if we fix those, we get (which I believe is reasonable):
|
This might be a duplicate of #39959. I'm posting a new issue here as the mechanism that the error is triggered significantly differs from that in the aforementioned issue.
Sample code
(Playground)
Details
use thisdoesntexistyolo::haha;
is replaced with anything more than 2 levels deep likeuse thisdoesntexistyolo::a::b;
, the code will compile without the error.The text was updated successfully, but these errors were encountered: