Skip to content

Conversation

@ple1n
Copy link
Contributor

@ple1n ple1n commented Aug 14, 2025

No description provided.

@sanity sanity requested a review from iduartgomez August 14, 2025 03:44
@iduartgomez
Copy link
Contributor

fails in tests:

error[E0433]: failed to resolve: could not find `freenet_stdlib` in the list of imported crates
  --> rust/src/log.rs:7:11
   |
7  |         ::freenet_stdlib::log::info(&format!($($arg)*));
   |           ^^^^^^^^^^^^^^ could not find `freenet_stdlib` in the list of imported crates
...
31 |     info!("n={}, y={:?}", 1, 2);
   |     --------------------------- in this macro invocation
   |
   = note: this error originates in the macro `info` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this module
   |
1  + use crate::log;

need to use relative import from crate

@ple1n
Copy link
Contributor Author

ple1n commented Oct 13, 2025

image

Does not fail on my machine.

Plus, if you change it to crate::log it will be unusable by dependencies, because IIRC macro_rules just injects code in place.

@ple1n
Copy link
Contributor Author

ple1n commented Oct 13, 2025

rustc --version
rustc 1.92.0-nightly (fa3155a64 2025-09-30)

Also I am on nightly.

@iduartgomez
Copy link
Contributor

iduartgomez commented Oct 13, 2025

Does not fail on my machine.

@ple1n please check CI, is failing, for this to be merged it has to pass CI

https://github.com/freenet/freenet-stdlib/actions/runs/18464415199/job/52607791262?pr=39

@ple1n
Copy link
Contributor Author

ple1n commented Oct 13, 2025

I moved testing to examples.

I dont think it can work in crate and outside the crate simultaneously. macro v1 cant do that.

@iduartgomez
Copy link
Contributor

You can absolutetly use and test regular macros within the same crate, but even if that was not the case, you can use integration tests that will run the CI pipeline instead of examples.

They just need to be defined before the tests or imported from a different module, proc_macros cannot be used within the same crate.

Copy link
Contributor

@iduartgomez iduartgomez left a comment

Choose a reason for hiding this comment

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

We could move the you example to integration tests instead.

@ple1n
Copy link
Contributor Author

ple1n commented Oct 14, 2025

so you are going to do it right? can we get this feature done asap.

you can commit to my branch directly

@iduartgomez
Copy link
Contributor

so you are going to do it right? can we get this feature done asap.

you can commit to my branch directly

Is your PR, you have to do the changes.

@iduartgomez
Copy link
Contributor

Actually just remove the example since is not doing any test really.

@ple1n
Copy link
Contributor Author

ple1n commented Oct 14, 2025

Removed.

@iduartgomez iduartgomez changed the title logging in contract and non contract env feat: logging in contract and non contract env Oct 14, 2025
@iduartgomez iduartgomez enabled auto-merge (squash) October 14, 2025 09:44
@iduartgomez iduartgomez merged commit d8728b3 into freenet:main Oct 14, 2025
7 checks passed
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.

2 participants