Skip to content

Commit

Permalink
Merge branch 'main' into write-sparse-index (upgrade to Rust 1.65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 4, 2022
2 parents c4e6849 + f2a8a45 commit 5406630
Show file tree
Hide file tree
Showing 49 changed files with 109 additions and 79 deletions.
2 changes: 1 addition & 1 deletion cargo-smart-release/src/bat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Support {
return Ok(());
}
if Command::new("bat")
.args(&["--paging=always", "-l=md", "--file-name"])
.args(["--paging=always", "-l=md", "--file-name"])
.arg(format!("{} ({})", path_for_title.display(), additional_title.as_ref()))
.arg(path)
.status()?
Expand Down
2 changes: 1 addition & 1 deletion cargo-smart-release/src/changelog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Section {
return false;
};
segments.iter().any(
|s| matches!(s, section::Segment::Conventional(section::segment::Conventional {kind, removed, is_breaking, ..}) if *is_breaking && removed.is_empty() && as_headline(*kind).is_none()),
|s| matches!(s, section::Segment::Conventional(section::segment::Conventional {kind, removed, is_breaking, ..}) if *is_breaking && removed.is_empty() && as_headline(kind).is_none()),
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions cargo-smart-release/src/changelog/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn parse_conventional_to_next_section_title(
]
.iter()
.find(|kind| {
let headline = section::segment::conventional::as_headline(*kind).unwrap_or(*kind);
let headline = section::segment::conventional::as_headline(kind).unwrap_or(*kind);
let common_len = headline.len().min(title.len());
title
.get(..common_len)
Expand All @@ -256,7 +256,7 @@ fn parse_conventional_to_next_section_title(
.expect("BUG: this list needs an update too if new kinds of conventional messages are added");

let mut conventional = section::segment::Conventional {
kind: *kind,
kind,
is_breaking,
removed: vec![],
messages: vec![],
Expand Down
2 changes: 1 addition & 1 deletion cargo-smart-release/src/command/release/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ fn generate_commit_message(
match (
pending_changelogs.len(),
pending_changelogs.iter().fold(0usize, |mut acc, (_, _, lock)| {
acc += if !lock.resource_path().is_file() { 1 } else { 0 };
acc += usize::from(!lock.resource_path().is_file());
acc
})
) {
Expand Down
2 changes: 1 addition & 1 deletion cargo-smart-release/src/command/release/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ fn perform_release(ctx: &Context, options: Options, crates: &[traverse::Dependen
let prevent_default_members = ctx.base.meta.workspace_members.len() > 1;
for (publishee, new_version) in crates.iter().filter_map(try_to_published_crate_and_new_version) {
if let Some((crate_, version)) = successful_publishees_and_version.last() {
if let Err(err) = wait_for_release(*crate_, version, options) {
if let Err(err) = wait_for_release(crate_, version, options) {
log::warn!(
"Failed to wait for crates-index update - trying to publish '{} v{}' anyway: {}.",
publishee.name,
Expand Down
2 changes: 1 addition & 1 deletion git-config-value/tests/value/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn ignores_case() {
// Random subset
for word in &["no", "yes", "on", "off", "true", "false"] {
let first: bool = Boolean::try_from(b(word)).unwrap().into();
let second: bool = Boolean::try_from(b(&*word.to_uppercase())).unwrap().into();
let second: bool = Boolean::try_from(b(&word.to_uppercase())).unwrap().into();
assert_eq!(first, second);
}
}
Expand Down
2 changes: 1 addition & 1 deletion git-config/src/file/access/read_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl<'event> File<'event> {
///
/// This is the metadata the file was instantiated with for use in all newly created sections.
pub fn meta(&self) -> &Metadata {
&*self.meta
&self.meta
}

/// Similar to [`meta()`][File::meta()], but with shared ownership.
Expand Down
9 changes: 5 additions & 4 deletions git-config/tests/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ pub fn cow_str(s: &str) -> Cow<'_, BStr> {

#[test]
fn size_in_memory() {
assert_eq!(
std::mem::size_of::<git_config::File<'_>>(),
1040,
"This shouldn't change without us noticing"
let actual = std::mem::size_of::<git_config::File<'_>>();
assert!(
actual <= 1040,
"{} <= 1040: This shouldn't change without us noticing",
actual
);
}

Expand Down
27 changes: 15 additions & 12 deletions git-config/tests/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ mod section;

#[test]
fn size_in_memory() {
assert_eq!(
std::mem::size_of::<Section<'_>>(),
6768,
"This shouldn't change without us noticing"
let actual = std::mem::size_of::<Section<'_>>();
assert!(
actual <= 6768,
"{} <= 6768: This shouldn't change without us noticing",
actual
);
assert_eq!(
std::mem::size_of::<Event<'_>>(),
104,
"This shouldn't change without us noticing"
let actual = std::mem::size_of::<Event<'_>>();
assert!(
actual <= 104,
"{} <= 104: This shouldn't change without us noticing",
actual
);
assert_eq!(
std::mem::size_of::<Events<'_>>(),
872,
"This shouldn't change without us noticing"
let actual = std::mem::size_of::<Events<'_>>();
assert!(
actual <= 872,
"{} <= 872: This shouldn't change without us noticing",
actual
);
}

Expand Down
4 changes: 2 additions & 2 deletions git-config/tests/value/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ fn all_quote_optimization_is_correct() {
#[test]
fn quotes_right_next_to_each_other() {
let cow = normalize_bstr("\"hello\"\" world\"");
assert_eq!(cow, cow_str("hello world").to_owned());
assert_eq!(cow, cow_str("hello world").clone());
assert!(matches!(cow, Cow::Owned(_)));
}

#[test]
fn escaped_quotes_are_kept() {
let cow = normalize_bstr(r#""hello \"\" world""#);
assert_eq!(cow, cow_str("hello \"\" world").to_owned(),);
assert_eq!(cow, cow_str("hello \"\" world").clone(),);
assert!(matches!(cow, Cow::Owned(_)));
}

Expand Down
1 change: 1 addition & 0 deletions git-credentials/src/helper/cascade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl Cascade {
///
/// When _getting_ credentials, all programs are asked until the credentials are complete, stopping the cascade.
/// When _storing_ or _erasing_ all programs are instructed in order.
#[allow(clippy::result_large_err)]
pub fn invoke(&mut self, mut action: helper::Action, mut prompt: git_prompt::Options<'_>) -> protocol::Result {
let mut url = action
.context_mut()
Expand Down
1 change: 1 addition & 0 deletions git-credentials/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub mod protocol;
/// contain only the URL to kick off the process, or should be created by [`helper::NextAction`].
///
/// If more control is required, use the [`Cascade`][helper::Cascade] type.
#[allow(clippy::result_large_err)]
pub fn builtin(action: helper::Action) -> protocol::Result {
protocol::helper_outcome_to_result(
helper::invoke(&mut Program::from_kind(program::Kind::Builtin), &action)?,
Expand Down
1 change: 1 addition & 0 deletions git-credentials/src/protocol/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ mod mutate {
/// Destructure the url at our `url` field into parts like protocol, host, username and path and store
/// them in our respective fields. If `use_http_path` is set, http paths are significant even though
/// normally this isn't the case.
#[allow(clippy::result_large_err)]
pub fn destructure_url_in_place(&mut self, use_http_path: bool) -> Result<&mut Self, protocol::Error> {
let url = git_url::parse(self.url.as_ref().ok_or(protocol::Error::UrlMissing)?.as_ref())?;
self.protocol = Some(url.scheme.as_str().into());
Expand Down
1 change: 1 addition & 0 deletions git-credentials/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub struct Context {
}

/// Convert the outcome of a helper invocation to a helper result, assuring that the identity is complete in the process.
#[allow(clippy::result_large_err)]
pub fn helper_outcome_to_result(outcome: Option<helper::Outcome>, action: helper::Action) -> Result {
fn redact(mut ctx: Context) -> Context {
if let Some(pw) = ctx.password.as_mut() {
Expand Down
1 change: 1 addition & 0 deletions git-credentials/tests/helper/cascade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ mod invoke {
}
}

#[allow(clippy::result_large_err)]
fn invoke_cascade<'a>(names: impl IntoIterator<Item = &'a str>, action: Action) -> protocol::Result {
Cascade::default().use_http_path(true).extend(fixtures(names)).invoke(
action,
Expand Down
9 changes: 5 additions & 4 deletions git-diff/src/tree/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ mod tests {

#[test]
fn size_of_change() {
assert_eq!(
std::mem::size_of::<Change>(),
46,
"this type shouldn't grow without us knowing"
let actual = std::mem::size_of::<Change>();
assert!(
actual <= 46,
"{} <= 46: this type shouldn't grow without us knowing",
actual
)
}
}
2 changes: 1 addition & 1 deletion git-discover/tests/is_git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn verify_on_exfat() -> crate::Result<()> {
let _cleanup = {
// Mount dmg file
Command::new("hdiutil")
.args(&["attach", "-nobrowse", "-mountpoint"])
.args(["attach", "-nobrowse", "-mountpoint"])
.arg(mount_point.path())
.arg(fixtures.as_path().join("exfat_repo.dmg"))
.status()?;
Expand Down
4 changes: 2 additions & 2 deletions git-discover/tests/upwards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ fn cross_fs() -> crate::Result {
let dmg_location = tempfile::tempdir()?;
let dmg_file = dmg_location.path().join("temp.dmg");
Command::new("hdiutil")
.args(&["create", "-size", "1m"])
.args(["create", "-size", "1m"])
.arg(&dmg_file)
.status()?;

// Mount dmg file into temporary location
let mount_point = tempfile::tempdir()?;
Command::new("hdiutil")
.args(&["attach", "-nobrowse", "-mountpoint"])
.args(["attach", "-nobrowse", "-mountpoint"])
.arg(mount_point.path())
.arg(&dmg_file)
.status()?;
Expand Down
2 changes: 1 addition & 1 deletion git-glob/tests/wildmatch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ fn corpus() {
} else if actual != expected {
failures.push((pattern, pattern_text, text, actual, expected));
} else {
at_least_one_panic += if actual.any_panicked() { 1 } else { 0 };
at_least_one_panic += i32::from(actual.any_panicked());
}
}

Expand Down
2 changes: 1 addition & 1 deletion git-index/src/extension/tree/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Tree {
prev = Some(child);
}
if let Some(buf) = find_buf.as_mut() {
let tree_entries = find(&parent_id, *buf).ok_or(Error::TreeNodeNotFound { oid: parent_id })?;
let tree_entries = find(&parent_id, buf).ok_or(Error::TreeNodeNotFound { oid: parent_id })?;
let mut num_entries = 0;
for entry in tree_entries
.filter_map(Result::ok)
Expand Down
11 changes: 11 additions & 0 deletions git-object/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,38 @@ impl Object {
}
}
/// Turns this instance into a [`Blob`][Blob] if it is one.
#[allow(clippy::result_large_err)]
pub fn try_into_blob(self) -> Result<Blob, Self> {
match self {
Object::Blob(v) => Ok(v),
_ => Err(self),
}
}
/// Turns this instance into a [`BlobRef`][BlobRef] if it is a blob.
pub fn try_into_blob_ref(&self) -> Option<BlobRef<'_>> {
match self {
Object::Blob(v) => Some(v.to_ref()),
_ => None,
}
}
/// Turns this instance into a [`Commit`][Commit] if it is one.
#[allow(clippy::result_large_err)]
pub fn try_into_commit(self) -> Result<Commit, Self> {
match self {
Object::Commit(v) => Ok(v),
_ => Err(self),
}
}
/// Turns this instance into a [`Tree`][Tree] if it is one.
#[allow(clippy::result_large_err)]
pub fn try_into_tree(self) -> Result<Tree, Self> {
match self {
Object::Tree(v) => Ok(v),
_ => Err(self),
}
}
/// Turns this instance into a [`Tag`][Tag] if it is one.
#[allow(clippy::result_large_err)]
pub fn try_into_tag(self) -> Result<Tag, Self> {
match self {
Object::Tag(v) => Ok(v),
Expand Down
9 changes: 5 additions & 4 deletions git-object/tests/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ fn fixture_bytes(path: &str) -> Vec<u8> {

#[test]
fn size_in_memory() {
assert_eq!(
std::mem::size_of::<git_object::Object>(),
264,
"Prevent unexpected growth of what should be lightweight objects"
let actual = std::mem::size_of::<git_object::Object>();
assert!(
actual <= 264,
"{} <= 264: Prevent unexpected growth of what should be lightweight objects",
actual
)
}
2 changes: 1 addition & 1 deletion git-odb/src/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl PotentialPrefix {
/// matching this prefix.
pub fn new(id: impl Into<git_hash::ObjectId>, hex_len: usize) -> Result<Self, git_hash::prefix::Error> {
let id = id.into();
git_hash::Prefix::new(&id, hex_len)?;
git_hash::Prefix::new(id, hex_len)?;
Ok(PotentialPrefix { id, hex_len })
}

Expand Down
3 changes: 2 additions & 1 deletion git-odb/src/store_impls/dynamic/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ mod error {

#[test]
fn error_size() {
assert_eq!(std::mem::size_of::<Error>(), 88, "should not grow without us noticing");
let actual = std::mem::size_of::<Error>();
assert!(actual <= 88, "{} <= 88: should not grow without us noticing", actual);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions git-odb/src/store_impls/dynamic/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub(crate) mod index_lookup {
},
pack_offset: index.pack_offset_at_index(idx),
},
index_file: IntraPackLookup::Single(&**index),
index_file: IntraPackLookup::Single(index),
pack: data,
}),
handle::SingleOrMultiIndex::Multi { index, data } => index.lookup(object_id).map(move |idx| {
Expand All @@ -192,7 +192,7 @@ pub(crate) mod index_lookup {
pack_offset,
},
index_file: IntraPackLookup::Multi {
index: &**index,
index,
required_pack_index: pack_index,
},
pack: &mut data[pack_index as usize],
Expand Down Expand Up @@ -309,7 +309,7 @@ where

/// Return a shared reference to the contained store.
pub fn store_ref(&self) -> &S::Target {
&*self.store
&self.store
}

/// Return an owned store with shared ownership.
Expand Down
10 changes: 2 additions & 8 deletions git-odb/src/store_impls/dynamic/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,9 @@ impl super::Store {
if bundle.is_disposable() {
unreachable_indices += 1;
unreachable_packs += match bundle {
IndexAndPacks::Index(single) => {
if single.data.is_loaded() {
1
} else {
0
}
}
IndexAndPacks::Index(single) => usize::from(single.data.is_loaded()),
IndexAndPacks::MultiIndex(multi) => {
multi.data.iter().map(|p| if p.is_loaded() { 1 } else { 0 }).sum()
multi.data.iter().map(|p| usize::from(p.is_loaded())).sum()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion git-odb/src/store_impls/dynamic/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub(crate) enum OnDiskFileState<T: Clone> {

impl<T: Clone> OnDiskFile<T> {
pub fn path(&self) -> &Path {
&*self.path
&self.path
}
/// Return true if we hold a memory map of the file already.
pub fn is_loaded(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion git-prompt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod imp {
/// Ask the user given a `prompt`, returning the result.
pub fn ask(prompt: &str, opts: &Options<'_>) -> Result<String, Error> {
if let Some(askpass) = opts.askpass.as_deref() {
match git_command::prepare(askpass).arg(&prompt).spawn() {
match git_command::prepare(askpass).arg(prompt).spawn() {
Ok(cmd) => {
if let Some(mut stdout) = cmd
.wait_with_output()
Expand Down
1 change: 1 addition & 0 deletions git-protocol/src/fetch/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub(crate) mod function {
/// turns out to be required. `extra_parameters` are the parameters `(name, optional value)` to add to the handshake,
/// each time it is performed in case authentication is required.
/// `progress` is used to inform about what's currently happening.
#[allow(clippy::result_large_err)]
#[maybe_async]
pub async fn handshake<AuthFn, T>(
mut transport: T,
Expand Down
1 change: 1 addition & 0 deletions git-protocol/src/fetch_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl Default for FetchConnection {
/// * `progress` is used to emit progress messages.
///
/// _Note_ that depending on the `delegate`, the actual action performed can be `ls-refs`, `clone` or `fetch`.
#[allow(clippy::result_large_err)]
#[maybe_async]
pub async fn fetch<F, D, T, P>(
mut transport: T,
Expand Down
Loading

0 comments on commit 5406630

Please sign in to comment.