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] Unresolved HRTB lifetime in APIT #96954

Closed
jackh726 opened this issue May 11, 2022 · 5 comments · Fixed by #97683
Closed

[ICE] Unresolved HRTB lifetime in APIT #96954

jackh726 opened this issue May 11, 2022 · 5 comments · Fixed by #97683
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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.

Comments

@jackh726
Copy link
Member

jackh726 commented May 11, 2022

This ICEs on nightly, but only errors in stable or beta: fn test_argument_position(x: impl for<'a> Tr<'a, Assoc = impl Copy + 'a>) {}

playground

Code

trait Tr<'a> {
	type Assoc;
}
fn test_argument_position(x: impl for<'a> Tr<'a, Assoc = impl Copy + 'a>)  {}
fn main() {}
Backtrace

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Could not resolve lifetime(HirId { owner: DefId(0:6 ~ playground[24bf]::test_argument_position), local_id: 9 }: 'a) in scope Binder {
                                    lifetimes: {},
                                    next_early_index: 2,
                                    track_lifetime_uses: true,
                                    opaque_type_parent: false,
                                    scope_type: Normal,
                                    hir_id: HirId {
                                        owner: DefId(0:6 ~ playground[24bf]::test_argument_position),
                                        local_id: 11,
                                    },
                                    s: TraitRefBoundary {
                                        s: Binder {
                                            lifetimes: {},
                                            next_early_index: 2,
                                            track_lifetime_uses: false,
                                            opaque_type_parent: true,
                                            scope_type: Normal,
                                            hir_id: HirId {
                                                owner: DefId(0:6 ~ playground[24bf]::test_argument_position),
                                                local_id: 0,
                                            },
                                            s: Root,
                                            allow_late_bound: true,
                                        },
                                    },
                                    allow_late_bound: true,
                                }
 --> src/main.rs:5:70
  |
5 | fn test_argument_position(x: impl for<'a> Tr<'a, Assoc = impl Copy + 'a>)  {}
  |                                                                      ^^
  |
  = note: delayed at compiler/rustc_resolve/src/late/lifetimes.rs:2316:27

error: internal compiler error: unelided lifetime in signature
 --> src/main.rs:5:70
  |
5 | fn test_argument_position(x: impl for<'a> Tr<'a, Assoc = impl Copy + 'a>)  {}
  |                                                                      ^^
  |
  = note: delayed at compiler/rustc_typeck/src/astconv/mod.rs:250:30

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1369:13
stack backtrace:
   0:     0x7f076b75be7d - std::backtrace_rs::backtrace::libunwind::trace::h85cc47332f2b05a9
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f076b75be7d - std::backtrace_rs::backtrace::trace_unsynchronized::h822c2fc2b1a1a752
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f076b75be7d - std::sys_common::backtrace::_print_fmt::h678c9b8abf6c5083
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f076b75be7d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2fb21895faf729c2
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f076b7b7afc - core::fmt::write::h6dc4a63f2d3360d8
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/core/src/fmt/mod.rs:1196:17
   5:     0x7f076b74d561 - std::io::Write::write_fmt::h8fe2d520dd3fbf2e
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/io/mod.rs:1654:15
   6:     0x7f076b75eb95 - std::sys_common::backtrace::_print::h6c3478d5fa62e7d8
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f076b75eb95 - std::sys_common::backtrace::print::hd6d4473e0c0113a9
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f076b75eb95 - std::panicking::default_hook::{{closure}}::h4dec78d051eecf7c
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:295:22
   9:     0x7f076b75e809 - std::panicking::default_hook::hc13b58dcc91e88ba
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:314:9
  10:     0x7f076bf20b21 - rustc_driver[d4386f1a79afc323]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f076b75f366 - std::panicking::rust_panic_with_hook::h3dd403ae323eac6a
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/panicking.rs:702:17
  12:     0x7f076d08c921 - std[d9fedb1e1dbc9663]::panicking::begin_panic::<rustc_errors[b91ec0213766c8bc]::ExplicitBug>::{closure#0}
  13:     0x7f076d08b716 - std[d9fedb1e1dbc9663]::sys_common::backtrace::__rust_end_short_backtrace::<std[d9fedb1e1dbc9663]::panicking::begin_panic<rustc_errors[b91ec0213766c8bc]::ExplicitBug>::{closure#0}, !>
  14:     0x7f076d09d786 - std[d9fedb1e1dbc9663]::panicking::begin_panic::<rustc_errors[b91ec0213766c8bc]::ExplicitBug>
  15:     0x7f076d0a1816 - std[d9fedb1e1dbc9663]::panic::panic_any::<rustc_errors[b91ec0213766c8bc]::ExplicitBug>
  16:     0x7f076e85adcb - <rustc_errors[b91ec0213766c8bc]::HandlerInner as core[9ba3ef39911e8828]::ops::drop::Drop>::drop
  17:     0x7f076dfb2bb8 - core[9ba3ef39911e8828]::ptr::drop_in_place::<rustc_session[93b3d23ec172418c]::parse::ParseSess>
  18:     0x7f076dfb4ec3 - <alloc[4e51958440f9dea6]::rc::Rc<rustc_session[93b3d23ec172418c]::session::Session> as core[9ba3ef39911e8828]::ops::drop::Drop>::drop
  19:     0x7f076dfb197d - core[9ba3ef39911e8828]::ptr::drop_in_place::<rustc_interface[50aa842067ddf2a9]::interface::Compiler>
  20:     0x7f076dfb1124 - rustc_span[5ada1bf86533b524]::with_source_map::<core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>, rustc_interface[50aa842067ddf2a9]::interface::create_compiler_and_run<core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>, rustc_driver[d4386f1a79afc323]::run_compiler::{closure#1}>::{closure#1}>
  21:     0x7f076df89824 - rustc_interface[50aa842067ddf2a9]::interface::create_compiler_and_run::<core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>, rustc_driver[d4386f1a79afc323]::run_compiler::{closure#1}>
  22:     0x7f076df870d2 - <scoped_tls[48edcdfa9356486f]::ScopedKey<rustc_span[5ada1bf86533b524]::SessionGlobals>>::set::<rustc_interface[50aa842067ddf2a9]::interface::run_compiler<core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>, rustc_driver[d4386f1a79afc323]::run_compiler::{closure#1}>::{closure#0}, core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>>
  23:     0x7f076df9e1ef - std[d9fedb1e1dbc9663]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[50aa842067ddf2a9]::util::run_in_thread_pool_with_globals<rustc_interface[50aa842067ddf2a9]::interface::run_compiler<core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>, rustc_driver[d4386f1a79afc323]::run_compiler::{closure#1}>::{closure#0}, core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>>::{closure#0}, core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>>
  24:     0x7f076df9e329 - <<std[d9fedb1e1dbc9663]::thread::Builder>::spawn_unchecked_<rustc_interface[50aa842067ddf2a9]::util::run_in_thread_pool_with_globals<rustc_interface[50aa842067ddf2a9]::interface::run_compiler<core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>, rustc_driver[d4386f1a79afc323]::run_compiler::{closure#1}>::{closure#0}, core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>>::{closure#0}, core[9ba3ef39911e8828]::result::Result<(), rustc_errors[b91ec0213766c8bc]::ErrorGuaranteed>>::{closure#1} as core[9ba3ef39911e8828]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f076b769273 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8e61158325523155
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/alloc/src/boxed.rs:1872:9
  26:     0x7f076b769273 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha439966d612c01d5
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/alloc/src/boxed.rs:1872:9
  27:     0x7f076b769273 - std::sys::unix::thread::Thread::new::thread_start::hf215f8619fb489d4
                               at /rustc/ecd44958e0a21110d09862ee080d95a4ca6c52f8/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f076b699609 - start_thread
  29:     0x7f076b5b2163 - clone
  30:                0x0 - <unknown>

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.62.0-nightly (ecd44958e 2022-05-10) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
end of query stack

@jackh726 jackh726 added 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. C-bug Category: This is a bug. labels May 11, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 11, 2022
@matthiaskrgr
Copy link
Member

This regressed in #95779

searched toolchains 878c7833f6c1ff10e2fd89074e5bd4ef5ff15936 through ec77f252434a532fdb5699ae4f21a3072d211edd


********************************************************************************
Regression in 1ec2c136b35bd4660cba778346f8df7daf2ab173
********************************************************************************

@jackh726
Copy link
Member Author

cc @cjgillot

@cjgillot cjgillot self-assigned this May 11, 2022
@cjgillot
Copy link
Contributor

The bug comes from a difference between the old and the new analysis. The old analysis was incorrect in that case: there should not be an error, impl Copy + 'a resolves to the for<'a> lifetime.
I'm not really sure what the correct fix should be.

@jackh726
Copy link
Member Author

Related discussion: https://rust-lang.zulipchat.com/#narrow/stream/245100-t-compiler.2Fwg-prioritization.2Falerts/topic/.2396194.20nested.20RPIT.20and.20HRTB.3A.20unclear.20semantics.20and.20future.20i.E2.80.A6/near/282011425

Correct fix (at least for now) is probably to change this back to an error - along with the case above. After that, correct fix is probably to treat this as a for<'a> (which is done in associated type bounds).

@apiraino
Copy link
Contributor

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 12, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 12, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 5, 2022
Fail gracefully when encountering an HRTB in APIT.

Fixes rust-lang#96954

~The first commit will be merged as part of rust-lang#97415
@bors bors closed this as completed in f2b3808 Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants