-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Switch to edition 2021 and resolver 2 This is effectively required for `no_std` support, as without it, dev-dependencies will enable features on regular dependencies, making it impossible to have `std` tests in `no_std` crates. * Add useful `no_std` lints These clippy lints highlight cases where an import is referencing `std` or `alloc` when it instead could import from `alloc` or `core`. This helps expose the "true" extent of `std` usage in a crate. * Update dependencies and features `termcolor` is incompatible with `no_std`, but `codespan` and `codespan-reporting` have valid use even without this crate. Making it optional allows `no_std` to be entirely decided by the contents of the codespan crates themselves. Serde is also `no_std` compatible, as long as we disable default features. * Increase MSRV to 1.67 During testing, `unicode-width` caused `cargo msrv find` to report `codespan-reporting`'s MSRV was 1.66, violating the current MSRV of 1.46. Since this is already the case, and there are features in 1.67, such as ilog10, which are desired within this crate, I have increased the MSRV to 1.67. * Switch to derived `Default` Before making substantive changes, `clippy` reported that these implementations for default can be derived. I have done so to silence the lint. * Suppress `clippy::should_implement_trait` `Span::from_str` shadows `FromStr::from_str`. Instead of breaking the public API, I added an explicit `allow` * Remove redundant `into()` calls Caught by clippy, and actioned to reduce warnings * Suppress `clippy::too_many_arguments` `Renderer::render_snippet_source` has too many arguments. Instead of breaking the public API, I'm suppressing this lint. * Remove redundant references These double-references are automatically dereferenced anyway. * Use `ilog10` in `count_digits` Increasing MSRV allows using the new `ilog10` method, solving a long-standing TODO * Use of `format` is redundant `ToString::to_string()` is preferred by `clippy` for converting `str` to `String` * Simplify `assert_eq!` statements `assert_eq` on a boolean is linted against by `clippy`, suggesting to use `assert!` instead. * Implement `termcolor` feature gating The `Styles` type is only needed for controlling colour, which is only needed with `termcolor`. Since we only deal with UTF8 strings, `std::fmt::Write` is equivalent to `WriteColor` when colour isn't required. * Add `no_std` support Switch imports to relying on `core` and `alloc`. `std::io::Write` can be replaced by `core::fmt::Write` since we deal exclusively with UTF8 strings. * Added `check-no-std` to CI This checks for `no_std` compatibility on 3 key targets: - `x86_64-unknown-none`: represents desktop `no_std`, such as in kernels - `wasm32v1-none`: represents Web builds using the most broadly support WASM target -`thumbv6m-none-eabi`: represents typical embedded targets, such as the Raspberry Pi Pico Testing on all three platforms ensures the widest possible compatibility. * Fixes from CI run - `cargo fmt` - Fix typo in `ci.yml` which misused the matrix * Switch from underscore to `allow(unused)` Co-Authored-By: Ben <[email protected]> * Document clippy lints Co-Authored-By: Ben <[email protected]> * Fix `check-no-std` `wasm32v1-none` was only added in 1.84, so I've set that as the earliest Rust version used for testing `no_std` compatibility. Note that it's typical for embedded development to be done on nightly anyway, so `no_std` will usually happen on the very latest version of Rust. * Format * Remove `serde/rc` from `codespan-reporting/serialization` Not currently used and is incompatible with `thumbv6m-none-eabi` * Test all combinations before giving up on `check-no-std` Co-Authored-By: Ben <[email protected]> --------- Co-authored-by: Ben <[email protected]>
- Loading branch information
1 parent
d282af1
commit 0f2450a
Showing
26 changed files
with
361 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ members = [ | |
"./codespan-reporting", | ||
"./codespan-lsp", | ||
] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.