Skip to content

Commit ce08dd6

Browse files
committed
Add cargo fmt and cargo clippy checks to CI
1 parent 8f13fc9 commit ce08dd6

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

.github/workflows/main.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88
merge_group:
99
types: [checks_requested]
10-
10+
1111
jobs:
1212
linux-ci:
1313
name: Linux
@@ -36,7 +36,10 @@ jobs:
3636
profile: minimal
3737
toolchain: ${{ matrix.toolchain }}
3838
override: true
39-
components: ${{ matrix.toolchain == 'nightly' && 'miri,rust-src' || '' }}
39+
components: rustfmt, clippy, ${{ matrix.toolchain == 'nightly' && 'miri,rust-src' || '' }}
40+
41+
- name: Cargo format & lint
42+
run: cargo fmt --check && cargo clippy -- -Dwarnings
4043

4144
- name: Cargo build
4245
run: cargo build ${{ matrix.features }}

color/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use std::str::FromStr;
2525
/// Matching is case-insensitive in the ASCII range.
2626
/// CSS escaping (if relevant) should be resolved before calling this function.
2727
/// (For example, the value of an `Ident` token is fine.)
28+
#[allow(clippy::result_unit_err)]
2829
#[inline]
2930
pub fn parse_color_keyword<Output>(ident: &str) -> Result<Output, ()>
3031
where

src/color.rs

+2
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ impl ToCss for PredefinedColorSpace {
143143
}
144144

145145
/// Parse a color hash, without the leading '#' character.
146+
#[allow(clippy::result_unit_err)]
146147
#[inline]
147148
pub fn parse_hash_color(value: &[u8]) -> Result<(u8, u8, u8, f32), ()> {
148149
Ok(match value.len() {
@@ -330,6 +331,7 @@ ascii_case_insensitive_phf_map! {
330331

331332
/// Returns the named color with the given name.
332333
/// <https://drafts.csswg.org/css-color-4/#typedef-named-color>
334+
#[allow(clippy::result_unit_err)]
333335
#[inline]
334336
pub fn parse_named_color(ident: &str) -> Result<(u8, u8, u8), ()> {
335337
named_colors::get(ident).copied().ok_or(())

src/parser.rs

+1
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
606606
/// See the `Parser::parse_nested_block` method to parse the content of functions or blocks.
607607
///
608608
/// This only returns a closing token when it is unmatched (and therefore an error).
609+
#[allow(clippy::should_implement_trait)]
609610
pub fn next(&mut self) -> Result<&Token<'i>, BasicParseError<'i>> {
610611
self.skip_whitespace();
611612
self.next_including_whitespace_and_comments()

src/rules_and_declarations.rs

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub trait AtRuleParser<'i> {
106106
/// This is only called when `parse_prelude` returned `WithoutBlock`, and
107107
/// either the `;` semicolon indeed follows the prelude, or parser is at
108108
/// the end of the input.
109+
#[allow(clippy::result_unit_err)]
109110
fn rule_without_block(
110111
&mut self,
111112
prelude: Self::Prelude,

src/tests.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,9 @@ fn serializer(preserve_comments: bool) {
430430
preserve_comments: bool,
431431
) {
432432
while let Ok(token) = if preserve_comments {
433-
input
434-
.next_including_whitespace_and_comments()
435-
.map(|t| t.clone())
433+
input.next_including_whitespace_and_comments().cloned()
436434
} else {
437-
input.next_including_whitespace().map(|t| t.clone())
435+
input.next_including_whitespace().cloned()
438436
} {
439437
let token_type = token.serialization_type();
440438
if !preserve_comments && previous_token.needs_separator_when_before(token_type)
@@ -856,7 +854,7 @@ impl<'i> DeclarationParser<'i> for JsonParser {
856854
let mut important = false;
857855
loop {
858856
let start = input.state();
859-
if let Ok(mut token) = input.next_including_whitespace().map(|t| t.clone()) {
857+
if let Ok(mut token) = input.next_including_whitespace().cloned() {
860858
// Hack to deal with css-parsing-tests assuming that
861859
// `!important` in the middle of a declaration value is OK.
862860
// This can never happen per spec
@@ -959,7 +957,7 @@ impl<'i> RuleBodyItemParser<'i, Value, ()> for JsonParser {
959957

960958
fn component_values_to_json(input: &mut Parser) -> Vec<Value> {
961959
let mut values = vec![];
962-
while let Ok(token) = input.next_including_whitespace().map(|t| t.clone()) {
960+
while let Ok(token) = input.next_including_whitespace().cloned() {
963961
values.push(one_component_value_to_json(token, input));
964962
}
965963
values

0 commit comments

Comments
 (0)