@@ -156,8 +156,8 @@ impl<'a> std::fmt::Debug for CrateDump<'a> {
156156enum CrateOrigin < ' a > {
157157 /// This crate was a dependency of another crate.
158158 IndirectDependency {
159- /// Where this dependency was included from.
160- dep_root : & ' a CratePaths ,
159+ /// Where this dependency was included from. Should only be used in error messages.
160+ dep_root_for_errors : & ' a CratePaths ,
161161 /// True if the parent is private, meaning the dependent should also be private.
162162 parent_private : bool ,
163163 /// Dependency info about this crate.
@@ -171,9 +171,11 @@ enum CrateOrigin<'a> {
171171
172172impl < ' a > CrateOrigin < ' a > {
173173 /// Return the dependency root, if any.
174- fn dep_root ( & self ) -> Option < & ' a CratePaths > {
174+ fn dep_root_for_errors ( & self ) -> Option < & ' a CratePaths > {
175175 match self {
176- CrateOrigin :: IndirectDependency { dep_root, .. } => Some ( dep_root) ,
176+ CrateOrigin :: IndirectDependency { dep_root_for_errors, .. } => {
177+ Some ( dep_root_for_errors)
178+ }
177179 _ => None ,
178180 }
179181 }
@@ -597,16 +599,16 @@ impl CStore {
597599 // Maintain a reference to the top most crate.
598600 // Stash paths for top-most crate locally if necessary.
599601 let crate_paths;
600- let dep_root = if let Some ( dep_root ) = origin. dep_root ( ) {
601- dep_root
602+ let dep_root_for_errors = if let Some ( dep_root_for_errors ) = origin. dep_root_for_errors ( ) {
603+ dep_root_for_errors
602604 } else {
603605 crate_paths = CratePaths :: new ( crate_root. name ( ) , source. clone ( ) ) ;
604606 & crate_paths
605607 } ;
606608
607609 let cnum_map = self . resolve_crate_deps (
608610 tcx,
609- dep_root ,
611+ dep_root_for_errors ,
610612 & crate_root,
611613 & metadata,
612614 cnum,
@@ -757,7 +759,7 @@ impl CStore {
757759 return Err ( CrateError :: NonAsciiName ( name) ) ;
758760 }
759761
760- let dep_root = origin. dep_root ( ) ;
762+ let dep_root_for_errors = origin. dep_root_for_errors ( ) ;
761763 let dep = origin. dep ( ) ;
762764 let hash = dep. map ( |d| d. hash ) ;
763765 let host_hash = dep. map ( |d| d. host_hash ) . flatten ( ) ;
@@ -795,7 +797,11 @@ impl CStore {
795797 host_hash,
796798 ) ? {
797799 Some ( res) => res,
798- None => return Err ( locator. into_error ( crate_rejections, dep_root. cloned ( ) ) ) ,
800+ None => {
801+ return Err (
802+ locator. into_error ( crate_rejections, dep_root_for_errors. cloned ( ) )
803+ ) ;
804+ }
799805 }
800806 }
801807 }
@@ -856,7 +862,7 @@ impl CStore {
856862 fn resolve_crate_deps (
857863 & mut self ,
858864 tcx : TyCtxt < ' _ > ,
859- dep_root : & CratePaths ,
865+ dep_root_for_errors : & CratePaths ,
860866 crate_root : & CrateRoot ,
861867 metadata : & MetadataBlob ,
862868 krate : CrateNum ,
@@ -866,7 +872,7 @@ impl CStore {
866872 debug ! (
867873 "resolving deps of external crate `{}` with dep root `{}`" ,
868874 crate_root. name( ) ,
869- dep_root . name
875+ dep_root_for_errors . name
870876 ) ;
871877 if crate_root. is_proc_macro_crate ( ) {
872878 return Ok ( CrateNumMap :: new ( ) ) ;
@@ -896,7 +902,7 @@ impl CStore {
896902 dep. name ,
897903 dep_kind,
898904 CrateOrigin :: IndirectDependency {
899- dep_root ,
905+ dep_root_for_errors ,
900906 parent_private : parent_is_private,
901907 dep : & dep,
902908 } ,
0 commit comments