Skip to content

Commit c7e859f

Browse files
Merge pull request google#424 from google:fix_clippy
PiperOrigin-RevId: 651900468
2 parents 18abece + e1cfd83 commit c7e859f

File tree

7 files changed

+39
-23
lines changed

7 files changed

+39
-23
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
- name: cargo clippy
3838
uses: actions-rs/[email protected]
3939
with:
40+
args: --all-targets --all-features
4041
token: ${{ secrets.GITHUB_TOKEN }}
4142

4243
test:
@@ -57,6 +58,22 @@ jobs:
5758
- name: cargo test --locked
5859
run: cargo test --locked --all-features
5960

61+
lint:
62+
runs-on: ubuntu-latest
63+
name: lint / ubuntu
64+
strategy:
65+
matrix:
66+
toolchain: [nightly]
67+
steps:
68+
- uses: actions/checkout@v4
69+
- name: Install ${{ matrix.toolchain }}
70+
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
71+
with:
72+
toolchain: ${{ matrix.toolchain }}
73+
components: rustfmt
74+
- name: cargo fmt --check
75+
run: cargo fmt --check
76+
6077
test-no-default-features:
6178
runs-on: ubuntu-latest
6279
name: test (no default features) / ubuntu / ${{ matrix.toolchain }}

googletest/src/matcher_support/count_elements.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ mod tests {
3636

3737
#[test]
3838
fn count_elements_vec() -> Result<()> {
39-
verify_that!(count_elements(&vec![1, 2, 3]), eq(3))
39+
verify_that!(count_elements(vec![1, 2, 3]), eq(3))
4040
}
4141

4242
#[test]

googletest/src/matcher_support/summarize_diff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ fn stdout_supports_color() -> bool {
306306

307307
#[rustversion::not(since(1.70))]
308308
fn stdout_supports_color() -> bool {
309-
is_env_var_set("FORCE_COLOR")
309+
is_env_var_set("FORCE_COLOR") && !is_env_var_set("NO_COLOR")
310310
}
311311

312312
fn is_env_var_set(var: &'static str) -> bool {

googletest/src/matchers/is_encoded_string_matcher.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ mod tests {
148148

149149
#[test]
150150
fn has_correct_explanation_in_matched_case() -> Result<()> {
151-
let explanation = is_utf8_string(eq("A string")).explain_match(&"A string".as_bytes());
151+
let explanation = is_utf8_string(eq("A string")).explain_match("A string".as_bytes());
152152

153153
verify_that!(
154154
explanation,
@@ -158,15 +158,14 @@ mod tests {
158158

159159
#[test]
160160
fn has_correct_explanation_when_byte_array_is_not_utf8_encoded() -> Result<()> {
161-
let explanation = is_utf8_string(eq("A string")).explain_match(&&[192, 128, 0, 64]);
161+
let explanation = is_utf8_string(eq("A string")).explain_match([192, 128, 0, 64]);
162162

163163
verify_that!(explanation, displays_as(starts_with("which is not a UTF-8 encoded string: ")))
164164
}
165165

166166
#[test]
167167
fn has_correct_explanation_when_inner_matcher_does_not_match() -> Result<()> {
168-
let explanation =
169-
is_utf8_string(eq("A string")).explain_match(&"Another string".as_bytes());
168+
let explanation = is_utf8_string(eq("A string")).explain_match("Another string".as_bytes());
170169

171170
verify_that!(
172171
explanation,

googletest/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ mod field_matcher_test;
2121
mod matches_pattern_test;
2222
mod pointwise_matcher_test;
2323
mod property_matcher_test;
24-
#[cfg(feature = "proptest")]
2524
mod proptest_integration_test;
2625
mod tuple_matcher_test;
2726
mod unordered_elements_are_matcher_test;

googletest/tests/no_color_test.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#![cfg(feature = "supports-color")]
16-
1715
use googletest::prelude::*;
18-
use indoc::indoc;
1916
use std::fmt::{Display, Write};
2017

2118
// Make a long text with each element of the iterator on one line.
@@ -35,20 +32,19 @@ fn colors_suppressed_when_both_no_color_and_force_color_are_set() -> Result<()>
3532
std::env::set_var("NO_COLOR", "1");
3633
std::env::set_var("FORCE_COLOR", "1");
3734

38-
let result = verify_that!(build_text(1..50), eq(build_text(1..51)));
35+
let result = verify_that!(build_text(1..50), eq(&build_text(1..51)));
3936

4037
verify_that!(
4138
result,
42-
err(displays_as(contains_substring(indoc! {
39+
err(displays_as(contains_substring(
4340
"
44-
45-
Difference(-actual / +expected):
46-
1
47-
2
48-
<---- 45 common lines omitted ---->
49-
48
50-
49
51-
+50"
52-
})))
41+
Difference(-actual / +expected):
42+
1
43+
2
44+
<---- 45 common lines omitted ---->
45+
48
46+
49
47+
+50"
48+
)))
5349
)
5450
}

googletest/tests/property_matcher_test.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,15 @@ fn describes_itself_in_not_matching_case() -> Result<()> {
128128

129129
#[test]
130130
fn explains_mismatch_referencing_explanation_of_inner_matcher() -> Result<()> {
131+
#[derive(Debug)]
132+
struct SomeStruct;
133+
131134
impl SomeStruct {
132135
fn get_a_collection(&self) -> Vec<u32> {
133136
vec![]
134137
}
135138
}
136-
let value = SomeStruct { a_property: 2 };
139+
let value = SomeStruct;
137140
let result =
138141
verify_that!(value, property!(&SomeStruct.get_a_collection(), ref container_eq([1])));
139142

@@ -184,12 +187,14 @@ fn describes_itself_in_not_matching_case_for_ref() -> Result<()> {
184187
#[test]
185188
fn explains_mismatch_referencing_explanation_of_inner_matcher_for_ref() -> Result<()> {
186189
static EMPTY_COLLECTION: Vec<u32> = vec![];
190+
#[derive(Debug)]
191+
struct SomeStruct;
187192
impl SomeStruct {
188193
fn get_a_collection_ref(&self) -> &[u32] {
189194
&EMPTY_COLLECTION
190195
}
191196
}
192-
let value = SomeStruct { a_property: 2 };
197+
let value = SomeStruct;
193198
let result =
194199
verify_that!(value, property!(&SomeStruct.get_a_collection_ref(), container_eq([1])));
195200

0 commit comments

Comments
 (0)