@@ -173,6 +173,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
173173
174174 let needs_infer = stack. obligation . predicate . has_infer_types_or_consts ( ) ;
175175
176+ let sized_predicate = self . tcx ( ) . lang_items ( ) . sized_trait ( )
177+ == Some ( stack. obligation . predicate . skip_binder ( ) . def_id ( ) ) ;
178+
176179 // If there are STILL multiple candidates, we can further
177180 // reduce the list by dropping duplicates -- including
178181 // resolving specializations.
@@ -181,6 +184,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
181184 while i < candidates. len ( ) {
182185 let is_dup = ( 0 ..candidates. len ( ) ) . filter ( |& j| i != j) . any ( |j| {
183186 self . candidate_should_be_dropped_in_favor_of (
187+ sized_predicate,
184188 & candidates[ i] ,
185189 & candidates[ j] ,
186190 needs_infer,
@@ -338,13 +342,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
338342 Ok ( candidates)
339343 }
340344
345+ #[ tracing:: instrument( level = "debug" , skip( self , candidates) ) ]
341346 fn assemble_candidates_from_projected_tys (
342347 & mut self ,
343348 obligation : & TraitObligation < ' tcx > ,
344349 candidates : & mut SelectionCandidateSet < ' tcx > ,
345350 ) {
346- debug ! ( ?obligation, "assemble_candidates_from_projected_tys" ) ;
347-
348351 // Before we go into the whole placeholder thing, just
349352 // quickly check if the self-type is a projection at all.
350353 match obligation. predicate . skip_binder ( ) . trait_ref . self_ty ( ) . kind ( ) {
@@ -369,12 +372,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
369372 /// supplied to find out whether it is listed among them.
370373 ///
371374 /// Never affects the inference environment.
375+ #[ tracing:: instrument( level = "debug" , skip( self , stack, candidates) ) ]
372376 fn assemble_candidates_from_caller_bounds < ' o > (
373377 & mut self ,
374378 stack : & TraitObligationStack < ' o , ' tcx > ,
375379 candidates : & mut SelectionCandidateSet < ' tcx > ,
376380 ) -> Result < ( ) , SelectionError < ' tcx > > {
377- debug ! ( ?stack. obligation, "assemble_candidates_from_caller_bounds" ) ;
381+ debug ! ( ?stack. obligation) ;
378382
379383 let all_bounds = stack
380384 . obligation
@@ -876,14 +880,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
876880 } ;
877881 }
878882
883+ #[ tracing:: instrument( level = "debug" , skip( self , obligation, candidates) ) ]
879884 fn assemble_candidates_for_trait_alias (
880885 & mut self ,
881886 obligation : & TraitObligation < ' tcx > ,
882887 candidates : & mut SelectionCandidateSet < ' tcx > ,
883888 ) {
884889 // Okay to skip binder here because the tests we do below do not involve bound regions.
885890 let self_ty = obligation. self_ty ( ) . skip_binder ( ) ;
886- debug ! ( ?self_ty, "assemble_candidates_for_trait_alias" ) ;
891+ debug ! ( ?self_ty) ;
887892
888893 let def_id = obligation. predicate . def_id ( ) ;
889894
@@ -894,21 +899,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
894899
895900 /// Assembles the trait which are built-in to the language itself:
896901 /// `Copy`, `Clone` and `Sized`.
902+ #[ tracing:: instrument( level = "debug" , skip( self , candidates) ) ]
897903 fn assemble_builtin_bound_candidates (
898904 & mut self ,
899905 conditions : BuiltinImplConditions < ' tcx > ,
900906 candidates : & mut SelectionCandidateSet < ' tcx > ,
901907 ) {
902908 match conditions {
903909 BuiltinImplConditions :: Where ( nested) => {
904- debug ! ( ?nested, "builtin_bound" ) ;
905910 candidates
906911 . vec
907912 . push ( BuiltinCandidate { has_nested : !nested. skip_binder ( ) . is_empty ( ) } ) ;
908913 }
909914 BuiltinImplConditions :: None => { }
910915 BuiltinImplConditions :: Ambiguous => {
911- debug ! ( "assemble_builtin_bound_candidates: ambiguous builtin" ) ;
912916 candidates. ambiguous = true ;
913917 }
914918 }
0 commit comments