Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert: remove double_contract_state_error diagnostic #1310

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions near-sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ fn has_nested_near_macros(item: TokenStream) -> bool {
.is_some()
}

fn check_duplicate_contract_state() -> bool {
static CONTRACT_STATE_DEFINED: ::std::sync::atomic::AtomicBool =
::std::sync::atomic::AtomicBool::new(false);

CONTRACT_STATE_DEFINED.swap(true, ::std::sync::atomic::Ordering::AcqRel)
}

#[proc_macro_attribute]
pub fn near(attr: TokenStream, item: TokenStream) -> TokenStream {
if attr.to_string().contains("event_json") {
Expand Down Expand Up @@ -111,16 +104,6 @@ pub fn near(attr: TokenStream, item: TokenStream) -> TokenStream {
let mut expanded: proc_macro2::TokenStream = quote! {};

if near_macro_args.contract_state.unwrap_or(false) {
if check_duplicate_contract_state() {
return TokenStream::from(
syn::Error::new(
Span::call_site(),
"Contract state can only be defined once per crate",
)
.to_compile_error(),
);
}

if let Some(metadata) = near_macro_args.contract_metadata {
expanded = quote! {#[#near_sdk_crate::near_bindgen(#metadata)]}
} else {
Expand Down
1 change: 0 additions & 1 deletion near-sdk/compilation_tests/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ fn compilation_tests() {
t.pass("compilation_tests/contract_metadata_bindgen.rs");
t.pass("compilation_tests/types.rs");
t.compile_fail("compilation_tests/nested_near_error.rs");
t.compile_fail("compilation_tests/double_contract_state_error.rs");
}
13 changes: 0 additions & 13 deletions near-sdk/compilation_tests/double_contract_state_error.rs

This file was deleted.

This file was deleted.

Loading