about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/impl_wf_check
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-11-23 01:00:11 +0000
committerMichael Goulet <michael@errs.io>2024-12-02 22:21:53 +0000
commit9bda88bb58c1c6fa175166a7d5272f483eac38c8 (patch)
tree9d1d45a29b5738d4f86c28415fab163ecf5993a8 /compiler/rustc_hir_analysis/src/impl_wf_check
parente91fc1bc0c05da68d218a01d550c6d12297f5703 (diff)
downloadrust-9bda88bb58c1c6fa175166a7d5272f483eac38c8.tar.gz
rust-9bda88bb58c1c6fa175166a7d5272f483eac38c8.zip
Fix const specialization
Diffstat (limited to 'compiler/rustc_hir_analysis/src/impl_wf_check')
-rw-r--r--compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs26
1 files changed, 0 insertions, 26 deletions
diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs
index 246643d8074..ee55e1bc21a 100644
--- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs
+++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs
@@ -66,7 +66,6 @@
 //! on traits with methods can.
 
 use rustc_data_structures::fx::FxHashSet;
-use rustc_hir as hir;
 use rustc_hir::def_id::{DefId, LocalDefId};
 use rustc_infer::infer::TyCtxtInferExt;
 use rustc_infer::infer::outlives::env::OutlivesEnvironment;
@@ -134,7 +133,6 @@ fn check_always_applicable(
         unconstrained_parent_impl_args(tcx, impl2_def_id, impl2_args)
     };
 
-    res = res.and(check_constness(tcx, impl1_def_id, impl2_node, span));
     res = res.and(check_static_lifetimes(tcx, &parent_args, span));
     res = res.and(check_duplicate_params(tcx, impl1_args, parent_args, span));
     res = res.and(check_predicates(tcx, impl1_def_id, impl1_args, impl2_node, impl2_args, span));
@@ -157,30 +155,6 @@ fn check_has_items(
     Ok(())
 }
 
-/// Check that the specializing impl `impl1` is at least as const as the base
-/// impl `impl2`
-fn check_constness(
-    tcx: TyCtxt<'_>,
-    impl1_def_id: LocalDefId,
-    impl2_node: Node,
-    span: Span,
-) -> Result<(), ErrorGuaranteed> {
-    if impl2_node.is_from_trait() {
-        // This isn't a specialization
-        return Ok(());
-    }
-
-    let impl1_constness = tcx.constness(impl1_def_id.to_def_id());
-    let impl2_constness = tcx.constness(impl2_node.def_id());
-
-    if let hir::Constness::Const = impl2_constness {
-        if let hir::Constness::NotConst = impl1_constness {
-            return Err(tcx.dcx().emit_err(errors::ConstSpecialize { span }));
-        }
-    }
-    Ok(())
-}
-
 /// Given a specializing impl `impl1`, and the base impl `impl2`, returns two
 /// generic parameters `(S1, S2)` that equate their trait references.
 /// The returned types are expressed in terms of the generics of `impl1`.