From 3291825dee8ea11af5fd17fe5d348953ea4a88af Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 22 Feb 2022 16:46:38 -0500 Subject: [PATCH 1/4] Add `cargo fmt` test to lint CI Formatting should be enforced the same ways as clippy, added it as a linting step. --- .github/workflows/test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 38b592905..3f58d0bce 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: name: ci result runs-on: ubuntu-latest needs: - - clippy + - lint - geo_types - geo - geo_postgis @@ -35,14 +35,14 @@ jobs: if: "!success()" run: exit 1 - clippy: - name: clippy + lint: + name: lint runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[skip ci]')" strategy: matrix: container_image: - # Use the latest stable clippy. No need for older versions. + # Use the latest stable version. No need for older versions. - "georust/geo-ci:rust-1.58" container: image: ${{ matrix.container_image }} @@ -50,6 +50,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - run: rustup component add clippy + - run: cargo fmt --all -- --check - run: cargo clippy --all-features --all-targets -- -Dwarnings geo_types: From 19a9b419b14effc5a6a9d6a05f11acda91651de0 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 22 Feb 2022 16:51:53 -0500 Subject: [PATCH 2/4] add component --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3f58d0bce..dd0aab622 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,7 +49,7 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v2 - - run: rustup component add clippy + - run: rustup component add rustfmt clippy - run: cargo fmt --all -- --check - run: cargo clippy --all-features --all-targets -- -Dwarnings From 87021a48a7a0d1564ae7c587052f3a93c923d315 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Thu, 24 Feb 2022 10:15:22 -0500 Subject: [PATCH 3/4] Fix macros not allowing trailing commas Macros like `coord!` need to support trailing comma cases: ``` coord! { x: 181.2, y: 51.79, // <-- this one } ``` More complex cases like `line_string!` also support trailing commas at all nesting levels --- geo-types/CHANGES.md | 3 ++- geo-types/src/macros.rs | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/geo-types/CHANGES.md b/geo-types/CHANGES.md index b05a48452..0f5d67695 100644 --- a/geo-types/CHANGES.md +++ b/geo-types/CHANGES.md @@ -2,7 +2,8 @@ ## Unreleased -* +* Macros `coord!`, `point!`, `line_string!`, and `polygon!` now support trailing commas such as `coord! { x: 181.2, y: 51.79, }` + * ## 0.7.3 diff --git a/geo-types/src/macros.rs b/geo-types/src/macros.rs index a2b6b95c1..dea9d555b 100644 --- a/geo-types/src/macros.rs +++ b/geo-types/src/macros.rs @@ -22,7 +22,7 @@ /// [`Point`]: ./struct.Point.html #[macro_export] macro_rules! point { - (x: $x:expr, y: $y:expr) => { + (x: $x:expr, y: $y:expr $(,)?) => { $crate::Point::new($x, $y) }; } @@ -48,7 +48,7 @@ macro_rules! point { /// [`Coordinate`]: ./struct.Point.html #[macro_export] macro_rules! coord { - (x: $x:expr, y: $y:expr) => { + (x: $x:expr, y: $y:expr $(,)?) => { $crate::Coordinate { x: $x, y: $y } }; } @@ -70,7 +70,7 @@ macro_rules! coord { /// (x: -21.95156, y: 64.1446), /// (x: -21.951, y: 64.14479), /// (x: -21.95044, y: 64.14527), -/// (x: -21.951445, y: 64.145508) +/// (x: -21.951445, y: 64.145508), /// ]; /// /// assert_eq!(ls[1], geo_types::Coordinate { @@ -118,7 +118,7 @@ macro_rules! coord { macro_rules! line_string { () => { $crate::LineString(vec![]) }; ( - $((x: $x:expr, y: $y:expr)),* + $((x: $x:expr, y: $y:expr $(,)?)),* $(,)? ) => { line_string![ @@ -212,12 +212,12 @@ macro_rules! polygon { () => { $crate::Polygon::new(line_string![], vec![]) }; ( exterior: [ - $((x: $exterior_x:expr, y: $exterior_y:expr)),* + $((x: $exterior_x:expr, y: $exterior_y:expr $(,)?)),* $(,)? ], interiors: [ $([ - $((x: $interior_x:expr, y: $interior_y:expr)),* + $((x: $interior_x:expr, y: $interior_y:expr $(,)?)),* $(,)? ]),* $(,)? @@ -234,7 +234,6 @@ macro_rules! polygon { $([ $($crate::Coordinate { x: $interior_x, y: $interior_y }),* ]),* - ], ) }; @@ -268,7 +267,7 @@ macro_rules! polygon { ) }; ( - $((x: $x:expr, y: $y:expr)),* + $((x: $x:expr, y: $y:expr $(,)?)),* $(,)? ) => { polygon![ From f49d51861573df2a82b1123467f72df906b712ad Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 7 Mar 2022 12:03:54 -0800 Subject: [PATCH 4/4] update CI to rust-1.59 --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dd0aab622..b91f06296 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,7 +43,7 @@ jobs: matrix: container_image: # Use the latest stable version. No need for older versions. - - "georust/geo-ci:rust-1.58" + - "georust/geo-ci:rust-1.59" container: image: ${{ matrix.container_image }} steps: @@ -69,8 +69,8 @@ jobs: # Minimum supported rust version (MSRV) - "georust/geo-ci:rust-1.55" # Two most recent releases - we omit older ones for expedient CI - - "georust/geo-ci:rust-1.57" - "georust/geo-ci:rust-1.58" + - "georust/geo-ci:rust-1.59" container: image: ${{ matrix.container_image }} steps: @@ -95,8 +95,8 @@ jobs: # Minimum supported rust version (MSRV) - "georust/geo-ci:rust-1.55" # Two most recent releases - we omit older ones for expedient CI - - "georust/geo-ci:rust-1.57" - "georust/geo-ci:rust-1.58" + - "georust/geo-ci:rust-1.59" container: image: ${{ matrix.container_image }} steps: @@ -122,8 +122,8 @@ jobs: # Minimum supported rust version (MSRV) - "georust/geo-ci:rust-1.55" # Two most recent releases - we omit older ones for expedient CI - - "georust/geo-ci:rust-1.57" - "georust/geo-ci:rust-1.58" + - "georust/geo-ci:rust-1.59" container: image: ${{ matrix.container_image }} steps: @@ -143,7 +143,7 @@ jobs: matrix: container_image: # Fuzz only on latest - - "georust/geo-ci:rust-1.57" + - "georust/geo-ci:rust-1.59" container: image: ${{ matrix.container_image }} steps: