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

Update rustc version incrementally to nightly-2022-12-06 #811

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
867db8b
Updated to `nightly-2022-08-22`, the latest version not requiring any…
kkysen Jan 4, 2023
74f703f
Used `Default::default()` instead of `Vec::new()` so that `ThinVec::n…
kkysen Jan 4, 2023
9416506
Updated to `nightly-2022-08-23` after the `Vec::new()` => `Default::d…
kkysen Jan 4, 2023
9f4e406
Updated to `nightly-2022-08-29`, the latest version not requiring any…
kkysen Jan 4, 2023
a2738de
Updated to `nightly-2022-09-30`, changing `.basic_blocks()` => `.basi…
kkysen Jan 4, 2023
de457a9
Updated to `nightly-2022-09-08`, changing `StatementKind::{CopyNonOve…
kkysen Jan 4, 2023
23d9928
`cargo clippy --fix` after the update to `nightly-2022-09-08`.
kkysen Jan 4, 2023
848a7e9
Updated to `nightly-2022-09-17`, the latest version not requiring an…
kkysen Jan 4, 2023
bf95e95
`cargo clippy --fix && cargo fmt` after the update to `nightly-2022-0…
kkysen Jan 5, 2023
4a740ab
In `c2rust_instrument::into_operand::make_const`, use `ConstantKind::…
kkysen Jan 5, 2023
76be307
Updated to `nightly-2022-09-19`, which seems to change the PDG by eli…
kkysen Jan 5, 2023
674d0e2
Updated to `nightly-2022-09-21`, adding a `match` arm for `Projection…
kkysen Jan 5, 2023
5ea3998
Updated to `nightly-2022-10-08`, the latest version not requiring any…
kkysen Jan 5, 2023
6ede894
`cargo clippy --fix` after the update to `nightly-2022-10-08`.
kkysen Jan 5, 2023
78d36f2
Trivial `clippy` fixes after the update to `nightly-2022-10-08`.
kkysen Jan 5, 2023
7fd06e3
Updated to `nightly-2022-10-09`, changing `CastKind{Misc => PtrToPtr}…
kkysen Jan 5, 2023
9e6a899
Updated to `nightly-2022-12-06`, the latest version not requiring any…
kkysen Jan 5, 2023
3bb66d6
`cargo clippy --fix && cargo fmt` after the update to `nightly-2022-1…
kkysen Jan 5, 2023
d835ba6
Trivial `clippy` fixes after the update to `nightly-2022-12-06`.
kkysen Jan 5, 2023
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
30 changes: 15 additions & 15 deletions analysis/runtime/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,31 @@ impl Debug for EventKind {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
use EventKind::*;
match *self {
CopyPtr(ptr) => write!(f, "copy(0x{:x})", ptr),
Field(ptr, id) => write!(f, "field(0x{:x}, {})", ptr, id),
CopyPtr(ptr) => write!(f, "copy(0x{ptr:x})"),
Field(ptr, id) => write!(f, "field(0x{ptr:x}, {id})"),
Alloc { size, ptr } => {
write!(f, "malloc({}) -> 0x{:x}", size, ptr)
write!(f, "malloc({size}) -> 0x{ptr:x}")
}
Free { ptr } => write!(f, "free(0x{:x})", ptr),
Free { ptr } => write!(f, "free(0x{ptr:x})"),
Realloc {
old_ptr,
size,
new_ptr,
} => write!(f, "realloc(0x{:x}, {}) -> 0x{:x}", old_ptr, size, new_ptr),
Ret(ptr) => write!(f, "ret(0x{:x})", ptr),
} => write!(f, "realloc(0x{old_ptr:x}, {size}) -> 0x{new_ptr:x}"),
Ret(ptr) => write!(f, "ret(0x{ptr:x})"),
Done => write!(f, "done"),
BeginFuncBody => write!(f, "begin func body"),
LoadAddr(ptr) => write!(f, "load(0x{:x})", ptr),
StoreAddr(ptr) => write!(f, "store(0x{:x})", ptr),
StoreAddrTaken(ptr) => write!(f, "store(0x{:x})", ptr),
LoadAddr(ptr) => write!(f, "load(0x{ptr:x})"),
StoreAddr(ptr) => write!(f, "store(0x{ptr:x})"),
StoreAddrTaken(ptr) => write!(f, "store(0x{ptr:x})"),
CopyRef => write!(f, "copy_ref"),
AddrOfLocal(ptr, _) => write!(f, "addr_of_local = 0x{:x}", ptr),
ToInt(ptr) => write!(f, "to_int(0x{:x})", ptr),
FromInt(ptr) => write!(f, "from_int(0x{:x})", ptr),
LoadValue(ptr) => write!(f, "load_value(0x{:x})", ptr),
StoreValue(ptr) => write!(f, "store_value(0x{:x})", ptr),
AddrOfLocal(ptr, _) => write!(f, "addr_of_local = 0x{ptr:x}"),
ToInt(ptr) => write!(f, "to_int(0x{ptr:x})"),
FromInt(ptr) => write!(f, "from_int(0x{ptr:x})"),
LoadValue(ptr) => write!(f, "load_value(0x{ptr:x})"),
StoreValue(ptr) => write!(f, "store_value(0x{ptr:x})"),
Offset(ptr, offset, new_ptr) => {
write!(f, "offset(0x{:x}, {:?}, 0x{:x})", ptr, offset, new_ptr)
write!(f, "offset(0x{ptr:x}, {offset:?}, 0x{new_ptr:x})")
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions analysis/runtime/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ pub fn ptr_field(mir_loc: MirLocId, ptr: usize, field_id: u32) {
pub fn ptr_copy(mir_loc: MirLocId, ptr: usize) {
RUNTIME.send_event(Event {
mir_loc,
kind: EventKind::CopyPtr(ptr as usize),
kind: EventKind::CopyPtr(ptr),
});
}

pub fn ptr_contrive(mir_loc: MirLocId, ptr: usize) {
RUNTIME.send_event(Event {
mir_loc,
kind: EventKind::FromInt(ptr as usize),
kind: EventKind::FromInt(ptr),
});
}

pub fn ptr_to_int(mir_loc: MirLocId, ptr: usize) {
RUNTIME.send_event(Event {
mir_loc,
kind: EventKind::ToInt(ptr as usize),
kind: EventKind::ToInt(ptr),
});
}

Expand Down
4 changes: 2 additions & 2 deletions analysis/runtime/src/mir_loc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ impl Display for MirPlace {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{:?}", self.local)?;
for p in &self.projection {
write!(f, ".{}", p)?;
write!(f, ".{p}")?;
}
Ok(())
}
}

impl Debug for MirPlace {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}", self)
write!(f, "{self}")
}
}

Expand Down
2 changes: 1 addition & 1 deletion analysis/runtime/src/runtime/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Detect for LogBackend {
.write(true)
.append(append)
.truncate(!append)
.open(&path)?;
.open(path)?;
let writer = BufWriter::new(file);
Ok(Self { writer })
}
Expand Down
2 changes: 1 addition & 1 deletion c2rust-analyze/src/borrowck/def_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<'tcx> Visitor<'tcx> for DefUseVisitor<'tcx, '_> {

fn visit_statement(&mut self, stmt: &Statement<'tcx>, location: Location) {
self.super_statement(stmt, location);
eprintln!("visit stmt {:?} at {:?}", stmt, location);
eprintln!("visit stmt {stmt:?} at {location:?}");

if let StatementKind::StorageDead(local) = stmt.kind {
// Observed: `StorageDead` emits `path_moved_at_base` at the `Mid` point.
Expand Down
4 changes: 2 additions & 2 deletions c2rust-analyze/src/borrowck/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl<K: Render + Ord, V: Render> OutputTable for FxHashMap<K, V> {

impl OutputTable for bool {
fn write(&self, out: &mut dyn Write, _maps: &AtomMaps) -> Result<(), Box<dyn Error>> {
writeln!(out, "{}", self)?;
writeln!(out, "{self}")?;
Ok(())
}
}
Expand Down Expand Up @@ -332,7 +332,7 @@ impl Render for Loan {
impl Render for Point {
fn to_string(&self, maps: &AtomMaps) -> String {
let (bb, idx, sub) = maps.get_point(*self);
format!("{:?}({:?}[{}])", sub, bb, idx)
format!("{sub:?}({bb:?}[{idx}])")
}
}

Expand Down
23 changes: 10 additions & 13 deletions c2rust-analyze/src/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub enum OriginArg<'tcx> {
impl<'tcx> Debug for OriginArg<'tcx> {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
match &self {
OriginArg::Actual(r) => write!(f, "{:}", r),
OriginArg::Actual(r) => write!(f, "{r:}"),
OriginArg::Hypothetical(h) => write!(f, "'h{h:?}"),
}
}
Expand Down Expand Up @@ -150,27 +150,24 @@ pub fn borrowck_mir<'tcx>(
.iter()
.find(|&&(_, l, _)| l == loan)
.map(|&(_, _, point)| point)
.unwrap_or_else(|| panic!("loan {:?} was never issued?", loan));
.unwrap_or_else(|| panic!("loan {loan:?} was never issued?"));
let issued_loc = maps.get_point_location(issued_point);
let stmt = mir.stmt_at(issued_loc).left().unwrap_or_else(|| {
panic!(
"loan {:?} was issued by a terminator (at {:?})?",
loan, issued_loc
);
panic!("loan {loan:?} was issued by a terminator (at {issued_loc:?})?");
});
let ptr = match stmt.kind {
StatementKind::Assign(ref x) => match describe_rvalue(&x.1) {
Some(RvalueDesc::Project { base, proj: _ }) => acx
.ptr_of(base)
.unwrap_or_else(|| panic!("missing pointer ID for {:?}", base)),
.unwrap_or_else(|| panic!("missing pointer ID for {base:?}")),
Some(RvalueDesc::AddrOfLocal { local, proj: _ }) => {
acx.addr_of_local[local]
}
None => panic!("loan {:?} was issued by unknown rvalue {:?}?", loan, x.1),
},
_ => panic!("loan {:?} was issued by non-assign stmt {:?}?", loan, stmt),
_ => panic!("loan {loan:?} was issued by non-assign stmt {stmt:?}?"),
};
eprintln!("want to drop UNIQUE from pointer {:?}", ptr);
eprintln!("want to drop UNIQUE from pointer {ptr:?}");

if hypothesis[ptr].contains(PermissionSet::UNIQUE) {
hypothesis[ptr].remove(PermissionSet::UNIQUE);
Expand Down Expand Up @@ -216,8 +213,8 @@ fn run_polonius<'tcx>(
//pretty::write_mir_fn(tcx, mir, &mut |_, _| Ok(()), &mut std::io::stdout()).unwrap();

// Populate `cfg_edge`
for (bb, bb_data) in mir.basic_blocks().iter_enumerated() {
eprintln!("{:?}:", bb);
for (bb, bb_data) in mir.basic_blocks.iter_enumerated() {
eprintln!("{bb:?}:");

for idx in 0..bb_data.statements.len() {
eprintln!(" {}: {:?}", idx, bb_data.statements[idx]);
Expand Down Expand Up @@ -319,10 +316,10 @@ fn run_polonius<'tcx>(
// Populate `var_defined/used/dropped_at` and `path_assigned/accessed_at_base`.
def_use::visit(&mut facts, &mut maps, mir);

dump::dump_facts_to_dir(&facts, &maps, format!("inspect/{}", name)).unwrap();
dump::dump_facts_to_dir(&facts, &maps, format!("inspect/{name}")).unwrap();

let output = polonius_engine::Output::compute(&facts, polonius_engine::Algorithm::Naive, true);
dump::dump_output_to_dir(&output, &maps, format!("inspect/{}", name)).unwrap();
dump::dump_output_to_dir(&output, &maps, format!("inspect/{name}")).unwrap();

(facts, maps, output)
}
Expand Down
12 changes: 6 additions & 6 deletions c2rust-analyze/src/borrowck/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
for proj in pl.projection {
lty = util::lty_project(lty, &proj, &mut adt_func);
}
eprintln!("final label for {pl:?}: {:?}", lty);
eprintln!("final label for {pl:?}: {lty:?}");
lty
}

Expand All @@ -182,7 +182,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
.push((path, loan, borrow_kind));
let point = self.current_point(SubPoint::Mid);
self.facts.loan_issued_at.push((origin, loan, point));
eprintln!("issued loan {:?} = {:?} ({:?})", loan, pl, borrow_kind);
eprintln!("issued loan {loan:?} = {pl:?} ({borrow_kind:?})");
origin
}

Expand Down Expand Up @@ -289,7 +289,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
// relations between the regions of the array and the regions of its elements
self.ltcx.label(ty, &mut |_ty| Label::default())
}
_ => panic!("unsupported rvalue AggregateKind {:?}", kind),
_ => panic!("unsupported rvalue AggregateKind {kind:?}"),
},

Rvalue::Len(..) => {
Expand All @@ -299,12 +299,12 @@ impl<'tcx> TypeChecker<'tcx, '_> {

Rvalue::UnaryOp(_, ref op) => self.visit_operand(op),

ref rv => panic!("unsupported rvalue {:?}", rv),
ref rv => panic!("unsupported rvalue {rv:?}"),
}
}

fn do_assign(&mut self, pl_lty: LTy<'tcx>, rv_lty: LTy<'tcx>) {
eprintln!("assign {:?} = {:?}", pl_lty, rv_lty);
eprintln!("assign {pl_lty:?} = {rv_lty:?}");

let mut add_subset_base = |pl: Origin, rv: Origin| {
let point = self.current_point(SubPoint::Mid);
Expand Down Expand Up @@ -433,7 +433,7 @@ pub fn visit_body<'tcx>(
adt_metadata,
};

for (bb, bb_data) in mir.basic_blocks().iter_enumerated() {
for (bb, bb_data) in mir.basic_blocks.iter_enumerated() {
for (idx, stmt) in bb_data.statements.iter().enumerate() {
tc.current_location = Location {
block: bb,
Expand Down
8 changes: 2 additions & 6 deletions c2rust-analyze/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,7 @@ impl<'a, 'tcx> AnalysisCtxt<'a, 'tcx> {
let (pointee_lty, proj, ptr) = match desc {
RvalueDesc::Project { base, proj } => {
let base_lty = self.type_of(base);
eprintln!(
"rvalue = {:?}, desc = {:?}, base_lty = {:?}",
rv, desc, base_lty
);
eprintln!("rvalue = {rv:?}, desc = {desc:?}, base_lty = {base_lty:?}");
(
self.project(base_lty, &PlaceElem::Deref),
proj,
Expand Down Expand Up @@ -502,8 +499,7 @@ fn label_no_pointers<'tcx>(acx: &AnalysisCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> LTy<'t
acx.lcx().label(ty, &mut |inner_ty| {
assert!(
!matches!(inner_ty.kind(), TyKind::Ref(..) | TyKind::RawPtr(..)),
"unexpected pointer type in {:?}",
ty,
"unexpected pointer type in {ty:?}",
);
PointerId::NONE
})
Expand Down
4 changes: 2 additions & 2 deletions c2rust-analyze/src/dataflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ impl DataflowConstraints {
eprintln!("=== propagating ===");
eprintln!("constraints:");
for c in &self.constraints {
eprintln!(" {:?}", c);
eprintln!(" {c:?}");
}
eprintln!("hypothesis:");
for (id, p) in hypothesis.iter() {
eprintln!(" {}: {:?}", id, p);
eprintln!(" {id}: {p:?}");
}

struct PropagatePerms;
Expand Down
10 changes: 5 additions & 5 deletions c2rust-analyze/src/dataflow/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
}

fn record_access(&mut self, ptr: PointerId, mutbl: Mutability) {
eprintln!("record_access({:?}, {:?})", ptr, mutbl);
eprintln!("record_access({ptr:?}, {mutbl:?})");
if ptr == PointerId::NONE {
return;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
}
}

_ => panic!("TODO: handle assignment of {:?}", rv),
_ => panic!("TODO: handle assignment of {rv:?}"),
}
}

Expand Down Expand Up @@ -211,7 +211,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
self.acx.tcx().erase_regions(lty2.ty)
);
for (sub_lty1, sub_lty2) in lty1.iter().zip(lty2.iter()) {
eprintln!("equate {:?} = {:?}", sub_lty1, sub_lty2);
eprintln!("equate {sub_lty1:?} = {sub_lty2:?}");
if sub_lty1.label != PointerId::NONE || sub_lty2.label != PointerId::NONE {
assert!(sub_lty1.label != PointerId::NONE);
assert!(sub_lty2.label != PointerId::NONE);
Expand All @@ -221,7 +221,7 @@ impl<'tcx> TypeChecker<'tcx, '_> {
}

pub fn visit_statement(&mut self, stmt: &Statement<'tcx>, loc: Location) {
eprintln!("visit_statement({:?})", stmt);
eprintln!("visit_statement({stmt:?})");
// TODO(spernsteiner): other `StatementKind`s will be handled in the future
#[allow(clippy::single_match)]
match stmt.kind {
Expand Down Expand Up @@ -383,7 +383,7 @@ pub fn visit<'tcx>(
equiv_constraints: Vec::new(),
};

for (bb, bb_data) in mir.basic_blocks().iter_enumerated() {
for (bb, bb_data) in mir.basic_blocks.iter_enumerated() {
for (i, stmt) in bb_data.statements.iter().enumerate() {
tc.visit_statement(
stmt,
Expand Down
4 changes: 2 additions & 2 deletions c2rust-analyze/src/expr_rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'a, 'tcx> ExprRewriteVisitor<'a, 'tcx> {
StatementKind::Retag(..) => {}
StatementKind::AscribeUserType(..) => {}
StatementKind::Coverage(..) => {}
StatementKind::CopyNonOverlapping(..) => todo!("statement {:?}", stmt),
StatementKind::Intrinsic(..) => todo!("statement {:?}", stmt),
StatementKind::Nop => {}
}
}
Expand Down Expand Up @@ -402,7 +402,7 @@ pub fn gen_expr_rewrites<'tcx>(

let mut v = ExprRewriteVisitor::new(acx, asn, &mut out, mir);

for (bb_id, bb) in mir.basic_blocks().iter_enumerated() {
for (bb_id, bb) in mir.basic_blocks.iter_enumerated() {
for (i, stmt) in bb.statements.iter().enumerate() {
let loc = Location {
block: bb_id,
Expand Down
Loading