Skip to content

Commit

Permalink
lint: fix clippy lint for rust 1.79
Browse files Browse the repository at this point in the history
  • Loading branch information
arbimo committed Jun 14, 2024
1 parent 546a4a5 commit e6a0084
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 145 deletions.
172 changes: 86 additions & 86 deletions .github/workflows/aries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@1.75.0 # fixed version to avoid failures on rust version releases
- uses: dtolnay/rust-toolchain@1.79.0 # fixed version to avoid failures on rust version releases
with:
components: clippy, rustfmt
- run: cargo fmt --all -- --check
Expand Down Expand Up @@ -96,24 +96,24 @@ jobs:
run: |
source planning/unified/dev.env
python3 planning/unified/deps/unified-planning/up_test_cases/report.py aries

tests: # Meta-job that only requires all test-jobs to pass
needs: [lints, unit-tests, integration-tests, unified-planning-api, unified-planning-integration]
needs: [ lints, unit-tests, integration-tests, unified-planning-api, unified-planning-integration ]
runs-on: ubuntu-latest
steps:
- run: true



# ================ Building & Releasing binaries.
# Only active on the master branch and when the previous validation steps passed
# ================ Building & Releasing binaries.
# Only active on the master branch and when the previous validation steps passed

build: # Build release binaries for all architecture and save them as artifacts
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
target: [amd64, arm64]
os: [ ubuntu-latest, macos-latest, windows-latest ]
target: [ amd64, arm64 ]
exclude:
- os: ubuntu-latest
target: arm64 # linux-arm64 build has linker issues, done in a distinct job
Expand Down Expand Up @@ -166,95 +166,95 @@ jobs:
path: bins/${{ env.BINARY }}
retention-days: 1

# Deactivated as induces very long CI times
# # Build linux-aarch64 binaries in a dedicated container.
# build-linux-arm64:
# runs-on: ubuntu-latest
# name: Build - ubuntu-latest - arm64
# if: github.ref == 'refs/heads/master'
# needs: [lints, unit-tests, integration-tests, unified-planning-api]
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - uses: uraimo/run-on-arch-action@v2
# name: Build on ubuntu-latest targetting ARM64
# id: build
# with:
# arch: aarch64
# distro: ubuntu20.04
#
# githubToken: ${{ secrets.GITHUB_TOKEN }}
#
# dockerRunArgs: |
# --privileged --volume "${PWD}:/workdir" --workdir /workdir
#
# shell: /bin/bash
# setup: mkdir -p bins/
# install: |
# apt-get update
# apt-get -y upgrade
# apt-get install -y libssl-dev libudev-dev pkg-config curl git
# apt-get install -y build-essential gcc-aarch64-linux-gnu python3.8
# curl https://sh.rustup.rs -sSf | sh -s -- -y
# echo $HOME/.cargo/bin >> ~/.bashrc
# source $HOME/.cargo/env
# rustup target add aarch64-unknown-linux-gnu
# run: |
# source $HOME/.cargo/env
# cargo build --release --target aarch64-unknown-linux-gnu --bin up-server
# cp target/aarch64-unknown-linux-gnu/release/up-server bins/up-aries_linux_arm64
# python3.8 ./ci/grpc.py --executable bins/up-aries_linux_arm64
#
# - name: Upload artifact
# uses: actions/upload-artifact@v2
# with:
# name: up-aries_linux_arm64
# path: bins/up-aries_linux_arm64
# retention-days: 1
# Deactivated as induces very long CI times
# # Build linux-aarch64 binaries in a dedicated container.
# build-linux-arm64:
# runs-on: ubuntu-latest
# name: Build - ubuntu-latest - arm64
# if: github.ref == 'refs/heads/master'
# needs: [lints, unit-tests, integration-tests, unified-planning-api]
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - uses: uraimo/run-on-arch-action@v2
# name: Build on ubuntu-latest targetting ARM64
# id: build
# with:
# arch: aarch64
# distro: ubuntu20.04
#
# githubToken: ${{ secrets.GITHUB_TOKEN }}
#
# dockerRunArgs: |
# --privileged --volume "${PWD}:/workdir" --workdir /workdir
#
# shell: /bin/bash
# setup: mkdir -p bins/
# install: |
# apt-get update
# apt-get -y upgrade
# apt-get install -y libssl-dev libudev-dev pkg-config curl git
# apt-get install -y build-essential gcc-aarch64-linux-gnu python3.8
# curl https://sh.rustup.rs -sSf | sh -s -- -y
# echo $HOME/.cargo/bin >> ~/.bashrc
# source $HOME/.cargo/env
# rustup target add aarch64-unknown-linux-gnu
# run: |
# source $HOME/.cargo/env
# cargo build --release --target aarch64-unknown-linux-gnu --bin up-server
# cp target/aarch64-unknown-linux-gnu/release/up-server bins/up-aries_linux_arm64
# python3.8 ./ci/grpc.py --executable bins/up-aries_linux_arm64
#
# - name: Upload artifact
# uses: actions/upload-artifact@v2
# with:
# name: up-aries_linux_arm64
# path: bins/up-aries_linux_arm64
# retention-days: 1

package-python:
name: Python Package (up_aries)
needs: [build]
needs: [ build ]
runs-on: ubuntu-latest
if: (github.ref == 'refs/heads/master') || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- name: Retrieve git tags # need full git history to determine version number when packaging
run: git fetch --prune --unshallow
- name: Available tags
run: |
git tag
git describe --tags --match v[0-9]*
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install build tools
run: pip install build
- uses: actions/download-artifact@v3
with:
path: planning/unified/plugin/artifacts
- name: Unpack artifacts
run: |
cd planning/unified/plugin/
ls -lR
mkdir -p up_aries/bin
cp artifacts/*/* up_aries/bin/
chmod +x up_aries/bin/*
ls -lR
python -m build --sdist
cp dist/up_aries-*.tar.gz up_aries.tar.gz
- uses: actions/upload-artifact@v3
with:
name: up_aries.tar.gz
path: planning/unified/plugin/up_aries.tar.gz
retention-days: 1
- uses: actions/checkout@v3
- name: Retrieve git tags # need full git history to determine version number when packaging
run: git fetch --prune --unshallow
- name: Available tags
run: |
git tag
git describe --tags --match v[0-9]*
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install build tools
run: pip install build
- uses: actions/download-artifact@v3
with:
path: planning/unified/plugin/artifacts
- name: Unpack artifacts
run: |
cd planning/unified/plugin/
ls -lR
mkdir -p up_aries/bin
cp artifacts/*/* up_aries/bin/
chmod +x up_aries/bin/*
ls -lR
python -m build --sdist
cp dist/up_aries-*.tar.gz up_aries.tar.gz
- uses: actions/upload-artifact@v3
with:
name: up_aries.tar.gz
path: planning/unified/plugin/up_aries.tar.gz
retention-days: 1

pre-release: # If on master branch, Upload all artifacts as a pre-release "latest"
pre-release: # If on master branch, Upload all artifacts as a pre-release "latest"
name: Pre Release
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs: [tests, build, package-python]
needs: [ tests, build, package-python ]
steps:
- name: Download artifact
uses: actions/download-artifact@v2
Expand Down
31 changes: 14 additions & 17 deletions planning/grpc/server/src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,24 +352,21 @@ impl UnifiedPlanning for UnifiedPlanningService {
let problem = Arc::new(problem);

let result = solve(problem, |_| {}, conf).await;
let mut answer = match result {
Ok(answer) => answer,
Err(e) => {
let message = format!("{}", e.chain().rev().format("\n Context: "));
eprintln!("ERROR: {}", &message);
let log_message = LogMessage {
level: log_message::LogLevel::Error as i32,
message,
};
PlanGenerationResult {
status: plan_generation_result::Status::InternalError as i32,
plan: None,
metrics: Default::default(),
log_messages: vec![log_message],
engine: Some(engine()),
}
let mut answer = result.unwrap_or_else(|e| {
let message = format!("{}", e.chain().rev().format("\n Context: "));
eprintln!("ERROR: {}", &message);
let log_message = LogMessage {
level: log_message::LogLevel::Error as i32,
message,
};
PlanGenerationResult {
status: plan_generation_result::Status::InternalError as i32,
plan: None,
metrics: Default::default(),
log_messages: vec![log_message],
engine: Some(engine()),
}
};
});
add_engine_time(&mut answer.metrics, &reception_time);
Ok(Response::new(answer))
}
Expand Down
2 changes: 1 addition & 1 deletion planning/grpc/server/src/chronicles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ impl<'a> ChronicleFactory<'a> {
}

/// Final value to minimize is converted to a condition at the chronicle end time
fn add_final_value_metric(&mut self, metrics: &Vec<Metric>) -> Result<(), Error> {
fn add_final_value_metric(&mut self, metrics: &[Metric]) -> Result<(), Error> {
ensure!(metrics.len() <= 1, "Unsupported: multiple metrics provided.");
let Some(metric) = metrics.first() else {
return Ok(()); // no metric to handle
Expand Down
4 changes: 2 additions & 2 deletions planning/planners/src/encode/symmetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ fn add_plan_space_symmetry_breaking(pb: &FiniteProblem, model: &mut Model, encod
clause.clear();
clause.push(!supports(*instance, *cond));

for prev_cond_index in 0..cond_index {
clause.push(supports(*prev, conditions[prev_cond_index]));
for prev_cond in &conditions[0..cond_index] {
clause.push(supports(*prev, *prev_cond));
}
model.enforce(or(clause.as_slice()), []);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl CausalSupport {
},
condition: TemplateCondID {
template_id: cond_template,
cond_id: cond_id,
cond_id,
},
}
}
Expand Down
7 changes: 3 additions & 4 deletions planning/planning/src/chronicles/analysis/static_fluents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,13 @@ pub fn is_static(target_fluent: &Fluent, pb: &Problem) -> bool {
.map(|tempplate| &tempplate.chronicle)
.chain(pb.chronicles.iter().map(|ch| &ch.chronicle));
let mut conditions = chronicles.flat_map(|ch| ch.conditions.iter());
let conditions_ok = conditions.all(|cond| {

conditions.all(|cond| {
if is_on_target_fluent(&cond.state_var) {
// the value of this condition must be transformable to an int
cond.value.int_view().is_some()
} else {
true // not interesting, continue
}
});

conditions_ok
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,15 @@ impl Graph {

/// Computes all shortest-path from this node
pub fn shortest_paths(&self, from: Node) -> impl Iterator<Item = (Node, Cost)> + '_ {
pathfinding::directed::dijkstra::dijkstra_reach(&from, |n, _c| self.adjacency[&n].iter().copied())
pathfinding::directed::dijkstra::dijkstra_reach(&from, |n, _c| self.adjacency[n].iter().copied())
.map(|item| (item.node, item.total_cost))
}

/// Returns the set of edges in the shortest path between two nodes
pub fn shortest_path(&self, from: Node, to: Node) -> Vec<(Node, Node, Cost)> {
let (parents, res) = pathfinding::directed::dijkstra::dijkstra_partial(
&from,
|n| self.adjacency[&n].iter().copied(),
|n| self.adjacency[n].iter().copied(),
|cur| cur == &to,
);
assert_eq!(res, Some(to));
Expand Down
4 changes: 2 additions & 2 deletions solver/src/collections/ref_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ where
&self.internal[k.into()]
}

pub fn get_ref<W: ?Sized>(&self, v: &W) -> Option<K>
pub fn get_ref<W>(&self, v: &W) -> Option<K>
where
W: Eq + Hash,
W: Eq + Hash + ?Sized,
V: Eq + Hash + Borrow<W>,
{
self.rev.get(v).copied()
Expand Down
1 change: 0 additions & 1 deletion solver/src/model/model_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ impl<Lbl: Label> Model<Lbl> {
*expr = ReifExpr::Lit(Lit::FALSE);
} else if lb1 == ub1 && ub1 == lb2 && lb2 == ub2 {
*expr = ReifExpr::Lit(Lit::TRUE);
} else {
}
}
ReifExpr::EqVal(v1, v2) => {
Expand Down
4 changes: 2 additions & 2 deletions solver/src/model/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ impl SymbolTable {

/// Retrieves the ID of a given symbol. Return None if the symbol doesn't appear in the
/// symbol table.
pub fn id<W: ?Sized>(&self, sym: &W) -> Option<SymId>
pub fn id<W>(&self, sym: &W) -> Option<SymId>
where
W: Eq + Hash,
W: Eq + Hash + ?Sized,
Sym: Eq + Hash + Borrow<W>,
{
self.ids.get(sym).copied()
Expand Down
4 changes: 2 additions & 2 deletions solver/src/model/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ impl TypeHierarchy {
self.id_of(&self.top_type).unwrap()
}

pub fn id_of<T2: ?Sized>(&self, tpe: &T2) -> Option<TypeId>
pub fn id_of<T2>(&self, tpe: &T2) -> Option<TypeId>
where
T2: Eq + Hash,
T2: Eq + Hash + ?Sized,
Sym: Eq + Hash + Borrow<T2>,
{
self.types.get_ref(tpe)
Expand Down
Loading

0 comments on commit e6a0084

Please sign in to comment.