@@ -169,28 +169,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
169
169
} ;
170
170
171
171
let def_id = cx. tcx . hir . local_def_id ( impl_item. id ) ;
172
- match cx. tcx . associated_item ( def_id) . container {
173
- TraitContainer ( cid) => {
174
- if let Some ( n) = cx. tcx . hir . as_local_node_id ( cid) {
175
- if !cx. access_levels . is_exported ( n) {
176
- // If a trait is being implemented for an item, and the
177
- // trait is not exported, we don't need #[inline]
178
- return ;
179
- }
180
- }
181
- } ,
182
- ImplContainer ( cid) => {
183
- if cx. tcx . impl_trait_ref ( cid) . is_some ( ) {
184
- let trait_ref = cx. tcx . impl_trait_ref ( cid) . unwrap ( ) ;
185
- if let Some ( n) = cx. tcx . hir . as_local_node_id ( trait_ref. def_id ) {
186
- if !cx. access_levels . is_exported ( n) {
187
- // If a trait is being implemented for an item, and the
188
- // trait is not exported, we don't need #[inline]
189
- return ;
190
- }
191
- }
172
+ let trait_def_id = match cx. tcx . associated_item ( def_id) . container {
173
+ TraitContainer ( cid) => Some ( cid) ,
174
+ ImplContainer ( cid) => cx. tcx . impl_trait_ref ( cid) . map ( |t| t. def_id ) ,
175
+ } ;
176
+
177
+ if let Some ( trait_def_id) = trait_def_id {
178
+ if let Some ( n) = cx. tcx . hir . as_local_node_id ( trait_def_id) {
179
+ if !cx. access_levels . is_exported ( n) {
180
+ // If a trait is being implemented for an item, and the
181
+ // trait is not exported, we don't need #[inline]
182
+ return ;
192
183
}
193
- } ,
184
+ }
194
185
}
195
186
196
187
check_missing_inline_attrs ( cx, & impl_item. attrs , impl_item. span , desc) ;
0 commit comments