@@ -93,7 +93,7 @@ impl Package {
9393 /// parses it. Lazy and tracked so we only pay the read and the R-parse
9494 /// for packages whose imports actually get resolved. Parsing every
9595 /// installed package's `NAMESPACE` eagerly would dominate the cost of
96- /// scanning a library with hundreds of packages, so we defer it.
96+ /// scanning a library with hundreds of packages, so we defer it (#1265) .
9797 ///
9898 /// A missing or unparseable `NAMESPACE` yields an empty `Namespace`.
9999 #[ salsa:: tracked( returns( ref) ) ]
@@ -114,19 +114,17 @@ impl Package {
114114 } ;
115115
116116 let namespace_path = dir. join ( "NAMESPACE" ) ;
117- let text = match fs:: read_to_string ( namespace_path. as_std_path ( ) ) {
118- Ok ( text) => text,
117+ match fs:: read_to_string ( namespace_path. as_std_path ( ) ) {
118+ Ok ( text) => Namespace :: parse ( & text) . log_err ( ) . unwrap_or_default ( ) ,
119119 // A package needn't ship a `NAMESPACE`, so absence is the normal
120120 // case and stays quiet. A file that exists but can't be read is
121121 // logged so the failure isn't silently read as "no namespace".
122- Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => return Namespace :: default ( ) ,
122+ Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => Namespace :: default ( ) ,
123123 Err ( err) => {
124124 log:: error!( "Failed to read `{namespace_path}`: {err:?}" ) ;
125- return Namespace :: default ( ) ;
125+ Namespace :: default ( )
126126 } ,
127- } ;
128-
129- Namespace :: parse ( & text) . log_err ( ) . unwrap_or_default ( )
127+ }
130128 }
131129
132130 /// The package's `Version:`, parsed lazily from `DESCRIPTION`. `None`
@@ -171,17 +169,16 @@ impl Package {
171169 report_untracked_if_zero ( db, self . description_revision ( db) ) ;
172170
173171 let path = self . description_path ( db) . as_path ( ) ?;
174- let text = match fs:: read_to_string ( path. as_std_path ( ) ) {
175- Ok ( text) => text,
172+ match fs:: read_to_string ( path. as_std_path ( ) ) {
173+ Ok ( text) => Description :: parse ( & text) . log_err ( ) ,
176174 // A missing `DESCRIPTION` is the normal "gone after a rescan" case
177175 // and stays quiet. A file that exists but can't be read is logged
178176 // rather than silently treated as absent.
179- Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => return None ,
177+ Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => None ,
180178 Err ( err) => {
181179 log:: error!( "Failed to read `{path}`: {err:?}" ) ;
182- return None ;
180+ None
183181 } ,
184- } ;
185- Description :: parse ( & text) . log_err ( )
182+ }
186183 }
187184}
0 commit comments