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

ICE with wrong method receiver as second parameter #62660

Closed
jfrimmel opened this issue Jul 13, 2019 · 3 comments · Fixed by #62668 or #62704
Closed

ICE with wrong method receiver as second parameter #62660

jfrimmel opened this issue Jul 13, 2019 · 3 comments · Fixed by #62668 or #62704
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jfrimmel
Copy link
Contributor

jfrimmel commented Jul 13, 2019

The following code (on compiler explorer) leads to an ICE:

struct Foo;
impl Foo {
    // mind the missing `>` of the receiver
    pub fn foo(_: i32, self: Box<Self) {}
}

Broken since 1.32.0 up to the current nightly, earlier versions are not affected.

Backtrace of the nightly build
error: internal compiler error: Error constructed but not emitted

thread 'rustc' panicked at 'explicit panic', src/librustc_errors/diagnostic_builder.rs:387:13
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   8: std::panicking::begin_panic
   9: <rustc_errors::diagnostic_builder::DiagnosticBuilder as core::ops::drop::Drop>::drop
  10: syntax::parse::parser::Parser::parse_arg_general
  11: syntax::parse::parser::Parser::parse_seq_to_before_tokens
  12: syntax::parse::parser::Parser::parse_impl_method
  13: syntax::parse::parser::Parser::parse_impl_item
  14: syntax::parse::parser::Parser::parse_item_implementation
  15: syntax::parse::parser::Parser::parse_item_
  16: syntax::parse::parser::Parser::parse_item
  17: syntax::parse::parser::Parser::parse_mod_items
  18: syntax::parse::parser::Parser::parse_crate_mod
  19: syntax::parse::parse_crate_from_file
  20: rustc_interface::passes::parse::{{closure}}
  21: rustc::util::common::time
  22: rustc_interface::passes::parse
  23: rustc_interface::queries::Query<T>::compute
  24: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::parse
  25: rustc_interface::interface::run_compiler_in_existing_thread_pool
  26: std::thread::local::LocalKey<T>::with
  27: scoped_tls::ScopedKey<T>::set
  28: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
end of query stack
error: aborting due to previous error


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.38.0-nightly (71f9384e3 2019-07-12) running on x86_64-unknown-linux-gnu

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

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

This comment has been minimized.

@rustbot rustbot added A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 13, 2019
@goodmanjonathan
Copy link
Contributor

@rustbot claim

@estebank
Copy link
Contributor

@goodmanjonathan you will need to change the line

if let Ok(Some(mut arg)) = self.parse_self_arg() {

to bubble the parse_self_arg error up:

if let Some(mut arg) = self.parse_self_arg()? {

Once you've done that code change create a new test file in src/test/ui/parser/issue-62660.rs.

@estebank estebank added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jul 13, 2019
goodmanjonathan added a commit to goodmanjonathan/rust that referenced this issue Jul 14, 2019
If the explicitly given type of a `self` parameter fails to parse correctly,
we need to propagate the error rather than dropping it and causing an ICE.

Fixes rust-lang#62660.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 15, 2019
Fix rust-lang#62660

If the explicitly given type of a `self` parameter fails to parse correctly, we need to propagate the error rather than dropping it and causing an ICE.

Fixes rust-lang#62660.
bors added a commit that referenced this issue Jul 16, 2019
Rollup of 14 pull requests

Successful merges:

 - #62103 (Add debug assertions to write_bytes and copy*)
 - #62405 (Remove never_type feature requirement for exhaustive patterns)
 - #62491 (Fix Pin urls in Option documentation)
 - #62533 (Add missing links for CannotReallocInPlace type)
 - #62634 (Less unsafe in the array example of MaybeUninit docs)
 - #62639 (Make VaListImpl<'f> invariant over the 'f lifetime)
 - #62646 (Tweak wording in feature gate errors)
 - #62662 (add spaces in front of trait requirements in libcore/cell.rs)
 - #62668 (Fix #62660)
 - #62673 (miri validation: better error messages for dangling references)
 - #62680 (Actually call `visit_block_entry` in `DataflowResultsConsumer`)
 - #62685 (Add info about undefined behavior to as_ref suggestions)
 - #62689 (Fix typo in RawWaker::new documentation)
 - #62698 (SGX target: don't pretend to be GNU/Linux to LLVM)

Failed merges:

r? @ghost
bors added a commit that referenced this issue Jul 22, 2019
[beta] Rollup backports

Cherry picked:

* rustc_target: avoid negative register counts in the SysV x86_64 ABI. #62380
* Fix ICEs when `Self` is used in type aliases #62417
* Raise the default recursion limit to 128 #62450
* Handle errors during error recovery gracefully #62604
* Correctly break out of recovery loop #62607
* Cancel unemitted diagnostics during error recovery #62666
* ci: pin awscli dependencies #62856
* Ensure that checkout is with \n line endings #62564

Rolled up:

* [beta] Backport #62615 #62793
* [beta] Fix #62660 #62792

r? @ghost
bors added a commit that referenced this issue Jul 22, 2019
[beta] Rollup backports

Cherry picked:

* rustc_target: avoid negative register counts in the SysV x86_64 ABI. #62380
* Fix ICEs when `Self` is used in type aliases #62417
* Raise the default recursion limit to 128 #62450
* Handle errors during error recovery gracefully #62604
* Correctly break out of recovery loop #62607
* Cancel unemitted diagnostics during error recovery #62666
* ci: pin awscli dependencies #62856
* Ensure that checkout is with \n line endings #62564

Rolled up:

* [beta] Backport #62615 #62793
* [beta] Fix #62660 #62792

r? @ghost
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 A-parser Area: The parsing of Rust source code to an AST I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants