From 0c73b41cd69c33b76ba2a833bf8bd94a95e73ccb Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 3 Jul 2023 15:27:41 +0000 Subject: [PATCH] remove TypeWellFormedFromEnv --- compiler/rustc_hir_analysis/src/astconv/mod.rs | 3 +-- .../src/impl_wf_check/min_specialization.rs | 3 +-- .../rustc_hir_analysis/src/outlives/explicit.rs | 3 +-- compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- compiler/rustc_hir_typeck/src/method/probe.rs | 3 +-- compiler/rustc_infer/src/infer/outlives/mod.rs | 3 +-- compiler/rustc_infer/src/traits/util.rs | 3 --- compiler/rustc_lint/src/builtin.rs | 3 +-- compiler/rustc_middle/src/ty/flags.rs | 3 --- compiler/rustc_middle/src/ty/mod.rs | 17 ++++------------- compiler/rustc_middle/src/ty/print/pretty.rs | 3 --- .../rustc_middle/src/ty/structural_impls.rs | 3 --- compiler/rustc_privacy/src/lib.rs | 1 - .../src/solve/eval_ctxt.rs | 3 --- .../src/traits/auto_trait.rs | 3 --- .../src/traits/error_reporting/mod.rs | 7 ------- .../rustc_trait_selection/src/traits/fulfill.rs | 6 ------ .../src/traits/object_safety.rs | 5 ++--- .../query/type_op/implied_outlives_bounds.rs | 2 +- .../src/traits/select/mod.rs | 3 --- compiler/rustc_trait_selection/src/traits/wf.rs | 6 ++---- .../src/normalize_erasing_regions.rs | 3 +-- src/librustdoc/clean/mod.rs | 3 +-- 23 files changed, 18 insertions(+), 73 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 9b5ff3240ed..1d5e4ac55f8 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -983,8 +983,7 @@ fn conv_object_ty_poly_trait_ref( ty::ClauseKind::RegionOutlives(_) | ty::ClauseKind::ConstArgHasType(..) | ty::ClauseKind::WellFormed(_) - | ty::ClauseKind::ConstEvaluatable(_) - | ty::ClauseKind::TypeWellFormedFromEnv(_) => { + | ty::ClauseKind::ConstEvaluatable(_) => { bug!() } } 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 67800dbd2a2..c64fb469bb2 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 @@ -551,7 +551,6 @@ fn trait_predicate_kind<'tcx>( | ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::ConstEquate(..) - | ty::PredicateKind::Ambiguous - | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => None, + | ty::PredicateKind::Ambiguous => None, } } diff --git a/compiler/rustc_hir_analysis/src/outlives/explicit.rs b/compiler/rustc_hir_analysis/src/outlives/explicit.rs index 3a04c3336ca..a7fca41f86a 100644 --- a/compiler/rustc_hir_analysis/src/outlives/explicit.rs +++ b/compiler/rustc_hir_analysis/src/outlives/explicit.rs @@ -53,8 +53,7 @@ pub(crate) fn explicit_predicates_of( | ty::ClauseKind::Projection(_) | ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::WellFormed(_) - | ty::ClauseKind::ConstEvaluatable(_) - | ty::ClauseKind::TypeWellFormedFromEnv(_) => {} + | ty::ClauseKind::ConstEvaluatable(_) => {} } } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index d9d91b0f6be..adf1b8e351f 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -685,7 +685,7 @@ pub(in super::super) fn obligations_for_self_ty<'b>( // inference variable. | ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::Ambiguous - | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => None, + => None, }, ) } diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 4c41fa38012..5e28ad5fd58 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -847,8 +847,7 @@ fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) { | ty::ClauseKind::Projection(_) | ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::WellFormed(_) - | ty::ClauseKind::ConstEvaluatable(_) - | ty::ClauseKind::TypeWellFormedFromEnv(_) => None, + | ty::ClauseKind::ConstEvaluatable(_) => None, } }); diff --git a/compiler/rustc_infer/src/infer/outlives/mod.rs b/compiler/rustc_infer/src/infer/outlives/mod.rs index c998c923760..cb92fc6ddb6 100644 --- a/compiler/rustc_infer/src/infer/outlives/mod.rs +++ b/compiler/rustc_infer/src/infer/outlives/mod.rs @@ -31,8 +31,7 @@ pub fn explicit_outlives_bounds<'tcx>( | ty::ClauseKind::Projection(_) | ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::WellFormed(_) - | ty::ClauseKind::ConstEvaluatable(_) - | ty::ClauseKind::TypeWellFormedFromEnv(_) => None, + | ty::ClauseKind::ConstEvaluatable(_) => None, }) } diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs index 66389cf5995..3aeed93baf2 100644 --- a/compiler/rustc_infer/src/traits/util.rs +++ b/compiler/rustc_infer/src/traits/util.rs @@ -370,9 +370,6 @@ fn elaborate(&mut self, elaboratable: &O) { }), ); } - ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => { - // Nothing to elaborate - } ty::PredicateKind::Ambiguous => {} ty::PredicateKind::AliasRelate(..) => { // No diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 3a177038ca8..c24760263bf 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1606,8 +1606,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { // Ignore bounds that a user can't type | ClauseKind::WellFormed(..) // FIXME(generic_const_exprs): `ConstEvaluatable` can be written - | ClauseKind::ConstEvaluatable(..) - | ClauseKind::TypeWellFormedFromEnv(_) => continue, + | ClauseKind::ConstEvaluatable(..) => continue, }; if predicate.is_global() { cx.emit_spanned_lint( diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 06a8e34cbab..ff391794703 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -287,9 +287,6 @@ fn add_predicate_atom(&mut self, atom: ty::PredicateKind<'_>) { self.add_const(expected); self.add_const(found); } - ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(ty)) => { - self.add_ty(ty); - } ty::PredicateKind::Ambiguous => {} ty::PredicateKind::AliasRelate(t1, t2, _) => { self.add_term(t1); diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 7bd49ad07ea..48388be2f46 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -554,8 +554,7 @@ pub fn allow_normalization(self) -> bool { | PredicateKind::Coerce(_) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(_)) | PredicateKind::ConstEquate(_, _) - | PredicateKind::Ambiguous - | PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(_)) => true, + | PredicateKind::Ambiguous => true, } } } @@ -661,11 +660,6 @@ pub enum ClauseKind<'tcx> { /// Constant initializer must evaluate successfully. ConstEvaluatable(ty::Const<'tcx>), - - /// Represents a type found in the environment that we can use for implied bounds. - /// - /// Only used for Chalk. - TypeWellFormedFromEnv(Ty<'tcx>), } #[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable)] @@ -1424,8 +1418,7 @@ pub fn to_opt_poly_trait_pred(self) -> Option> { | PredicateKind::Clause(ClauseKind::TypeOutlives(..)) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(..)) | PredicateKind::ConstEquate(..) - | PredicateKind::Ambiguous - | PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(..)) => None, + | PredicateKind::Ambiguous => None, } } @@ -1445,8 +1438,7 @@ pub fn to_opt_poly_projection_pred(self) -> Option | PredicateKind::Clause(ClauseKind::TypeOutlives(..)) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(..)) | PredicateKind::ConstEquate(..) - | PredicateKind::Ambiguous - | PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(..)) => None, + | PredicateKind::Ambiguous => None, } } @@ -1466,8 +1458,7 @@ pub fn to_opt_type_outlives(self) -> Option> { | PredicateKind::ClosureKind(..) | PredicateKind::Clause(ClauseKind::ConstEvaluatable(..)) | PredicateKind::ConstEquate(..) - | PredicateKind::Ambiguous - | PredicateKind::Clause(ClauseKind::TypeWellFormedFromEnv(..)) => None, + | PredicateKind::Ambiguous => None, } } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index dcc8247937d..f912ff04496 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2888,9 +2888,6 @@ pub struct PrintClosureAsImpl<'tcx> { ty::ClauseKind::ConstEvaluatable(ct) => { p!("the constant `", print(ct), "` can be evaluated") } - ty::ClauseKind::TypeWellFormedFromEnv(ty) => { - p!("the type `", print(ty), "` is found in the environment") - } } } diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 113328de176..f195b062a62 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -189,9 +189,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ty::ClauseKind::ConstEvaluatable(ct) => { write!(f, "ConstEvaluatable({ct:?})") } - ty::ClauseKind::TypeWellFormedFromEnv(ty) => { - write!(f, "TypeWellFormedFromEnv({:?})", ty) - } } } } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 055006373ef..4fcee9396ed 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -174,7 +174,6 @@ fn visit_clause(&mut self, clause: ty::Clause<'tcx>) -> ControlFlow } ty::ClauseKind::ConstEvaluatable(ct) => ct.visit_with(self), ty::ClauseKind::WellFormed(arg) => arg.visit_with(self), - ty::ClauseKind::TypeWellFormedFromEnv(_) => bug!("unexpected clause: {clause}"), } } diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs index 3b0c5849099..6b7be73b631 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs @@ -435,9 +435,6 @@ fn compute_goal(&mut self, goal: Goal<'tcx, ty::Predicate<'tcx>>) -> QueryResult ty::PredicateKind::ConstEquate(_, _) => { bug!("ConstEquate should not be emitted when `-Ztrait-solver=next` is active") } - ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => { - bug!("TypeWellFormedFromEnv is only used for Chalk") - } ty::PredicateKind::AliasRelate(lhs, rhs, direction) => self .compute_alias_relate_goal(Goal { param_env, diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index fb6bf7211b9..cb42281152d 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -836,9 +836,6 @@ fn evaluate_nested_obligations( // FIXME(generic_const_exprs): you can absolutely add this as a where clauses | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::Coerce(..) => {} - ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => { - bug!("predicate should only exist in the environment: {bound_predicate:?}") - } ty::PredicateKind::Ambiguous => return false, }; } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index cddfb15869f..5fff645dd22 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1094,13 +1094,6 @@ fn report_selection_error( ty::PredicateKind::Ambiguous => span_bug!(span, "ambiguous"), - ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => { - span_bug!( - span, - "TypeWellFormedFromEnv predicate should only exist in the environment" - ) - } - ty::PredicateKind::AliasRelate(..) => span_bug!( span, "AliasRelate predicate should never be the predicate cause of a SelectionError" diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index e3472a1c4c1..3d96c422256 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -359,9 +359,6 @@ fn process_obligation( ProcessResult::Changed(mk_pending(vec![obligation.with(infcx.tcx, pred)])) } ty::PredicateKind::Ambiguous => ProcessResult::Unchanged, - ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => { - bug!("TypeWellFormedFromEnv is only used for Chalk") - } ty::PredicateKind::AliasRelate(..) => { bug!("AliasRelate is only used for new solver") } @@ -627,9 +624,6 @@ fn process_obligation( } } ty::PredicateKind::Ambiguous => ProcessResult::Unchanged, - ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => { - bug!("TypeWellFormedFromEnv is only used for Chalk") - } ty::PredicateKind::AliasRelate(..) => { bug!("AliasRelate is only used for new solver") } diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index 78270b7d535..08be60c65d4 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -311,7 +311,7 @@ fn predicate_references_self<'tcx>( | ty::ClauseKind::RegionOutlives(..) // FIXME(generic_const_exprs): this can mention `Self` | ty::ClauseKind::ConstEvaluatable(..) - | ty::ClauseKind::TypeWellFormedFromEnv(_) => None, + => None, } } @@ -351,8 +351,7 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool { | ty::ClauseKind::Projection(_) | ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::WellFormed(_) - | ty::ClauseKind::ConstEvaluatable(_) - | ty::ClauseKind::TypeWellFormedFromEnv(_) => false, + | ty::ClauseKind::ConstEvaluatable(_) => false, }) } diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs index 83d536c9ca5..42c2c37eca2 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs @@ -134,7 +134,7 @@ pub fn compute_implied_outlives_bounds_inner<'tcx>( | ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::Ambiguous | ty::PredicateKind::AliasRelate(..) - | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {} + => {} // We need to search through *all* WellFormed predicates ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => { diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index c12d92b9012..eb11163de42 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -972,9 +972,6 @@ fn evaluate_predicate_recursively<'o>( } } } - ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => { - bug!("TypeWellFormedFromEnv is only used for chalk") - } ty::PredicateKind::AliasRelate(..) => { bug!("AliasRelate is only used for new solver") } diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 8bb4288f80d..86c7fc45ff7 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -184,8 +184,7 @@ pub fn predicate_obligations<'tcx>( | ty::PredicateKind::Coerce(..) | ty::PredicateKind::ConstEquate(..) | ty::PredicateKind::Ambiguous - | ty::PredicateKind::AliasRelate(..) - | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => { + | ty::PredicateKind::AliasRelate(..) => { bug!("We should only wf check where clauses, unexpected predicate: {predicate:?}") } } @@ -1005,8 +1004,7 @@ pub(crate) fn required_region_bounds<'tcx>( | ty::ClauseKind::Projection(_) | ty::ClauseKind::ConstArgHasType(_, _) | ty::ClauseKind::WellFormed(_) - | ty::ClauseKind::ConstEvaluatable(_) - | ty::ClauseKind::TypeWellFormedFromEnv(_) => None, + | ty::ClauseKind::ConstEvaluatable(_) => None, } }) .collect() diff --git a/compiler/rustc_traits/src/normalize_erasing_regions.rs b/compiler/rustc_traits/src/normalize_erasing_regions.rs index b83abf98592..2563e3ed1a3 100644 --- a/compiler/rustc_traits/src/normalize_erasing_regions.rs +++ b/compiler/rustc_traits/src/normalize_erasing_regions.rs @@ -69,7 +69,6 @@ fn not_outlives_predicate(p: ty::Predicate<'_>) -> bool { | ty::PredicateKind::Coerce(..) | ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..)) | ty::PredicateKind::ConstEquate(..) - | ty::PredicateKind::Ambiguous - | ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => true, + | ty::PredicateKind::Ambiguous => true, } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index b2f9c0bccea..0182d50773d 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -342,8 +342,7 @@ pub(crate) fn clean_predicate<'tcx>( // FIXME(generic_const_exprs): should this do something? ty::ClauseKind::ConstEvaluatable(..) | ty::ClauseKind::WellFormed(..) - | ty::ClauseKind::ConstArgHasType(..) - | ty::ClauseKind::TypeWellFormedFromEnv(..) => None, + | ty::ClauseKind::ConstArgHasType(..) => None, } }