Closed
Description
Code
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::str::Split;
use std::path::Path;
pub trait Parser<D>
where dyn Parser<D>: Sized
{
fn new(split_header: Split<&str>) -> Self where Self: Sized;
fn parse_line(&self, split_line: &Split<&str>) -> D;
}
pub struct CsvReader<D> {
parser: Box<dyn Parser<D>>,
reader: BufReader<File>,
buf: String, // Buffer we will read into. Avoids re-allocation on each line.
path: String, // Record this so we can return more informative error messages.
line: usize, // Same motivation for this.
}
impl<D> CsvReader<D>
where dyn Parser<D>: Sized
{
fn new<F>(path: &str, make_parser: F) -> CsvReader<D>
where F: Fn(Split<char>) -> dyn Parser<D> {
let file = match File::open(Path::new(path)) {
Err(err) => panic!("Couldn't read {}: {}", path, err),
Ok(file) => file,
};
let mut reader = BufReader::new(file);
let mut buf = String::new();
let parser = Box::new(match reader.read_line(&mut buf) {
Err(err) => panic!("Failed to read the header line from {}: {}", path, err),
Ok(_) => {
let split_header = buf.split(',');
make_parser(split_header)
},
});
CsvReader {
parser: parser,
reader,
buf,
path: path.to_string(),
line: 2,
}
}
}
Meta
rustc --version --verbose
:
rustc 1.55.0 (c8dfcfe04 2021-09-06)
binary: rustc
commit-hash: c8dfcfe046a7680554bf4eb612bad840e7631c4b
commit-date: 2021-09-06
host: x86_64-unknown-linux-gnu
release: 1.55.0
LLVM version: 12.0.1
This crash also happens with 1.58.0-nightly (1f12ac872 2021-10-17)
.
Error output
Compiling csv_bug_repro v0.1.0 (/home/harry/coding/rust_sandbox/csv_bug_repro)
warning: struct is never constructed: `CsvReader`
--> src/csv_reader.rs:14:12
|
14 | pub struct CsvReader<D> {
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: associated function is never used: `new`
--> src/csv_reader.rs:26:8
|
26 | fn new<F>(path: &str, make_parser: F) -> CsvReader<D>
| ^^^
warning: Error finalizing incremental compilation session directory `/home/harry/coding/rust_sandbox/csv_bug_repro/target/debug/incremental/csv_bug_repro-t1krx8ndn25r/s-g3h06ix8xp-1apzozo-working`: No such file or directory (os error 2)
error: internal compiler error: receiver when `Self = (dyn Parser<D> + 'static)` should have a ScalarPair ABI; found Some(Scalar(Scalar { value: Pointer, valid_range: 1..=18446744073709551615 }))
--> src/csv_reader.rs:10:5
|
10 | fn parse_line(&self, split_line: &Split<&str>) -> D;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: delayed at compiler/rustc_trait_selection/src/traits/object_safety.rs:507:30
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
note: run with `RUST_BACKTRACE=1` environment variable to display a 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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.55.0 (c8dfcfe04 2021-09-06) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
warning: `csv_bug_repro` (bin "csv_bug_repro") generated 3 warnings
error: could not compile `csv_bug_repro`; 3 warnings emitted
Backtrace
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1050:13
stack backtrace:
0: 0x7efecd3aeb40 - std::backtrace_rs::backtrace::libunwind::trace::ha0ad43e8a952bfe7
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
1: 0x7efecd3aeb40 - std::backtrace_rs::backtrace::trace_unsynchronized::h6830419c0c4130dc
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7efecd3aeb40 - std::sys_common::backtrace::_print_fmt::h8f3516631ffa1ef5
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:67:5
3: 0x7efecd3aeb40 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he1640d5f0d93f618
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:46:22
4: 0x7efecd41c6bc - core::fmt::write::h88012e1f01caeebf
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/fmt/mod.rs:1115:17
5: 0x7efecd3a02d5 - std::io::Write::write_fmt::h360fa85b30182555
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/io/mod.rs:1665:15
6: 0x7efecd3b289b - std::sys_common::backtrace::_print::ha1f00492f406a015
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:49:5
7: 0x7efecd3b289b - std::sys_common::backtrace::print::hd54561b13feb6af3
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:36:9
8: 0x7efecd3b289b - std::panicking::default_hook::{{closure}}::h84fe124cd0864662
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:208:50
9: 0x7efecd3b2371 - std::panicking::default_hook::h5a8e74a76ce290a7
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:225:9
10: 0x7efecdb8b251 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h6de3be617154114e
11: 0x7efecd3b30c9 - std::panicking::rust_panic_with_hook::h67c812a4fe9d4c91
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:626:17
12: 0x7efecd3b2b87 - std::panicking::begin_panic_handler::{{closure}}::h33f9c1b96af300d7
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:519:13
13: 0x7efecd3af03c - std::sys_common::backtrace::__rust_end_short_backtrace::h51bae64be5921f0e
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:141:18
14: 0x7efecd3b2ae9 - rust_begin_unwind
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
15: 0x7efecd37baab - std::panicking::begin_panic_fmt::h7ab3d84aa4ae32a2
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:457:5
16: 0x7efecffecd69 - rustc_errors::HandlerInner::flush_delayed::h3cf13f1d614b970c
17: 0x7efecffeb7cd - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h1ba213c91f42b705
18: 0x7efecf69fa76 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::hf39666c9be42225f
19: 0x7efecf6a1e8e - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::h7cb2a8407593b01a
20: 0x7efecf67703d - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::haa98f3f95730172a
21: 0x7efecf676623 - rustc_span::with_source_map::hc5adfd8eb2dd5236
22: 0x7efecf687c8a - rustc_interface::interface::create_compiler_and_run::h976ed8e22b4f89b8
23: 0x7efecf67ae89 - scoped_tls::ScopedKey<T>::set::h4a2887b4d5b96c48
24: 0x7efecf6779aa - std::sys_common::backtrace::__rust_begin_short_backtrace::h220030c0c75c9d89
25: 0x7efecf676df5 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hd62830e2741d6b63
26: 0x7efecd3bf657 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6bff7798948b1075
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/alloc/src/boxed.rs:1572:9
27: 0x7efecd3bf657 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc2d25ac38f6b2342
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/alloc/src/boxed.rs:1572:9
28: 0x7efecd3bf657 - std::sys::unix::thread::Thread::new::thread_start::hbba5bc368baac205
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys/unix/thread.rs:74:17
29: 0x7efecd0ff6db - start_thread
30: 0x7efecca1ca3f - __clone
31: 0x0 - <unknown>
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: This bug is tracked inside the repo by a `known-bug` test.Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.