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

Improvements and Bug Fixes #21

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d1d5a06
Lock crates used for testing
zgrannan Mar 13, 2025
6ea610a
remove build.rs
zgrannan Mar 13, 2025
6287c21
WIP
zgrannan Mar 14, 2025
ca685aa
Two-phase borrows
zgrannan Mar 14, 2025
0f878d3
Appease clippy
zgrannan Mar 14, 2025
4c0b1d5
Polonius fixes
zgrannan Mar 14, 2025
1a841ce
No capabilities on region projections
zgrannan Mar 14, 2025
208f559
Use dyn
zgrannan Mar 15, 2025
8ce9e46
Fix liveness computation for RP graph
zgrannan Mar 15, 2025
35adcbf
Support for havocing of nested references in fn calls
zgrannan Mar 16, 2025
21741af
Render alias edges
zgrannan Mar 16, 2025
8fc8ceb
Graph rendering improvements
zgrannan Mar 16, 2025
5893e62
Support an additional case
zgrannan Mar 17, 2025
22f37ae
another case
zgrannan Mar 17, 2025
efc4768
Fix dotgraph tooltip
zgrannan Mar 17, 2025
acd5185
Small stuff
zgrannan Mar 17, 2025
9546516
Fix visualization
zgrannan Mar 17, 2025
7d5cf5d
add additional test
zgrannan Mar 19, 2025
34e5e5a
cleanup
zgrannan Mar 20, 2025
54fd516
Add a fix for loops
zgrannan Mar 21, 2025
b6769d8
Fix for polonius
zgrannan Mar 21, 2025
8b93951
loop fixes
zgrannan Mar 22, 2025
8775218
update benchmarks
zgrannan Mar 22, 2025
0024efa
typecheck only version for comparison
zgrannan Mar 23, 2025
4f0873b
Save cached lockfiles
zgrannan Mar 23, 2025
c933b13
Add all the lockfiles
zgrannan Mar 23, 2025
80f53cf
WIP
zgrannan Mar 24, 2025
e874765
Try not merging sccs
zgrannan Mar 24, 2025
3bb36f9
Try not merging sccs
zgrannan Mar 24, 2025
34b0f16
ignore crate
zgrannan Mar 24, 2025
ee65309
loop fix
zgrannan Mar 24, 2025
f5cc50a
WIP
zgrannan Mar 24, 2025
f2ebbfa
CI fixes
zgrannan Mar 24, 2025
301920e
CI fixes
zgrannan Mar 24, 2025
bb043aa
Disable validity checks on this crate for now
zgrannan Mar 24, 2025
429cc28
WIP
zgrannan Mar 24, 2025
749e576
Fix Jonas's example
zgrannan Mar 24, 2025
372c278
Mostly fix visualization
zgrannan Mar 24, 2025
e5d2063
Maybe improvements for rpa construction
zgrannan Mar 25, 2025
1c3d5d7
Fix issues Jasper identified
zgrannan Mar 25, 2025
80989cd
Performance improvements for serde_derive
zgrannan Mar 25, 2025
f869106
Fix stupid weaken issue
zgrannan Mar 25, 2025
2f0a3e4
Fix itertools and regex-syntax
zgrannan Mar 25, 2025
ce37652
update benchmark results
zgrannan Mar 25, 2025
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
Prev Previous commit
Next Next commit
Fix issues Jasper identified
  • Loading branch information
