@@ -393,7 +393,7 @@ fn create_substs_for_ast_path<'tcx>(
393393 let tcx = this. tcx ( ) ;
394394
395395 debug ! ( "create_substs_for_ast_path(decl_generics={:?}, self_ty={:?}, \
396- types_provided={:?}, region_substs={:?}",
396+ types_provided={:?}, region_substs={:?}) ",
397397 decl_generics, self_ty, types_provided,
398398 region_substs) ;
399399
@@ -474,6 +474,9 @@ fn create_substs_for_ast_path<'tcx>(
474474 }
475475 }
476476
477+ debug ! ( "create_substs_for_ast_path(decl_generics={:?}, self_ty={:?}) -> {:?}" ,
478+ decl_generics, self_ty, substs) ;
479+
477480 substs
478481}
479482
@@ -741,6 +744,7 @@ fn ast_path_to_poly_trait_ref<'a,'tcx>(
741744 poly_projections : & mut Vec < ty:: PolyProjectionPredicate < ' tcx > > )
742745 -> ty:: PolyTraitRef < ' tcx >
743746{
747+ debug ! ( "ast_path_to_poly_trait_ref(trait_segment={:?})" , trait_segment) ;
744748 // The trait reference introduces a binding level here, so
745749 // we need to shift the `rscope`. It'd be nice if we could
746750 // do away with this rscope stuff and work this knowledge
@@ -774,6 +778,8 @@ fn ast_path_to_poly_trait_ref<'a,'tcx>(
774778 poly_projections. extend ( converted_bindings) ;
775779 }
776780
781+ debug ! ( "ast_path_to_poly_trait_ref(trait_segment={:?}, projections={:?}) -> {:?}" ,
782+ trait_segment, poly_projections, poly_trait_ref) ;
777783 poly_trait_ref
778784}
779785
@@ -1103,7 +1109,18 @@ fn make_object_type<'tcx>(this: &AstConv<'tcx>,
11031109 object. principal_trait_ref_with_self_ty ( tcx, tcx. types . err ) ;
11041110
11051111 // ensure the super predicates and stop if we encountered an error
1106- if this. ensure_super_predicates ( span, object. principal_def_id ( ) ) . is_err ( ) {
1112+ if this. ensure_super_predicates ( span, principal. def_id ( ) ) . is_err ( ) {
1113+ return tcx. types . err ;
1114+ }
1115+
1116+ // check that there are no gross object safety violations,
1117+ // most importantly, that the supertraits don't contain Self,
1118+ // to avoid ICE-s.
1119+ let object_safety_violations =
1120+ traits:: astconv_object_safety_violations ( tcx, principal. def_id ( ) ) ;
1121+ if !object_safety_violations. is_empty ( ) {
1122+ traits:: report_object_safety_error (
1123+ tcx, span, principal. def_id ( ) , object_safety_violations, false ) ;
11071124 return tcx. types . err ;
11081125 }
11091126
0 commit comments