@@ -179,31 +179,55 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
179179 let mut primary_span = lhs. span ;
180180 let mut secondary_span = lhs. span ;
181181 let mut post_message = "" ;
182- if let hir:: ExprKind :: Path ( hir:: QPath :: Resolved (
183- None ,
184- hir:: Path { res : hir:: def:: Res :: Local ( hir_id) , .. } ,
185- ) ) = lhs. kind
186- {
187- if let Some ( hir:: Node :: Binding ( pat) ) = self . tcx . hir ( ) . find ( * hir_id) {
188- let parent = self . tcx . hir ( ) . get_parent_node ( pat. hir_id ) ;
189- primary_span = pat. span ;
190- secondary_span = pat. span ;
191- match self . tcx . hir ( ) . find ( parent) {
192- Some ( hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , .. } ) ) => {
193- primary_span = ty. span ;
194- post_message = " type" ;
195- }
196- Some ( hir:: Node :: Local ( hir:: Local { init : Some ( init) , .. } ) ) => {
197- primary_span = init. span ;
198- post_message = " value" ;
199- }
200- Some ( hir:: Node :: Param ( hir:: Param { ty_span, .. } ) ) => {
201- primary_span = * ty_span;
202- post_message = " parameter type" ;
182+ match lhs. kind {
183+ hir:: ExprKind :: Path ( hir:: QPath :: Resolved (
184+ None ,
185+ hir:: Path {
186+ res :
187+ hir:: def:: Res :: Def (
188+ hir:: def:: DefKind :: Static | hir:: def:: DefKind :: Const ,
189+ def_id,
190+ ) ,
191+ ..
192+ } ,
193+ ) ) => {
194+ if let Some ( hir:: Node :: Item ( hir:: Item {
195+ ident,
196+ kind : hir:: ItemKind :: Static ( ty, ..) | hir:: ItemKind :: Const ( ty, ..) ,
197+ ..
198+ } ) ) = self . tcx . hir ( ) . get_if_local ( * def_id)
199+ {
200+ primary_span = ty. span ;
201+ secondary_span = ident. span ;
202+ post_message = " type" ;
203+ }
204+ }
205+ hir:: ExprKind :: Path ( hir:: QPath :: Resolved (
206+ None ,
207+ hir:: Path { res : hir:: def:: Res :: Local ( hir_id) , .. } ,
208+ ) ) => {
209+ if let Some ( hir:: Node :: Binding ( pat) ) = self . tcx . hir ( ) . find ( * hir_id) {
210+ let parent = self . tcx . hir ( ) . get_parent_node ( pat. hir_id ) ;
211+ primary_span = pat. span ;
212+ secondary_span = pat. span ;
213+ match self . tcx . hir ( ) . find ( parent) {
214+ Some ( hir:: Node :: Local ( hir:: Local { ty : Some ( ty) , .. } ) ) => {
215+ primary_span = ty. span ;
216+ post_message = " type" ;
217+ }
218+ Some ( hir:: Node :: Local ( hir:: Local { init : Some ( init) , .. } ) ) => {
219+ primary_span = init. span ;
220+ post_message = " value" ;
221+ }
222+ Some ( hir:: Node :: Param ( hir:: Param { ty_span, .. } ) ) => {
223+ primary_span = * ty_span;
224+ post_message = " parameter type" ;
225+ }
226+ _ => { }
203227 }
204- _ => { }
205228 }
206229 }
230+ _ => { }
207231 }
208232
209233 if primary_span != secondary_span
0 commit comments