Repository: paritytech/ink
Pull request #931 (2021-09-21 07:58:09)

Check namespace argument is identifier
Just checks that `argument` in `#[ink(namespace = "argument")]` is a valid Rust identifier and adds tests for it.

codecov-commenter: # [Codecov](https://codecov.io/gh/paritytech/ink/pull/931?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech) Report
> Merging [#931](https://codecov.io/gh/paritytech/ink/pull/931?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech) (26f1233) into [master](https://codecov.io/gh/paritytech/ink/commit/725c2f70bb89263c15d999bd616e9813d2182233?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech) (725c2f7) will **increase** coverage by `1.01%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/paritytech/ink/pull/931/graphs/tree.svg?width=650&height=150&src=pr&token=tYyVaCZb7o&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech)](https://codecov.io/gh/paritytech/ink/pull/931?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech)

```diff
@@            Coverage Diff             @@
##           master     #931      +/-   ##
==========================================
+ Coverage   86.17%   87.18%   +1.01%     
==========================================
  Files         171      169       -2     
  Lines        7653     7556      -97     
==========================================
- Hits         6595     6588       -7     
+ Misses       1058      968      -90     
```


| [Impacted Files](https://codecov.io/gh/paritytech/ink/pull/931?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech) | Coverage Δ | |
|---|---|---|
| [crates/lang/ir/src/ir/attrs.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL2xhbmcvaXIvc3JjL2lyL2F0dHJzLnJz) | `82.55% <100.00%> (+0.17%)` | :arrow_up: |
| [...ates/storage/src/collections/hashmap/fuzz\_tests.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL3N0b3JhZ2Uvc3JjL2NvbGxlY3Rpb25zL2hhc2htYXAvZnV6el90ZXN0cy5ycw==) | `95.74% <0.00%> (-4.26%)` | :arrow_down: |
| [crates/metadata/src/layout/mod.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL21ldGFkYXRhL3NyYy9sYXlvdXQvbW9kLnJz) | `89.04% <0.00%> (-0.57%)` | :arrow_down: |
| [crates/storage/src/traits/layout/mod.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL3N0b3JhZ2Uvc3JjL3RyYWl0cy9sYXlvdXQvbW9kLnJz) | | |
| [crates/storage/src/traits/layout/impls.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL3N0b3JhZ2Uvc3JjL3RyYWl0cy9sYXlvdXQvaW1wbHMucnM=) | | |
| [crates/storage/src/lazy/entry.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL3N0b3JhZ2Uvc3JjL2xhenkvZW50cnkucnM=) | `100.00% <0.00%> (+5.26%)` | :arrow_up: |
| [crates/storage/src/collections/bitstash/counts.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL3N0b3JhZ2Uvc3JjL2NvbGxlY3Rpb25zL2JpdHN0YXNoL2NvdW50cy5ycw==) | `100.00% <0.00%> (+7.14%)` | :arrow_up: |
| [crates/storage/src/collections/bitvec/mod.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL3N0b3JhZ2Uvc3JjL2NvbGxlY3Rpb25zL2JpdHZlYy9tb2QucnM=) | `97.59% <0.00%> (+7.59%)` | :arrow_up: |
| [crates/storage/src/collections/bitvec/iter.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL3N0b3JhZ2Uvc3JjL2NvbGxlY3Rpb25zL2JpdHZlYy9pdGVyLnJz) | `91.50% <0.00%> (+9.30%)` | :arrow_up: |
| [crates/storage/src/collections/bitvec/impls.rs](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech#diff-Y3JhdGVzL3N0b3JhZ2Uvc3JjL2NvbGxlY3Rpb25zL2JpdHZlYy9pbXBscy5ycw==) | `93.33% <0.00%> (+10.98%)` | :arrow_up: |
| ... and [8 more](https://codecov.io/gh/paritytech/ink/pull/931/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/paritytech/ink/pull/931?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/paritytech/ink/pull/931?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech). Last update [725c2f7...26f1233](https://codecov.io/gh/paritytech/ink/pull/931?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=paritytech).


Patch:
diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml
index 2648622d3d..dcc9530842 100644
--- a/crates/engine/Cargo.toml
+++ b/crates/engine/Cargo.toml
@@ -15,7 +15,7 @@ categories = ["no-std", "embedded"]
 include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
 
 [dependencies]
-scale = { package = "parity-scale-codec", version = "2.0", default-features = false, features = ["derive", "full"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] }
 derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
 
 sha2 = { version = "0.9" }
diff --git a/crates/env/Cargo.toml b/crates/env/Cargo.toml
index e9ec3eaeb9..6a6e0fcc83 100644
--- a/crates/env/Cargo.toml
+++ b/crates/env/Cargo.toml
@@ -21,7 +21,7 @@ ink_allocator = { version = "3.0.0-rc5", path = "../allocator/", default-feature
 ink_primitives = { version = "3.0.0-rc5", path = "../primitives/", default-features = false }
 ink_prelude = { version = "3.0.0-rc5", path = "../prelude/", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] }
 derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
 num-traits = { version = "0.2", default-features = false, features = ["i128"] }
 cfg-if = "1.0"
diff --git a/crates/lang/Cargo.toml b/crates/lang/Cargo.toml
index 57a2e3183b..0a91a88fd4 100644
--- a/crates/lang/Cargo.toml
+++ b/crates/lang/Cargo.toml
@@ -22,7 +22,7 @@ ink_metadata = { version = "3.0.0-rc5", path = "../metadata", default-features =
 ink_prelude = { version = "3.0.0-rc5", path = "../prelude", default-features = false }
 ink_lang_macro = { version = "3.0.0-rc5", path = "macro", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] }
 derive_more = { version = "0.99", default-features = false, features = ["from"] }
 static_assertions = "1.1"
 
diff --git a/crates/lang/codegen/Cargo.toml b/crates/lang/codegen/Cargo.toml
index e0f06a1ab7..0262115943 100644
--- a/crates/lang/codegen/Cargo.toml
+++ b/crates/lang/codegen/Cargo.toml
@@ -27,7 +27,7 @@ itertools = "0.10"
 either = { version = "1.5", default-features = false }
 blake2 = "0.9"
 heck = "0.3.1"
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] }
 impl-serde = "0.3.1"
 
 [features]
diff --git a/crates/lang/ir/src/ir/attrs.rs b/crates/lang/ir/src/ir/attrs.rs
index 6f50373d8f..64fa45efbb 100644
--- a/crates/lang/ir/src/ir/attrs.rs
+++ b/crates/lang/ir/src/ir/attrs.rs
@@ -766,11 +766,16 @@ impl TryFrom<syn::NestedMeta> for AttributeFrag {
                         }
                         if name_value.path.is_ident("namespace") {
                             if let syn::Lit::Str(lit_str) = &name_value.lit {
-                                let bytes = lit_str.value().into_bytes();
+                                let argument = lit_str.value();
+                                syn::parse_str::<syn::Ident>(&argument)
+                                    .map_err(|_error| format_err!(
+                                        lit_str,
+                                        "encountered invalid Rust identifier for namespace argument",
+                                    ))?;
                                 return Ok(AttributeFrag {
                                     ast: meta,
                                     arg: AttributeArg::Namespace(
-                                        Namespace::from(bytes),
+                                        Namespace::from(argument.into_bytes()),
                                     ),
                                 })
                             }
@@ -1090,6 +1095,16 @@ mod tests {
         );
     }
 
+    #[test]
+    fn namespace_invalid_identifier() {
+        assert_attribute_try_from(
+            syn::parse_quote! {
+                #[ink(namespace = "::invalid_identifier")]
+            },
+            Err("encountered invalid Rust identifier for namespace argument"),
+        );
+    }
+
     #[test]
     fn namespace_invalid_type() {
         assert_attribute_try_from(
diff --git a/crates/lang/macro/Cargo.toml b/crates/lang/macro/Cargo.toml
index 5fd15921f3..29cc59537d 100644
--- a/crates/lang/macro/Cargo.toml
+++ b/crates/lang/macro/Cargo.toml
@@ -19,7 +19,7 @@ ink_lang_ir = { version = "3.0.0-rc5", path = "../ir", default-features = false
 ink_lang_codegen = { version = "3.0.0-rc5", path = "../codegen", default-features = false }
 ink_primitives = { version = "3.0.0-rc5", path = "../../primitives/", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 syn = "1"
 proc-macro2 = "1"
 
diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml
index 72c1e473f9..6939af1974 100644
--- a/crates/primitives/Cargo.toml
+++ b/crates/primitives/Cargo.toml
@@ -16,7 +16,7 @@ include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
 
 [dependencies]
 ink_prelude = { version = "3.0.0-rc5", path = "../prelude/", default-features = false }
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [dev-dependencies]
diff --git a/crates/storage/Cargo.toml b/crates/storage/Cargo.toml
index f3c3d22ecb..864b01f50f 100644
--- a/crates/storage/Cargo.toml
+++ b/crates/storage/Cargo.toml
@@ -21,7 +21,7 @@ ink_primitives = { version = "3.0.0-rc5", path = "../primitives/", default-featu
 ink_storage_derive = { version = "3.0.0-rc5", path = "derive", default-features = false }
 ink_prelude = { version = "3.0.0-rc5", path = "../prelude/", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] }
 derive_more = { version = "0.99", default-features = false, features = ["from", "display"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 cfg-if = "1.0"
diff --git a/crates/storage/derive/Cargo.toml b/crates/storage/derive/Cargo.toml
index 0b2ecc8490..72c57f81e5 100644
--- a/crates/storage/derive/Cargo.toml
+++ b/crates/storage/derive/Cargo.toml
@@ -24,7 +24,7 @@ proc-macro2 = "1.0"
 synstructure = "0.12.4"
 
 [dev-dependencies]
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive", "full"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive", "full"] }
 ink_env = { version = "3.0.0-rc5", path = "../../env" }
 ink_primitives = { version = "3.0.0-rc5", path = "../../primitives" }
 ink_metadata = { version = "3.0.0-rc5", path = "../../metadata" }
diff --git a/examples/contract-terminate/Cargo.toml b/examples/contract-terminate/Cargo.toml
index f36a4608c3..3a29788df2 100644
--- a/examples/contract-terminate/Cargo.toml
+++ b/examples/contract-terminate/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../crates/env", default-features =
 ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/contract-transfer/Cargo.toml b/examples/contract-transfer/Cargo.toml
index 8d17550e54..159fbe7fb5 100644
--- a/examples/contract-transfer/Cargo.toml
+++ b/examples/contract-transfer/Cargo.toml
@@ -12,7 +12,7 @@ ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-fe
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 ink_prelude = { version = "3.0.0-rc5", path = "../../crates/prelude", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/delegator/Cargo.toml b/examples/delegator/Cargo.toml
index c819352265..9d6398c236 100644
--- a/examples/delegator/Cargo.toml
+++ b/examples/delegator/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../crates/env", default-features =
 ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 
 adder = { version = "3.0.0-rc5", path = "adder", default-features = false, features = ["ink-as-dependency"] }
 subber = { version = "3.0.0-rc5", path = "subber", default-features = false, features = ["ink-as-dependency"] }
diff --git a/examples/delegator/accumulator/Cargo.toml b/examples/delegator/accumulator/Cargo.toml
index c203f7adbf..d311cc44fc 100644
--- a/examples/delegator/accumulator/Cargo.toml
+++ b/examples/delegator/accumulator/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../../crates/env", default-feature
 ink_storage = { version = "3.0.0-rc5", path = "../../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/delegator/adder/Cargo.toml b/examples/delegator/adder/Cargo.toml
index b8d26d7871..0f7653fb04 100644
--- a/examples/delegator/adder/Cargo.toml
+++ b/examples/delegator/adder/Cargo.toml
@@ -13,7 +13,7 @@ ink_lang = { version = "3.0.0-rc5", path = "../../../crates/lang", default-featu
 
 accumulator = { version = "3.0.0-rc5", path = "../accumulator", default-features = false, features = ["ink-as-dependency"] }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/delegator/subber/Cargo.toml b/examples/delegator/subber/Cargo.toml
index ce56559368..9bab0c8df3 100644
--- a/examples/delegator/subber/Cargo.toml
+++ b/examples/delegator/subber/Cargo.toml
@@ -13,7 +13,7 @@ ink_lang = { version = "3.0.0-rc5", path = "../../../crates/lang", default-featu
 
 accumulator = { version = "3.0.0-rc5", path = "../accumulator", default-features = false, features = ["ink-as-dependency"] }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/dns/Cargo.toml b/examples/dns/Cargo.toml
index 3274d9d44e..b993f92b64 100644
--- a/examples/dns/Cargo.toml
+++ b/examples/dns/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../crates/env", default-features =
 ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/erc1155/Cargo.toml b/examples/erc1155/Cargo.toml
index d31b3dfa1e..e319c3e702 100644
--- a/examples/erc1155/Cargo.toml
+++ b/examples/erc1155/Cargo.toml
@@ -12,7 +12,7 @@ ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-fe
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 ink_prelude = { version = "3.0.0-rc5", path = "../../crates/prelude", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/erc20/Cargo.toml b/examples/erc20/Cargo.toml
index 4e1b596bc5..6f010abaa4 100644
--- a/examples/erc20/Cargo.toml
+++ b/examples/erc20/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../crates/env", default-features =
 ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/erc721/Cargo.toml b/examples/erc721/Cargo.toml
index c8f9987416..07e14c3a42 100644
--- a/examples/erc721/Cargo.toml
+++ b/examples/erc721/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../crates/env", default-features =
 ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/flipper/Cargo.toml b/examples/flipper/Cargo.toml
index 309736b43a..f15018b624 100644
--- a/examples/flipper/Cargo.toml
+++ b/examples/flipper/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../crates/env", default-features =
 ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/incrementer/Cargo.toml b/examples/incrementer/Cargo.toml
index 45c5cc3feb..e967be9b7b 100644
--- a/examples/incrementer/Cargo.toml
+++ b/examples/incrementer/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../crates/env", default-features =
 ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/multisig_plain/Cargo.toml b/examples/multisig_plain/Cargo.toml
index 582e34e2ae..8097d9a090 100755
--- a/examples/multisig_plain/Cargo.toml
+++ b/examples/multisig_plain/Cargo.toml
@@ -12,7 +12,7 @@ ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-fe
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 ink_prelude = { version = "3.0.0-rc5", path = "../../crates/prelude", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/rand-extension/Cargo.toml b/examples/rand-extension/Cargo.toml
index 2f479989a7..edd4fa0abf 100755
--- a/examples/rand-extension/Cargo.toml
+++ b/examples/rand-extension/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { path = "../../crates/env", default-features = false }
 ink_storage = { path = "../../crates/storage", default-features = false }
 ink_lang = { path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/trait-erc20/Cargo.toml b/examples/trait-erc20/Cargo.toml
index 2f8faedcae..2921853c4f 100644
--- a/examples/trait-erc20/Cargo.toml
+++ b/examples/trait-erc20/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../crates/env", default-features =
 ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]
diff --git a/examples/trait-flipper/Cargo.toml b/examples/trait-flipper/Cargo.toml
index b6f1d932ca..5d2f2046ca 100644
--- a/examples/trait-flipper/Cargo.toml
+++ b/examples/trait-flipper/Cargo.toml
@@ -11,7 +11,7 @@ ink_env = { version = "3.0.0-rc5", path = "../../crates/env", default-features =
 ink_storage = { version = "3.0.0-rc5", path = "../../crates/storage", default-features = false }
 ink_lang = { version = "3.0.0-rc5", path = "../../crates/lang", default-features = false }
 
-scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
+scale = { package = "parity-scale-codec", version = "2", default-features = false, features = ["derive"] }
 scale-info = { version = "0.6", default-features = false, features = ["derive"], optional = true }
 
 [lib]


Test patch:
diff --git a/crates/lang/macro/tests/compile_tests.rs b/crates/lang/macro/tests/compile_tests.rs
index 65b51b6cf4..fc0ea55aeb 100644
--- a/crates/lang/macro/tests/compile_tests.rs
+++ b/crates/lang/macro/tests/compile_tests.rs
@@ -60,5 +60,9 @@ fn compile_tests() {
     t.compile_fail("tests/ui/fail/S-05-storage-as-event.rs");
     t.compile_fail("tests/ui/fail/S-06-event-as-storage.rs");
 
+    t.compile_fail("tests/ui/fail/N-01-namespace-invalid-identifier.rs");
+    t.compile_fail("tests/ui/fail/N-02-namespace-invalid-type.rs");
+    t.compile_fail("tests/ui/fail/N-03-namespace-missing-argument.rs");
+
     t.pass("tests/ui/chain_extension/E-01-simple.rs");
 }
diff --git a/crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.rs b/crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.rs
new file mode 100644
index 0000000000..21d08c2d3d
--- /dev/null
+++ b/crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.rs
@@ -0,0 +1,20 @@
+use ink_lang as ink;
+
+#[ink::contract]
+mod invalid_namespace_identifier {
+    #[ink(storage)]
+    pub struct MyStorage {}
+
+    #[ink(namespace = "::invalid_identifier")]
+    impl MyStorage {
+        #[ink(constructor)]
+        pub fn constructor() -> Self {
+            Self {}
+        }
+
+        #[ink(message)]
+        pub fn message(&self) {}
+    }
+}
+
+fn main() {}
diff --git a/crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.stderr b/crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.stderr
new file mode 100644
index 0000000000..8e3bacd08e
--- /dev/null
+++ b/crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.stderr
@@ -0,0 +1,5 @@
+error: encountered invalid Rust identifier for namespace argument
+ --> $DIR/N-01-namespace-invalid-identifier.rs:8:23
+  |
+8 |     #[ink(namespace = "::invalid_identifier")]
+  |                       ^^^^^^^^^^^^^^^^^^^^^^
diff --git a/crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.rs b/crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.rs
new file mode 100644
index 0000000000..60871df1e5
--- /dev/null
+++ b/crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.rs
@@ -0,0 +1,20 @@
+use ink_lang as ink;
+
+#[ink::contract]
+mod invalid_namespace_identifier {
+    #[ink(storage)]
+    pub struct MyStorage {}
+
+    #[ink(namespace = true)]
+    impl MyStorage {
+        #[ink(constructor)]
+        pub fn constructor() -> Self {
+            Self {}
+        }
+
+        #[ink(message)]
+        pub fn message(&self) {}
+    }
+}
+
+fn main() {}
diff --git a/crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.stderr b/crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.stderr
new file mode 100644
index 0000000000..aed0beed38
--- /dev/null
+++ b/crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.stderr
@@ -0,0 +1,5 @@
+error: expecteded string type for `namespace` argument, e.g. #[ink(namespace = "hello")]
+ --> $DIR/N-02-namespace-invalid-type.rs:8:11
+  |
+8 |     #[ink(namespace = true)]
+  |           ^^^^^^^^^^^^^^^^
diff --git a/crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.rs b/crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.rs
new file mode 100644
index 0000000000..a4af79c249
--- /dev/null
+++ b/crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.rs
@@ -0,0 +1,20 @@
+use ink_lang as ink;
+
+#[ink::contract]
+mod invalid_namespace_identifier {
+    #[ink(storage)]
+    pub struct MyStorage {}
+
+    #[ink(namespace)]
+    impl MyStorage {
+        #[ink(constructor)]
+        pub fn constructor() -> Self {
+            Self {}
+        }
+
+        #[ink(message)]
+        pub fn message(&self) {}
+    }
+}
+
+fn main() {}
diff --git a/crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.stderr b/crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.stderr
new file mode 100644
index 0000000000..e5298677d2
--- /dev/null
+++ b/crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.stderr
@@ -0,0 +1,5 @@
+error: encountered #[ink(namespace)] that is missing its string parameter. Did you mean #[ink(namespace = name: str)] ?
+ --> $DIR/N-03-namespace-missing-argument.rs:8:11
+  |
+8 |     #[ink(namespace)]
+  |           ^^^^^^^^^