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 on edition 2018 with anonymous impl lifetime in the wrong place #52098

Closed
zackmdavis opened this issue Jul 6, 2018 · 2 comments · Fixed by #55162
Closed

ICE on edition 2018 with anonymous impl lifetime in the wrong place #52098

zackmdavis opened this issue Jul 6, 2018 · 2 comments · Fixed by #55162
Assignees
Labels
A-edition-2018 Area: The 2018 edition A-lifetimes Area: Lifetimes / regions F-rust_2018_preview `#![feature(rust_2018_preview)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@zackmdavis
Copy link
Member

Reduced:

struct IceCube<'a> {
    v: Vec<&'a char>
}

impl<'_> IceCube {}

fn main() {}

(Correct) errors on edition 2015:

zmd@ReflectiveCoherence:~/Code/Misc$ rustc +nightly icy.rs 
error[E0262]: invalid lifetime parameter name: `'_`
 --> icy.rs:5:6
  |
5 | impl<'_> IceCube {}
  |      ^^ '_ is a reserved lifetime name

error[E0106]: missing lifetime specifier
 --> icy.rs:5:10
  |
5 | impl<'_> IceCube {}
  |          ^^^^^^^ expected lifetime parameter

error: aborting due to 2 previous errors

Some errors occurred: E0106, E0262.
For more information about an error, try `rustc --explain E0106`.

Stacktrace on edition 2018:

zmd@ReflectiveCoherence:~/Code/Misc$ RUST_BACKTRACE=full rustc +nightly icy.rs --edition 2018
thread 'main' panicked at 'assertion failed: self.is_collecting_in_band_lifetimes', librustc/hir/lowering.rs:735:9
stack backtrace:
   0:     0x7f7b651c10fe - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h50a634a60cb4e5f7
                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7f7b651984b6 - std::sys_common::backtrace::print::hfdd27bb0425df770
                               at libstd/sys_common/backtrace.rs:71
                               at libstd/sys_common/backtrace.rs:59
   2:     0x7f7b651c834d - std::panicking::default_hook::{{closure}}::h027136eae47935d0
                               at libstd/panicking.rs:211
   3:     0x7f7b651c80c0 - std::panicking::default_hook::hed5917d304f00a1b
                               at libstd/panicking.rs:227
   4:     0x7f7b6185a3e5 - rustc::util::common::panic_hook::h9e9cb098ca9688d6
   5:     0x7f7b651c8ad3 - std::panicking::rust_panic_with_hook::hc482345e1eead25b
                               at libstd/panicking.rs:515
   6:     0x7f7b612a4336 - std::panicking::begin_panic::hc99c40d451548ee4
   7:     0x7f7b6180c531 - rustc::hir::lowering::LoweringContext::lower_lifetime::hde6e623ecce2735f
   8:     0x7f7b617a4e2b - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &'a mut F>::call_once::h7b1ed582bf44fa1a
   9:     0x7f7b613ac666 - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter::h942b3350b2cd31a5
  10:     0x7f7b6180c96f - rustc::hir::lowering::LoweringContext::lower_generics::hcf6e7430f81e15a4
  11:     0x7f7b61810dff - rustc::hir::lowering::LoweringContext::lower_item::hf3bbbc3afed70764
  12:     0x7f7b617fe81b - <rustc::hir::lowering::LoweringContext::lower_crate::ItemLowerer<'lcx, 'interner> as syntax::visit::Visitor<'lcx>>::visit_item::h8578ba219875c385
  13:     0x7f7b617fd84a - rustc::hir::lowering::lower_crate::hba78ac42c9a968fe
  14:     0x7f7b6556f1e6 - rustc::util::common::time::h116d0a6c5fad3bc0
  15:     0x7f7b65563e50 - rustc_driver::driver::phase_2_configure_and_expand::h805364562785bbc9
  16:     0x7f7b6555e81b - rustc_driver::driver::compile_input::h95eb8b7dd032d269
  17:     0x7f7b655eb295 - rustc_driver::run_compiler_with_pool::h94fbd18de41dc2e2
  18:     0x7f7b6554f97b - <scoped_tls::ScopedKey<T>>::set::h4c03440eebe30a1f
  19:     0x7f7b65524f2a - syntax::with_globals::h57af6031309babcc
  20:     0x7f7b65505722 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hb1f190602052e50b
  21:     0x7f7b651d6c59 - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:105
  22:     0x7f7b655e8423 - rustc_driver::run::h7fa1696458a8f761
  23:     0x7f7b655f826a - rustc_driver::main::he4d005c782d5073a
  24:     0x55c2d9ebbb52 - std::rt::lang_start::{{closure}}::h99d53d66d7fac3dd
  25:     0x7f7b651c8512 - std::panicking::try::do_call::h7e0ed4dd1b773c21
                               at libstd/rt.rs:59
                               at libstd/panicking.rs:310
  26:     0x7f7b651d6c59 - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:105
  27:     0x7f7b6518cd55 - std::rt::lang_start_internal::h7c38f1310577c409
                               at libstd/panicking.rs:289
                               at libstd/panic.rs:392
                               at libstd/rt.rs:58
  28:     0x55c2d9ebbbb3 - main
  29:     0x7f7b64d9082f - __libc_start_main
  30:     0x55c2d9ebba38 - <unknown>
query stack during panic:
end of query stack

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.28.0-nightly (e3bf634e0 2018-06-28) running on x86_64-unknown-linux-gnu

The failing assertion is during HIR lowering.

zmd@ReflectiveCoherence:~/Code/Misc$ rustc +nightly --version --verbose
rustc 1.28.0-nightly (e3bf634e0 2018-06-28)
binary: rustc
commit-hash: e3bf634e060bc2f8665878288bcea02008ca346e
commit-date: 2018-06-28
host: x86_64-unknown-linux-gnu
release: 1.28.0-nightly
LLVM version: 6.0
@oli-obk oli-obk added A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ F-rust_2018_preview `#![feature(rust_2018_preview)]` labels Jul 6, 2018
@aturon aturon modified the milestones: Rust 2018 RC, Edition RC 2 Sep 5, 2018
@nikomatsakis nikomatsakis added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-nominated labels Oct 4, 2018
@nikomatsakis
Copy link
Contributor

Nominating for prioritization. RC2 blocker, it seems.

@pnkfelix
Copy link
Member

visited at compiler team mtg. Should be handled by PR #55162

bors added a commit that referenced this issue Oct 19, 2018
…mandry

handle underscore bounds in unexpected places

Per the discussion on #54902, I made it a hard error to use lifetime bounds in various places where they used to be permitted:

- `where Foo: Bar<'_>` for example

I also moved error reporting to HIR lowering and added `Error` variants to let us suppress downstream errors that result.

I (imo) improved the error message wording to be clearer, as well.

In the process, I fixed the ICE in #52098.

Fixes #54902
Fixes #52098
@fmease fmease added the A-edition-2018 Area: The 2018 edition label Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018 Area: The 2018 edition A-lifetimes Area: Lifetimes / regions F-rust_2018_preview `#![feature(rust_2018_preview)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority 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.

7 participants