Skip to content

Added keep_attr to #[ink::contract] and #[ink::trait_definition]#1145

Merged
cmichi merged 3 commits into
use-ink:masterfrom
Supercolony-net:feature/customization-attributes-call-builder
Feb 24, 2022
Merged

Added keep_attr to #[ink::contract] and #[ink::trait_definition]#1145
cmichi merged 3 commits into
use-ink:masterfrom
Supercolony-net:feature/customization-attributes-call-builder

Conversation

@xgreenx
Copy link
Copy Markdown
Contributor

@xgreenx xgreenx commented Feb 23, 2022

Added keep_attr to #[ink::contract] and #[ink::trait_definition] to manage that attributes should be passed to call builder during codegen. All attributes are ignore by default except: cfg, cfg_attr, allow, warn, deny, forbid, deprecated, must_use, doc.

More information in the conversation of #1130

…` to manage that attributes should be passed to call builder during codegen.
@paritytech-cicd-pr
Copy link
Copy Markdown

paritytech-cicd-pr commented Feb 23, 2022

🦑 📈 ink! Example Contracts ‒ Changes Report 📉 🦑

⚠️ The ink! master is ahead of your branch, this might skew the comparison data below.

These are the results when building the examples/* contracts from this branch with cargo-contract 0.17.0-ab41bd9 and comparing them to ink! master:

Δ Optimized Size Δ Used Gas Total Optimized Size Total Used Gas
accumulator 1.28 K
adder 2.23 K
contract-terminate 1.23 K 215_704
contract-transfer 8.37 K 15_704
delegator 6.26 K 33_142
dns 9.64 K 47_112
erc1155 27.71 K 94_224
erc20 9.12 K 47_112
erc721 14.40 K 125_632
flipper 1.57 K 15_704
incrementer 1.49 K 15_704
multisig 26.38 K 103_006
proxy 2.98 K 32_082
rand-extension 4.40 K 15_704
subber 2.24 K
trait-erc20 9.39 K 47_112
trait-flipper 1.35 K 15_704
trait-incrementer 1.45 K 31_408

Link to the run | Last update: Thu Feb 24 12:30:54 CET 2022

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 23, 2022

Codecov Report

Merging #1145 (a4a95eb) into master (ff5add1) will increase coverage by 0.04%.
The diff coverage is 84.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1145      +/-   ##
==========================================
+ Coverage   78.69%   78.73%   +0.04%     
==========================================
  Files         252      254       +2     
  Lines        9395     9448      +53     
==========================================
+ Hits         7393     7439      +46     
- Misses       2002     2009       +7     
Impacted Files Coverage Δ
crates/lang/macro/src/lib.rs 100.00% <ø> (ø)
...es/lang/tests/ui/contract/pass/config-keep-attr.rs 14.28% <14.28%> (ø)
crates/lang/ir/src/ir/trait_def/config.rs 54.54% <85.71%> (+8.39%) ⬆️
crates/lang/ir/src/ir/config.rs 92.40% <93.75%> (+0.91%) ⬆️
...odegen/src/generator/as_dependency/call_builder.rs 100.00% <100.00%> (ø)
...odegen/src/generator/as_dependency/contract_ref.rs 100.00% <100.00%> (ø)
...ng/codegen/src/generator/trait_def/call_builder.rs 100.00% <100.00%> (ø)
.../codegen/src/generator/trait_def/call_forwarder.rs 100.00% <100.00%> (ø)
...tes/lang/tests/ui/trait_def/pass/with_keep_attr.rs 100.00% <100.00%> (ø)
crates/lang/ir/src/ir/trait_def/mod.rs 83.33% <0.00%> (+16.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff5add1...a4a95eb. Read the comment docs.

}

impl WhitelistedAttributes {
pub fn parse_arg_value(&mut self, arg: &MetaNameValue) -> Result<(), syn::Error> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks solid, could you add a comment to this pub function here please?

}
}

pub fn filter_attr(&self, attrs: Vec<syn::Attribute>) -> Vec<syn::Attribute> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here a comment as well plz.

Copy link
Copy Markdown
Collaborator

@cmichi cmichi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Just two nitpicks from my side.

Comment thread crates/lang/ir/src/ir/config.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants