-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Using impl Trait with closure local functions across crates results in ICE #43135
Comments
Actually, it looks like defining the function inside the closure is not needed, even just a private helper function in the crate that is only called from the closure will trigger this, e.g. fn msg() -> String { format!("Hello, {}!", "world") }
pub fn foo2() -> impl Future<Item=String, Error=()> {
future::ok(()).and_then(|()| future::ok(msg()) )
} |
Stack trace:
|
I am also hitting this ICE. Is there a workaround? |
@maximih Yes. Marking #[inline] as you encounter the error. |
Thanks. Using #[inline] seem to fix some occurances but not all. I still get the error for this method: #[inline]
fn login<'a>(&'a self) -> impl Future<Item = String, Error = Error> + 'a {
let req = self.prepare_login_request();
result(req)
.and_then(move |resp| check_http_status_parse_body(resp, hyper::Ok))
.and_then(move |api_resp| {
// check if the authentication was successful
if &api_resp.status.reqStatus[..] == "SUCCESS" {
if api_resp.status.credentials.is_some() {
// save a copy of the token to be returned later
let to_return = api_resp.status.credentials.as_ref().unwrap().clone();
// add the data to cache
debug!("Login successful! Caching the response");
let to_store = Arc::new(api_resp);
// add the data to the cache
self.cache.insert_new(self.auth_url.clone(), to_store);
// return the token
ok(to_return)
} else {
err(Error::Auth)
}
} else {
err(Error::Auth)
}
})
} The error I get:
|
Triage: close? @Mark-Simulacrum |
Having an
impl Trait
type, containing a closure, where the closure has a locally defined function inside it, being passed across crate boundaries, results in an ICE.The following function, defined in one crate, then used in another:
gives the error:
Presumably related to #40839/#35870, I found this while trying to come up with a decent workaround for #40839 specifically.
I have pushed a full testcase to https://github.com/Nemo157/impl-trait-across-crates, try building the
foo2
crate.The text was updated successfully, but these errors were encountered: