|
1 | | -use crate::infer::{InferCtxt, TyCtxtInferExt}; |
2 | | -use crate::traits::{ObligationCause, ObligationCtxt}; |
3 | | - |
4 | 1 | use rustc_data_structures::fx::FxHashSet; |
5 | 2 | use rustc_hir as hir; |
6 | | -use rustc_hir::lang_items::LangItem; |
7 | | -use rustc_middle::ty::query::Providers; |
8 | 3 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; |
9 | 4 | use rustc_span::Span; |
10 | 5 | use std::ops::ControlFlow; |
@@ -59,41 +54,6 @@ pub fn search_for_adt_const_param_violation<'tcx>( |
59 | 54 | .break_value() |
60 | 55 | } |
61 | 56 |
|
62 | | -/// This method returns true if and only if `adt_ty` itself has been marked as |
63 | | -/// eligible for structural-match: namely, if it implements both |
64 | | -/// `StructuralPartialEq` and `StructuralEq` (which are respectively injected by |
65 | | -/// `#[derive(PartialEq)]` and `#[derive(Eq)]`). |
66 | | -/// |
67 | | -/// Note that this does *not* recursively check if the substructure of `adt_ty` |
68 | | -/// implements the traits. |
69 | | -fn type_marked_structural<'tcx>( |
70 | | - infcx: &InferCtxt<'tcx>, |
71 | | - adt_ty: Ty<'tcx>, |
72 | | - cause: ObligationCause<'tcx>, |
73 | | -) -> bool { |
74 | | - let ocx = ObligationCtxt::new(infcx); |
75 | | - // require `#[derive(PartialEq)]` |
76 | | - let structural_peq_def_id = |
77 | | - infcx.tcx.require_lang_item(LangItem::StructuralPeq, Some(cause.span)); |
78 | | - ocx.register_bound(cause.clone(), ty::ParamEnv::empty(), adt_ty, structural_peq_def_id); |
79 | | - // for now, require `#[derive(Eq)]`. (Doing so is a hack to work around |
80 | | - // the type `for<'a> fn(&'a ())` failing to implement `Eq` itself.) |
81 | | - let structural_teq_def_id = |
82 | | - infcx.tcx.require_lang_item(LangItem::StructuralTeq, Some(cause.span)); |
83 | | - ocx.register_bound(cause, ty::ParamEnv::empty(), adt_ty, structural_teq_def_id); |
84 | | - |
85 | | - // We deliberately skip *reporting* fulfillment errors (via |
86 | | - // `report_fulfillment_errors`), for two reasons: |
87 | | - // |
88 | | - // 1. The error messages would mention `std::marker::StructuralPartialEq` |
89 | | - // (a trait which is solely meant as an implementation detail |
90 | | - // for now), and |
91 | | - // |
92 | | - // 2. We are sometimes doing future-incompatibility lints for |
93 | | - // now, so we do not want unconditional errors here. |
94 | | - ocx.select_all_or_error().is_empty() |
95 | | -} |
96 | | - |
97 | 57 | /// This implements the traversal over the structure of a given type to try to |
98 | 58 | /// find instances of ADTs (specifically structs or enums) that do not implement |
99 | 59 | /// the structural-match traits (`StructuralPartialEq` and `StructuralEq`). |
@@ -249,11 +209,3 @@ impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> { |
249 | 209 | }) |
250 | 210 | } |
251 | 211 | } |
252 | | - |
253 | | -pub fn provide(providers: &mut Providers) { |
254 | | - providers.has_structural_eq_impls = |tcx, ty| { |
255 | | - let infcx = tcx.infer_ctxt().build(); |
256 | | - let cause = ObligationCause::dummy(); |
257 | | - type_marked_structural(&infcx, ty, cause) |
258 | | - }; |
259 | | -} |
0 commit comments