@@ -164,15 +164,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
164164 let symbol_name = tcx. symbol_name ( instance) . name ;
165165 let is_weak = attrs. linkage == Some ( Linkage :: WeakAny ) ;
166166 if symbol_name == link_name. as_str ( ) {
167- if let Some ( SymbolTarget {
168- instance : original_instance,
169- cnum : original_cnum,
170- is_weak : original_is_weak,
171- } ) = symbol_target
167+ if let Some ( original) = & symbol_target
172168 {
173169 // There is more than one definition with this name. What we do now
174170 // depends on whether one or both definitions are weak.
175- match ( is_weak, original_is_weak ) {
171+ match ( is_weak, original . is_weak ) {
176172 ( false , true ) => {
177173 // Original definition is a weak definition. Override it.
178174
@@ -193,14 +189,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
193189
194190 // Make sure we are consistent wrt what is 'first' and 'second'.
195191 let original_span =
196- tcx. def_span ( original_instance . def_id ( ) ) . data ( ) ;
192+ tcx. def_span ( original . instance . def_id ( ) ) . data ( ) ;
197193 let span = tcx. def_span ( def_id) . data ( ) ;
198194 if original_span < span {
199195 throw_machine_stop ! (
200196 TerminationInfo :: MultipleSymbolDefinitions {
201197 link_name,
202198 first: original_span,
203- first_crate: tcx. crate_name( original_cnum ) ,
199+ first_crate: tcx. crate_name( original . cnum ) ,
204200 second: span,
205201 second_crate: tcx. crate_name( cnum) ,
206202 }
@@ -212,7 +208,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
212208 first: span,
213209 first_crate: tcx. crate_name( cnum) ,
214210 second: original_span,
215- second_crate: tcx. crate_name( original_cnum ) ,
211+ second_crate: tcx. crate_name( original . cnum ) ,
216212 }
217213 ) ;
218214 }
@@ -229,6 +225,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
229225 interp_ok ( ( ) )
230226 } ) ?;
231227
228+ // Once we identified the instance corresponding to the symbol, ensure
229+ // it is a function. It is okay to encounter non-functions in the search above
230+ // as long as the final instance we arrive at is a function.
232231 if let Some ( SymbolTarget { instance, .. } ) = symbol_target {
233232 if !matches ! ( tcx. def_kind( instance. def_id( ) ) , DefKind :: Fn | DefKind :: AssocFn ) {
234233 throw_ub_format ! (
0 commit comments