@@ -191,6 +191,7 @@ impl<'a> CrateLoader<'a> {
191
191
192
192
let Library { source, metadata } = lib;
193
193
let crate_root = metadata. get_root ( ) ;
194
+ let host_hash = host_lib. as_ref ( ) . map ( |lib| lib. metadata . get_root ( ) . hash ) ;
194
195
self . verify_no_symbol_conflicts ( span, & crate_root) ;
195
196
196
197
let private_dep = self . sess . opts . externs . get ( & name. as_str ( ) )
@@ -245,6 +246,7 @@ impl<'a> CrateLoader<'a> {
245
246
def_path_table,
246
247
trait_impls,
247
248
root : crate_root,
249
+ host_hash,
248
250
blob : metadata,
249
251
cnum_map,
250
252
cnum,
@@ -283,9 +285,7 @@ impl<'a> CrateLoader<'a> {
283
285
LoadResult :: Previous ( cnum) => return Some ( ( LoadResult :: Previous ( cnum) , None ) ) ,
284
286
LoadResult :: Loaded ( library) => Some ( LoadResult :: Loaded ( library) )
285
287
} ;
286
- // Don't look for a matching hash when looking for the host crate.
287
- // It won't be the same as the target crate hash
288
- locate_ctxt. hash = None ;
288
+ locate_ctxt. hash = locate_ctxt. host_hash ;
289
289
// Use the locate_ctxt when looking for the host proc macro crate, as that is required
290
290
// so we want it to affect the error message
291
291
( locate_ctxt, result)
@@ -334,10 +334,15 @@ impl<'a> CrateLoader<'a> {
334
334
dep : Option < ( & ' b CratePaths , & ' b CrateDep ) > ,
335
335
) -> Result < CrateNum , LoadError < ' b > > {
336
336
info ! ( "resolving crate `{}`" , name) ;
337
- let ( root, hash, extra_filename, path_kind) = match dep {
338
- Some ( ( root, dep) ) =>
339
- ( Some ( root) , Some ( & dep. hash ) , Some ( & dep. extra_filename [ ..] ) , PathKind :: Dependency ) ,
340
- None => ( None , None , None , PathKind :: Crate ) ,
337
+ let ( root, hash, host_hash, extra_filename, path_kind) = match dep {
338
+ Some ( ( root, dep) ) => (
339
+ Some ( root) ,
340
+ Some ( & dep. hash ) ,
341
+ dep. host_hash . as_ref ( ) ,
342
+ Some ( & dep. extra_filename [ ..] ) ,
343
+ PathKind :: Dependency
344
+ ) ,
345
+ None => ( None , None , None , None , PathKind :: Crate ) ,
341
346
} ;
342
347
let result = if let Some ( cnum) = self . existing_match ( name, hash, path_kind) {
343
348
( LoadResult :: Previous ( cnum) , None )
@@ -348,6 +353,7 @@ impl<'a> CrateLoader<'a> {
348
353
span,
349
354
crate_name : name,
350
355
hash,
356
+ host_hash,
351
357
extra_filename,
352
358
filesearch : self . sess . target_filesearch ( path_kind) ,
353
359
target : & self . sess . target . target ,
0 commit comments