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: deref projection of non-dereferenceable ty with feature(type_alias_impl_trait) and polymorphization #126896

Closed
Naserume opened this issue Jun 24, 2024 · 1 comment · Fixed by #129472
Labels
-Zpolymorphize Unstable option: Polymorphization. C-bug Category: This is a bug. 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

@Naserume
Copy link

Code

#![feature(type_alias_impl_trait)]
type Two<'a, 'b> = impl std::fmt::Debug;

fn set(x: &mut isize) -> isize {
    *x
}

fn d(x: Two) {
    let c1 = || set(x);
    c1;
}

fn main() {
}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (bcf94dec5 2024-06-23)
binary: rustc
commit-hash: bcf94dec5ba6838e435902120c0384c360126a26
commit-date: 2024-06-23
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Command
/home/user/.cargo/bin/rustc ./E7BC0.rs -Zpolymorphize=on -Zinline-mir=yes

Error output

error[E0792]: expected generic lifetime parameter, found `'_`
 --> ./E7BC0.rs:9:17
  |
2 | type Two<'a, 'b> = impl std::fmt::Debug;
  |          -- this generic parameter must be used with a generic lifetime parameter
...
9 |     let c1 = || set(x);
  |                 ^^^^^^
Backtrace

error: internal compiler error: compiler/rustc_middle/src/mir/tcx.rs:83:21: deref projection of non-dereferenceable ty PlaceTy { ty: {type error}, variant_index: None }

