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

Panic in nightly rustc_errors::CodeSuggestion::splice_lines #57521

Closed
NickFinco opened this issue Jan 11, 2019 · 6 comments
Closed

Panic in nightly rustc_errors::CodeSuggestion::splice_lines #57521

NickFinco opened this issue Jan 11, 2019 · 6 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@NickFinco
Copy link

Full source file:
fn x<T, '_, 'b>() {}

Panic output:

x@y.z:~/repro$ RUST_BACKTRACE=full cargo build
   Compiling repro v0.1.0 (/home/x/repro)
error: lifetime parameters must be declared prior to type parameters
 --> src/lib.rs:1:9
  |
1 | fn x<T, '_, 'b>() {}
  |         ^^  ^^
thread 'rustc' panicked at 'begin <= end (12 <= 10) when slicing `fn x<T, '_, 'b>() {}`', src/libcore/str/mod.rs:2085:5
stack backtrace:
   0:     0x7f3e690d9643 - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h150bfa0663b43d9c
                               at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1:     0x7f3e690d1ca8 - std::sys_common::backtrace::_print::haf67371a49a69611
                               at src/libstd/sys_common/backtrace.rs:70
   2:     0x7f3e690d57d2 - std::panicking::default_hook::{{closure}}::hfc43ed4580f31f37
                               at src/libstd/sys_common/backtrace.rs:58
                               at src/libstd/panicking.rs:200
   3:     0x7f3e690d5544 - std::panicking::default_hook::h9b7f9ea5176f68e5
                               at src/libstd/panicking.rs:215
   4:     0x7f3e690d5ee0 - std::panicking::rust_panic_with_hook::h71fb7e2d0df54e52
                               at src/libstd/panicking.rs:478
   5:     0x7f3e690d5a61 - std::panicking::continue_panic_fmt::h7e9d5b7aec3fd429
                               at src/libstd/panicking.rs:385
   6:     0x7f3e690d5945 - rust_begin_unwind
                               at src/libstd/panicking.rs:312
   7:     0x7f3e690ffc7c - core::panicking::panic_fmt::h77387da9b048cc4b
                               at src/libcore/panicking.rs:85
   8:     0x7f3e691021ed - core::str::slice_error_fail::h368eecf1ba87bfe3
                               at src/libcore/str/mod.rs:0
   9:     0x7f3e639f5fc1 - core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::Range<usize>>::index::{{closure}}::h70438d1d5e25fc9e
  10:     0x7f3e639f66d9 - rustc_errors::CodeSuggestion::splice_lines::push_trailing::hbf8e90335f4e2bb1
  11:     0x7f3e639db7d5 - <core::iter::Map<I, F> as core::iter::iterator::Iterator>::fold::h67192288499ae88c
  12:     0x7f3e639e9255 - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter::h43c363b3f75ad1ab
  13:     0x7f3e639cf31f - <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit::h8853175141876d04
  14:     0x7f3e639f8ef3 - rustc_errors::Handler::emit_db::h421840da2bbe513f
  15:     0x7f3e639e3137 - rustc_errors::diagnostic_builder::DiagnosticBuilder::emit::he5215c099ff8cf17
  16:     0x7f3e63cfbb96 - syntax::parse::parser::Parser::parse_generic_params::hd5de9a47f6fadd18
  17:     0x7f3e63cfc8cc - syntax::parse::parser::Parser::parse_generics::h1e95f88cfb3ffee6
  18:     0x7f3e63d01422 - syntax::parse::parser::Parser::parse_item_fn::h7c9b251954586049
  19:     0x7f3e63d10bc1 - syntax::parse::parser::Parser::parse_item_implementation::h7f6fdd21562dab35
  20:     0x7f3e63d0e2e3 - syntax::parse::parser::Parser::parse_item_::hf7a2db2c185b3b7c
  21:     0x7f3e63d24039 - syntax::parse::parser::Parser::parse_item::h73139576d53e3863
  22:     0x7f3e63d0b7e0 - syntax::parse::parser::Parser::parse_mod_items::hfdc10792132eab23
  23:     0x7f3e63d24d46 - syntax::parse::parser::Parser::parse_crate_mod::h2c19d9f9e4e17439
  24:     0x7f3e63de0a88 - syntax::parse::parse_crate_from_file::h20069ccc4bc2b875
  25:     0x7f3e69446c8b - rustc_driver::driver::phase_1_parse_input::{{closure}}::ha4e265e108e0b04a
  26:     0x7f3e694467be - rustc_driver::driver::phase_1_parse_input::hb92f841897290bd6
  27:     0x7f3e6943f27b - rustc_driver::driver::compile_input::h0205d11fa4255421
  28:     0x7f3e693ceb30 - rustc_driver::run_compiler_with_pool::hdb7366dec3b2aedf
  29:     0x7f3e693d9ff5 - <scoped_tls::ScopedKey<T>>::set::hc8c0a4e63f3470da
  30:     0x7f3e693cd97a - rustc_driver::run_compiler::he1ef103f381b0a7a
  31:     0x7f3e693d99ea - <scoped_tls::ScopedKey<T>>::set::h9a000850eb3d4fe8
  32:     0x7f3e694acbe2 - std::sys_common::backtrace::__rust_begin_short_backtrace::he0524e22fe3ddb41
  33:     0x7f3e690e7569 - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:92
  34:     0x7f3e694b8260 - <F as alloc::boxed::FnBox<A>>::call_box::h04932c55efd4205e
  35:     0x7f3e690e632d - std::sys::unix::thread::Thread::new::thread_start::h3de0150320ce4b08
                               at /rustc/c2d381d39d282c0586d50ea7d7a431ffd5ddb3fb/src/liballoc/boxed.rs:744
                               at src/libstd/sys_common/thread.rs:14
                               at src/libstd/sys/unix/thread.rs:81
  36:     0x7f3e68e5b493 - start_thread
  37:     0x7f3e68791a8e - __clone
  38:                0x0 - <unknown>

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.33.0-nightly (c2d381d39 2019-01-10) running on x86_64-unknown-linux-gnu

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

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

error: Could not compile `repro`.
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Jan 11, 2019
@estebank
Copy link
Contributor

I believe push_trailing needs to be fixed. I believe the calculation of hi_opt might have a bug, which triggers when slicing line until hi, causing the presented backtrace.

@dlrobertson
Copy link
Contributor

Dug into this a bit last night and after updating push_trailing we don't panic, but we also don't generate the correct error message. I think we also need to update parse_generic_params

@pnkfelix
Copy link
Member

pnkfelix commented Jan 17, 2019

triage: Marking as P-high. Assigning self. (but also need to follow up with @dlrobertson to see what their status is; don't want to duplicate effort!)

@pnkfelix pnkfelix self-assigned this Jan 17, 2019
@pnkfelix pnkfelix added the P-high High priority label Jan 17, 2019
@estebank
Copy link
Contributor

@dlrobertson what does the incorrect error message look like? That might give me an idea of what is wrong.

@dlrobertson
Copy link
Contributor

dlrobertson commented Jan 17, 2019

After fixing push_trailing, I've been trying to figure out how to push the correct snippet to be shown and snippet to be removed here. I currently end up with a trailing comma (fn x<'a, 'b, T, > instead of fn <'a, 'b, T>) when there is no type parameter following the lifetimes. I think the trailing comma issue happens due to the calculation of remove_sp when ate_comma is set, but there is no type parameter following the bad lifetime(s).

@dlrobertson
Copy link
Contributor

Figured it out. I'll post a PR shortly.

Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
Fix suggestions given mulitple bad lifetimes

When given multiple lifetimes prior to type parameters in generic
parameters, do not ICE and print the correct suggestion.

r? @estebank

CC @pnkfelix

Fixes: rust-lang#57521
Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
Fix suggestions given mulitple bad lifetimes

When given multiple lifetimes prior to type parameters in generic
parameters, do not ICE and print the correct suggestion.

r? @estebank

CC @pnkfelix

Fixes: rust-lang#57521
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 18, 2019
Fix suggestions given mulitple bad lifetimes

When given multiple lifetimes prior to type parameters in generic
parameters, do not ICE and print the correct suggestion.

r? @estebank

CC @pnkfelix

Fixes: rust-lang#57521
Centril added a commit to Centril/rust that referenced this issue Jan 18, 2019
Fix suggestions given mulitple bad lifetimes

When given multiple lifetimes prior to type parameters in generic
parameters, do not ICE and print the correct suggestion.

r? @estebank

CC @pnkfelix

Fixes: rust-lang#57521
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants