Skip to content

Commit d4323d1

Browse files
committed
Remove existing instances of only
1 parent ae6b93c commit d4323d1

10 files changed

Lines changed: 26 additions & 28 deletions

File tree

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ pub(crate) struct EmptyConfusables {
331331
}
332332

333333
#[derive(Diagnostic)]
334-
#[help("`#[{$name}{$attribute_args}]` can {$only}be applied to {$applied}")]
334+
#[help("`#[{$name}{$attribute_args}]` can {$only_prefix}be applied to {$applied}")]
335335
#[diag("`#[{$name}{$attribute_args}]` attribute cannot be used on {$target}")]
336336
pub(crate) struct InvalidTarget {
337337
#[primary_span]
@@ -345,7 +345,7 @@ pub(crate) struct InvalidTarget {
345345
pub name: AttrPath,
346346
pub target: &'static str,
347347
pub applied: DiagArgValue,
348-
pub only: &'static str,
348+
pub only_prefix: &'static str,
349349
pub attribute_args: &'static str,
350350
#[subdiagnostic]
351351
pub help: Option<InvalidTargetHelp>,

compiler/rustc_attr_parsing/src/target_checking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ impl<'sess> AttributeParser<'sess> {
124124
}
125125

126126
let allowed_targets = allowed_targets.allowed_targets();
127-
let (applied, only) = allowed_targets_applied(allowed_targets, cx.target, cx.features);
127+
let (applied, only_prefix) = allowed_targets_applied(allowed_targets, cx.target, cx.features);
128128
let diag = InvalidTarget {
129129
span: cx.attr_span.clone(),
130130
name: cx.attr_path.clone(),
131131
target: cx.target.plural_name(),
132-
only: if only { "only " } else { "" },
132+
only_prefix: if only_prefix { "only " } else { "" },
133133
applied: DiagArgValue::StrListSepByAnd(applied.into_iter().map(Cow::Owned).collect()),
134134
attribute_args,
135135
help: Self::target_checking_help(attribute_args, cx),

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
14301430
span.push_span_label(expr.span, "you could clone this value");
14311431
let types: Vec<_> = types.into_iter().collect();
14321432
let msg = match &types[..] {
1433-
[only] => format!("`{only}`"),
1433+
[single] => format!("`{single}`"),
14341434
[head @ .., last] => format!(
14351435
"{} and `{last}`",
14361436
head.iter().map(|t| format!("`{t}`")).collect::<Vec<_>>().join(", ")

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11521152
has_ref_dupes && missing_trait_names.len() > 1 && matches!(rcvr_ty.kind(), ty::Adt(..));
11531153
let missing_trait_list = if should_condense {
11541154
Some(match missing_trait_names.as_slice() {
1155-
[only] => only.clone(),
1155+
[single] => single.clone(),
11561156
[first, second] => format!("{first} or {second}"),
11571157
[rest @ .., last] => format!("{} or {last}", rest.join(", ")),
11581158
[] => String::new(),
@@ -1493,13 +1493,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14931493
inherent_impls_candidate.dedup();
14941494
let msg = match &inherent_impls_candidate[..] {
14951495
[] => return,
1496-
[only] => {
1496+
[single] => {
14971497
vec![
14981498
StringPart::normal(format!("the {item_kind} was found for `")),
14991499
StringPart::highlighted(
15001500
self.tcx
15011501
.at(span)
1502-
.type_of(*only)
1502+
.type_of(*single)
15031503
.instantiate_identity()
15041504
.skip_norm_wip()
15051505
.to_string(),

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ macro_rules! pluralize {
4141
// FIXME(estebank): this needs to be changed to go through the translation machinery.
4242
pub fn listify<T>(list: &[T], fmt: impl Fn(&T) -> String) -> Option<String> {
4343
Some(match list {
44-
[only] => fmt(&only),
44+
[single] => fmt(&single),
4545
[others @ .., last] => format!(
4646
"{} and {}",
4747
others.iter().map(|i| fmt(i)).collect::<Vec<_>>().join(", "),

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,29 +1373,29 @@ fn report_non_exhaustive_match<'p, 'tcx>(
13731373
format!(" {{{indentation}{more}{suggested_arm},{indentation}}}",),
13741374
));
13751375
}
1376-
[only] => {
1377-
let only = &thir[*only];
1376+
[single] => {
1377+
let single = &thir[*single];
13781378
let (pre_indentation, is_multiline) = if let Some(snippet) =
1379-
sm.indentation_before(only.span)
1379+
sm.indentation_before(single.span)
13801380
&& let Ok(with_trailing) =
1381-
sm.span_extend_while(only.span, |c| c.is_whitespace() || c == ',')
1381+
sm.span_extend_while(single.span, |c| c.is_whitespace() || c == ',')
13821382
&& sm.is_multiline(with_trailing)
13831383
{
13841384
(format!("\n{snippet}"), true)
13851385
} else {
13861386
(" ".to_string(), false)
13871387
};
1388-
let only_body = &thir[only.body];
1388+
let only_body = &thir[single.body];
13891389
let comma = if matches!(only_body.kind, ExprKind::Block { .. })
1390-
&& only.span.eq_ctxt(only_body.span)
1390+
&& single.span.eq_ctxt(only_body.span)
13911391
&& is_multiline
13921392
{
13931393
""
13941394
} else {
13951395
","
13961396
};
13971397
suggestion = Some((
1398-
only.span.shrink_to_hi(),
1398+
single.span.shrink_to_hi(),
13991399
format!("{comma}{pre_indentation}{suggested_arm}"),
14001400
));
14011401
}

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ impl<'a> Parser<'a> {
828828
});
829829
let attr_span = match &expr.attrs[..] {
830830
[] => unreachable!(),
831-
[only] => only.span,
831+
[single] => single.span,
832832
[first, rest @ ..] => {
833833
for attr in rest {
834834
err.span_label(attr.span, "");

src/tools/clippy/lintcheck/src/config.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use clap::{Parser, Subcommand, ValueEnum};
21
use std::num::NonZero;
32
use std::path::PathBuf;
43

4+
use clap::{Parser, Subcommand, ValueEnum};
5+
56
#[expect(clippy::struct_excessive_bools)]
67
#[derive(Parser, Clone, Debug)]
78
#[command(args_conflicts_with_subcommands = true)]
@@ -33,7 +34,7 @@ pub(crate) struct LintcheckConfig {
3334
pub lintcheck_results_path: PathBuf, // Overridden in new()
3435
/// Only process a single crate on the list
3536
#[clap(long, value_name = "CRATE")]
36-
pub only: Option<String>,
37+
pub only_crate: Option<String>,
3738
/// Runs cargo clippy --fix and checks if all suggestions apply
3839
#[clap(long, conflicts_with("max_jobs"))]
3940
pub fix: bool,
@@ -124,10 +125,7 @@ impl LintcheckConfig {
124125
for lint_name in &mut config.lint_filter {
125126
*lint_name = format!(
126127
"clippy::{}",
127-
lint_name
128-
.strip_prefix("clippy::")
129-
.unwrap_or(lint_name)
130-
.replace('_', "-")
128+
lint_name.strip_prefix("clippy::").unwrap_or(lint_name).replace('_', "-")
131129
);
132130
}
133131

src/tools/rust-analyzer/crates/rust-analyzer/src/cli/analysis_stats.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ impl flags::AnalysisStats {
836836
let name = body_id.name(db).unwrap_or_else(Name::missing);
837837
let module = body_id.module(db);
838838
let display_target = module.krate(db).to_display_target(db);
839-
if let Some(only_name) = self.only.as_deref()
839+
if let Some(only_name) = self.solely.as_deref()
840840
&& name.display(db, Edition::LATEST).to_string() != only_name
841841
&& full_name(db, || body_id.name(db), module) != only_name
842842
{
@@ -951,7 +951,7 @@ impl flags::AnalysisStats {
951951
}
952952
is_partially_unknown
953953
};
954-
if self.only.is_some() && verbosity.is_spammy() {
954+
if self.solely.is_some() && verbosity.is_spammy() {
955955
// in super-verbose mode for just one function, we print every single expression
956956
if let Some((_, start, end)) = expr_syntax_range(db, vfs, sm(), expr_id) {
957957
bar.println(format!(
@@ -1056,7 +1056,7 @@ impl flags::AnalysisStats {
10561056
}
10571057
is_partially_unknown
10581058
};
1059-
if self.only.is_some() && verbosity.is_spammy() {
1059+
if self.solely.is_some() && verbosity.is_spammy() {
10601060
// in super-verbose mode for just one function, we print every single pattern
10611061
if let Some((_, start, end)) = pat_syntax_range(db, vfs, sm(), pat_id) {
10621062
bar.println(format!(
@@ -1461,7 +1461,7 @@ impl flags::AnalysisStats {
14611461
name_fn: impl Fn() -> Option<Name>,
14621462
module: hir::Module,
14631463
) -> bool {
1464-
if let Some(only_name) = self.only.as_deref() {
1464+
if let Some(only_name) = self.solely.as_deref() {
14651465
let name = name_fn().unwrap_or_else(Name::missing);
14661466

14671467
if name.display(db, Edition::LATEST).to_string() != only_name

src/tools/rust-analyzer/crates/rust-analyzer/src/cli/flags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ pub struct AnalysisStats {
256256
pub output: Option<OutputFormat>,
257257
pub randomize: bool,
258258
pub parallel: bool,
259-
pub only: Option<String>,
259+
pub solely: Option<String>,
260260
pub with_deps: bool,
261261
pub no_sysroot: bool,
262262
pub no_test: bool,

0 commit comments

Comments
 (0)