Skip to content

ICE: Drop impl without drop function #110858

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

#![allow(unused)]
#![feature(const_trait_impl, inline_const, negative_impls)]

use std::marker::Destruct;

const fn f<T: ~const Destruct>(x: T) {}

struct UnconstDrop;

impl Drop for UnconstDrop {
    fn drop(&mut self) {}
}

struct NonDrop;

impl !Drop for NonDrop {}

fn main() {
    const {}
}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (458d4dae8 2023-04-25)
binary: rustc
commit-hash: 458d4dae845ec155b285681a5b88305641abb868
commit-date: 2023-04-25
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

Error output

<output>
Backtrace

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

error: internal compiler error: Drop impl without drop function
  --> 4/40B2C0CCC0AB3AEC0083CAF0738647A6D11BD9BA2F3B1DEF7211B7BD15FD7A77.rs:16:1
   |
16 | impl !Drop for NonDrop {}
   | ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at    0: <rustc_errors::HandlerInner>::emit_diagnostic
              1: <rustc_errors::Handler>::delay_span_bug::<rustc_span::span_encoding::Span, &str>
              2: <rustc_middle::ty::context::TyCtxt>::calculate_dtor::<rustc_hir_analysis::check::dropck::check_drop_impl>::{closure#0}
              3: <rustc_middle::ty::context::TyCtxt>::calculate_dtor::<rustc_hir_analysis::check::dropck::check_drop_impl>
              4: rustc_hir_analysis::check::adt_destructor
              5: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::adt_destructor, rustc_query_impl::plumbing::QueryCtxt>
              6: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::adt_destructor
              7: <rustc_middle::ty::adt::AdtDef>::destructor
              8: rustc_hir_analysis::check::check::check_mod_item_types
              9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
             10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
             11: <rustc_middle::hir::map::Map>::for_each_module::<rustc_hir_analysis::check_crate::{closure#6}::{closure#0}>
             12: <rustc_session::session::Session>::time::<(), rustc_hir_analysis::check_crate::{closure#6}>
             13: rustc_hir_analysis::check_crate
             14: rustc_interface::passes::analysis
             15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
             16: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
             17: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             18: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
             19: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
             20: std::sys_common::backtrace::__rust_begin_short_backtrace::<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#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
             21: <<std::thread::Builder>::spawn_unchecked_<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#1}>::{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}
             22: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/458d4dae845ec155b285681a5b88305641abb868/library/alloc/src/boxed.rs:1962:9
             23: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
                        at /rustc/458d4dae845ec155b285681a5b88305641abb868/library/alloc/src/boxed.rs:1962:9
             24: std::sys::unix::thread::Thread::new::thread_start
                        at /rustc/458d4dae845ec155b285681a5b88305641abb868/library/std/src/sys/unix/thread.rs:108:17
             25: <unknown>
             26: <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: rustc 1.71.0-nightly (458d4dae8 2023-04-25) running on x86_64-unknown-linux-gnu

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

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions