-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
ICE when using impl FnOnce...
in argument position on 1.25.0-nightly 2018-01-24
. Unexpected panic.
A quick note, the offending argument is of type: impl FnOnce(_) -> Box<_>
(omitting the concrete types with _
). That said, I'm not sure if universal_impl_trait
actually explicitly supports impl Trait
in argument position for the fn
family at this point in time.
code sample that causes the bug
Working example:
#[derive(Clone, StateData, NewMiddleware)]
pub struct CoreServices {
pub header_value: Arc<String>,
}
impl Middleware for CoreServices {
fn call<Chain>(self, mut state: State, chain: Chain) -> Box<HandlerFuture>
where Chain: FnOnce(State) -> Box<HandlerFuture>,
{
state.put(self);
let f = chain(state).and_then(move |(state, mut response)| {
let data = state.borrow::<CoreServices>();
let headers = response.headers_mut();
let header_val = (*data.header_value).clone();
headers.set_raw(String::from("X-Super-Header"), header_val);
future::ok((state, response))
});
Box::new(f)
}
}
The code which breaks it:
#[derive(Clone, StateData, NewMiddleware)]
pub struct CoreServices {
pub header_value: Arc<String>,
}
impl Middleware for CoreServices {
fn call(self, mut state: State, chain: impl FnOnce(State) -> Box<HandlerFuture>) -> Box<HandlerFuture>
{
state.put(self);
let f = chain(state).and_then(move |(state, mut response)| {
let data = state.borrow::<CoreServices>();
let headers = response.headers_mut();
let header_val = (*data.header_value).clone();
headers.set_raw(String::from("X-Super-Header"), header_val);
future::ok((state, response))
});
Box::new(f)
}
}
I expected the code to compile. I have the following nightly features enabled:
#![feature(
conservative_impl_trait,
generators,
nll,
proc_macro,
universal_impl_trait,
use_nested_groups,
)]
meta
rustc info:
$ rustc --version --verbose
rustc 1.25.0-nightly (a0dcecff9 2018-01-24)
binary: rustc
commit-hash: a0dcecff90c45ad5d4eb60859e22bb3f1b03842a
commit-date: 2018-01-24
host: x86_64-apple-darwin
release: 1.25.0-nightly
LLVM version: 4.0
Backtrace:
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.25.0-nightly (a0dcecff9 2018-01-24) running on x86_64-apple-darwin
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:335:21
stack backtrace:
0: 0x10ca43eab - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::ha9efc95a1760cacd
1: 0x10ca50044 - std::sys_common::backtrace::print::hf5c8aa5eb53db16a
2: 0x10ca436e0 - std::panicking::default_hook::{{closure}}::hdce9608c60053b8f
3: 0x10ca433e3 - std::panicking::default_hook::hba09553cc28730a2
4: 0x10ca43b66 - std::panicking::rust_panic_with_hook::h3639511a0c7cb848
5: 0x10ca439be - std::panicking::begin_panic::h0e3595e70a446052
6: 0x10ca43913 - std::panicking::begin_panic_fmt::h94f1111cdb67ea95
7: 0x10ca43882 - rust_begin_unwind
8: 0x10cab9df3 - core::panicking::panic_fmt::h7800179476794181
9: 0x10cab9ce6 - core::panicking::panic::h4f9b253c2f9854a3
10: 0x109dfacf9 - rustc_typeck::check::compare_method::compare_impl_method::h257f59c3b52215a2
11: 0x109d86fda - rustc_typeck::check::check_item_type::h969b3c82c24011db
12: 0x109d0da8f - rustc::hir::Crate::visit_all_item_likes::h14dadb1787741be5
13: 0x109ddd868 - rustc_typeck::check_crate::h6ea8f3ed64500660
14: 0x106649aba - <std::thread::local::LocalKey<T>>::with::hc97c0f695fc47a37
15: 0x1066471ec - <std::thread::local::LocalKey<T>>::with::h5232c8db13d095a5
16: 0x1066753e3 - rustc_driver::driver::compile_input::h13c6388277ea77a3
17: 0x10668617c - rustc_driver::run_compiler::hebc5d6e3e17d092c
18: 0x1066042d1 - std::sys_common::backtrace::__rust_begin_short_backtrace::he16271a6bff11c29
19: 0x10ca72fbe - __rust_maybe_catch_panic
20: 0x1065b8ddd - <F as alloc::boxed::FnBox<A>>::call_box::h838126c6997c937c
21: 0x10ca52a67 - std::sys_common::thread::start_thread::hee6a12d8ac7037fd
22: 0x10ca5eda8 - std::sys::unix::thread::Thread::new::thread_start::hca6ddd0e0fdf932d
23: 0x7fff6b51d6c0 - _pthread_body
24: 0x7fff6b51d56c - _pthread_start
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.