@@ -191,6 +191,7 @@ impl<'a> CrateLoader<'a> {
191191
192192 let Library { source, metadata } = lib;
193193 let crate_root = metadata. get_root ( ) ;
194+ let host_hash = host_lib. as_ref ( ) . map ( |lib| lib. metadata . get_root ( ) . hash ) ;
194195 self . verify_no_symbol_conflicts ( span, & crate_root) ;
195196
196197 let private_dep = self . sess . opts . externs . get ( & name. as_str ( ) )
@@ -245,6 +246,7 @@ impl<'a> CrateLoader<'a> {
245246 def_path_table,
246247 trait_impls,
247248 root : crate_root,
249+ host_hash,
248250 blob : metadata,
249251 cnum_map,
250252 cnum,
@@ -283,9 +285,7 @@ impl<'a> CrateLoader<'a> {
283285 LoadResult :: Previous ( cnum) => return Some ( ( LoadResult :: Previous ( cnum) , None ) ) ,
284286 LoadResult :: Loaded ( library) => Some ( LoadResult :: Loaded ( library) )
285287 } ;
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 ;
289289 // Use the locate_ctxt when looking for the host proc macro crate, as that is required
290290 // so we want it to affect the error message
291291 ( locate_ctxt, result)
@@ -334,10 +334,15 @@ impl<'a> CrateLoader<'a> {
334334 dep : Option < ( & ' b CratePaths , & ' b CrateDep ) > ,
335335 ) -> Result < CrateNum , LoadError < ' b > > {
336336 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 ) ,
341346 } ;
342347 let result = if let Some ( cnum) = self . existing_match ( name, hash, path_kind) {
343348 ( LoadResult :: Previous ( cnum) , None )
@@ -348,6 +353,7 @@ impl<'a> CrateLoader<'a> {
348353 span,
349354 crate_name : name,
350355 hash,
356+ host_hash,
351357 extra_filename,
352358 filesearch : self . sess . target_filesearch ( path_kind) ,
353359 target : & self . sess . target . target ,
0 commit comments