zgrannan committed Mar 25, 2025
commit 1c3d5d71c54b4eadfad681c75ff3aef5fc200a36
14 changes: 11 additions & 3 deletions src/borrow_pcg/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ use super::{
latest::Latest,
path_condition::{PathCondition, PathConditions},
};
use crate::borrow_pcg::edge::borrow::{BorrowEdge, LocalBorrow};
use crate::{borrow_pcg::action::executed_actions::ExecutedActions, combined_pcs::PcgError};
use crate::{
borrow_pcg::action::executed_actions::ExecutedActions,
combined_pcs::PcgError,
};
use crate::{
borrow_pcg::edge::borrow::{BorrowEdge, LocalBorrow},
};
use crate::{
borrow_pcg::edge::kind::BorrowPCGEdgeKind, utils::place::maybe_remote::MaybeRemotePlace,
};
Expand Down Expand Up @@ -94,7 +99,9 @@ impl<'tcx> BorrowsState<'tcx> {
if removed {
for node in edge.blocked_by_nodes(repacker) {
if !self.graph.contains(node, repacker) {
let _ = self.remove_capability(node.place().into());
if let PCGNode::Place(MaybeOldPlace::Current { place }) = node {
let _ = self.remove_capability(place.into());
}
}
}
}
Expand Down Expand Up @@ -191,6 +198,7 @@ impl<'tcx> BorrowsState<'tcx> {
changed
}

#[tracing::instrument(skip(self, edge, location, repacker))]
pub(super) fn remove_edge_and_set_latest(
&mut self,
edge: impl BorrowPCGEdgeLike<'tcx>,
Expand Down
3 changes: 2 additions & 1 deletion src/borrow_pcg/state/obtain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ impl<'tcx> BorrowsState<'tcx> {
if !place.is_owned(repacker) {
pcg_validity_assert!(
self.get_capability(place.into()).is_some(),
"Place {:?} does not have a capability after obtain {:?}",
"{:?}: Place {:?} does not have a capability after obtain {:?}",
location,
place,
obtain_reason
);
Expand Down
21 changes: 14 additions & 7 deletions src/free_pcs/impl/triple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

use crate::pcg_validity_assert;
use crate::rustc_interface::middle::mir::{
visit::Visitor, BorrowKind, Local, Location, Operand, ProjectionElem, Rvalue, Statement,
StatementKind, Terminator, TerminatorKind, RETURN_PLACE,
visit::Visitor, BorrowKind, Local, Location, MutBorrowKind, Operand, ProjectionElem, Rvalue,
Statement, StatementKind, Terminator, TerminatorKind, RETURN_PLACE,
};

use crate::{
combined_pcs::{PcgError, PCGUnsupportedError},
combined_pcs::{PCGUnsupportedError, PcgError},
free_pcs::CapabilityKind,
utils::{display::DisplayWithRepacker, Place, PlaceRepacker},
};
Expand Down Expand Up @@ -230,10 +230,17 @@ impl<'tcx> Visitor<'tcx> for TripleWalker<'_, 'tcx> {
post: Some(Condition::read(*place)),
},
BorrowKind::Fake(..) => return,
BorrowKind::Mut { .. } => Triple {
pre: Condition::exclusive(*place, self.repacker),
post: Some(Condition::RemoveCapability((*place).into())),
},
BorrowKind::Mut { kind } => {
let post = if matches!(kind, MutBorrowKind::TwoPhaseBorrow) {
Some(Condition::read(*place))
} else {
Some(Condition::RemoveCapability((*place).into()))
};
Triple {
pre: Condition::exclusive(*place, self.repacker),
post,
}
}
};
self.main_triples.push(triple);
}
Expand Down
56 changes: 56 additions & 0 deletions test-files/126_hashbrown_occupied_error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#![feature(allocator_api)]

pub type DefaultHashBuilder = ();

pub struct Bucket<T> {
// Actually it is pointer to next element than element itself
// this is needed to maintain pointer arithmetic invariants
// keeping direct pointer to element introduces difficulty.
// Using `NonNull` for variance and niche layout
ptr: NonNull<T>,
}

use std::ptr::NonNull;
use std::collections::HashMap;
use std::fmt::Debug;
use std::alloc::{Allocator, Global};
use std::fmt;
pub struct OccupiedEntry<'a, K, V, S = DefaultHashBuilder, A: Allocator = Global> {
hash: u64,
elem: Bucket<(K, V)>,
table: &'a mut (),
phantom: std::marker::PhantomData<(S, A)>,
}

impl<'a, K, V, S, A: Allocator> OccupiedEntry<'a, K, V, S, A> {
pub fn key(&self) -> &K {
unimplemented!()
}

pub fn get(&self) -> &V {
unimplemented!()
}
}

pub struct OccupiedError<'a, K, V, S, A: Allocator = Global> {
/// The entry in the map that was already occupied.
pub entry: OccupiedEntry<'a, K, V, S, A>,
/// The value which was not inserted, because the entry was already occupied.
pub value: V,
}

impl<K: Debug, V: Debug, S, A: Allocator> fmt::Display for OccupiedError<'_, K, V, S, A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"failed to insert {:?}, key {:?} already exists with value {:?}",
self.value,
self.entry.key(),
self.entry.get(),
)
}
}

fn main(){

}
29 changes: 29 additions & 0 deletions test-files/127_syn_tokenbuffer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
pub struct TokenStream {
inner: (),
_marker: (),
}

enum Entry {
End(isize, isize),
}

pub struct TokenBuffer {
// NOTE: Do not implement clone on this - while the current design could be
// cloned, other designs which could be desirable may not be cloneable.
entries: Box<[Entry]>,
}

impl TokenBuffer {
fn recursive_new(entries: &mut Vec<Entry>, stream: TokenStream) {
}
pub fn new2(stream: TokenStream) -> Self {
let mut entries = Vec::new();
Self::recursive_new(&mut entries, stream);
entries.push(Entry::End(-(entries.len() as isize), 0));
Self {
entries: entries.into_boxed_slice(),
}
}
}

fn main(){}
19 changes: 19 additions & 0 deletions tests/selected_crates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ fn test_selected_crates() {
// common::run_on_crate("cookie", "0.18.1", Some("2025-03-13"), false, true);
// common::run_on_crate("futures-util", "0.3.31", false);
// common::run_on_crate("gimli", "0.31.1", false);
common::run_on_crate(
"hashbrown",
"0.15.2",
Some("2025-03-13"),
common::RunOnCrateOptions::RunPCG {
target: common::Target::Release,
validity_checks: true,
},
);
// common::run_on_crate("http", "1.2.0", true);
// common::run_on_crate("miniz_oxide", "0.8.5", true);
// common::run_on_crate("num-conv", "0.1.0", true);
Expand All @@ -33,6 +42,16 @@ fn test_selected_crates() {
// },
// );

common::run_on_crate(
"syn",
"2.0.100",
Some("2025-03-13"),
common::RunOnCrateOptions::RunPCG {
target: common::Target::Release,
validity_checks: true,
},
);

// common::run_on_crate(
// "cfg-if",
// "1.0.0",
Expand Down