diff options
| author | Alex Macleod <alex@macleod.io> | 2025-04-23 13:24:01 +0000 |
|---|---|---|
| committer | Alex Macleod <alex@macleod.io> | 2025-04-25 01:03:03 +0000 |
| commit | 7b337f6e259ce3ae19e1c0c22c8ff493ecb4a8a3 (patch) | |
| tree | 2eb9e277472f520863f1cf25a5f6dbd682555c80 /clippy_lints/src/write.rs | |
| parent | aa27ae3fee9f112699ad5e4d6efb2245388a77f1 (diff) | |
| download | rust-7b337f6e259ce3ae19e1c0c22c8ff493ecb4a8a3.tar.gz rust-7b337f6e259ce3ae19e1c0c22c8ff493ecb4a8a3.zip | |
Replace some `Symbol::as_str` usage
Diffstat (limited to 'clippy_lints/src/write.rs')
| -rw-r--r-- | clippy_lints/src/write.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index 11c14c14777..f24c127c452 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -1,8 +1,8 @@ use clippy_config::Conf; use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; -use clippy_utils::is_in_test; use clippy_utils::macros::{FormatArgsStorage, MacroCall, format_arg_removal_span, root_macro_call_first_node}; use clippy_utils::source::{SpanRangeExt, expand_past_previous_comma}; +use clippy_utils::{is_in_test, sym}; use rustc_ast::token::LitKind; use rustc_ast::{ FormatArgPosition, FormatArgPositionKind, FormatArgs, FormatArgsPiece, FormatOptions, FormatPlaceholder, @@ -12,7 +12,7 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, Impl, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_session::impl_lint_pass; -use rustc_span::{BytePos, Span, sym}; +use rustc_span::{BytePos, Span}; declare_clippy_lint! { /// ### What it does @@ -359,7 +359,7 @@ fn is_debug_impl(cx: &LateContext<'_>, item: &Item<'_>) -> bool { } fn check_newline(cx: &LateContext<'_>, format_args: &FormatArgs, macro_call: &MacroCall, name: &str) { - let Some(FormatArgsPiece::Literal(last)) = format_args.template.last() else { + let Some(&FormatArgsPiece::Literal(last)) = format_args.template.last() else { return; }; @@ -401,7 +401,7 @@ fn check_newline(cx: &LateContext<'_>, format_args: &FormatArgs, macro_call: &Ma return; }; - if format_args.template.len() == 1 && last.as_str() == "\n" { + if format_args.template.len() == 1 && last == sym::LF { // print!("\n"), write!(f, "\n") diag.multipart_suggestion( @@ -427,9 +427,7 @@ fn check_newline(cx: &LateContext<'_>, format_args: &FormatArgs, macro_call: &Ma } fn check_empty_string(cx: &LateContext<'_>, format_args: &FormatArgs, macro_call: &MacroCall, name: &str) { - if let [FormatArgsPiece::Literal(literal)] = &format_args.template[..] - && literal.as_str() == "\n" - { + if let [FormatArgsPiece::Literal(sym::LF)] = &format_args.template[..] { let mut span = format_args.span; let lint = if name == "writeln" { |
