Skip to content

Commit

Permalink
test: prop test for error report and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Sep 25, 2023
1 parent afe2d3c commit 61031d6
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 98 deletions.
2 changes: 1 addition & 1 deletion src/internal/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<T> Id<T> {
}
fn from(n: u32) -> Self {
Self {
raw: n as u32,
raw: n,
_ty: PhantomData,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/internal/partial_solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<P: Package, VS: VersionSet> PartialSolution<P, VS> {
}
}
self.current_decision_level = self.current_decision_level.increment();
let mut pa = self
let pa = self
.package_assignments
.get_mut(&package)
.expect("Derivations must already exist");
Expand Down Expand Up @@ -177,7 +177,7 @@ impl<P: Package, VS: VersionSet> PartialSolution<P, VS> {
self.next_global_index += 1;
match self.package_assignments.entry(package) {
Entry::Occupied(mut occupied) => {
let mut pa = occupied.get_mut();
let pa = occupied.get_mut();
pa.highest_decision_level = self.current_decision_level;
match &mut pa.assignments_intersection {
// Check that add_derivation is never called in the wrong context.
Expand Down
4 changes: 2 additions & 2 deletions src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl DefaultStringReporter {
fn build_recursive<P: Package, VS: VersionSet>(&mut self, derived: &Derived<P, VS>) {
self.build_recursive_helper(derived);
if let Some(id) = derived.shared_id {
if self.shared_with_ref.get(&id) == None {
if self.shared_with_ref.get(&id).is_none() {
self.add_line_ref();
self.shared_with_ref.insert(id, self.ref_count);
}
Expand Down Expand Up @@ -260,7 +260,7 @@ impl DefaultStringReporter {
// and finally conclude.
(None, None) => {
self.build_recursive(derived1);
if derived1.shared_id != None {
if derived1.shared_id.is_some() {
self.lines.push("".into());
self.build_recursive(current);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ pub fn resolve<P: Package, VS: VersionSet>(
Dependencies::Known(x) if x.contains_key(p) => {
return Err(PubGrubError::SelfDependency {
package: p.clone(),
version: v.clone(),
version: v,
});
}
Dependencies::Known(x) => {
if let Some((dependent, _)) = x.iter().find(|(_, r)| r == &&VS::empty()) {
return Err(PubGrubError::DependencyOnTheEmptySet {
package: p.clone(),
version: v.clone(),
version: v,
dependent: dependent.clone(),
});
}
Expand Down
Loading

0 comments on commit 61031d6

Please sign in to comment.