Skip to content

Release 0.20.0 #1203

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

Merged
merged 9 commits into from
Feb 25, 2025
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
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.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exclude = [
]

[workspace.package]
version = "0.19.0"
version = "0.20.0"
authors = ["The C2Rust Project Developers <[email protected]>"]
edition = "2021"
rust-version = "1.65"
Expand Down
1 change: 1 addition & 0 deletions analysis/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true
publish = false

[dependencies]
serde = { version = "1.0", features = ["derive"] }
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.19.0" }
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.20.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.19.0" }
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.20.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.19.0" }
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.20.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.19.0" }
c2rust-analysis-rt = { path = "../../runtime", optional = true, version = "0.20.0" }

[features]
miri = []
7 changes: 4 additions & 3 deletions c2rust-analyze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true
publish = false

[dependencies]
polonius-engine = "0.13.0"
rustc-hash = "1.1.0"
bitflags = "1.3.2"
c2rust-pdg = { path = "../pdg" }
c2rust-pdg = { path = "../pdg", version = "0.20.0"}
bincode = "1.0"
serde = "1.0"
assert_matches = "1.5.0"
Expand All @@ -32,11 +33,11 @@ toml_edit = "0.19.8"
sha2 = "0.10.8"

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

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

Expand Down
10 changes: 5 additions & 5 deletions c2rust-analyze/src/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ fn parse_def_id(s: &str) -> Result<DefId, String> {
};

