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

Compiler error due to web::block opaque type #840

Closed
sylvain101010 opened this issue May 13, 2019 · 2 comments
Closed

Compiler error due to web::block opaque type #840

sylvain101010 opened this issue May 13, 2019 · 2 comments

Comments

@sylvain101010
Copy link

Hi,
the following code causes a compiler error:

fn handle_upload(report_path: &str, field: Field) -> Box<Stream<Item = (), Error = Error>> {
    let file = match fs::File::create(report_path) {
        Ok(file) => file,
        Err(e) => return Box::new(future::err(error::ErrorInternalServerError(e)).into_stream()),
    };

    return Box::new(
        Box::new(
            field.fold((file, 0u64), move |(mut file, mut acc), bytes| {
                web::block(move || {
                    file.write_all(bytes.as_ref()).map_err(|e| {
                        MultipartError::Payload(error::PayloadError::Io(e))
                    })?;
                    acc += bytes.len() as u64;
                    if acc > crate::REPORT_MAX_SIZE {
                        return Err(MultipartError::Payload(error::PayloadError::Overflow));
                    }
                    Ok((file, acc))
                })
                .map_err(|e: error::BlockingError<MultipartError>| {
                    match e {
                        error::BlockingError::Error(e) => e,
                        error::BlockingError::Canceled => MultipartError::Incomplete,
                    }
                })
            })
            .map(|(_)| ())
            .map_err(|e| error::ErrorInternalServerError(e)),
        ).into_stream()
    );
}

cause the following error:

error: internal compiler error: unexpected region in query response: `ReScope(Destruction(282))`

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:354:17
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic
   7: <rustc_errors::Handler as core::ops::drop::Drop>::drop
   8: core::ptr::real_drop_in_place
   9: core::ptr::real_drop_in_place
  10: core::ptr::real_drop_in_place  11: syntax::with_globals
  12: __rust_maybe_catch_panic
  13: <F as alloc::boxed::FnBox<A>>::call_box
  14: std::sys::unix::thread::Thread::new::thread_start
  15: _pthread_body
  16: _pthread_start
query stack during panic:
end of query stack

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.34.1 

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `api`.

as you can see, the code is not very different than https://github.com/actix/examples/tree/master/multipart

according to rust-lang/rust#60127

The reason may be the opaque return type of web::block.

Is it possible to improve this ?

@fafhrd91
Copy link
Member

You should file rustc bug report

@sylvain101010
Copy link
Author

sylvain101010 commented May 13, 2019

I just tested with nightly and it compiles without error, so effectively a rustc error.

Sorry for the inconveniences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants