Replace STD to CORE lib - #37
Conversation
bharatGoswami8
commented
May 22, 2026
- Change most possible import from std to core
- Updated alternative solution
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
28df195 to
d013dd5
Compare
|
@AS1100K, could you please review this PR. |
2 similar comments
|
@AS1100K, could you please review this PR. |
|
@AS1100K, could you please review this PR. |
|
@AS1100K , could you please review this PR. |
1 similar comment
|
@AS1100K , could you please review this PR. |
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce reliance on std by switching many imports to core, while also adjusting token construction logic in the proc-macro implementation and tightening CI coverage enforcement.
Changes:
- Replaced several
std::*imports withcore::*equivalents across the crate. - Updated
pasted_to_tokensidentifier handling and added additional invalid-identifier test cases (including a new compile-fail doctest). - Added a CI step to print coverage summary and enforce 100% line/region coverage thresholds.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/test_helpers.rs |
Switches FromStr import from std to core in internal proc-macro test helpers. |
src/segment.rs |
Switches Peekable import from std to core. |
src/lib.rs |
Switches common imports to core, modifies identifier/literal token creation logic, and adds additional tests/doctests for invalid paste inputs. |
src/error.rs |
Switches iterator/result type references from std to core. |
src/attr.rs |
Switches iter, mem, and FromStr imports from std to core. |
.github/workflows/ci.yml |
Adds an extra llvm-cov step to print coverage summary and enforce coverage thresholds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Justification for not catching panics from Ident::new/Ident::new_raw: | ||
| // After basic validation above, these functions might still panic for edge cases | ||
| // (e.g., keywords without raw mode, Unicode edge cases). If we reach this point | ||
| // with such input, it indicates a bug in our paste logic (segment parsing, | ||
| // modifier handling, or concatenation). Letting it panic surfaces these bugs | ||
| // during development/testing. The proc_macro validation is comprehensive and | ||
| // handles Unicode, keywords, and other edge cases correctly. | ||
| let ident = if raw_mode { | ||
| let mut spasted = pasted.clone(); | ||
| spasted.remove(0); | ||
| spasted.remove(0); | ||
| TokenTree::Ident(Ident::new_raw(&spasted, span)) | ||
| } else { | ||
| TokenTree::Ident(Ident::new(&pasted, span)) | ||
| }; |
There was a problem hiding this comment.
Any alternative can you suggest, i want to remove the dependency of std most of the possible place.
There was a problem hiding this comment.
@AS1100K , Could you please check once the updated commit / solution, now we are doing error handing for those cases rather than panic.
AS1100K
left a comment
There was a problem hiding this comment.
Thanks @bharatGoswami8 for working on this!
I'm sorry that it took so long to review this PR as my university exams were going on during that time, and I didn't found any time looking into the PRs
| - run: cargo +nightly llvm-cov --workspace --branch --exclude-from-report pastey-test-suite --doctests --lcov --output-path lcov.info | ||
| env: | ||
| RUSTFLAGS: -C instrument-coverage -C llvm-args=-pgo-warn-missing-function | ||
| - name: Print coverage summary and thresould check | ||
| run: cargo +nightly llvm-cov --workspace --branch --exclude-from-report pastey-test-suite --doctests --fail-under-lines 100 --fail-under-regions 100 | ||
| env: | ||
| RUSTFLAGS: -C instrument-coverage -C llvm-args=-pgo-warn-missing-function |
There was a problem hiding this comment.
Can't we just keep the single run command instead of similar two run commands, so that in future it eliminates the chances of the commands not synced
There was a problem hiding this comment.
no i think because the above one is storing the result in lcov.info which we can not print directly on CI.
| // Justification for not catching panics from Ident::new/Ident::new_raw: | ||
| // After basic validation above, these functions might still panic for edge cases | ||
| // (e.g., keywords without raw mode, Unicode edge cases). If we reach this point | ||
| // with such input, it indicates a bug in our paste logic (segment parsing, | ||
| // modifier handling, or concatenation). Letting it panic surfaces these bugs | ||
| // during development/testing. The proc_macro validation is comprehensive and | ||
| // handles Unicode, keywords, and other edge cases correctly. | ||
| let ident = if raw_mode { | ||
| let mut spasted = pasted.clone(); | ||
| spasted.remove(0); | ||
| spasted.remove(0); | ||
| TokenTree::Ident(Ident::new_raw(&spasted, span)) | ||
| } else { | ||
| TokenTree::Ident(Ident::new(&pasted, span)) | ||
| }; |
|
@bharatGoswami8 Why do we need we need the crate to shift away from using |
* Change most possible import from std to core * Updated alternative solution
7fadeb2 to
7e748d7
Compare
Hi @AS1100K , I have reverted major changes related catch_unwind, now only we are using the alternative of std from core. |
|
@AS1100K, could you please review this PR. |
|
@AS1100K, could you please review this PR and merge it. |