about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/adt.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-10-29 20:08:55 +0000
committerMichael Goulet <michael@errs.io>2024-11-22 16:54:40 +0000
commit59408add4d67e7e04fa1dcf378e4e1cc71c6ff48 (patch)
treeb9d50a919f1f8667097b6236cc177c4029b9019a /compiler/rustc_middle/src/ty/adt.rs
parenta7d9ebdf088f166e91759ec5b3b0625e3c1d0c82 (diff)
downloadrust-59408add4d67e7e04fa1dcf378e4e1cc71c6ff48.tar.gz
rust-59408add4d67e7e04fa1dcf378e4e1cc71c6ff48.zip
Implement ~const Destruct in new solver
Diffstat (limited to 'compiler/rustc_middle/src/ty/adt.rs')
-rw-r--r--compiler/rustc_middle/src/ty/adt.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs
index 79d56702be2..447cbc8932e 100644
--- a/compiler/rustc_middle/src/ty/adt.rs
+++ b/compiler/rustc_middle/src/ty/adt.rs
@@ -18,6 +18,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable};
 use rustc_query_system::ich::StableHashingContext;
 use rustc_session::DataTypeKind;
 use rustc_span::symbol::sym;
+use rustc_type_ir::solve::AdtDestructorKind;
 use tracing::{debug, info, trace};
 
 use super::{
@@ -232,6 +233,13 @@ impl<'tcx> rustc_type_ir::inherent::AdtDef<TyCtxt<'tcx>> for AdtDef<'tcx> {
     fn is_fundamental(self) -> bool {
         self.is_fundamental()
     }
+
+    fn destructor(self, tcx: TyCtxt<'tcx>) -> Option<AdtDestructorKind> {
+        Some(match self.destructor(tcx)?.constness {
+            hir::Constness::Const => AdtDestructorKind::Const,
+            hir::Constness::NotConst => AdtDestructorKind::NotConst,
+        })
+    }
 }
 
 #[derive(Copy, Clone, Debug, Eq, PartialEq, HashStable, TyEncodable, TyDecodable)]
@@ -402,10 +410,6 @@ impl<'tcx> AdtDef<'tcx> {
         self.destructor(tcx).is_some()
     }
 
-    pub fn has_non_const_dtor(self, tcx: TyCtxt<'tcx>) -> bool {
-        matches!(self.destructor(tcx), Some(Destructor { constness: hir::Constness::NotConst, .. }))
-    }
-
     /// Asserts this is a struct or union and returns its unique variant.
     pub fn non_enum_variant(self) -> &'tcx VariantDef {
         assert!(self.is_struct() || self.is_union());