Skip to content
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

Release 0.19.0 #1116

Merged
merged 7 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ marks.*.json
inspect/
*.analysis.txt
analysis.txt
polonius_cache/
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"analysis/runtime",
"c2rust",
Expand All @@ -23,9 +24,10 @@ exclude = [
]

[workspace.package]
version = "0.18.0"
version = "0.19.0"
authors = ["The C2Rust Project Developers <[email protected]>"]
edition = "2021"
rust-version = "1.65"
readme = "README.md"
homepage = "https://c2rust.com/"
repository = "https://github.com/immunant/c2rust/"
Expand Down
2 changes: 1 addition & 1 deletion analysis/tests/lighttpd-minimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
libc = "0.2"
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.18.0" }
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.19.0" }

[features]
miri = []
2 changes: 1 addition & 1 deletion analysis/tests/lighttpd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
libc = "0.2"
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.18.0" }
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.19.0" }

[features]
miri = []
2 changes: 1 addition & 1 deletion analysis/tests/minimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"

[dependencies]
libc = "0.2"
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.18.0" }
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.19.0" }

[features]
miri = []
2 changes: 1 addition & 1 deletion analysis/tests/misc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
libc = "0.2"
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.18.0" }
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.19.0" }

[features]
miri = []
4 changes: 2 additions & 2 deletions c2rust-analyze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ toml_edit = "0.19.8"
sha2 = "0.10.8"

[build-dependencies]
c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.18.0" }
c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.19.0" }
print_bytes = "1.1"

[dev-dependencies]
c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.18.0" }
c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.19.0" }
clap = { version = "4.1.9", features = ["derive"] }
shlex = "1.3.0"

Expand Down
23 changes: 11 additions & 12 deletions c2rust-analyze/src/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn mark_foreign_fixed<'tcx>(
make_ty_fixed(gasn, lty);

// Also fix the `addr_of_static` permissions.
let ptr = gacx.addr_of_static[&did];
let ptr = gacx.addr_of_static[did];
gasn.flags[ptr].insert(FlagSet::FIXED);
}
}
Expand All @@ -397,7 +397,7 @@ fn mark_all_statics_fixed<'tcx>(gacx: &mut GlobalAnalysisCtxt<'tcx>, gasn: &mut
make_ty_fixed(gasn, lty);

// Also fix the `addr_of_static` permissions.
let ptr = gacx.addr_of_static[&did];
let ptr = gacx.addr_of_static[did];
gasn.flags[ptr].insert(FlagSet::FIXED);
}
}
Expand Down Expand Up @@ -425,7 +425,7 @@ fn parse_def_id(s: &str) -> Result<DefId, String> {
let s = s
.strip_prefix("DefId(")
.ok_or("does not start with `DefId(`")?;
let s = s.strip_suffix(")").ok_or("does not end with `)`")?;
let s = s.strip_suffix(')').ok_or("does not end with `)`")?;
let s = match s.find(" ~ ") {
Some(i) => &s[..i],
None => s,
Expand Down Expand Up @@ -459,11 +459,11 @@ fn read_fixed_defs_list(fixed_defs: &mut HashSet<DefId>, path: &str) -> io::Resu
for (i, line) in f.lines().enumerate() {
let line = line?;
let line = line.trim();
if line.len() == 0 || line.starts_with('#') {
if line.is_empty() || line.starts_with('#') {
continue;
}

let def_id = parse_def_id(&line).unwrap_or_else(|e| {
let def_id = parse_def_id(line).unwrap_or_else(|e| {
panic!("failed to parse {} line {}: {}", path, i + 1, e);
});
fixed_defs.insert(def_id);
Expand All @@ -481,7 +481,7 @@ fn check_rewrite_path_prefixes(tcx: TyCtxt, fixed_defs: &mut HashSet<DefId>, pre
.split(',')
// Exclude empty paths. This allows for leading/trailing commas or double commas within
// the list, which may result when building the list programmatically.
.filter(|prefix| prefix.len() > 0)
.filter(|prefix| !prefix.is_empty())
.map(|prefix| prefix.split("::").map(Symbol::intern).collect::<Vec<_>>())
.collect();
let sym_impl = Symbol::intern("{impl}");
Expand Down Expand Up @@ -1510,8 +1510,7 @@ fn run2<'tcx>(
continue;
}

let adt_rewrites =
rewrite::gen_adt_ty_rewrites(&gacx, &gasn, &global_pointee_types, def_id);
let adt_rewrites = rewrite::gen_adt_ty_rewrites(&gacx, &gasn, global_pointee_types, def_id);
let report = adt_reports.entry(def_id).or_default();
writeln!(
report,
Expand Down Expand Up @@ -1691,7 +1690,7 @@ fn run2<'tcx>(
ptrs.push(ptr);
format!("{{{}}}", ptr)
});
if ptrs.len() == 0 {
if ptrs.is_empty() {
continue;
}
ann.emit(span, format_args!("typeof({}) = {}", name, ty_str));
Expand Down Expand Up @@ -1789,7 +1788,7 @@ fn run2<'tcx>(
all_fn_ldids.len()
);

if known_perm_error_fns.len() > 0 {
if !known_perm_error_fns.is_empty() {
eprintln!(
"saw permission errors in {} known fns",
known_perm_error_fns.len()
Expand Down Expand Up @@ -1893,7 +1892,7 @@ fn apply_test_attr_force_non_null_args(
let mut updates_forbidden = g_updates_forbidden.and_mut(&mut info.l_updates_forbidden);

let lsig = &gacx.fn_sigs[&ldid.to_def_id()];
for arg_lty in lsig.inputs.iter().copied() {
for arg_lty in lsig.inputs {
for lty in arg_lty.iter() {
let ptr = lty.label;
if !ptr.is_none() {
Expand Down Expand Up @@ -2014,7 +2013,7 @@ fn print_function_pointee_types<'tcx>(

for ptr in all_pointer_ids {
let tys = &pointee_types[ptr];
if tys.ltys.len() == 0 && !tys.incomplete {
if tys.ltys.is_empty() && !tys.incomplete {
continue;
}
eprintln!(
Expand Down
4 changes: 2 additions & 2 deletions c2rust-analyze/src/borrowck/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
self.facts,
self.maps,
&self.acx.gacx.adt_metadata,
&self.acx.gacx.static_tys[&did],
self.acx.gacx.static_tys[&did],
);

for l in lty.iter() {
Expand Down Expand Up @@ -585,7 +585,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
}
Callee::Memcpy => {
let _pl_lty = self.visit_place(destination);
let _rv_lty = assert_matches!(&args[..], [dest, src, _] => {
assert_matches!(&args[..], [dest, src, _] => {
self.visit_operand(dest);
self.visit_operand(src);
});
Expand Down
20 changes: 10 additions & 10 deletions c2rust-analyze/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ pub fn print_ty_with_pointer_labels_into<L: Copy>(
// Types with arguments
Adt(adt_def, _substs) => {
write!(dest, "{:?}", adt_def.did()).unwrap();
if lty.args.len() != 0 {
if !lty.args.is_empty() {
dest.push('<');
// TODO: region args
for (i, &arg_lty) in lty.args.iter().enumerate() {
Expand Down Expand Up @@ -1532,31 +1532,31 @@ pub fn print_ty_with_pointer_labels_into<L: Copy>(
dest.push_str("*mut ");
}
let s = f(lty.label);
if s.len() > 0 {
if !s.is_empty() {
dest.push_str(&s);
dest.push_str(" ");
dest.push(' ');
}
print_ty_with_pointer_labels_into(dest, lty.args[0], f);
}
&Ref(_rg, _ty, mutbl) => {
let s = f(lty.label);
if mutbl == Mutability::Not {
dest.push_str("&");
if s.len() > 0 {
dest.push('&');
if !s.is_empty() {
dest.push(' ');
}
} else {
dest.push_str("&mut ");
}
if s.len() > 0 {
if !s.is_empty() {
dest.push_str(&s);
dest.push_str(" ");
dest.push(' ');
}
print_ty_with_pointer_labels_into(dest, lty.args[0], f);
}
FnDef(def_id, _substs) => {
write!(dest, "{:?}", def_id).unwrap();
if lty.args.len() != 0 {
if !lty.args.is_empty() {
dest.push('<');
// TODO: region args
for (i, &arg_lty) in lty.args.iter().enumerate() {
Expand All @@ -1581,14 +1581,14 @@ pub fn print_ty_with_pointer_labels_into<L: Copy>(
print_ty_with_pointer_labels_into(dest, ret_lty, f);
}
Tuple(_) => {
dest.push_str("(");
dest.push('(');
for (i, &arg_lty) in lty.args.iter().enumerate() {
if i > 0 {
dest.push_str(", ");
}
print_ty_with_pointer_labels_into(dest, arg_lty, f);
}
dest.push_str(")");
dest.push(')');
}

// Types that aren't actually supported by this code yet
Expand Down
2 changes: 1 addition & 1 deletion c2rust-analyze/src/dataflow/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
self.visit_operand(&args[0]);
}
Callee::Null { .. } => {
assert!(args.len() == 0);
assert!(args.is_empty());
self.visit_place(destination, Mutability::Mut);
let pl_lty = self.acx.type_of(destination);
// We are assigning a null pointer to `destination`, so it must not have the
Expand Down
2 changes: 1 addition & 1 deletion c2rust-analyze/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ fn cargo_wrapper(rustc_wrapper: &Path) -> anyhow::Result<()> {
cmd.env("C2RUST_ANALYZE_FIXED_DEFS_LIST", fixed_defs_list);
}

if rewrite_paths.len() > 0 {
if !rewrite_paths.is_empty() {
let rewrite_paths = rewrite_paths.join(OsStr::new(","));
cmd.env("C2RUST_ANALYZE_REWRITE_PATHS", rewrite_paths);
}
Expand Down
4 changes: 2 additions & 2 deletions c2rust-analyze/src/pointee_type/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn propagate_types<'tcx>(
if new && !ty_sets[ptr1].is_subset(&ty_sets[ptr2]) {
let (tys1, tys2) = index_both(&mut ty_sets, ptr1, ptr2);
for cty in tys1.iter() {
tys2.insert(cty.clone());
tys2.insert(*cty);
}
// Since `ty_sets[ptr2]` was not a subset of `ty_sets[ptr1]`, we must have added at
// least one element to `ty_sets[ptr2]`.
Expand All @@ -75,7 +75,7 @@ pub fn propagate_types<'tcx>(
if !ty_sets[ptr1].is_subset(&ty_sets[ptr2]) {
let (tys1, tys2) = index_both(&mut ty_sets, ptr1, ptr2);
for cty in tys1.iter() {
tys2.insert(cty.clone());
tys2.insert(*cty);
}
// Since `ty_sets[ptr2]` was not a subset of `ty_sets[ptr1]`, we must have added at
// least one element to `ty_sets[ptr2]`.
Expand Down
Loading
Loading