@@ -114,10 +114,11 @@ def from_dep_kind(cls, kind: str):
114
114
for dependency_namespace , name_in_toml in names_in_toml :
115
115
if (dependency_namespace , name_in_toml ) in explicit_names_in_toml :
116
116
# If the `name_in_toml` is explicitly renamed one, it equals to the `extern_crate_name`.
117
- unused_packages [ dependency_namespace ]. add ( dependencies [dependency_namespace ][name_in_toml ]['id' ])
117
+ unused_package = dependencies [dependency_namespace ][name_in_toml ]['id' ]
118
118
else :
119
119
# Otherwise, it equals to the `package.name`.
120
- unused_packages [dependency_namespace ].add (next (p ['id' ] for p in dependencies [dependency_namespace ].values () if p ['name' ] == name_in_toml ))
120
+ unused_package = next (p ['id' ] for p in dependencies [dependency_namespace ].values () if p ['name' ] == name_in_toml )
121
+ unused_packages [dependency_namespace ].add (unused_package )
121
122
122
123
# Finally, adds source files related to the depended crates except:
123
124
#
@@ -170,21 +171,20 @@ def _related_source_files(metadata: Dict[str, Any]) -> Dict[pathlib.Path, Frozen
170
171
)
171
172
for d_file_path in d_file_paths :
172
173
with open (d_file_path ) as d_file :
173
- d = d_file .read ()
174
- found = False
175
- for line in d .splitlines ():
174
+ d_file_content = d_file .read ()
175
+ for line in d_file_content .splitlines ():
176
176
words = line .split (':' )
177
177
if len (words ) == 2 and pathlib .Path (words [0 ]) == d_file_path :
178
178
# Ignores paths like `/dev/null` or `/usr/share/foo/bar` (if any).
179
179
paths = [pathlib .Path (metadata ['workspace_root' ], s ) for s in words [1 ].split () if not pathlib .Path (s ).is_absolute ()]
180
180
if paths [:1 ] == [pathlib .Path (target ['src_path' ])]:
181
181
ret [paths [0 ]] = frozenset (paths [1 :])
182
- found = True
183
182
break
184
- if found :
185
- break
183
+ else :
184
+ continue
185
+ break
186
186
else :
187
- logger .warning ('no `.d` file for `%s`' , target ["name" ])
187
+ logger .error ('no `.d` file for `%s`' , target ["name" ])
188
188
189
189
_related_source_files_by_workspace [pathlib .Path (metadata ['workspace_root' ])] = ret
190
190
return ret
0 commit comments