From d7a0d6b938e42bbe71f430d201534ab8a67cd0af Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Thu, 11 Jan 2024 10:22:34 -0300 Subject: [PATCH 01/11] feat: Use custom `clippy_utils` We need this in order to publish `ink_linting` crates on crates.io, because all the dependencies must be published as well. --- linting/extra/Cargo.toml | 2 +- linting/extra/src/ink_utils.rs | 2 +- linting/extra/src/non_fallible_api.rs | 4 ++-- linting/extra/src/primitive_topic.rs | 4 ++-- linting/extra/src/storage_never_freed.rs | 4 ++-- linting/extra/src/strict_balance_equality.rs | 4 ++-- linting/mandatory/Cargo.toml | 2 +- linting/mandatory/src/no_main.rs | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/linting/extra/Cargo.toml b/linting/extra/Cargo.toml index 3fff7174a2c..3a909d62e17 100644 --- a/linting/extra/Cargo.toml +++ b/linting/extra/Cargo.toml @@ -18,7 +18,7 @@ include = ["Cargo.toml", "*.rs", "LICENSE"] crate-type = ["cdylib"] [dependencies] -clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "1d334696587ac22b3a9e651e7ac684ac9e0697b2" } +ink_linting_clippy_utils = "0.1.73" dylint_linting = "2.1.12" if_chain = "1.0.2" log = "0.4.14" diff --git a/linting/extra/src/ink_utils.rs b/linting/extra/src/ink_utils.rs index c63fa825b5e..6b4ba299131 100644 --- a/linting/extra/src/ink_utils.rs +++ b/linting/extra/src/ink_utils.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use clippy_utils::match_def_path; use if_chain::if_chain; +use ink_linting_clippy_utils::match_def_path; use rustc_hir::{ ExprKind, HirId, diff --git a/linting/extra/src/non_fallible_api.rs b/linting/extra/src/non_fallible_api.rs index d709ece227e..f80958aa4ff 100644 --- a/linting/extra/src/non_fallible_api.rs +++ b/linting/extra/src/non_fallible_api.rs @@ -16,12 +16,12 @@ use crate::ink_utils::{ expand_unnamed_consts, find_contract_impl_id, }; -use clippy_utils::{ +use if_chain::if_chain; +use ink_linting_clippy_utils::{ diagnostics::span_lint_and_then, is_lint_allowed, match_def_path, }; -use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{ self as hir, diff --git a/linting/extra/src/primitive_topic.rs b/linting/extra/src/primitive_topic.rs index a54daa5608b..956d4f8ad06 100644 --- a/linting/extra/src/primitive_topic.rs +++ b/linting/extra/src/primitive_topic.rs @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -use clippy_utils::{ +use if_chain::if_chain; +use ink_linting_clippy_utils::{ diagnostics::span_lint_and_then, is_lint_allowed, match_def_path, source::snippet_opt, }; -use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{ self, diff --git a/linting/extra/src/storage_never_freed.rs b/linting/extra/src/storage_never_freed.rs index 6f623fd5d19..601ddeb3246 100644 --- a/linting/extra/src/storage_never_freed.rs +++ b/linting/extra/src/storage_never_freed.rs @@ -17,13 +17,13 @@ use crate::ink_utils::{ find_contract_impl_id, find_storage_struct, }; -use clippy_utils::{ +use if_chain::if_chain; +use ink_linting_clippy_utils::{ diagnostics::span_lint_and_help, is_lint_allowed, match_def_path, match_path, }; -use if_chain::if_chain; use rustc_hir::{ self as hir, def::{ diff --git a/linting/extra/src/strict_balance_equality.rs b/linting/extra/src/strict_balance_equality.rs index bdcc7705dbe..3dca8cb1d1e 100644 --- a/linting/extra/src/strict_balance_equality.rs +++ b/linting/extra/src/strict_balance_equality.rs @@ -16,12 +16,12 @@ use crate::ink_utils::{ expand_unnamed_consts, find_contract_impl_id, }; -use clippy_utils::{ +use if_chain::if_chain; +use ink_linting_clippy_utils::{ diagnostics::span_lint_hir_and_then, match_any_def_paths, match_def_path, }; -use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{ self as hir, diff --git a/linting/mandatory/Cargo.toml b/linting/mandatory/Cargo.toml index db178816137..6b06fc089b3 100644 --- a/linting/mandatory/Cargo.toml +++ b/linting/mandatory/Cargo.toml @@ -18,7 +18,7 @@ include = ["Cargo.toml", "*.rs", "LICENSE"] crate-type = ["cdylib"] [dependencies] -clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "1d334696587ac22b3a9e651e7ac684ac9e0697b2" } +ink_linting_clippy_utils = "0.1.73" dylint_linting = "2.1.12" if_chain = "1.0.2" log = "0.4.14" diff --git a/linting/mandatory/src/no_main.rs b/linting/mandatory/src/no_main.rs index 3fff050b3b4..53fcba2aac5 100644 --- a/linting/mandatory/src/no_main.rs +++ b/linting/mandatory/src/no_main.rs @@ -16,8 +16,8 @@ use ast::{ AttrStyle, Crate, }; -use clippy_utils::diagnostics::span_lint_and_help; use if_chain::if_chain; +use ink_linting_clippy_utils::diagnostics::span_lint_and_help; use rustc_ast as ast; use rustc_lint::{ EarlyContext, From cff5707e2cd7ff175364d5a58e893d0b8cd767b3 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 12:04:48 -0300 Subject: [PATCH 02/11] feat(all): Use `parity-clippy-utils` This is necessary, because we need all the dependencies available on crates.io to publish our crates. --- linting/Cargo.toml | 1 + linting/extra/Cargo.toml | 3 +- linting/extra/src/lib.rs | 1 - linting/extra/src/non_fallible_api.rs | 14 ++++---- linting/extra/src/primitive_topic.rs | 2 +- linting/extra/src/storage_never_freed.rs | 16 ++++----- linting/extra/src/strict_balance_equality.rs | 14 ++++---- linting/mandatory/Cargo.toml | 3 +- linting/mandatory/src/no_main.rs | 2 +- linting/utils/Cargo.toml | 21 ++++++++++++ .../src/ink_utils.rs => utils/src/lib.rs} | 34 +++++++++++++------ 11 files changed, 72 insertions(+), 39 deletions(-) create mode 100644 linting/utils/Cargo.toml rename linting/{extra/src/ink_utils.rs => utils/src/lib.rs} (86%) diff --git a/linting/Cargo.toml b/linting/Cargo.toml index 82264da62e4..7c096836ce6 100644 --- a/linting/Cargo.toml +++ b/linting/Cargo.toml @@ -3,6 +3,7 @@ resolver = "2" members = [ "mandatory", "extra", + "utils", ] [workspace.metadata.dylint] diff --git a/linting/extra/Cargo.toml b/linting/extra/Cargo.toml index 3a909d62e17..ab26dcc2973 100644 --- a/linting/extra/Cargo.toml +++ b/linting/extra/Cargo.toml @@ -3,7 +3,6 @@ name = "ink_linting" version = "5.0.0-rc" authors = ["Parity Technologies "] edition = "2021" -publish = false license = "Apache-2.0" readme = "README.md" @@ -18,11 +17,11 @@ include = ["Cargo.toml", "*.rs", "LICENSE"] crate-type = ["cdylib"] [dependencies] -ink_linting_clippy_utils = "0.1.73" dylint_linting = "2.1.12" if_chain = "1.0.2" log = "0.4.14" regex = "1.5.4" +ink_utils = { path = "../utils" } # ink! dependencies used in the linter implementation ink_env = { path = "../../crates/env", default-features = false } diff --git a/linting/extra/src/lib.rs b/linting/extra/src/lib.rs index 00cc666d70a..19c7ebe69a5 100644 --- a/linting/extra/src/lib.rs +++ b/linting/extra/src/lib.rs @@ -32,7 +32,6 @@ extern crate rustc_session; extern crate rustc_span; extern crate rustc_type_ir; -mod ink_utils; mod non_fallible_api; mod primitive_topic; mod storage_never_freed; diff --git a/linting/extra/src/non_fallible_api.rs b/linting/extra/src/non_fallible_api.rs index 734747c0d5c..d0d2d481f10 100644 --- a/linting/extra/src/non_fallible_api.rs +++ b/linting/extra/src/non_fallible_api.rs @@ -12,16 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::ink_utils::{ +use if_chain::if_chain; +use ink_utils::{ + clippy::{ + diagnostics::span_lint_and_then, + is_lint_allowed, + match_def_path, + }, expand_unnamed_consts, find_contract_impl_id, }; -use if_chain::if_chain; -use ink_linting_clippy_utils::{ - diagnostics::span_lint_and_then, - is_lint_allowed, - match_def_path, -}; use rustc_errors::Applicability; use rustc_hir::{ self as hir, diff --git a/linting/extra/src/primitive_topic.rs b/linting/extra/src/primitive_topic.rs index 956d4f8ad06..0f674c89456 100644 --- a/linting/extra/src/primitive_topic.rs +++ b/linting/extra/src/primitive_topic.rs @@ -13,7 +13,7 @@ // limitations under the License. use if_chain::if_chain; -use ink_linting_clippy_utils::{ +use ink_utils::clippy::{ diagnostics::span_lint_and_then, is_lint_allowed, match_def_path, diff --git a/linting/extra/src/storage_never_freed.rs b/linting/extra/src/storage_never_freed.rs index 601ddeb3246..a7070822dc6 100644 --- a/linting/extra/src/storage_never_freed.rs +++ b/linting/extra/src/storage_never_freed.rs @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::ink_utils::{ +use if_chain::if_chain; +use ink_utils::{ + clippy::{ + diagnostics::span_lint_and_help, + is_lint_allowed, + match_def_path, + match_path, + }, expand_unnamed_consts, find_contract_impl_id, find_storage_struct, }; -use if_chain::if_chain; -use ink_linting_clippy_utils::{ - diagnostics::span_lint_and_help, - is_lint_allowed, - match_def_path, - match_path, -}; use rustc_hir::{ self as hir, def::{ diff --git a/linting/extra/src/strict_balance_equality.rs b/linting/extra/src/strict_balance_equality.rs index 3dca8cb1d1e..00fcebb9c24 100644 --- a/linting/extra/src/strict_balance_equality.rs +++ b/linting/extra/src/strict_balance_equality.rs @@ -12,16 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::ink_utils::{ +use if_chain::if_chain; +use ink_utils::{ + clippy::{ + diagnostics::span_lint_hir_and_then, + match_any_def_paths, + match_def_path, + }, expand_unnamed_consts, find_contract_impl_id, }; -use if_chain::if_chain; -use ink_linting_clippy_utils::{ - diagnostics::span_lint_hir_and_then, - match_any_def_paths, - match_def_path, -}; use rustc_errors::Applicability; use rustc_hir::{ self as hir, diff --git a/linting/mandatory/Cargo.toml b/linting/mandatory/Cargo.toml index 6b06fc089b3..ede44237964 100644 --- a/linting/mandatory/Cargo.toml +++ b/linting/mandatory/Cargo.toml @@ -3,7 +3,6 @@ name = "ink_linting_mandatory" version = "5.0.0-rc" authors = ["Parity Technologies "] edition = "2021" -publish = false license = "Apache-2.0" readme = "README.md" @@ -18,11 +17,11 @@ include = ["Cargo.toml", "*.rs", "LICENSE"] crate-type = ["cdylib"] [dependencies] -ink_linting_clippy_utils = "0.1.73" dylint_linting = "2.1.12" if_chain = "1.0.2" log = "0.4.14" regex = "1.5.4" +ink_utils = { path = "../utils" } [dev-dependencies] dylint_testing = "2.1.12" diff --git a/linting/mandatory/src/no_main.rs b/linting/mandatory/src/no_main.rs index 53fcba2aac5..06a0e9fab54 100644 --- a/linting/mandatory/src/no_main.rs +++ b/linting/mandatory/src/no_main.rs @@ -17,7 +17,7 @@ use ast::{ Crate, }; use if_chain::if_chain; -use ink_linting_clippy_utils::diagnostics::span_lint_and_help; +use ink_utils::clippy::diagnostics::span_lint_and_help; use rustc_ast as ast; use rustc_lint::{ EarlyContext, diff --git a/linting/utils/Cargo.toml b/linting/utils/Cargo.toml new file mode 100644 index 00000000000..095942208f5 --- /dev/null +++ b/linting/utils/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "ink_utils" +version = "5.0.0-rc" +authors = ["Parity Technologies "] +edition = "2021" + +license = "Apache-2.0" +readme = "README.md" +repository = "https://github.com/paritytech/ink" +documentation = "https://docs.rs/ink_linting" +homepage = "https://github.com/paritytech/ink" +description = "Utilities used internally in ink_linting crates" +keywords = ["parity", "blockchain", "ink", "smart contracts", "substrate"] +include = ["Cargo.toml", "*.rs", "LICENSE"] + +[dependencies] +if_chain = "1.0.2" +parity_clippy_utils = "0.1.73" + +[package.metadata.rust-analyzer] +rustc_private = true diff --git a/linting/extra/src/ink_utils.rs b/linting/utils/src/lib.rs similarity index 86% rename from linting/extra/src/ink_utils.rs rename to linting/utils/src/lib.rs index 6b4ba299131..117884b862b 100644 --- a/linting/extra/src/ink_utils.rs +++ b/linting/utils/src/lib.rs @@ -12,8 +12,28 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![doc( + html_logo_url = "https://use.ink/img/crate-docs/logo.png", + html_favicon_url = "https://use.ink/crate-docs/favicon.png" +)] +#![feature(rustc_private)] +#![feature(box_patterns)] + +extern crate rustc_ast; +extern crate rustc_errors; +extern crate rustc_hir; +extern crate rustc_index; +extern crate rustc_lint; +extern crate rustc_middle; +extern crate rustc_mir_dataflow; +extern crate rustc_session; +extern crate rustc_span; +extern crate rustc_type_ir; + +pub use parity_clippy_utils as clippy; + +use clippy::match_def_path; use if_chain::if_chain; -use ink_linting_clippy_utils::match_def_path; use rustc_hir::{ ExprKind, HirId, @@ -34,10 +54,7 @@ fn has_storage_attr(cx: &LateContext, hir: HirId) -> bool { } /// Returns `ItemId` of the structure annotated with `#[ink(storage)]` -pub(crate) fn find_storage_struct( - cx: &LateContext, - item_ids: &[ItemId], -) -> Option { +pub fn find_storage_struct(cx: &LateContext, item_ids: &[ItemId]) -> Option { item_ids .iter() .find(|&item_id| { @@ -78,10 +95,7 @@ fn items_in_unnamed_const(cx: &LateContext<'_>, id: &ItemId) -> Vec { } /// Collect all the `ItemId`s in nested `const _: () = {}` -pub(crate) fn expand_unnamed_consts( - cx: &LateContext<'_>, - item_ids: &[ItemId], -) -> Vec { +pub fn expand_unnamed_consts(cx: &LateContext<'_>, item_ids: &[ItemId]) -> Vec { item_ids.iter().fold(Vec::new(), |mut acc, item_id| { acc.push(*item_id); acc.append(&mut items_in_unnamed_const(cx, item_id)); @@ -124,7 +138,7 @@ fn eq_hir_struct_tys(lhs: &Ty<'_>, rhs: &Ty<'_>) -> bool { } /// Finds an ID of the implementation of the contract struct containing user-defined code -pub(crate) fn find_contract_impl_id( +pub fn find_contract_impl_id( cx: &LateContext<'_>, item_ids: Vec, ) -> Option { From c5120ddb83f5f46660472a7623057bc8b7d04728 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 12:39:07 -0300 Subject: [PATCH 03/11] feat(cargo): Inherit common options from workspace' Cargo.toml --- linting/Cargo.toml | 9 +++++++++ linting/extra/Cargo.toml | 14 +++++++------- linting/mandatory/Cargo.toml | 16 ++++++++-------- linting/utils/Cargo.toml | 16 ++++++++-------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/linting/Cargo.toml b/linting/Cargo.toml index 7c096836ce6..56eb8244aa8 100644 --- a/linting/Cargo.toml +++ b/linting/Cargo.toml @@ -6,6 +6,15 @@ members = [ "utils", ] +[workspace.package] +version = "5.0.0-rc" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +repository = "https://github.com/paritytech/ink" +homepage = "https://www.parity.io/" +keywords = ["parity", "blockchain", "edsl", "dylint", "linting"] + [workspace.metadata.dylint] libraries = [ { path = "mandatory" }, diff --git a/linting/extra/Cargo.toml b/linting/extra/Cargo.toml index ab26dcc2973..dc61151e3f9 100644 --- a/linting/extra/Cargo.toml +++ b/linting/extra/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "ink_linting" -version = "5.0.0-rc" -authors = ["Parity Technologies "] -edition = "2021" +version.workspace = true +authors.workspace = true +edition.workspace = true -license = "Apache-2.0" +license.workspace = true readme = "README.md" -repository = "https://github.com/paritytech/ink" +repository.workspace = true documentation = "https://docs.rs/ink_linting" -homepage = "https://github.com/paritytech/ink" +homepage.workspace = true description = "Extra linting rules for ink! smart contracts" -keywords = ["parity", "blockchain", "ink", "smart contracts", "substrate"] +keywords.workspace = true include = ["Cargo.toml", "*.rs", "LICENSE"] [lib] diff --git a/linting/mandatory/Cargo.toml b/linting/mandatory/Cargo.toml index ede44237964..9495b241efe 100644 --- a/linting/mandatory/Cargo.toml +++ b/linting/mandatory/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "ink_linting_mandatory" -version = "5.0.0-rc" -authors = ["Parity Technologies "] -edition = "2021" +version.workspace = true +authors.workspace = true +edition.workspace = true -license = "Apache-2.0" +license.workspace = true readme = "README.md" -repository = "https://github.com/paritytech/ink" -documentation = "https://docs.rs/ink_linting" -homepage = "https://github.com/paritytech/ink" +repository.workspace = true +documentation = "https://docs.rs/ink_linting_mandatory" +homepage.workspace = true description = "Mandatory ink! linting rules integrated in contracts' build process" -keywords = ["parity", "blockchain", "ink", "smart contracts", "substrate"] +keywords.workspace = true include = ["Cargo.toml", "*.rs", "LICENSE"] [lib] diff --git a/linting/utils/Cargo.toml b/linting/utils/Cargo.toml index 095942208f5..38ead519ccc 100644 --- a/linting/utils/Cargo.toml +++ b/linting/utils/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "ink_utils" -version = "5.0.0-rc" -authors = ["Parity Technologies "] -edition = "2021" +version.workspace = true +authors.workspace = true +edition.workspace = true -license = "Apache-2.0" +license.workspace = true readme = "README.md" -repository = "https://github.com/paritytech/ink" -documentation = "https://docs.rs/ink_linting" -homepage = "https://github.com/paritytech/ink" +repository.workspace = true +documentation = "https://docs.rs/ink_utils" +homepage.workspace = true description = "Utilities used internally in ink_linting crates" -keywords = ["parity", "blockchain", "ink", "smart contracts", "substrate"] +keywords.workspace = true include = ["Cargo.toml", "*.rs", "LICENSE"] [dependencies] From 6e5be121bbf33c536dcc1de1d28d89113079f541 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 12:41:14 -0300 Subject: [PATCH 04/11] feat(utils): Add README and LICENSE --- linting/utils/LICENSE | 1 + linting/utils/README.md | 2 ++ 2 files changed, 3 insertions(+) create mode 120000 linting/utils/LICENSE create mode 100644 linting/utils/README.md diff --git a/linting/utils/LICENSE b/linting/utils/LICENSE new file mode 120000 index 00000000000..ea5b60640b0 --- /dev/null +++ b/linting/utils/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/linting/utils/README.md b/linting/utils/README.md new file mode 100644 index 00000000000..3cd9a91e37f --- /dev/null +++ b/linting/utils/README.md @@ -0,0 +1,2 @@ +# ink! linting utilities +This crate implements various utility functions used in `ink_linting` crates. It also provides access to the specific version of the `clippy_utils` crate. From 7fab8331d67fbc7201cea4c0ab828f5bb182f967 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 12:50:21 -0300 Subject: [PATCH 05/11] chore: `s/ink_utils/ink_linting_utils/g` To clarify the crate name when publishing on crates.io. --- linting/extra/Cargo.toml | 2 +- linting/extra/src/non_fallible_api.rs | 2 +- linting/extra/src/primitive_topic.rs | 2 +- linting/extra/src/storage_never_freed.rs | 2 +- linting/extra/src/strict_balance_equality.rs | 2 +- linting/mandatory/Cargo.toml | 2 +- linting/mandatory/src/no_main.rs | 2 +- linting/utils/Cargo.toml | 4 ++-- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/linting/extra/Cargo.toml b/linting/extra/Cargo.toml index dc61151e3f9..70df7e7073a 100644 --- a/linting/extra/Cargo.toml +++ b/linting/extra/Cargo.toml @@ -21,7 +21,7 @@ dylint_linting = "2.1.12" if_chain = "1.0.2" log = "0.4.14" regex = "1.5.4" -ink_utils = { path = "../utils" } +ink_linting_utils = { path = "../utils" } # ink! dependencies used in the linter implementation ink_env = { path = "../../crates/env", default-features = false } diff --git a/linting/extra/src/non_fallible_api.rs b/linting/extra/src/non_fallible_api.rs index d0d2d481f10..24a5ff1e358 100644 --- a/linting/extra/src/non_fallible_api.rs +++ b/linting/extra/src/non_fallible_api.rs @@ -13,7 +13,7 @@ // limitations under the License. use if_chain::if_chain; -use ink_utils::{ +use ink_linting_utils::{ clippy::{ diagnostics::span_lint_and_then, is_lint_allowed, diff --git a/linting/extra/src/primitive_topic.rs b/linting/extra/src/primitive_topic.rs index 0f674c89456..da86ed7de93 100644 --- a/linting/extra/src/primitive_topic.rs +++ b/linting/extra/src/primitive_topic.rs @@ -13,7 +13,7 @@ // limitations under the License. use if_chain::if_chain; -use ink_utils::clippy::{ +use ink_linting_utils::clippy::{ diagnostics::span_lint_and_then, is_lint_allowed, match_def_path, diff --git a/linting/extra/src/storage_never_freed.rs b/linting/extra/src/storage_never_freed.rs index a7070822dc6..bafa3ed6ebc 100644 --- a/linting/extra/src/storage_never_freed.rs +++ b/linting/extra/src/storage_never_freed.rs @@ -13,7 +13,7 @@ // limitations under the License. use if_chain::if_chain; -use ink_utils::{ +use ink_linting_utils::{ clippy::{ diagnostics::span_lint_and_help, is_lint_allowed, diff --git a/linting/extra/src/strict_balance_equality.rs b/linting/extra/src/strict_balance_equality.rs index 00fcebb9c24..a5bfb3f83c3 100644 --- a/linting/extra/src/strict_balance_equality.rs +++ b/linting/extra/src/strict_balance_equality.rs @@ -13,7 +13,7 @@ // limitations under the License. use if_chain::if_chain; -use ink_utils::{ +use ink_linting_utils::{ clippy::{ diagnostics::span_lint_hir_and_then, match_any_def_paths, diff --git a/linting/mandatory/Cargo.toml b/linting/mandatory/Cargo.toml index 9495b241efe..79c8f689b0b 100644 --- a/linting/mandatory/Cargo.toml +++ b/linting/mandatory/Cargo.toml @@ -21,7 +21,7 @@ dylint_linting = "2.1.12" if_chain = "1.0.2" log = "0.4.14" regex = "1.5.4" -ink_utils = { path = "../utils" } +ink_linting_utils = { path = "../utils" } [dev-dependencies] dylint_testing = "2.1.12" diff --git a/linting/mandatory/src/no_main.rs b/linting/mandatory/src/no_main.rs index 06a0e9fab54..2fcf89bfac8 100644 --- a/linting/mandatory/src/no_main.rs +++ b/linting/mandatory/src/no_main.rs @@ -17,7 +17,7 @@ use ast::{ Crate, }; use if_chain::if_chain; -use ink_utils::clippy::diagnostics::span_lint_and_help; +use ink_linting_utils::clippy::diagnostics::span_lint_and_help; use rustc_ast as ast; use rustc_lint::{ EarlyContext, diff --git a/linting/utils/Cargo.toml b/linting/utils/Cargo.toml index 38ead519ccc..5f8d3fa41c9 100644 --- a/linting/utils/Cargo.toml +++ b/linting/utils/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ink_utils" +name = "ink_linting_utils" version.workspace = true authors.workspace = true edition.workspace = true @@ -7,7 +7,7 @@ edition.workspace = true license.workspace = true readme = "README.md" repository.workspace = true -documentation = "https://docs.rs/ink_utils" +documentation = "https://docs.rs/ink_linting_utils" homepage.workspace = true description = "Utilities used internally in ink_linting crates" keywords.workspace = true From b977fc7884ed400c66fca8cd21d46c3b8ec18420 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 14:11:33 -0300 Subject: [PATCH 06/11] chore(cargo): Move the common dependency on workspace level --- linting/Cargo.toml | 3 +++ linting/extra/Cargo.toml | 2 +- linting/mandatory/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/linting/Cargo.toml b/linting/Cargo.toml index 56eb8244aa8..a3159ba46ec 100644 --- a/linting/Cargo.toml +++ b/linting/Cargo.toml @@ -15,6 +15,9 @@ repository = "https://github.com/paritytech/ink" homepage = "https://www.parity.io/" keywords = ["parity", "blockchain", "edsl", "dylint", "linting"] +[workspace.dependencies] +ink_linting_utils = { version = "=5.0.0-rc", path = "utils" } + [workspace.metadata.dylint] libraries = [ { path = "mandatory" }, diff --git a/linting/extra/Cargo.toml b/linting/extra/Cargo.toml index 70df7e7073a..dc98303c51f 100644 --- a/linting/extra/Cargo.toml +++ b/linting/extra/Cargo.toml @@ -21,7 +21,7 @@ dylint_linting = "2.1.12" if_chain = "1.0.2" log = "0.4.14" regex = "1.5.4" -ink_linting_utils = { path = "../utils" } +ink_linting_utils = { workspace = true } # ink! dependencies used in the linter implementation ink_env = { path = "../../crates/env", default-features = false } diff --git a/linting/mandatory/Cargo.toml b/linting/mandatory/Cargo.toml index 79c8f689b0b..c1ccc941781 100644 --- a/linting/mandatory/Cargo.toml +++ b/linting/mandatory/Cargo.toml @@ -21,7 +21,7 @@ dylint_linting = "2.1.12" if_chain = "1.0.2" log = "0.4.14" regex = "1.5.4" -ink_linting_utils = { path = "../utils" } +ink_linting_utils = { workspace = true } [dev-dependencies] dylint_testing = "2.1.12" From 2ebfbc7069c9921f142a5aa0e186f219603008e5 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 14:20:26 -0300 Subject: [PATCH 07/11] chore: Fix typo --- linting/utils/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linting/utils/Cargo.toml b/linting/utils/Cargo.toml index 5f8d3fa41c9..59f6a16c1eb 100644 --- a/linting/utils/Cargo.toml +++ b/linting/utils/Cargo.toml @@ -9,7 +9,7 @@ readme = "README.md" repository.workspace = true documentation = "https://docs.rs/ink_linting_utils" homepage.workspace = true -description = "Utilities used internally in ink_linting crates" +description = "Utilities used internally in ink_linting" keywords.workspace = true include = ["Cargo.toml", "*.rs", "LICENSE"] From ad3105c429121c06b139d88743c04acadaefe550 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 14:31:21 -0300 Subject: [PATCH 08/11] chore(mandatory): Set explicit versions of the ink! deps Needed to use `cargo publish` --- linting/mandatory/Cargo.toml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/linting/mandatory/Cargo.toml b/linting/mandatory/Cargo.toml index c1ccc941781..66c22915cb1 100644 --- a/linting/mandatory/Cargo.toml +++ b/linting/mandatory/Cargo.toml @@ -25,12 +25,17 @@ ink_linting_utils = { workspace = true } [dev-dependencies] dylint_testing = "2.1.12" -# The following are ink! dependencies, they are only required for the `ui` tests. -ink_env = { path = "../../crates/env", default-features = false } -ink = { path = "../../crates/ink", default-features = false, features = ["std"] } -ink_metadata = { path = "../../crates/metadata", default-features = false } -ink_primitives = { path = "../../crates/primitives", default-features = false } -ink_storage = { path = "../../crates/storage", default-features = false } + +# The ink! dependencies used to build the `ui` tests and to compile the linting +# library with `--default-features=std` (see the `features` section bellow). +# +# These cannot be moved to the workspace level because `cargo` does not provide +# the `[[workspace.dev-dependencies]]` directive. +ink = { version = "=5.0.0-rc", path = "../../crates/ink", default-features = false, features = ["std"] } +ink_env = { version = "=5.0.0-rc", path = "../../crates/env", default-features = false } +ink_metadata = { version = "=5.0.0-rc", path = "../../crates/metadata", default-features = false } +ink_primitives = { version = "=5.0.0-rc", path = "../../crates/primitives", default-features = false } +ink_storage = { version = "=5.0.0-rc", path = "../../crates/storage", default-features = false } scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] } scale-info = { version = "2.6", default-features = false, features = ["derive"] } From e8829819b35f4374bcb53fd8894fe0ec7bedc452 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 14:33:04 -0300 Subject: [PATCH 09/11] chore(mandatory): Change the crate description --- linting/mandatory/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linting/mandatory/Cargo.toml b/linting/mandatory/Cargo.toml index 66c22915cb1..753dc39b0f2 100644 --- a/linting/mandatory/Cargo.toml +++ b/linting/mandatory/Cargo.toml @@ -9,7 +9,7 @@ readme = "README.md" repository.workspace = true documentation = "https://docs.rs/ink_linting_mandatory" homepage.workspace = true -description = "Mandatory ink! linting rules integrated in contracts' build process" +description = "Mandatory ink! linting rules" keywords.workspace = true include = ["Cargo.toml", "*.rs", "LICENSE"] From 1614cfa3c33377bffbdadf680c377045e58f26b3 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 14:35:26 -0300 Subject: [PATCH 10/11] chore(extra): Prepare `Cargo.toml` for publishing --- linting/extra/Cargo.toml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/linting/extra/Cargo.toml b/linting/extra/Cargo.toml index dc98303c51f..2cf9797fb70 100644 --- a/linting/extra/Cargo.toml +++ b/linting/extra/Cargo.toml @@ -9,7 +9,7 @@ readme = "README.md" repository.workspace = true documentation = "https://docs.rs/ink_linting" homepage.workspace = true -description = "Extra linting rules for ink! smart contracts" +description = "Extra ink! linting rules" keywords.workspace = true include = ["Cargo.toml", "*.rs", "LICENSE"] @@ -22,16 +22,20 @@ if_chain = "1.0.2" log = "0.4.14" regex = "1.5.4" ink_linting_utils = { workspace = true } -# ink! dependencies used in the linter implementation -ink_env = { path = "../../crates/env", default-features = false } +ink_env = { version = "=5.0.0-rc", path = "../../crates/env", default-features = false } [dev-dependencies] dylint_testing = "2.1.12" -# The following are ink! dependencies, they are only required for the `ui` tests. -ink = { path = "../../crates/ink", default-features = false, features = ["std"] } -ink_metadata = { path = "../../crates/metadata", default-features = false } -ink_primitives = { path = "../../crates/primitives", default-features = false } -ink_storage = { path = "../../crates/storage", default-features = false } + +# The ink! dependencies used to build the `ui` tests and to compile the linting +# library with `--default-features=std` (see the `features` section bellow). +# +# These cannot be moved to the workspace level because `cargo` does not provide +# the `[[workspace.dev-dependencies]]` directive. +ink = { version = "=5.0.0-rc", path = "../../crates/ink", default-features = false, features = ["std"] } +ink_metadata = { version = "=5.0.0-rc", path = "../../crates/metadata", default-features = false } +ink_primitives = { version = "=5.0.0-rc", path = "../../crates/primitives", default-features = false } +ink_storage = { version = "=5.0.0-rc", path = "../../crates/storage", default-features = false } scale = { package = "parity-scale-codec", version = "3.4", default-features = false, features = ["derive"] } scale-info = { version = "2.6", default-features = false, features = ["derive"] } From 9a113ea995a08bbd81ecc2574f36ffb676859958 Mon Sep 17 00:00:00 2001 From: Georgiy Komarov Date: Fri, 12 Jan 2024 14:40:02 -0300 Subject: [PATCH 11/11] chore: Add the changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f8261b02a8..1a3cbb883df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Custom signature topic in Events - #[2031](https://github.com/paritytech/ink/pull/2031) - Linter: `non_fallible_api` lint - [#2004](https://github.com/paritytech/ink/pull/2004) +- Linter: Publish the linting crates on crates.io - [#2060](https://github.com/paritytech/ink/pull/2060) ### Fixed - Fix the `StorageVec` type by excluding the `len_cached` field from its type info - [#2052](https://github.com/paritytech/ink/pull/2052)