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

Update comparison_chain lint solution to make it work with no_std as well #12139

Conversation

GuillaumeGomez
Copy link
Member

Fixes #11785.

Just a small sentence fix to also make it work in no_std crates.

r? @llogiq

changelog: Update comparison_chain lint solution to make it work with no_std as well

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 12, 2024
@samueltardieu
Copy link
Contributor

@GuillaumeGomez I'm quite dubious about this one: except for two lints, all other lints seem to use std:: over core:: when describing the lint. As an embedded systems programmer myself, I would prefer to see core:: or alloc:: instead of std:: whenever possible, but I feel this is less friendly for beginners.

Can't we expect that people using #![no_std] usually know where to look? Or should we add a generic warning on the documentation page saying "If you use Rust in an embedded context with !#[no_std], you might want to look up the standard modules in core or allow rather than std"?

You can look at those examples for references to std which should be replaced by core in an embedded context as well:

@GuillaumeGomez
Copy link
Member Author

I'm very fine with closing this PR and the related issue as is.

@GuillaumeGomez GuillaumeGomez deleted the comparison_chain-no_std branch January 13, 2024 19:57
@llogiq
Copy link
Contributor

llogiq commented Jan 14, 2024

I think doing this in the docs is overrated. OTOH, switching the suggestions between core/alloc and std depending on whether the code has a no_std marker isn't.

@GuillaumeGomez
Copy link
Member Author

Fair point.

@GuillaumeGomez
Copy link
Member Author

I opened #12149 for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[comparison_chain]: Recommended fix not possible in no_std
4 participants