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

rustc panics on invalid syntax where T: !u64 #59051

Closed
hawkrives opened this issue Mar 9, 2019 · 3 comments
Closed

rustc panics on invalid syntax where T: !u64 #59051

hawkrives opened this issue Mar 9, 2019 · 3 comments
Labels
A-parser Area: The parsing of Rust source code to an AST I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@hawkrives
Copy link

I tried this code:

trait Thing {}

impl<T> Thing for Option<T> where T: !u64 {}

Now, I realize that that's invalid code, but I expected an error message instead of a panic?

For example, rustfmt reports:

error: expected one of `(`, `,`, `?`, `for`, `{`, lifetime, or path, found `!`
 --> /Users/rives/Projects/gobbldygook-area-auditor/foo.rs:3:38
  |
3 | impl<T> Thing for Option<T> where T: !u64 {}
  |                                      ^ expected one of 7 possible tokens here

Meta

rustup run nightly -- rustc --version --verbose:

rustc 1.35.0-nightly (2a65cbe 2019-03-08)
binary: rustc
commit-hash: 2a65cbe
commit-date: 2019-03-08
host: x86_64-apple-darwin
release: 1.35.0-nightly
LLVM version: 8.0

Backtrace:

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:345:21
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::panicking::panic
   9: syntax::parse::parser::Parser::parse_generic_bounds_common
  10: syntax::parse::parser::Parser::parse_where_clause
  11: syntax::parse::parser::Parser::parse_item_implementation
  12: syntax::parse::parser::Parser::parse_item_
  13: syntax::parse::parser::Parser::parse_item
  14: syntax::parse::parser::Parser::parse_mod_items
  15: syntax::parse::parser::Parser::parse_crate_mod
  16: syntax::parse::parse_crate_from_file
  17: rustc_driver::driver::phase_1_parse_input::{{closure}}
  18: rustc::util::common::time
  19: rustc_driver::driver::phase_1_parse_input
  20: rustc_driver::driver::compile_input
  21: rustc_driver::run_compiler_with_pool
  22: <scoped_tls::ScopedKey<T>>::set
  23: rustc_driver::run_compiler
  24: syntax::with_globals
  25: __rust_maybe_catch_panic
  26: <F as alloc::boxed::FnBox<A>>::call_box
  27: std::sys::unix::thread::Thread::new::thread_start
  28: _pthread_body
  29: _pthread_start

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.35.0-nightly (2a65cbeea 2019-03-08) running on x86_64-apple-darwin
@jonas-schievink
Copy link
Contributor

Might be duplicate of #58857 - please check with the next nightly, which should contain #58861

@hawkrives
Copy link
Author

Yep! Looks like a duplicate of that issue. I'll be sure to test the next nightly.

@estebank estebank added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-parser Area: The parsing of Rust source code to an AST labels Mar 9, 2019
@estebank
Copy link
Contributor

estebank commented Mar 9, 2019

Confirmed fixed in master:

error: negative trait bounds are not supported
 --> file.rs:3:36
  |
3 | impl<T> Thing for Option<T> where T: !u64 {}
  |                                    ^^^^^^ help: remove the trait bound

@estebank estebank closed this as completed Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants