@@ -538,23 +538,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
538
538
}
539
539
540
540
ty:: PredicateKind :: Clause ( ty:: ClauseKind :: HostEffect ( predicate) ) => {
541
- // FIXME(const_trait_impl): We should recompute the predicate with `~const`
542
- // if it's `const`, and if it holds, explain that this bound only
543
- // *conditionally* holds. If that fails, we should also do selection
544
- // to drill this down to an impl or built-in source, so we can
545
- // point at it and explain that while the trait *is* implemented,
546
- // that implementation is not const.
547
- let err_msg = self . get_standard_error_message (
548
- bound_predicate. rebind ( ty:: TraitPredicate {
549
- trait_ref : predicate. trait_ref ,
550
- polarity : ty:: PredicatePolarity :: Positive ,
551
- } ) ,
552
- None ,
553
- Some ( predicate. constness ) ,
554
- None ,
555
- String :: new ( ) ,
556
- ) ;
557
- struct_span_code_err ! ( self . dcx( ) , span, E0277 , "{}" , err_msg)
541
+ self . report_host_effect_error ( bound_predicate. rebind ( predicate) , obligation. param_env , span)
558
542
}
559
543
560
544
ty:: PredicateKind :: Subtype ( predicate) => {
@@ -763,6 +747,41 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
763
747
applied_do_not_recommend
764
748
}
765
749
750
+ fn report_host_effect_error (
751
+ & self ,
752
+ predicate : ty:: Binder < ' tcx , ty:: HostEffectPredicate < ' tcx > > ,
753
+ param_env : ty:: ParamEnv < ' tcx > ,
754
+ span : Span ,
755
+ ) -> Diag < ' a > {
756
+ // FIXME(const_trait_impl): We should recompute the predicate with `~const`
757
+ // if it's `const`, and if it holds, explain that this bound only
758
+ // *conditionally* holds. If that fails, we should also do selection
759
+ // to drill this down to an impl or built-in source, so we can
760
+ // point at it and explain that while the trait *is* implemented,
761
+ // that implementation is not const.
762
+ let trait_ref = predicate. map_bound ( |predicate| ty:: TraitPredicate {
763
+ trait_ref : predicate. trait_ref ,
764
+ polarity : ty:: PredicatePolarity :: Positive ,
765
+ } ) ;
766
+ let err_msg = self . get_standard_error_message (
767
+ trait_ref,
768
+ None ,
769
+ Some ( predicate. constness ( ) ) ,
770
+ None ,
771
+ String :: new ( ) ,
772
+ ) ;
773
+ let mut diag = struct_span_code_err ! ( self . dcx( ) , span, E0277 , "{}" , err_msg) ;
774
+ if !self . predicate_may_hold ( & Obligation :: new (
775
+ self . tcx ,
776
+ ObligationCause :: dummy ( ) ,
777
+ param_env,
778
+ trait_ref,
779
+ ) ) {
780
+ diag. downgrade_to_delayed_bug ( ) ;
781
+ }
782
+ diag
783
+ }
784
+
766
785
fn emit_specialized_closure_kind_error (
767
786
& self ,
768
787
obligation : & PredicateObligation < ' tcx > ,
0 commit comments