@@ -15,7 +15,7 @@ use rustc_infer::infer::{DefineOpaqueTypes, TyCtxtInferExt};
1515use rustc_infer:: traits:: Obligation ;
1616use rustc_middle:: ty:: adjustment:: CoerceUnsizedInfo ;
1717use rustc_middle:: ty:: { self , suggest_constraining_type_params, Ty , TyCtxt , TypeVisitableExt } ;
18- use rustc_span:: Span ;
18+ use rustc_span:: { Span , DUMMY_SP } ;
1919use rustc_trait_selection:: traits:: error_reporting:: TypeErrCtxtExt ;
2020use rustc_trait_selection:: traits:: misc:: {
2121 type_allowed_to_implement_const_param_ty, type_allowed_to_implement_copy,
@@ -95,18 +95,20 @@ fn visit_implementation_of_copy(
9595 if let ty:: ImplPolarity :: Negative = tcx. impl_polarity ( impl_did) {
9696 return Ok ( ( ) ) ;
9797 }
98- let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
9998
100- let cause = traits:: ObligationCause :: misc ( span , impl_did) ;
99+ let cause = traits:: ObligationCause :: misc ( DUMMY_SP , impl_did) ;
101100 match type_allowed_to_implement_copy ( tcx, param_env, self_type, cause) {
102101 Ok ( ( ) ) => Ok ( ( ) ) ,
103102 Err ( CopyImplementationError :: InfringingFields ( fields) ) => {
103+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
104104 Err ( infringing_fields_error ( tcx, fields, LangItem :: Copy , impl_did, span) )
105105 }
106106 Err ( CopyImplementationError :: NotAnAdt ) => {
107+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
107108 Err ( tcx. dcx ( ) . emit_err ( errors:: CopyImplOnNonAdt { span } ) )
108109 }
109110 Err ( CopyImplementationError :: HasDestructor ) => {
111+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
110112 Err ( tcx. dcx ( ) . emit_err ( errors:: CopyImplOnTypeWithDtor { span } ) )
111113 }
112114 }
@@ -124,15 +126,16 @@ fn visit_implementation_of_const_param_ty(
124126 if let ty:: ImplPolarity :: Negative = tcx. impl_polarity ( impl_did) {
125127 return Ok ( ( ) ) ;
126128 }
127- let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
128129
129- let cause = traits:: ObligationCause :: misc ( span , impl_did) ;
130+ let cause = traits:: ObligationCause :: misc ( DUMMY_SP , impl_did) ;
130131 match type_allowed_to_implement_const_param_ty ( tcx, param_env, self_type, cause) {
131132 Ok ( ( ) ) => Ok ( ( ) ) ,
132133 Err ( ConstParamTyImplementationError :: InfrigingFields ( fields) ) => {
134+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
133135 Err ( infringing_fields_error ( tcx, fields, LangItem :: ConstParamTy , impl_did, span) )
134136 }
135137 Err ( ConstParamTyImplementationError :: NotAnAdtOrBuiltinAllowed ) => {
138+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
136139 Err ( tcx. dcx ( ) . emit_err ( errors:: ConstParamTyImplOnNonAdt { span } ) )
137140 }
138141 }
0 commit comments