thread 'rustc' panicked at compiler/rustc_middle/src/mir/tcx.rs:83:21:
Box<dyn Any>
stack backtrace:
   0:        0x10bae6b43 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he71f7af0ddafc64d
   1:        0x10bb3225b - core::fmt::write::h30d0e266faff29b6
   2:        0x10badcace - std::io::Write::write_fmt::he666ca78eb4b8406
   3:        0x10bae6931 - std::sys::backtrace::print::h22721f9ab9a2749a
   4:        0x10bae9709 - std::panicking::default_hook::{{closure}}::h145e29ed875d8021
   5:        0x10bae948a - std::panicking::default_hook::h5d437c7e6bf0e3b5
   6:        0x114d8147c - std[8efa578c02603ef9]::panicking::update_hook::<alloc[135510a28be92df]::boxed::Box<rustc_driver_impl[63f2171535a6fe49]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x10baea326 - std::panicking::rust_panic_with_hook::h6889093a56e48d04
   8:        0x114df0337 - std[8efa578c02603ef9]::panicking::begin_panic::<rustc_errors[8995f93e9c4bcc9a]::ExplicitBug>::{closure#0}
   9:        0x114ddc949 - std[8efa578c02603ef9]::sys::backtrace::__rust_end_short_backtrace::<std[8efa578c02603ef9]::panicking::begin_panic<rustc_errors[8995f93e9c4bcc9a]::ExplicitBug>::{closure#0}, !>
  10:        0x1197e2f09 - std[8efa578c02603ef9]::panicking::begin_panic::<rustc_errors[8995f93e9c4bcc9a]::ExplicitBug>
  11:        0x114e02276 - <rustc_errors[8995f93e9c4bcc9a]::diagnostic::BugAbort as rustc_errors[8995f93e9c4bcc9a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x115a9c95e - rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt::<rustc_span[aed5394308446158]::span_encoding::Span>::{closure#0}
  13:        0x115a522b7 - rustc_middle[4384e439927f71dd]::ty::context::tls::with_opt::<rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt<rustc_span[aed5394308446158]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:        0x115a51d75 - rustc_middle[4384e439927f71dd]::ty::context::tls::with_context_opt::<rustc_middle[4384e439927f71dd]::ty::context::tls::with_opt<rustc_middle[4384e439927f71dd]::util::bug::opt_span_bug_fmt<rustc_span[aed5394308446158]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:        0x1198a57eb - rustc_middle[4384e439927f71dd]::util::bug::bug_fmt
  16:        0x115a118af - <rustc_middle[4384e439927f71dd]::mir::tcx::PlaceTy>::projection_ty
  17:        0x115dfe1b0 - <rustc_mir_transform[6fada3a7f62d9c6e]::remove_zsts::Replacer as rustc_middle[4384e439927f71dd]::mir::visit::MutVisitor>::visit_operand
  18:        0x115dfdbf1 - <rustc_mir_transform[6fada3a7f62d9c6e]::remove_zsts::RemoveZsts as rustc_middle[4384e439927f71dd]::mir::MirPass>::run_pass
  19:        0x115d76f44 - rustc_mir_transform[6fada3a7f62d9c6e]::pass_manager::run_passes_inner
  20:        0x115e2a633 - rustc_mir_transform[6fada3a7f62d9c6e]::optimized_mir
  21:        0x11641c908 - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>
  22:        0x1161f724f - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::DefIdCache<rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  23:        0x116435849 - rustc_query_impl[a24e9023943e74ab]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  24:        0x115e5faef - rustc_middle[4384e439927f71dd]::query::plumbing::query_get_at::<rustc_query_system[30bd0146b5104221]::query::caches::DefIdCache<rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 8usize]>>>
  25:        0x115e9bf18 - rustc_monomorphize[7e44dc73c1b07443]::polymorphize::unused_generic_params
  26:        0x116420333 - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::unused_generic_params::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 4usize]>>
  27:        0x1163d4c0f - <rustc_query_impl[a24e9023943e74ab]::query_impl::unused_generic_params::dynamic_query::{closure#2} as core[9412a59d758dca42]::ops::function::FnOnce<(rustc_middle[4384e439927f71dd]::ty::context::TyCtxt, rustc_middle[4384e439927f71dd]::ty::instance::InstanceKind)>>::call_once
  28:        0x11625c12c - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::DefaultCache<rustc_middle[4384e439927f71dd]::ty::instance::InstanceKind, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 4usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  29:        0x11647a486 - rustc_query_impl[a24e9023943e74ab]::query_impl::unused_generic_params::get_query_non_incr::__rust_end_short_backtrace
  30:        0x1156dac81 - rustc_interface[73216d77aad0c3a5]::passes::run_required_analyses
  31:        0x1156dccb3 - rustc_interface[73216d77aad0c3a5]::passes::analysis
  32:        0x116422dec - rustc_query_impl[a24e9023943e74ab]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a24e9023943e74ab]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>
  33:        0x11620249e - rustc_query_system[30bd0146b5104221]::query::plumbing::try_execute_query::<rustc_query_impl[a24e9023943e74ab]::DynamicConfig<rustc_query_system[30bd0146b5104221]::query::caches::SingleCache<rustc_middle[4384e439927f71dd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a24e9023943e74ab]::plumbing::QueryCtxt, false>
  34:        0x11642d307 - rustc_query_impl[a24e9023943e74ab]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:        0x114d258d7 - <rustc_interface[73216d77aad0c3a5]::queries::QueryResult<&rustc_middle[4384e439927f71dd]::ty::context::GlobalCtxt>>::enter::<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  36:        0x114d7fc94 - rustc_interface[73216d77aad0c3a5]::interface::run_compiler::<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1}
  37:        0x114d6ec91 - std[8efa578c02603ef9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_with_globals<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_pool_with_globals<rustc_interface[73216d77aad0c3a5]::interface::run_compiler<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>
  38:        0x114d8a3a6 - <<std[8efa578c02603ef9]::thread::Builder>::spawn_unchecked_<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_with_globals<rustc_interface[73216d77aad0c3a5]::util::run_in_thread_pool_with_globals<rustc_interface[73216d77aad0c3a5]::interface::run_compiler<core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>, rustc_driver_impl[63f2171535a6fe49]::run_compiler::{closure#0}>::{closure#1}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9412a59d758dca42]::result::Result<(), rustc_span[aed5394308446158]::ErrorGuaranteed>>::{closure#2} as core[9412a59d758dca42]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:        0x10baf352b - std::sys::pal::unix::thread::Thread::new::thread_start::h68d49fa26efc1659
  40:     0x7ff801f5318b - __pthread_start

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 make sure that you have updated to the latest nightly

note: please attach the file at `/Users/Documents/rustc-ice-27151.txt` to your bug report

note: compiler flags: -Z polymorphize=on -Z inline-mir=yes

query stack during panic:
#0 [optimized_mir] optimizing MIR for `d::{closure#0}`
#1 [unused_generic_params] determining which generic parameters are unused by `d::{closure#0}`
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0792`.

@Naserume Naserume 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 Jun 24, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 24, 2024
@lqd lqd added the -Zpolymorphize Unstable option: Polymorphization. label Jun 24, 2024
@lqd
Copy link
Member

lqd commented Jun 24, 2024

The -Zpolymorphize=on flag is load-bearing here not the TAIT one. Anyways, bisects to #120550.

@lqd lqd changed the title ICE: deref projection of non-dereferenceable ty with feature(type_alias_impl_trait) ICE: deref projection of non-dereferenceable ty with feature(type_alias_impl_trait) and polymorphization Jun 24, 2024
@lqd lqd removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 24, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jul 5, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 5, 2024
…m-const, r=lcnr

fix ICE when `asm_const` and `const_refs_to_static` are combined

fixes rust-lang#129462
fixes rust-lang#126896
fixes rust-lang#124164

I think this is a case that was missed in the fix for rust-lang#125558, which inserts a type error in the case of an invalid (that is, non-integer) type being passed to an asm `const` operand.

I'm not 100% sure that `span_mirbug_and_err` is the right macro here, but it is used earlier with `builtin_deref` and seems to do the trick.

r? `@lcnr`
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 6, 2024
…m-const, r=lcnr

fix ICE when `asm_const` and `const_refs_to_static` are combined

fixes rust-lang#129462
fixes rust-lang#126896
fixes rust-lang#124164

I think this is a case that was missed in the fix for rust-lang#125558, which inserts a type error in the case of an invalid (that is, non-integer) type being passed to an asm `const` operand.

I'm not 100% sure that `span_mirbug_and_err` is the right macro here, but it is used earlier with `builtin_deref` and seems to do the trick.

r? ```@lcnr```
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 6, 2024
…m-const, r=lcnr

fix ICE when `asm_const` and `const_refs_to_static` are combined

fixes rust-lang#129462
fixes rust-lang#126896
fixes rust-lang#124164

I think this is a case that was missed in the fix for rust-lang#125558, which inserts a type error in the case of an invalid (that is, non-integer) type being passed to an asm `const` operand.

I'm not 100% sure that `span_mirbug_and_err` is the right macro here, but it is used earlier with `builtin_deref` and seems to do the trick.

r? ````@lcnr````
@bors bors closed this as completed in 3daa015 Sep 6, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 6, 2024
Rollup merge of rust-lang#129472 - folkertdev:const-refs-to-static-asm-const, r=lcnr

fix ICE when `asm_const` and `const_refs_to_static` are combined

fixes rust-lang#129462
fixes rust-lang#126896
fixes rust-lang#124164

I think this is a case that was missed in the fix for rust-lang#125558, which inserts a type error in the case of an invalid (that is, non-integer) type being passed to an asm `const` operand.

I'm not 100% sure that `span_mirbug_and_err` is the right macro here, but it is used earlier with `builtin_deref` and seems to do the trick.

r? ``@lcnr``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zpolymorphize Unstable option: Polymorphization. C-bug Category: This is a bug. 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

Successfully merging a pull request may close this issue.

4 participants