```toml
[package]
name = "test_contract"
description = "cargo-near-new-project-description"
version = "0.1.0"
edition = "2021"
# TODO: Fill out the repository field to help NEAR ecosystem tools to discover your project.
# NEP-0330 is automatically implemented for all contracts built with https://github.com/near/cargo-near.
# Link to the repository will be available via `contract_source_metadata` view-function.
#repository = "https://github.com/xxx/xxx"
[lib]
crate-type = ["cdylib", "rlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
near-sdk = { version = "5.1.0", features = ["unit-testing"], git = "https://github.com/near/near-sdk-rs.git", rev = "c843e9aec747b9acc7e240a6dea80a14448a7bfd" }
[dev-dependencies]
near-sdk = { version = "5.1.0", features = ["unit-testing"], git = "https://github.com/near/near-sdk-rs.git", rev = "c843e9aec747b9acc7e240a6dea80a14448a7bfd" }
near-workspaces = { version = "0.10.0", features = ["unstable"] }
tokio = { version = "1.12.0", features = ["full"] }
serde_json = "1"
[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
opt-level = "z"
lto = true
debug = false
panic = "abort"
# Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801
overflow-checks = true
```
it results in following error:
• Checking the host environment...
• done
• Collecting cargo project metadata...
• done
• Generating ABI
│ Compiling test_contract v0.1.0 (/home/user/Documents/code/test_contract)
│ error[E0261]: use of undeclared lifetime name `'a`
│ --> src/lib.rs:13:59
│ |
│ 13 | pub fn is_ident<'a>(&self, other: &'a u32) -> Option<&'a u32> {
│ | - ^^ undeclared lifetime
│ | |
│ | help: consider introducing lifetime `'a` here: `<'a>`
│
│ For more information about this error, try `rustc --explain E0261`.
│ error: could not compile `test_contract` (lib) due to 1 previous error
Here is the console command if you ever need to re-run it again:
cargo near build --no-locked --no-docker
Error:
0: `cd "/home/user/Documents/code/test_contract" && CARGO_NEAR_ABI_GENERATION="true" CARGO_PROFILE_DEV_DEBUG="0" CARGO_PROFILE_DEV_LTO="off" CARGO_PROFILE_DEV_OPT_LEVEL="0" RUSTFLAGS="-Awarnings" "/home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo" "build" "--message-format=json-render-diagnostics" "--features" "near-sdk/__abi-generate" "--color" "auto"` failed with exit code: Some(101)
expansion by cargo expand --features near-sdk/__abi-generate has this:
Originally highlighted by this test, but it was run under wrong feature flag
abi
instead of__abi-generate
.when doing
cargo near build
against this codeCargo.toml
```toml [package] name = "test_contract" description = "cargo-near-new-project-description" version = "0.1.0" edition = "2021" # TODO: Fill out the repository field to help NEAR ecosystem tools to discover your project. # NEP-0330 is automatically implemented for all contracts built with https://github.com/near/cargo-near. # Link to the repository will be available via `contract_source_metadata` view-function. #repository = "https://github.com/xxx/xxx" [lib] crate-type = ["cdylib", "rlib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] near-sdk = { version = "5.1.0", features = ["unit-testing"], git = "https://github.com/near/near-sdk-rs.git", rev = "c843e9aec747b9acc7e240a6dea80a14448a7bfd" } [dev-dependencies] near-sdk = { version = "5.1.0", features = ["unit-testing"], git = "https://github.com/near/near-sdk-rs.git", rev = "c843e9aec747b9acc7e240a6dea80a14448a7bfd" } near-workspaces = { version = "0.10.0", features = ["unstable"] } tokio = { version = "1.12.0", features = ["full"] } serde_json = "1" [profile.release] codegen-units = 1 # Tell `rustc` to optimize for small code size. opt-level = "z" lto = true debug = false panic = "abort" # Opt into extra safety checks on arithmetic operations https://stackoverflow.com/a/64136471/249801 overflow-checks = true ```
it results in following error:
expansion by
cargo expand --features near-sdk/__abi-generate
has this:Code, that produces the expansion is somewhere here https://github.com/near/near-sdk-rs/blob/c843e9aec747b9acc7e240a6dea80a14448a7bfd/near-sdk-macros/src/core_impl/abi/abi_generator.rs#L135-L146 and here https://github.com/near/near-sdk-rs/blob/c843e9aec747b9acc7e240a6dea80a14448a7bfd/near-sdk-macros/src/core_impl/abi/abi_generator.rs#L258-L272