@@ -164,15 +164,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
164
164
let symbol_name = tcx. symbol_name ( instance) . name ;
165
165
let is_weak = attrs. linkage == Some ( Linkage :: WeakAny ) ;
166
166
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
172
168
{
173
169
// There is more than one definition with this name. What we do now
174
170
// depends on whether one or both definitions are weak.
175
- match ( is_weak, original_is_weak ) {
171
+ match ( is_weak, original . is_weak ) {
176
172
( false , true ) => {
177
173
// Original definition is a weak definition. Override it.
178
174
@@ -193,14 +189,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
193
189
194
190
// Make sure we are consistent wrt what is 'first' and 'second'.
195
191
let original_span =
196
- tcx. def_span ( original_instance . def_id ( ) ) . data ( ) ;
192
+ tcx. def_span ( original . instance . def_id ( ) ) . data ( ) ;
197
193
let span = tcx. def_span ( def_id) . data ( ) ;
198
194
if original_span < span {
199
195
throw_machine_stop ! (
200
196
TerminationInfo :: MultipleSymbolDefinitions {
201
197
link_name,
202
198
first: original_span,
203
- first_crate: tcx. crate_name( original_cnum ) ,
199
+ first_crate: tcx. crate_name( original . cnum ) ,
204
200
second: span,
205
201
second_crate: tcx. crate_name( cnum) ,
206
202
}
@@ -212,7 +208,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
212
208
first: span,
213
209
first_crate: tcx. crate_name( cnum) ,
214
210
second: original_span,
215
- second_crate: tcx. crate_name( original_cnum ) ,
211
+ second_crate: tcx. crate_name( original . cnum ) ,
216
212
}
217
213
) ;
218
214
}
@@ -229,6 +225,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
229
225
interp_ok ( ( ) )
230
226
} ) ?;
231
227
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.
232
231
if let Some ( SymbolTarget { instance, .. } ) = symbol_target {
233
232
if !matches ! ( tcx. def_kind( instance. def_id( ) ) , DefKind :: Fn | DefKind :: AssocFn ) {
234
233
throw_ub_format ! (
0 commit comments