@@ -38,7 +38,6 @@ use rustc_middle::ty::{
3838 self , GenericArgs , GenericArgsRef , Ty , TyCtxt , TypeFolder , TypeSuperFoldable ,
3939 TypeSuperVisitable , TypingMode , Upcast ,
4040} ;
41- use rustc_session:: lint;
4241use rustc_span:: def_id:: DefId ;
4342use rustc_span:: { DUMMY_SP , Span } ;
4443use tracing:: { debug, instrument} ;
@@ -493,10 +492,6 @@ pub enum EvaluateConstErr {
493492 /// CTFE failed to evaluate the constant in some unrecoverable way (e.g. encountered a `panic!`).
494493 /// This is also used when the constant was already tainted by error.
495494 EvaluationFailure ( ErrorGuaranteed ) ,
496- /// The constant requires impossible clauses to hold in order for it to be evaluated. This does not
497- /// necessarily imply that type checking should error as there may be similar impossible clauses in
498- /// the type checking environment that can be used to prove this constant wf.
499- ImpossibleClauses ,
500495}
501496
502497// FIXME(BoxyUwU): Private this once we `generic_const_exprs` isn't doing its own normalization routine
@@ -518,7 +513,7 @@ pub fn evaluate_const<'tcx>(
518513 Err ( EvaluateConstErr :: EvaluationFailure ( e) | EvaluateConstErr :: InvalidConstParamTy ( e) ) => {
519514 ty:: Const :: new_error ( infcx. tcx , e)
520515 }
521- Err ( EvaluateConstErr :: ImpossibleClauses | EvaluateConstErr :: HasGenericsOrInfers ) => ct,
516+ Err ( EvaluateConstErr :: HasGenericsOrInfers ) => ct,
522517 }
523518}
524519
@@ -635,30 +630,6 @@ pub fn try_evaluate_const<'tcx>(
635630 let args = GenericArgs :: identity_for_item ( tcx, uv. def ) ;
636631 let typing_env = ty:: TypingEnv :: post_analysis ( tcx, uv. def ) ;
637632
638- // Instead of erroring when encountering a constant with impossible preds we just FCW, as
639- // it would be a breaking change.
640- if tcx
641- . instantiate_and_check_impossible_predicates ( ( uv. def , tcx. erase_regions ( args) ) )
642- {
643- if let Some ( local_def) = uv. def . as_local ( ) {
644- tcx. node_span_lint (
645- lint:: builtin:: CONST_EVALUATABLE_UNCHECKED ,
646- tcx. local_def_id_to_hir_id ( local_def) ,
647- tcx. def_span ( uv. def ) ,
648- |lint| {
649- lint. primary_message (
650- "cannot use constants which depend on trivially-false where clauses" ,
651- ) ;
652- } ,
653- )
654- } else {
655- // If the anon const is not a local def then it's probably a GCE const from some
656- // upstream crate. We don't need to lint on that. It also shouldn't be possible
657- // for an upstream crate to put a repeat expr count anon const into a signature
658- // and have it *only* evaluated in a downstream crate.
659- }
660- } ;
661-
662633 ( args, typing_env)
663634 } else {
664635 // We are only dealing with "truly" generic/uninferred constants here:
@@ -671,24 +642,6 @@ pub fn try_evaluate_const<'tcx>(
671642 return Err ( EvaluateConstErr :: HasGenericsOrInfers ) ;
672643 }
673644
674- // If we are dealing with a fully monomorphic constant then we should ensure that
675- // it is well formed as otherwise CTFE will ICE. For the same reasons as with
676- // deferring evaluation of generic/uninferred constants, we do not have to worry
677- // about `generic_const_exprs`
678- //
679- // This check is done in an empty environment which is a little weird, however, mir
680- // bodies with impossible predicates (in an empty environment) are sometimes built as
681- // only an `unreachable` terminator which makes evaluating them incorrect even if the
682- // impossible pred is satsifiable in this environment.
683- if tcx. instantiate_and_check_impossible_predicates ( (
684- uv. def ,
685- tcx. erase_regions ( uv. args ) ,
686- ) ) {
687- // We can't delay a bug here as that could ICE the compiler if we are in an environment
688- // where the impossible pred actually holds due to it also existing in this env.
689- return Err ( EvaluateConstErr :: ImpossibleClauses ) ;
690- }
691-
692645 let typing_env = infcx
693646 . typing_env ( tcx. erase_regions ( param_env) )
694647 . with_post_analysis_normalized ( tcx) ;
0 commit comments