Skip to content

Commit 0dc83b4

Browse files
kassensfacebook-github-bot
authored andcommitted
apply lint fixes
Reviewed By: tyao1 Differential Revision: D80359270 fbshipit-source-id: 3248e3f644f97953ca87a6545661408274200d1a
1 parent 2511213 commit 0dc83b4

96 files changed

Lines changed: 463 additions & 606 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/crates/common/src/console_logger.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ pub struct ConsoleLogger;
2020
impl PerfLogEvent for ConsoleLogEvent {
2121
type Timer = (&'static str, Instant);
2222
fn number(&self, name: &'static str, number: usize) {
23-
debug!("{}: {}", name, number);
23+
debug!("{name}: {number}");
2424
}
2525
fn bool(&self, name: &'static str, value: bool) {
26-
debug!("{}: {}", name, value);
26+
debug!("{name}: {value}");
2727
}
2828
fn string(&self, name: &'static str, value: String) {
29-
debug!("{}: {}", name, value);
29+
debug!("{name}: {value}");
3030
}
3131
fn start(&self, name: &'static str) -> Self::Timer {
3232
(name, Instant::now())
@@ -47,7 +47,7 @@ impl PerfLogger for ConsoleLogger {
4747

4848
pub fn print_time(name: &str, time: Instant) {
4949
let elapsed_ms = time.elapsed().as_millis();
50-
let elapsed_str = format!("{:4}ms", elapsed_ms);
50+
let elapsed_str = format!("{elapsed_ms:4}ms");
5151
let elapsed_color = if elapsed_ms < 10 {
5252
elapsed_str.dimmed()
5353
} else if elapsed_ms < 100 {

compiler/crates/common/src/feature_flags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ impl Display for FeatureFlag {
232232
f.write_str("limited to: ")?;
233233
f.write_str(&items.join(", "))
234234
}
235-
FeatureFlag::Rollout { rollout } => write!(f, "Rollout: {:#?}", rollout),
236-
FeatureFlag::RolloutRange { rollout } => write!(f, "RolloutRange: {:#?}", rollout),
235+
FeatureFlag::Rollout { rollout } => write!(f, "Rollout: {rollout:#?}"),
236+
FeatureFlag::RolloutRange { rollout } => write!(f, "RolloutRange: {rollout:#?}"),
237237
}
238238
}
239239
}

compiler/crates/dependency-analyzer/src/ast.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ pub fn get_reachable_ast(
4747
let name = FragmentDefinitionName(fragment.name.value);
4848
assert!(
4949
base_definitions_map.insert(name, base_definition).is_none(),
50-
"get_reachable_ast called on graph with duplicate definition of `{}`",
51-
name
50+
"get_reachable_ast called on graph with duplicate definition of `{name}`"
5251
)
5352
}
5453
ExecutableDefinition::Operation(_) => {}

compiler/crates/dependency-analyzer/src/ir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ fn add_related_nodes(
259259

260260
let parents = match dependency_graph.get(&key) {
261261
None => {
262-
panic!("Fragment {:?} not found in IR.", key);
262+
panic!("Fragment {key:?} not found in IR.");
263263
}
264264
Some(node) => &node.parents,
265265
};
@@ -301,7 +301,7 @@ fn add_descendants(
301301
}
302302
}
303303
_ => {
304-
panic!("Fragment {:?} not found in IR.", key);
304+
panic!("Fragment {key:?} not found in IR.");
305305
}
306306
}
307307
}

compiler/crates/fixture-tests/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,9 @@ pub async fn test_fixture<T, U, V>(
156156
panic!(
157157
"Expected transform to succeed but it failed with, use 'expected-to-throw' if this is expected. Error:
158158
#############################################################################
159-
{}
159+
{error}
160160
#############################################################################
161-
",
162-
error
161+
"
163162
);
164163
}
165164
_ => {}

compiler/crates/fixture-tests/src/main.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ fn main() {
6464
});
6565
if path.extension().unwrap() == EXPECTED_EXTENSION {
6666
if let Some(ref previous) = test_case.expected {
67-
panic!("Conflicting fixture name, {:?} and {:?}", previous, path);
67+
panic!("Conflicting fixture name, {previous:?} and {path:?}");
6868
}
6969
test_case.expected = Some(path);
7070
} else {
7171
if let Some(ref previous) = test_case.input {
72-
panic!("Conflicting fixture name, {:?} and {:?}", previous, path);
72+
panic!("Conflicting fixture name, {previous:?} and {path:?}");
7373
}
7474
test_case.input = Some(path);
7575
}
@@ -109,17 +109,15 @@ async fn {0}() {{
109109
test_case
110110
.input
111111
.unwrap_or_else(|| panic!(
112-
"Expected input for test {:?} to exist",
113-
test_case_name
112+
"Expected input for test {test_case_name:?} to exist"
114113
))
115114
.file_name()
116115
.and_then(|x| x.to_str())
117116
.unwrap(),
118117
test_case
119118
.expected
120119
.unwrap_or_else(|| panic!(
121-
"Expected output for test {:?} to exist",
122-
test_case_name
120+
"Expected output for test {test_case_name:?} to exist"
123121
))
124122
.file_name()
125123
.and_then(|x| x.to_str())
@@ -150,17 +148,12 @@ async fn {0}() {{
150148
* This source code is licensed under the MIT license found in the
151149
* LICENSE file in the root directory of this source tree.
152150
*
153-
* {signing_token}
151+
* {SIGNING_TOKEN}
154152
*/
155153
",
156-
signing_token = SIGNING_TOKEN,
157154
)
158155
} else if let Some(customized_header) = &opt.customized_header {
159-
format!(
160-
"// {signing_token}\n// {customized_header}\n",
161-
signing_token = SIGNING_TOKEN,
162-
customized_header = customized_header
163-
)
156+
format!("// {SIGNING_TOKEN}\n// {customized_header}\n")
164157
} else {
165158
format!(
166159
"// {signing_token}
@@ -204,11 +197,8 @@ fn check_targets_file(test_dir: &Path) {
204197
if !targets_content.contains(&expected_substr) {
205198
eprintln!(
206199
"{}",
207-
format!(
208-
"WARNING: expected {:?} to contain substring {}",
209-
targets_path, expected_substr
210-
)
211-
.yellow()
200+
format!("WARNING: expected {targets_path:?} to contain substring {expected_substr}")
201+
.yellow()
212202
);
213203
}
214204
}

compiler/crates/fixture-tests/src/print_diff.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ pub(crate) fn print_diff(expected: &str, actual: &str) {
1616
Both(context, _context) => {
1717
// Print 1 line of context
1818
let prev_is_change = line_index > 0 && is_change(&changes[line_index - 1]);
19-
let next_is_change = changes.get(line_index + 1).map_or(false, is_change);
19+
let next_is_change = changes.get(line_index + 1).is_some_and(is_change);
2020
if prev_is_change || next_is_change {
21-
format!("| {}", context).dimmed()
21+
format!("| {context}").dimmed()
2222
} else {
2323
continue;
2424
}
2525
}
26-
Left(removed) => format!("- {}", removed).red(),
27-
Right(added) => format!("+ {}", added).green(),
26+
Left(removed) => format!("- {removed}").red(),
27+
Right(added) => format!("+ {added}").green(),
2828
};
2929
println!("{:4} {}", line_index + 1, formatted_line);
3030
}

compiler/crates/graphql-ir-validations/src/validate_selection_conflict.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ impl<'s, B: LocationAgnosticBehavior + Sync> ValidateSelectionConflict<'s, B> {
505505
.metadata_for_machine("field_name", field_name.lookup())
506506
.metadata_for_machine("arg_a", arguments_a_printed)
507507
.metadata_for_machine("arg_b", arguments_b_printed)
508-
.metadata_for_machine("loc_a", format!("{:?}", location_a))
509-
.metadata_for_machine("loc_b", format!("{:?}", location_b))
508+
.metadata_for_machine("loc_a", format!("{location_a:?}"))
509+
.metadata_for_machine("loc_b", format!("{location_b:?}"))
510510
}
511511
}
512512

compiler/crates/graphql-ir/src/build.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,12 +1358,12 @@ impl<'schema, 'signatures, 'options> Builder<'schema, 'signatures, 'options> {
13581358
// Check for repeated directives that are not @repeatable
13591359
if directives.len() > 1 {
13601360
for (index, directive) in directives.iter().enumerate() {
1361-
let directive_repeatable = self.schema.get_directive(directive.name.item).map_or(
1362-
// Default to `false` instead of expecting a definition
1363-
// since @arguments directive is not defined in the schema.
1364-
false,
1365-
|dir| dir.repeatable,
1366-
);
1361+
let directive_repeatable =
1362+
self.schema.get_directive(directive.name.item).is_some_and(
1363+
// Default to `false` instead of expecting a definition
1364+
// since @arguments directive is not defined in the schema.
1365+
|dir| dir.repeatable,
1366+
);
13671367
if directive_repeatable {
13681368
continue;
13691369
}
@@ -2037,7 +2037,7 @@ impl<'schema, 'signatures, 'options> Builder<'schema, 'signatures, 'options> {
20372037
if !self.options.allow_custom_scalar_literals {
20382038
return Err(vec![Diagnostic::error(
20392039
ValidationMessage::UnexpectedCustomScalarLiteral {
2040-
literal_value: format!("{}", value),
2040+
literal_value: format!("{value}"),
20412041
scalar_type_name: type_definition.name.item,
20422042
},
20432043
self.location.with_span(value.span()),

compiler/crates/graphql-ir/src/ir.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl ExecutableDefinitionName {
243243
pub fn unwrap_fragment_definition_name(&self) -> FragmentDefinitionName {
244244
match self {
245245
ExecutableDefinitionName::OperationDefinitionName(_) => {
246-
panic!("Expected FragmentDefinitionName, found {}", self)
246+
panic!("Expected FragmentDefinitionName, found {self}")
247247
}
248248
ExecutableDefinitionName::FragmentDefinitionName(name) => *name,
249249
}
@@ -401,11 +401,11 @@ impl Selection {
401401
impl fmt::Debug for Selection {
402402
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
403403
match self {
404-
Selection::FragmentSpread(node) => f.write_fmt(format_args!("{:#?}", node)),
405-
Selection::InlineFragment(node) => f.write_fmt(format_args!("{:#?}", node)),
406-
Selection::LinkedField(node) => f.write_fmt(format_args!("{:#?}", node)),
407-
Selection::ScalarField(node) => f.write_fmt(format_args!("{:#?}", node)),
408-
Selection::Condition(node) => f.write_fmt(format_args!("{:#?}", node)),
404+
Selection::FragmentSpread(node) => f.write_fmt(format_args!("{node:#?}")),
405+
Selection::InlineFragment(node) => f.write_fmt(format_args!("{node:#?}")),
406+
Selection::LinkedField(node) => f.write_fmt(format_args!("{node:#?}")),
407+
Selection::ScalarField(node) => f.write_fmt(format_args!("{node:#?}")),
408+
Selection::Condition(node) => f.write_fmt(format_args!("{node:#?}")),
409409
}
410410
}
411411
}
@@ -663,15 +663,15 @@ impl Value {
663663
/// Panics if the value is not a constant.
664664
pub fn expect_constant(&self) -> &ConstantValue {
665665
self.get_constant().unwrap_or_else(|| {
666-
panic!("expected a constant, got {:?}", self);
666+
panic!("expected a constant, got {self:?}");
667667
})
668668
}
669669

670670
/// Return the constant string literal of this value.
671671
/// Panics if the value is not a constant string literal.
672672
pub fn expect_string_literal(&self) -> StringKey {
673673
self.get_string_literal().unwrap_or_else(|| {
674-
panic!("expected a string literal, got {:?}", self);
674+
panic!("expected a string literal, got {self:?}");
675675
})
676676
}
677677
}

0 commit comments

Comments
 (0)