Skip to content

Commit 1b3733e

Browse files
committed
rustc: minor changes suggested by clippy perf lints.
1 parent 9bd71af commit 1b3733e

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

compiler/rustc_errors/src/emitter.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -2362,11 +2362,7 @@ impl FileWithAnnotatedLines {
23622362

23632363
let label = label.as_ref().map(|m| {
23642364
normalize_whitespace(
2365-
&emitter
2366-
.translate_message(m, &args)
2367-
.map_err(Report::new)
2368-
.unwrap()
2369-
.to_string(),
2365+
&emitter.translate_message(m, &args).map_err(Report::new).unwrap(),
23702366
)
23712367
});
23722368

compiler/rustc_middle/src/ty/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub fn suggest_constraining_type_params<'a>(
274274
span,
275275
if span_to_replace.is_some() {
276276
constraint.clone()
277-
} else if constraint.starts_with("<") {
277+
} else if constraint.starts_with('<') {
278278
constraint.to_string()
279279
} else if bound_list_non_empty {
280280
format!(" + {constraint}")

compiler/rustc_resolve/src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15451545
let (span, sugg, post) = if let SuggestionTarget::SimilarlyNamed = suggestion.target
15461546
&& let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span)
15471547
&& let Some(span) = suggestion.span
1548-
&& let Some(candidate) = suggestion.candidate.as_str().strip_prefix("_")
1548+
&& let Some(candidate) = suggestion.candidate.as_str().strip_prefix('_')
15491549
&& snippet == candidate
15501550
{
15511551
// When the suggested binding change would be from `x` to `_x`, suggest changing the

compiler/rustc_session/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2477,7 +2477,7 @@ pub fn parse_externs(
24772477
let mut error = handler.early_struct_error(format!(
24782478
"crate name `{name}` passed to `--extern` is not a valid ASCII identifier"
24792479
));
2480-
let adjusted_name = name.replace("-", "_");
2480+
let adjusted_name = name.replace('-', "_");
24812481
if crate::utils::is_ascii_ident(&adjusted_name) {
24822482
error.help(format!(
24832483
"consider replacing the dashes with underscores: `{adjusted_name}`"

0 commit comments

Comments
 (0)