let rendered = format!("{:?}", def_id);
if &rendered != orig_s {
if rendered != orig_s {
return Err(format!(
"path mismatch: after parsing input {}, obtained a different path {:?}",
orig_s, def_id
Expand Down Expand Up @@ -915,7 +915,7 @@ fn run(tcx: TyCtxt) {
borrowck::borrowck_mir(
&acx,
&info.dataflow,
&mut asn.perms_mut(),
asn.perms_mut(),
&updates_forbidden,
name.as_str(),
&mir,
Expand Down Expand Up @@ -964,7 +964,7 @@ fn run(tcx: TyCtxt) {
loop_count, num_changed
);

if &asn.perms.as_slice()[..gacx.num_global_pointers()] == &old_gasn {
if asn.perms.as_slice()[..gacx.num_global_pointers()] == old_gasn {
break;
}
}
Expand Down Expand Up @@ -1117,13 +1117,13 @@ fn run(tcx: TyCtxt) {
continue;
}
ann.emit(span, format_args!("typeof({:?}) = {}", local, ty_str));
if static_non_null_ptrs.len() > 0 {
if !static_non_null_ptrs.is_empty() {
ann.emit(
span,
format_args!(" static NON_NULL: {:?}", static_non_null_ptrs),
);
}
if dynamic_non_null_ptrs.len() > 0 {
if !dynamic_non_null_ptrs.is_empty() {
ann.emit(
span,
format_args!(" dynamic NON_NULL: {:?}", dynamic_non_null_ptrs),
Expand Down
8 changes: 4 additions & 4 deletions c2rust-analyze/src/borrowck/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ impl<'tcx> TypeChecker<'tcx, '_> {
{
let field_lifetime_param = OriginParam::try_from(field_lifetime_arg).ok();

field_lifetime_param.and_then(|field_lifetime_param| {
if let Some((base_lifetime_param, og)) = field_lifetime_param.and_then(|field_lifetime_param| {
base_origin_param_map.get_key_value(&field_lifetime_param)
}).map(|(base_lifetime_param, og)| {
}) {
debug!(
"mapping {base_adt_def:?} lifetime parameter {base_lifetime_param:?} to \
{base_adt_def:?}.{:} struct definition lifetime parameter {field_struct_lifetime_param:?}, \
corresponding to its lifetime parameter {field_lifetime_param:?} within {base_adt_def:?}",
field_def.name
);
field_origin_param_map.push((*field_struct_lifetime_param, *og));
});
field_origin_param_map.push((*field_struct_lifetime_param, *og));
}
}

let origin_params= self.ltcx.arena().alloc_from_iter(field_origin_param_map.into_iter());
Expand Down
4 changes: 2 additions & 2 deletions c2rust-analyze/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ impl<'tcx> GlobalAnalysisCtxt<'tcx> {
}

/// Iterate over the `DefId`s of all functions that should skip rewriting.
pub fn iter_fns_skip_rewrite<'a>(&'a self) -> impl Iterator<Item = DefId> + 'a {
pub fn iter_fns_skip_rewrite(&self) -> impl Iterator<Item = DefId> + '_ {
self.dont_rewrite_fns.keys()
}

Expand Down Expand Up @@ -1675,7 +1675,7 @@ where
mem::take(&mut self.new)
}

pub fn keys<'a>(&'a self) -> impl Iterator<Item = K> + 'a {
pub fn keys(&self) -> impl Iterator<Item = K> + '_ {
self.m.keys().copied()
}
}
Expand Down
2 changes: 1 addition & 1 deletion c2rust-analyze/src/last_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl LastUse {
self.set.contains_key(&(loc, which))
}

pub fn iter<'a>(&'a self) -> impl Iterator<Item = (Location, WhichPlace, Local)> + 'a {
pub fn iter(&self) -> impl Iterator<Item = (Location, WhichPlace, Local)> + '_ {
self.set
.iter()
.map(|(&(loc, which), &local)| (loc, which, local))
Expand Down
4 changes: 0 additions & 4 deletions c2rust-analyze/src/pointer_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ impl PartialEq for PointerId {
fn eq(&self, other: &PointerId) -> bool {
self.index() == other.index()
}

fn ne(&self, other: &PointerId) -> bool {
self.index() != other.index()
}
}

impl Eq for PointerId {}
Expand Down
2 changes: 1 addition & 1 deletion c2rust-analyze/src/recent_writes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl BlockWrites {
}

impl RecentWrites {
pub fn new<'tcx>(mir: &Body<'tcx>) -> RecentWrites {
pub fn new(mir: &Body) -> RecentWrites {
calc_recent_writes(mir)
}

Expand Down
12 changes: 6 additions & 6 deletions c2rust-analyze/src/rewrite/expr/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,20 +806,20 @@ fn generate_zeroize_code(zero_ty: &ZeroizeType, lv: &str) -> String {
/// Generate an expression to produce a zeroized version of a value.
fn generate_zeroize_expr(zero_ty: &ZeroizeType) -> String {
match *zero_ty {
ZeroizeType::Int => format!("0"),
ZeroizeType::Bool => format!("false"),
ZeroizeType::Option => format!("None"),
ZeroizeType::Int => "0".to_string(),
ZeroizeType::Bool => "false".to_string(),
ZeroizeType::Option => "None".to_string(),
ZeroizeType::Array(ref elem_zero_ty) => format!(
"std::array::from_fn(|| {})",
generate_zeroize_expr(elem_zero_ty)
),
ZeroizeType::Struct(ref name, ref fields) => {
let mut s = String::new();
write!(s, "{} {{\n", name).unwrap();
writeln!(s, "{} {{", name).unwrap();
for (name, field_zero_ty) in fields {
write!(s, "{}: {},\n", name, generate_zeroize_expr(field_zero_ty),).unwrap();
writeln!(s, "{}: {},", name, generate_zeroize_expr(field_zero_ty),).unwrap();
}
write!(s, "}}\n").unwrap();
writeln!(s, "}}").unwrap();
s
}
}
Expand Down
8 changes: 4 additions & 4 deletions c2rust-analyze/src/rewrite/expr/mir_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
rewrite::ty::rewrite_lty(
tcx,
lty,
&self.perms,
&self.flags,
self.perms,
self.flags,
&self.pointee_types,
&self.acx.gacx.adt_metadata,
)
Expand Down Expand Up @@ -795,7 +795,7 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
.intersects(PermissionSet::OFFSET_ADD | PermissionSet::OFFSET_SUB);

let opt_zero_ty =
ZeroizeType::from_lty(&v.acx, v.perms, v.flags, pointee_lty);
ZeroizeType::from_lty(v.acx, v.perms, v.flags, pointee_lty);
let zero_ty = match opt_zero_ty {
Some(x) => x,
// TODO: emit void* cast before bailing out
Expand Down Expand Up @@ -1198,7 +1198,7 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {

// TODO: downgrade Move to Imm if the new type is Copy

debug_assert!(pl.projection.len() >= 1);
debug_assert!(!pl.projection.is_empty());
// `LTy` of the base place, before the last projection.
let base_lty = proj_ltys[pl.projection.len() - 1];
// `LTy` resulting from applying `last_proj` to `base_lty`.
Expand Down
4 changes: 2 additions & 2 deletions c2rust-analyze/src/rewrite/statics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use rustc_span::Span;

/// For every static, if its write permission does not match its declared mutability, emit a rewrite
/// changing the declaration to match observed/analyzed usage.
pub fn gen_static_rewrites<'tcx>(
tcx: TyCtxt<'tcx>,
pub fn gen_static_rewrites(
tcx: TyCtxt,
asn: &Assignment,
def_id: DefId,
ptr: PointerId,
Expand Down
2 changes: 1 addition & 1 deletion c2rust-analyze/src/type_desc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'tcx> From<TypeDesc<'tcx>> for PtrDesc {
}

impl PtrDesc {
pub fn to_type_desc<'tcx>(self, pointee_ty: Ty<'tcx>) -> TypeDesc<'tcx> {
pub fn to_type_desc(self, pointee_ty: Ty) -> TypeDesc {
let PtrDesc {
own,
qty,
Expand Down
2 changes: 1 addition & 1 deletion c2rust-ast-exporter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bindgen = { version = "0.65", features = ["logging"] }
clang-sys = "1.3"
cmake = "0.1.49"
env_logger = "0.10"
c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.19.0" }
c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.20.0" }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion c2rust-bitfields/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
c2rust-bitfields-derive = { version = "0.19.0", path = "../c2rust-bitfields-derive" }
c2rust-bitfields-derive = { version = "0.20.0", path = "../c2rust-bitfields-derive" }

[dev-dependencies]
libc = "0.2"
Expand Down
Loading
Loading