@@ -15,7 +15,7 @@ use rustc_infer::infer::{DefineOpaqueTypes, TyCtxtInferExt};
15
15
use rustc_infer:: traits:: Obligation ;
16
16
use rustc_middle:: ty:: adjustment:: CoerceUnsizedInfo ;
17
17
use rustc_middle:: ty:: { self , suggest_constraining_type_params, Ty , TyCtxt , TypeVisitableExt } ;
18
- use rustc_span:: Span ;
18
+ use rustc_span:: { Span , DUMMY_SP } ;
19
19
use rustc_trait_selection:: traits:: error_reporting:: TypeErrCtxtExt ;
20
20
use rustc_trait_selection:: traits:: misc:: {
21
21
type_allowed_to_implement_const_param_ty, type_allowed_to_implement_copy,
@@ -95,18 +95,20 @@ fn visit_implementation_of_copy(
95
95
if let ty:: ImplPolarity :: Negative = tcx. impl_polarity ( impl_did) {
96
96
return Ok ( ( ) ) ;
97
97
}
98
- let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
99
98
100
- let cause = traits:: ObligationCause :: misc ( span , impl_did) ;
99
+ let cause = traits:: ObligationCause :: misc ( DUMMY_SP , impl_did) ;
101
100
match type_allowed_to_implement_copy ( tcx, param_env, self_type, cause) {
102
101
Ok ( ( ) ) => Ok ( ( ) ) ,
103
102
Err ( CopyImplementationError :: InfringingFields ( fields) ) => {
103
+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
104
104
Err ( infringing_fields_error ( tcx, fields, LangItem :: Copy , impl_did, span) )
105
105
}
106
106
Err ( CopyImplementationError :: NotAnAdt ) => {
107
+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
107
108
Err ( tcx. dcx ( ) . emit_err ( errors:: CopyImplOnNonAdt { span } ) )
108
109
}
109
110
Err ( CopyImplementationError :: HasDestructor ) => {
111
+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
110
112
Err ( tcx. dcx ( ) . emit_err ( errors:: CopyImplOnTypeWithDtor { span } ) )
111
113
}
112
114
}
@@ -124,15 +126,16 @@ fn visit_implementation_of_const_param_ty(
124
126
if let ty:: ImplPolarity :: Negative = tcx. impl_polarity ( impl_did) {
125
127
return Ok ( ( ) ) ;
126
128
}
127
- let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
128
129
129
- let cause = traits:: ObligationCause :: misc ( span , impl_did) ;
130
+ let cause = traits:: ObligationCause :: misc ( DUMMY_SP , impl_did) ;
130
131
match type_allowed_to_implement_const_param_ty ( tcx, param_env, self_type, cause) {
131
132
Ok ( ( ) ) => Ok ( ( ) ) ,
132
133
Err ( ConstParamTyImplementationError :: InfrigingFields ( fields) ) => {
134
+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
133
135
Err ( infringing_fields_error ( tcx, fields, LangItem :: ConstParamTy , impl_did, span) )
134
136
}
135
137
Err ( ConstParamTyImplementationError :: NotAnAdtOrBuiltinAllowed ) => {
138
+ let span = tcx. hir ( ) . expect_item ( impl_did) . expect_impl ( ) . self_ty . span ;
136
139
Err ( tcx. dcx ( ) . emit_err ( errors:: ConstParamTyImplOnNonAdt { span } ) )
137
140
}
138
141
}
0 commit comments