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 "... is not fully resolved'" with min_specialization and lifetime param #103708

Open
jruderman opened this issue Oct 29, 2022 · 5 comments
Open
Assignees
Labels
C-bug Category: This is a bug. F-specialization `#![feature(specialization)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jruderman
Copy link
Contributor

jruderman commented Oct 29, 2022

This ICEs with #![feature(min_specialization)]. Oddly enough, it does not ICE with #![feature(specialization)], which is supposedly more unstable.

Found by fuzzing.

edited: New example, still failing after #116663 (thanks @matthiaskrgr)

#![feature(min_specialization)]

trait MySpecTrait {
    fn f();
}

impl<'a, T: ?Sized> MySpecTrait for T {
    default fn f() {}
}

impl<'a, T: ?Sized> MySpecTrait for &'a T {
    fn f() {}
}

fn main() {}

Code

#![feature(min_specialization)]

trait Dance {}

impl<'a, T> Dance for T {}

impl Dance for bool {}

fn main() {}

Error output

thread 'rustc' panicked at '`Ok(['_#0r, bool])` is not fully resolved', compiler/rustc_infer/src/infer/mod.rs:1473:9
Full output with backtrace

thread 'rustc' panicked at '`Ok(['_#0r, bool])` is not fully resolved', /rustc/0da281b6068a7d889ae89a9bd8991284cc9b7535/compiler/rustc_infer/src/infer/mod.rs:1473:9
stack backtrace:
   0:        0x1070c68a2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h98e7719cdb057d8f
   1:        0x10711e74a - core::fmt::write::he324e6f3a7ef7ed0
   2:        0x1070b897c - std::io::Write::write_fmt::h295c914c323e508a
   3:        0x1070c666a - std::sys_common::backtrace::print::hb2f2bd76d0a1d9b2
   4:        0x1070c9a76 - std::panicking::default_hook::{{closure}}::h7f2a23a911934152
   5:        0x1070c97c7 - std::panicking::default_hook::h576cf5867894044c
   6:        0x114b9f62d - rustc_driver[ba5c792b9438c2b]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x1070ca271 - std::panicking::rust_panic_with_hook::hf0781b554a936fbf
   8:        0x1070ca003 - std::panicking::begin_panic_handler::{{closure}}::h8d2525e276d552d8
   9:        0x1070c6d38 - std::sys_common::backtrace::__rust_end_short_backtrace::hf3badbbd5492e2d6
  10:        0x1070c9ccd - _rust_begin_unwind
  11:        0x10714b1b3 - core::panicking::panic_fmt::h15d4409e62dc090a
  12:        0x11757859f - <rustc_infer[b40902abbc4e8850]::infer::InferCtxt>::fully_resolve::<&rustc_middle[298407787cc28eff]::ty::list::List<rustc_middle[298407787cc28eff]::ty::subst::GenericArg>>
  13:        0x1175fee24 - rustc_hir_analysis[3f5a3f8b91adb05]::impl_wf_check::min_specialization::check_always_applicable
  14:        0x1175fe8da - rustc_hir_analysis[3f5a3f8b91adb05]::impl_wf_check::min_specialization::check_min_specialization
  15:        0x1175aaf07 - rustc_hir_analysis[3f5a3f8b91adb05]::impl_wf_check::check_mod_impl_wf
  16:        0x11838d855 - rustc_query_system[fd3d689380a50de4]::query::plumbing::try_execute_query::<rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt, rustc_query_system[fd3d689380a50de4]::query::caches::DefaultCache<rustc_span[73e074df7cba0abf]::def_id::LocalDefId, ()>>
  17:        0x11847c845 - rustc_query_system[fd3d689380a50de4]::query::plumbing::get_query::<rustc_query_impl[f77634870212a75e]::queries::check_mod_impl_wf, rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt>
  18:        0x117611608 - <rustc_middle[298407787cc28eff]::hir::map::Map>::for_each_module::<rustc_hir_analysis[3f5a3f8b91adb05]::check_crate::{closure#2}::{closure#0}::{closure#0}>
  19:        0x1176027d1 - <rustc_session[43d2d941ace548e5]::session::Session>::track_errors::<rustc_hir_analysis[3f5a3f8b91adb05]::check_crate::{closure#2}, ()>
  20:        0x1175b22fb - rustc_hir_analysis[3f5a3f8b91adb05]::check_crate
  21:        0x114c77fda - rustc_interface[a666f6d755ed9279]::passes::analysis
  22:        0x11841026c - rustc_query_system[fd3d689380a50de4]::query::plumbing::try_execute_query::<rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt, rustc_query_system[fd3d689380a50de4]::query::caches::DefaultCache<(), core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>>
  23:        0x11848a3f9 - rustc_query_system[fd3d689380a50de4]::query::plumbing::get_query::<rustc_query_impl[f77634870212a75e]::queries::analysis, rustc_query_impl[f77634870212a75e]::plumbing::QueryCtxt>
  24:        0x114b2e296 - <rustc_interface[a666f6d755ed9279]::passes::QueryContext>::enter::<rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>
  25:        0x114b72a4d - rustc_span[73e074df7cba0abf]::with_source_map::<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  26:        0x114b6234c - <scoped_tls[c17fceff1b2b43d8]::ScopedKey<rustc_span[73e074df7cba0abf]::SessionGlobals>>::set::<rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>
  27:        0x114b31e5a - std[8878bd7dd366d71b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a666f6d755ed9279]::util::run_in_thread_pool_with_globals<rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>
  28:        0x114b17f7b - <<std[8878bd7dd366d71b]::thread::Builder>::spawn_unchecked_<rustc_interface[a666f6d755ed9279]::util::run_in_thread_pool_with_globals<rustc_interface[a666f6d755ed9279]::interface::run_compiler<core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>, rustc_driver[ba5c792b9438c2b]::run_compiler::{closure#1}>::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[13371b8ce97f01bb]::result::Result<(), rustc_errors[b0e16a209d58ca7d]::ErrorGuaranteed>>::{closure#1} as core[13371b8ce97f01bb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:        0x1070d3387 - std::sys::unix::thread::Thread::new::thread_start::hfd54df40dd14130e
  30:     0x7ff814d514e1 - __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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.66.0-nightly (0da281b60 2022-10-27) running on x86_64-apple-darwin

query stack during panic:
#0 [check_mod_impl_wf] checking that impls are well-formed in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack

Regression

Bisected to 6365e5a (#102903, @compiler-errors).

But that's just when the assertion was added.

Bisection details

searched nightlies: from nightly-2022-10-26 to nightly-2022-10-28
regressed nightly: nightly-2022-10-27
searched commit range: bed4ad6...1898c34
regressed commit: 6365e5a

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-apple-darwin

Version

rustc --version --verbose:

rustc 1.66.0-nightly (0da281b60 2022-10-27)
binary: rustc
commit-hash: 0da281b6068a7d889ae89a9bd8991284cc9b7535
commit-date: 2022-10-27
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2
@jruderman jruderman added C-bug Category: This is a bug. 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 Oct 29, 2022
@compiler-errors
Copy link
Member

compiler-errors commented Oct 29, 2022

😃 i'm glad that the assertion found something! worth investigating at least.

i'll take a look at it, though I'm not exactly sure why Rust allows us to have an unconstrained lifetime parameter in the impl :/

(.. this is why)

// (*) This is a horrible concession to reality. I think it'd be
// better to just ban unconstrained lifetimes outright, but in
// practice people do non-hygienic macros like:
//
// ```
// macro_rules! __impl_slice_eq1 {
// ($Lhs: ty, $Rhs: ty, $Bound: ident) => {
// impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> {
// ....
// }
// }
// }
// ```
//
// In a concession to backwards compatibility, we continue to
// permit those, so long as the lifetimes aren't used in
// associated types. I believe this is sound, because lifetimes
// used elsewhere are not projected back out.

(maybe we can just hack it away by unifying unconstrained lifetime parameters to 'static... cc @jackh726)

@matthiaskrgr
Copy link
Member

Hah, looks like #116663 DID actually fix this 🙃

@matthiaskrgr matthiaskrgr added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 19, 2023
@compiler-errors
Copy link
Member

buy one get one free

@compiler-errors
Copy link
Member

Also this should still ICE:

#![feature(min_specialization)]

trait Dance {
    fn foo();
}

impl<'a, T> Dance for T {
    fn foo() {}
}

impl Dance for bool {
    fn foo() {}
}

fn main() {}

The root cause for this issue is not fixed.

@compiler-errors compiler-errors removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 19, 2023
@matthiaskrgr matthiaskrgr added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Jan 9, 2024
@matthiaskrgr
Copy link
Member

ah nvm, this one is fixed #103708 (comment) but
this one (see top comment)

#![feature(min_specialization)]

trait MySpecTrait {
    fn f();
}

impl<'a, T: ?Sized> MySpecTrait for T {
    default fn f() {}
}

impl<'a, T: ?Sized> MySpecTrait for &'a T {
    fn f() {}
}

isnt

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

error: internal compiler error: `['?0, &ReEarlyParam(DefId(0:10 ~ c[ed0c]::{impl#1}::'a), 0, 'a) T/#1]` is not fully resolved
  |
  = note: delayed at /rustc/ca663b06c5492ac2dde5e53cd11579fa8e4d68bd/compiler/rustc_infer/src/infer/mod.rs:1440:26
             0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
             1: <rustc_errors::DiagCtxt>::emit_diagnostic
             2: <rustc_errors::DiagCtxt>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
             3: rustc_hir_analysis::impl_wf_check::min_specialization::get_impl_args
             4: rustc_hir_analysis::impl_wf_check::check_mod_impl_wf
             5: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_mod_impl_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
             6: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
             7: rustc_query_impl::query_impl::check_mod_impl_wf::get_query_non_incr::__rust_end_short_backtrace
             8: rustc_hir_analysis::check_crate
             9: rustc_interface::passes::analysis
            10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 1]>>
            11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            12: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
            13: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
            14: std::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
            15: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
            16: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/ca663b06c5492ac2dde5e53cd11579fa8e4d68bd/library/alloc/src/boxed.rs:2016:9
            17: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                       at /rustc/ca663b06c5492ac2dde5e53cd11579fa8e4d68bd/library/alloc/src/boxed.rs:2016:9
            18: std::sys::unix::thread::Thread::new::thread_start
                       at /rustc/ca663b06c5492ac2dde5e53cd11579fa8e4d68bd/library/std/src/sys/unix/thread.rs:108:17
            19: <unknown>
            20: <unknown>


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: please attach the file at `/tmp/ices/ticket/rustc-ice-2024-01-09T23_15_14-1749787.txt` to your bug report

query stack during panic:
end of query stack
error: aborting due to 2 previous errors

@matthewjasper matthewjasper added the F-specialization `#![feature(specialization)]` label Apr 19, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 20, 2024
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. F-specialization `#![feature(specialization)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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

5 participants