-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement --locked
for build-std
#14589
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -103,6 +103,12 @@ pub struct Workspace<'gctx> { | |||||||||||||||||||
/// file. This is set for `cargo install` without `--locked`. | ||||||||||||||||||||
ignore_lock: bool, | ||||||||||||||||||||
|
||||||||||||||||||||
/// If `true`, then the resolver will not update the `Cargo.lock` file and | ||||||||||||||||||||
/// return an error if the lockfile is missing or out of date, similar | ||||||||||||||||||||
/// to the `GlobalContext::locked()` behaviour. Note that | ||||||||||||||||||||
Comment on lines
+106
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are already too many fields controlling the
Suggested change
|
||||||||||||||||||||
/// the lockfile is not written if `require_optional_deps` is false. | ||||||||||||||||||||
is_locked: bool, | ||||||||||||||||||||
|
||||||||||||||||||||
/// Requested path of the lockfile (i.e. passed as the cli flag) | ||||||||||||||||||||
requested_lockfile_path: Option<PathBuf>, | ||||||||||||||||||||
|
||||||||||||||||||||
|
@@ -240,6 +246,7 @@ impl<'gctx> Workspace<'gctx> { | |||||||||||||||||||
member_ids: HashSet::new(), | ||||||||||||||||||||
default_members: Vec::new(), | ||||||||||||||||||||
is_ephemeral: false, | ||||||||||||||||||||
is_locked: false, | ||||||||||||||||||||
require_optional_deps: true, | ||||||||||||||||||||
loaded_packages: RefCell::new(HashMap::new()), | ||||||||||||||||||||
ignore_lock: false, | ||||||||||||||||||||
|
@@ -635,6 +642,14 @@ impl<'gctx> Workspace<'gctx> { | |||||||||||||||||||
self | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
pub fn is_locked(&self) -> bool { | ||||||||||||||||||||
self.is_locked | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
pub fn set_is_locked(&mut self, is_locked: bool) { | ||||||||||||||||||||
self.is_locked = is_locked | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
/// Returns the directory where the lockfile is in. | ||||||||||||||||||||
pub fn lock_root(&self) -> Filesystem { | ||||||||||||||||||||
if let Some(requested) = self.requested_lockfile_path.as_ref() { | ||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -66,6 +66,14 @@ pub fn write_pkg_lockfile(ws: &Workspace<'_>, resolve: &mut Resolve) -> CargoRes | |||||||||||||||
); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
if ws.is_locked() { | ||||||||||||||||
anyhow::bail!( | ||||||||||||||||
"Attempted to write to the standard library's lockfile.\n\ | ||||||||||||||||
This most likely means the lockfile has been previously modified by mistake.\ | ||||||||||||||||
Try removing and readding the `rust-src` component." | ||||||||||||||||
Comment on lines
+71
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
// While we're updating the lock file anyway go ahead and update its | ||||||||||||||||
// encoding to whatever the latest default is. That way we can slowly roll | ||||||||||||||||
// out lock file updates as they're otherwise already updated, and changes | ||||||||||||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we remove this? Did it cause any issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargo/src/cargo/ops/resolve.rs
Lines 289 to 294 in 15fbd2f
Okay it is this one.
I am unsure if removing this is the correct approach.
require_optional_deps
affects how we resolve dependencies. And with that std starts respecting path override.cargo/src/cargo/ops/resolve.rs
Lines 163 to 173 in 15fbd2f