-
Notifications
You must be signed in to change notification settings - Fork 103
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
WIP/DNM: Use 2024 edition #1130
base: main
Are you sure you want to change the base?
Changes from 1 commit
7f78da7
d6d4458
d7446ac
1cb0418
c519c27
9309167
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 |
---|---|---|
|
@@ -229,7 +229,8 @@ match-architectures = ["x86_64", "aarch64"] | |
.to_string(); | ||
let parsed_kargs = parse_kargs_toml(&file_content, sys_arch).unwrap(); | ||
assert_eq!(parsed_kargs, ["console=tty0", "nosmt"]); | ||
std::env::set_var("ARCH", "aarch64"); | ||
// TODO: Audit that the environment access only happens in single-threaded code. | ||
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. It definitely doesn't, rust runs unit tests in multiple threads by default. We need to stop setting this environment variable in the tests at all. At a quick look it's not clear we need this line of code, shouldn't we be just doing 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. Yeah it doesn't even reference the environment variable anywhere. No idea what that was ever about. I'll go open a separate PR against main to fix just that. 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.
|
||
unsafe { std::env::set_var("ARCH", "aarch64") }; | ||
let parsed_kargs = parse_kargs_toml(&file_content, sys_arch).unwrap(); | ||
assert_eq!(parsed_kargs, ["console=tty0", "nosmt"]); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,35 +136,35 @@ struct Generation { | |
dirmeta_found: BTreeSet<RcStr>, | ||
} | ||
|
||
fn push_dirmeta(repo: &ostree::Repo, gen: &mut Generation, checksum: &str) -> Result<()> { | ||
if gen.dirtree_found.contains(checksum) { | ||
fn push_dirmeta(repo: &ostree::Repo, r#gen: &mut Generation, checksum: &str) -> Result<()> { | ||
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. This is fine as an automated fix, but I think it'd be nicer to rename this to 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. 100%, I did exactly that manually before I realized that |
||
if r#gen.dirtree_found.contains(checksum) { | ||
return Ok(()); | ||
} | ||
let checksum = RcStr::from(checksum); | ||
gen.dirmeta_found.insert(RcStr::clone(&checksum)); | ||
r#gen.dirmeta_found.insert(RcStr::clone(&checksum)); | ||
let child_v = repo.load_variant(ostree::ObjectType::DirMeta, checksum.borrow())?; | ||
gen.metadata_size += child_v.data_as_bytes().as_ref().len() as u64; | ||
r#gen.metadata_size += child_v.data_as_bytes().as_ref().len() as u64; | ||
Ok(()) | ||
} | ||
|
||
fn push_dirtree( | ||
repo: &ostree::Repo, | ||
gen: &mut Generation, | ||
r#gen: &mut Generation, | ||
checksum: &str, | ||
) -> Result<glib::Variant> { | ||
let child_v = repo.load_variant(ostree::ObjectType::DirTree, checksum)?; | ||
if !gen.dirtree_found.contains(checksum) { | ||
gen.metadata_size += child_v.data_as_bytes().as_ref().len() as u64; | ||
if !r#gen.dirtree_found.contains(checksum) { | ||
r#gen.metadata_size += child_v.data_as_bytes().as_ref().len() as u64; | ||
} else { | ||
let checksum = RcStr::from(checksum); | ||
gen.dirtree_found.insert(checksum); | ||
r#gen.dirtree_found.insert(checksum); | ||
} | ||
Ok(child_v) | ||
} | ||
|
||
fn generate_chunking_recurse( | ||
repo: &ostree::Repo, | ||
gen: &mut Generation, | ||
r#gen: &mut Generation, | ||
chunk: &mut Chunk, | ||
dt: &glib::Variant, | ||
) -> Result<()> { | ||
|
@@ -176,7 +176,7 @@ fn generate_chunking_recurse( | |
let mut hexbuf = [0u8; 64]; | ||
for file in files { | ||
let (name, csum) = file.to_tuple(); | ||
let fpath = gen.path.join(name.to_str()); | ||
let fpath = r#gen.path.join(name.to_str()); | ||
hex::encode_to_slice(csum, &mut hexbuf)?; | ||
let checksum = std::str::from_utf8(&hexbuf)?; | ||
let meta = repo.query_file(checksum, gio::Cancellable::NONE)?.0; | ||
|
@@ -193,17 +193,17 @@ fn generate_chunking_recurse( | |
let (name, contents_csum, meta_csum) = item.to_tuple(); | ||
let name = name.to_str(); | ||
// Extend our current path | ||
gen.path.push(name); | ||
r#gen.path.push(name); | ||
hex::encode_to_slice(contents_csum, &mut hexbuf)?; | ||
let checksum_s = std::str::from_utf8(&hexbuf)?; | ||
let dirtree_v = push_dirtree(repo, gen, checksum_s)?; | ||
generate_chunking_recurse(repo, gen, chunk, &dirtree_v)?; | ||
let dirtree_v = push_dirtree(repo, r#gen, checksum_s)?; | ||
generate_chunking_recurse(repo, r#gen, chunk, &dirtree_v)?; | ||
drop(dirtree_v); | ||
hex::encode_to_slice(meta_csum, &mut hexbuf)?; | ||
let checksum_s = std::str::from_utf8(&hexbuf)?; | ||
push_dirmeta(repo, gen, checksum_s)?; | ||
push_dirmeta(repo, r#gen, checksum_s)?; | ||
// We did a push above, so pop must succeed. | ||
assert!(gen.path.pop()); | ||
assert!(r#gen.path.pop()); | ||
} | ||
Ok(()) | ||
} | ||
|
@@ -246,7 +246,7 @@ impl Chunking { | |
let commit = commit.to_tuple(); | ||
|
||
// Load it all into a single chunk | ||
let mut gen = Generation { | ||
let mut r#gen = Generation { | ||
path: Utf8PathBuf::from("/"), | ||
..Default::default() | ||
}; | ||
|
@@ -255,14 +255,14 @@ impl Chunking { | |
// Find the root directory tree | ||
let contents_checksum = &hex::encode(commit.6); | ||
let contents_v = repo.load_variant(ostree::ObjectType::DirTree, contents_checksum)?; | ||
push_dirtree(repo, &mut gen, contents_checksum)?; | ||
push_dirtree(repo, &mut r#gen, contents_checksum)?; | ||
let meta_checksum = &hex::encode(commit.7); | ||
push_dirmeta(repo, &mut gen, meta_checksum.as_str())?; | ||
push_dirmeta(repo, &mut r#gen, meta_checksum.as_str())?; | ||
|
||
generate_chunking_recurse(repo, &mut gen, &mut chunk, &contents_v)?; | ||
generate_chunking_recurse(repo, &mut r#gen, &mut chunk, &contents_v)?; | ||
|
||
let chunking = Chunking { | ||
metadata_size: gen.metadata_size, | ||
metadata_size: r#gen.metadata_size, | ||
remainder: chunk, | ||
..Default::default() | ||
}; | ||
|
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.
Here and I think all the other changes this is
cargo fix
being conservative with the drop ordering change. IMOif let
is easier to read thanmatch
and so we should not apply these changes.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.
For reference since I had to go find it - https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html