Closed
Description
I've just encountered an interesting ICE on both stable
and nightly
which only presents itself when using for<'de>
in a where clause and boxed trait objects.
A quick skim through the backtrace makes it look like an issue with type inference and the fact that the first argument is self
.
Example:
extern crate serde;
use std::error::Error;
use std::iter;
use serde::Deserialize;
pub trait Paginated: Executor {
fn paginated<T>(self) -> Box<Iterator<Item = Result<T, Box<Error>>>>
where
Self: Sized,
T: for<'de> Deserialize<'de>,
{
match self.execute::<Vec<T>>() {
Ok(got) => Box::new(iter::empty()),
Err(e) => Box::new(iter::once(Err(e))),
}
}
}
trait Executor {
fn execute<T>(self) -> Result<T, Box<Error>>
where
Self: Sized,
T: for<'de> Deserialize<'de>,
{
unimplemented!()
}
}
fn main() {}
Backtrace:
$ RUST_BACKTRACE=full cargo run
...
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.22.1 (05e2e1c41 2017-11-22) running on x86_64-unknown-linux-gnu
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: !(self.has_self && idx == 0)', /checkout/src/librustc/ty/mod.rs:788:16
stack backtrace:
0: 0x7fcfa867ce43 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::h8ed7485deb8ab958
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: 0x7fcfa8677590 - std::sys_common::backtrace::_print::h3d4f9ea58578e60f
at /checkout/src/libstd/sys_common/backtrace.rs:69
2: 0x7fcfa868a343 - std::panicking::default_hook::{{closure}}::h0088fe51b67c687c
at /checkout/src/libstd/sys_common/backtrace.rs:58
at /checkout/src/libstd/panicking.rs:381
3: 0x7fcfa868a04a - std::panicking::default_hook::hf425c768c5ffbbad
at /checkout/src/libstd/panicking.rs:391
4: 0x7fcfa868a807 - std::panicking::rust_panic_with_hook::h25b934bb4484e9e0
at /checkout/src/libstd/panicking.rs:577
5: 0x7fcfa505aa3a - std::panicking::begin_panic::h00bf2a70e069c223
6: 0x7fcfa536ab7f - rustc::ty::Generics::type_param::h91ef8c39b7e0fd49
7: 0x7fcfa5223ae3 - rustc::infer::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_region_errors::h5eada194f4b8f339
8: 0x7fcfa52491a7 - rustc::infer::InferCtxt::resolve_regions_and_report_errors::h64edcb890c069ae8
9: 0x7fcfa764d2a5 - rustc_typeck::check::typeck_tables_of::{{closure}}::h042d0873aaf7fde0
10: 0x7fcfa7649b3b - rustc_typeck::check::typeck_tables_of::he5b52d40ac01f6ff
11: 0x7fcfa54198e4 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::force::h22c9013a5fcfb086
12: 0x7fcfa541a341 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get::hf118a95b7cc6e708
13: 0x7fcfa550ae9a - rustc::ty::maps::TyCtxtAt::typeck_tables_of::h51c78abcf9c5a929
14: 0x7fcfa5507653 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of::hbf69b4488e565710
15: 0x7fcfa7648e27 - rustc_typeck::check::typeck_item_bodies::h39b104d6bb6d2f89
16: 0x7fcfa5416b0d - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::force::h28d47d1ad55f84fa
17: 0x7fcfa5417543 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get::h2e813186439f4ed0
18: 0x7fcfa550ad74 - rustc::ty::maps::TyCtxtAt::typeck_item_bodies::h4b1084eafa435c5e
19: 0x7fcfa5507623 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies::hc5ad0d8db8d5fb90
20: 0x7fcfa769dccb - rustc_typeck::check_crate::h855fcdb3ee4b5abc
21: 0x7fcfa89aeb39 - rustc::ty::context::TyCtxt::create_and_enter::h3dad1968772b9cec
22: 0x7fcfa8a2cd4b - rustc_driver::driver::compile_input::h4bf59ac61f928939
23: 0x7fcfa8a489fe - rustc_driver::run_compiler::h2a410e29e6088b6b
24: 0x7fcfa89677c7 - std::sys_common::backtrace::__rust_begin_short_backtrace::hb62d9d382e421fd7
25: 0x7fcfa86c4bdc - __rust_maybe_catch_panic
at /checkout/src/libpanic_unwind/lib.rs:99
26: 0x7fcfa89a0870 - <F as alloc::boxed::FnBox<A>>::call_box::h56ea5c52b2f008af
27: 0x7fcfa868920b - std::sys::imp::thread::Thread::new::thread_start::hbaf1b5aa1ca8e3ea
at /checkout/src/liballoc/boxed.rs:736
at /checkout/src/libstd/sys_common/thread.rs:24
at /checkout/src/libstd/sys/unix/thread.rs:90
28: 0x7fcfa3543089 - start_thread
29: 0x7fcfa834b42e - __clone
30: 0x0 - <unknown>
error: Could not compile `repo-backup`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
No labels