Skip to content

Commit b89d18b

Browse files
committed
refactor(source): Remove redundant PathSource::loaded
1 parent 5c820b8 commit b89d18b

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/cargo/sources/path.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ pub struct PathSource<'gctx> {
2929
source_id: SourceId,
3030
/// The root path of this source.
3131
path: PathBuf,
32-
/// Whether this source has loaded all package information it may contain.
33-
loaded: bool,
3432
/// Packages that this sources has discovered.
3533
package: Option<Package>,
3634
gctx: &'gctx GlobalContext,
@@ -45,7 +43,6 @@ impl<'gctx> PathSource<'gctx> {
4543
Self {
4644
source_id,
4745
path: path.to_path_buf(),
48-
loaded: false,
4946
package: None,
5047
gctx,
5148
}
@@ -59,7 +56,6 @@ impl<'gctx> PathSource<'gctx> {
5956
Self {
6057
source_id,
6158
path,
62-
loaded: true,
6359
package: Some(pkg),
6460
gctx,
6561
}
@@ -96,7 +92,7 @@ impl<'gctx> PathSource<'gctx> {
9692

9793
/// Gets the last modified file in a package.
9894
pub fn last_modified_file(&self, pkg: &Package) -> CargoResult<(FileTime, PathBuf)> {
99-
if !self.loaded {
95+
if self.package.is_none() {
10096
return Err(internal(format!(
10197
"BUG: source `{:?}` was not loaded",
10298
self.path
@@ -112,9 +108,8 @@ impl<'gctx> PathSource<'gctx> {
112108

113109
/// Discovers packages inside this source if it hasn't yet done.
114110
pub fn load(&mut self) -> CargoResult<()> {
115-
if !self.loaded {
111+
if self.package.is_none() {
116112
self.package = Some(self.read_package()?);
117-
self.loaded = true;
118113
}
119114

120115
Ok(())

0 commit comments

Comments
 (0)