File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
compiler/rustc_trait_selection/src Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -846,7 +846,16 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
846
846
if let Some ( result) = self . try_merge_responses ( & responses) {
847
847
return Ok ( result) ;
848
848
} else {
849
- self . flounder ( & responses)
849
+ let param_env_candidates = candidates
850
+ . iter ( )
851
+ . filter ( |c| matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) )
852
+ . map ( |c| c. result )
853
+ . collect :: < Vec < _ > > ( ) ;
854
+ if let Some ( result) = self . try_merge_responses ( & param_env_candidates) {
855
+ return Ok ( result) ;
856
+ } else {
857
+ self . flounder ( & responses)
858
+ }
850
859
}
851
860
}
852
861
}
Original file line number Diff line number Diff line change @@ -390,6 +390,31 @@ pub fn normalize_param_env_or_error<'tcx>(
390
390
let mut predicates = non_outlives_predicates;
391
391
predicates. extend ( outlives_predicates) ;
392
392
debug ! ( "normalize_param_env_or_error: final predicates={:?}" , predicates) ;
393
+ if tcx. next_trait_solver_globally ( ) {
394
+ predicates. retain ( |& p| {
395
+ if p. is_global ( ) {
396
+ let infcx = tcx. infer_ctxt ( ) . build ( ) ;
397
+ let ocx = ObligationCtxt :: new ( & infcx) ;
398
+ let param_env = ty:: ParamEnv :: empty ( ) ;
399
+ ocx. register_obligation ( Obligation :: new (
400
+ tcx,
401
+ ObligationCause :: dummy ( ) ,
402
+ param_env,
403
+ p,
404
+ ) ) ;
405
+ if !ocx. select_all_or_error ( ) . is_empty ( ) {
406
+ true
407
+ } else if ocx. resolve_regions ( & OutlivesEnvironment :: new ( param_env) ) . is_empty ( ) {
408
+ // A trivially true global bound, ignore it.
409
+ false
410
+ } else {
411
+ true
412
+ }
413
+ } else {
414
+ true
415
+ }
416
+ } )
417
+ }
393
418
ty:: ParamEnv :: new ( tcx. mk_clauses ( & predicates) , unnormalized_env. reveal ( ) )
394
419
}
395
420
You can’t perform that action at this time.
0 commit comments