Skip to content

feat(env_filter): support no_std#404

Open
cagatay-y wants to merge 4 commits intorust-cli:mainfrom
cagatay-y:feature/filter-no_std
Open

feat(env_filter): support no_std#404
cagatay-y wants to merge 4 commits intorust-cli:mainfrom
cagatay-y:feature/filter-no_std

Conversation

@cagatay-y
Copy link
Copy Markdown

Based on #378, this PR adds a new default feature std that allows the crate to be used in no_std crates. I tried to incorporate the feedback that was given to the previous PR. Hopefully, I didn't miss anything.

The PR is still a breaking change for crates that have the default features disabled and use Builder::from_env, or expect Builder::parse to print warnings to stderr and don't have the log target set to stderr.

It may make sense to squash 9c70eaf and 663c9c2 (and potentially b754c66). I kept them separate to make sure I don't misattribute the work of the author of the base PR.

cagatay-y and others added 4 commits April 2, 2026 16:36
Co-authored-by: WolverinDEV <git@did.science>
Co-authored-by: Çağatay Yiğit Şahin <cyigitsahin@outlook.com>
env_filter

Some parts of the tests are skipped with no_std as they require
`snapbox::str!` which does not support no_std.
@cagatay-y cagatay-y changed the title refactor(env_filter): fix unreachable pub warning feat(env_filter): support no_std Apr 2, 2026
Comment on lines 40 to 44
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
#![warn(clippy::print_stderr)]
#![warn(clippy::print_stdout)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For a no-std crate, I would expect the following lints added

#![warn(clippy::std_instead_of_core)]
#![warn(clippy::std_instead_of_alloc)]

Comment on lines +75 to +81
run:
- cargo hack check --each-feature --locked --rust-version --ignore-private --package env_logger --all-targets --keep-going
# When the std feature is enabled, a lower MSRV of 1.71 is sufficient and was the MSRV for the crate before std was made optional.
# To make sure we keep it that way, check configurations with std enabled and disabled separately and with their respective MSRVs.
# "--at-least-one-of" requires "--feature-powerset", which can be made to emulate "--each-feature" with "--depth 1".
- cargo hack check --feature-powerset --depth 1 --locked --version-range 1.71..=1.71 --ignore-private --package env_filter --all-targets --keep-going --at-least-one-of std,default,regex
- cargo hack check --no-default-features --locked --version-range 1.81..=1.81 --ignore-private --package env_filter --all-targets --keep-going
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. This is too complicated
  2. I am not keen on having feature-dependent MSRVs

@epage
Copy link
Copy Markdown
Contributor

epage commented Apr 2, 2026

FYI I expect PRs to be presented for how they should be reviewed and merged and not for how they were developed. Please clean up the commit history

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants