@@ -94,14 +94,6 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
94
94
95
95
// We'll try to suggest constraining type parameters to fulfill the requirements of
96
96
// their `Copy` implementation.
97
- let mut generics = None ;
98
- if let ty:: Adt ( def, _substs) = self_type. kind ( ) {
99
- let self_def_id = def. did ( ) ;
100
- if let Some ( local) = self_def_id. as_local ( ) {
101
- let self_item = tcx. hir ( ) . expect_item ( local) ;
102
- generics = self_item. kind . generics ( ) ;
103
- }
104
- }
105
97
let mut errors: BTreeMap < _ , Vec < _ > > = Default :: default ( ) ;
106
98
let mut bounds = vec ! [ ] ;
107
99
@@ -163,16 +155,14 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
163
155
& format ! ( "the `Copy` impl for `{}` requires that `{}`" , ty, error_predicate) ,
164
156
) ;
165
157
}
166
- if let Some ( generics) = generics {
167
- suggest_constraining_type_params (
168
- tcx,
169
- generics,
170
- & mut err,
171
- bounds. iter ( ) . map ( |( param, constraint, def_id) | {
172
- ( param. as_str ( ) , constraint. as_str ( ) , * def_id)
173
- } ) ,
174
- ) ;
175
- }
158
+ suggest_constraining_type_params (
159
+ tcx,
160
+ tcx. hir ( ) . get_generics ( impl_did) . expect ( "impls always have generics" ) ,
161
+ & mut err,
162
+ bounds. iter ( ) . map ( |( param, constraint, def_id) | {
163
+ ( param. as_str ( ) , constraint. as_str ( ) , * def_id)
164
+ } ) ,
165
+ ) ;
176
166
err. emit ( ) ;
177
167
}
178
168
Err ( CopyImplementationError :: NotAnAdt ) => {
0 commit comments