Skip to content

Commit eb6c593

Browse files
committed
Make the default suggestions show the full patch output
Before ``` error: almost complete ascii range --> tests/ui/almost_complete_range.rs:17:17 | LL | let _ = ('a') ..'z'; | ^^^^^^--^^^ | | | help: use an inclusive range: `..=` | = note: `-D clippy::almost-complete-range` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::almost_complete_range)]` ``` After ``` error: almost complete ascii range --> tests/ui/almost_complete_range.rs:17:17 | LL | let _ = ('a') ..'z'; | ^^^^^^^^^^^ | = note: `-D clippy::almost-complete-range` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::almost_complete_range)]` help: use an inclusive range | LL | let _ = ('a') ..='z'; | ~~~ ```
1 parent c422581 commit eb6c593

File tree

1,704 files changed

+44007
-11642
lines changed

Some content is hidden

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

1,704 files changed

+44007
-11642
lines changed

compiler/rustc_ast_lowering/src/errors.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub struct MisplacedImplTrait<'a> {
102102
pub struct MisplacedAssocTyBinding {
103103
#[primary_span]
104104
pub span: Span,
105-
#[suggestion(code = " = impl", applicability = "maybe-incorrect", style = "verbose")]
105+
#[suggestion(code = " = impl", applicability = "maybe-incorrect")]
106106
pub suggestion: Option<Span>,
107107
}
108108

@@ -118,7 +118,7 @@ pub struct UnderscoreExprLhsAssign {
118118
#[diag(ast_lowering_base_expression_double_dot, code = E0797)]
119119
pub struct BaseExpressionDoubleDot {
120120
#[primary_span]
121-
#[suggestion(code = "/* expr */", applicability = "has-placeholders", style = "verbose")]
121+
#[suggestion(code = "/* expr */", applicability = "has-placeholders")]
122122
pub span: Span,
123123
}
124124

@@ -301,7 +301,6 @@ pub struct SubTupleBinding<'a> {
301301
#[label]
302302
#[suggestion(
303303
ast_lowering_sub_tuple_binding_suggestion,
304-
style = "verbose",
305304
code = "..",
306305
applicability = "maybe-incorrect"
307306
)]
@@ -448,6 +447,6 @@ pub(crate) struct NoPreciseCapturesOnRpitit {
448447
pub(crate) struct YieldInClosure {
449448
#[primary_span]
450449
pub span: Span,
451-
#[suggestion(code = "#[coroutine] ", applicability = "maybe-incorrect", style = "verbose")]
450+
#[suggestion(code = "#[coroutine] ", applicability = "maybe-incorrect")]
452451
pub suggestion: Option<Span>,
453452
}

compiler/rustc_ast_passes/src/errors.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ pub enum ExternBlockSuggestion {
221221
pub struct InvalidSafetyOnExtern {
222222
#[primary_span]
223223
pub item_span: Span,
224-
#[suggestion(code = "unsafe ", applicability = "machine-applicable", style = "verbose")]
224+
#[suggestion(code = "unsafe ", applicability = "machine-applicable")]
225225
pub block: Option<Span>,
226226
}
227227

@@ -380,7 +380,7 @@ pub struct ArgsBeforeConstraint {
380380
pub constraints: Span,
381381
#[label(ast_passes_args)]
382382
pub args: Span,
383-
#[suggestion(code = "{suggestion}", applicability = "machine-applicable", style = "verbose")]
383+
#[suggestion(code = "{suggestion}", applicability = "machine-applicable")]
384384
pub data: Span,
385385
pub suggestion: String,
386386
pub constraint_len: usize,
@@ -550,11 +550,7 @@ pub enum WhereClauseBeforeTypeAliasSugg {
550550
#[primary_span]
551551
span: Span,
552552
},
553-
#[multipart_suggestion(
554-
ast_passes_move_suggestion,
555-
applicability = "machine-applicable",
556-
style = "verbose"
557-
)]
553+
#[multipart_suggestion(ast_passes_move_suggestion, applicability = "machine-applicable")]
558554
Move {
559555
#[suggestion_part(code = "")]
560556
left: Span,
@@ -722,12 +718,7 @@ pub struct EqualityInWhere {
722718
}
723719

724720
#[derive(Subdiagnostic)]
725-
#[suggestion(
726-
ast_passes_suggestion,
727-
code = "{param}: {path}",
728-
style = "verbose",
729-
applicability = "maybe-incorrect"
730-
)]
721+
#[suggestion(ast_passes_suggestion, code = "{param}: {path}", applicability = "maybe-incorrect")]
731722
pub struct AssociatedSuggestion {
732723
#[primary_span]
733724
pub span: Span,

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
257257
if is_loop_move & !in_pattern && !matches!(use_spans, UseSpans::ClosureUse { .. }) {
258258
if let ty::Ref(_, _, hir::Mutability::Mut) = ty.kind() {
259259
// We have a `&mut` ref, we need to reborrow on each iteration (#62112).
260-
err.span_suggestion_verbose(
260+
err.span_suggestion(
261261
span.shrink_to_lo(),
262262
format!(
263263
"consider creating a fresh reborrow of {} here",
@@ -500,7 +500,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
500500
if let Some(pat) = finder.parent_pat {
501501
sugg.insert(0, (pat.span.shrink_to_lo(), "ref ".to_string()));
502502
}
503-
err.multipart_suggestion_verbose(
503+
err.multipart_suggestion(
504504
"borrow this binding in the pattern to avoid moving the value",
505505
sugg,
506506
Applicability::MachineApplicable,
@@ -680,7 +680,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
680680
return;
681681
};
682682

683-
err.span_suggestion_verbose(
683+
err.span_suggestion(
684684
sugg_span.shrink_to_hi(),
685685
"consider assigning a value",
686686
format!(" = {assign_value}"),
@@ -748,7 +748,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
748748
(move_span.shrink_to_lo(), suggestion)
749749
})
750750
.collect();
751-
err.multipart_suggestion_verbose(
751+
err.multipart_suggestion(
752752
format!("consider {}borrowing {value_name}", borrow_level.mutably_str()),
753753
sugg,
754754
Applicability::MaybeIncorrect,
@@ -1071,7 +1071,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
10711071
"{prefix}clone the value from the field instead of using the functional record update \
10721072
syntax",
10731073
);
1074-
err.span_suggestion_verbose(span, msg, sugg, Applicability::MachineApplicable);
1074+
err.span_suggestion(span, msg, sugg, Applicability::MachineApplicable);
10751075
}
10761076

10771077
pub(crate) fn suggest_cloning(
@@ -1345,7 +1345,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
13451345
} else {
13461346
"consider cloning the value if the performance cost is acceptable"
13471347
};
1348-
err.multipart_suggestion_verbose(msg, sugg, Applicability::MachineApplicable);
1348+
err.multipart_suggestion(msg, sugg, Applicability::MachineApplicable);
13491349
true
13501350
}
13511351

@@ -2604,7 +2604,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
26042604
sugg.push((span, suggest));
26052605
}
26062606

2607-
err.multipart_suggestion_verbose(
2607+
err.multipart_suggestion(
26082608
"try explicitly pass `&Self` into the Closure as an argument",
26092609
sugg,
26102610
Applicability::MachineApplicable,
@@ -3164,7 +3164,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
31643164
&& path.ident.name == sym::iter
31653165
&& let Some(ty) = expr_ty
31663166
{
3167-
err.span_suggestion_verbose(
3167+
err.span_suggestion(
31683168
path.ident.span,
31693169
format!(
31703170
"consider consuming the `{ty}` when turning it into an \
@@ -3176,7 +3176,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
31763176
}
31773177
if !is_format_arguments_item {
31783178
let addition = format!("let binding = {};\n{}", s, " ".repeat(p));
3179-
err.multipart_suggestion_verbose(
3179+
err.multipart_suggestion(
31803180
msg,
31813181
vec![
31823182
(stmt.span.shrink_to_lo(), addition),
@@ -3297,7 +3297,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
32973297
.type_implements_trait(iter_trait, [return_ty], self.param_env)
32983298
.must_apply_modulo_regions()
32993299
{
3300-
err.span_suggestion_hidden(
3300+
err.span_suggestion(
33013301
return_span.shrink_to_hi(),
33023302
"use `.collect()` to allocate the iterator",
33033303
".collect::<Vec<_>>()",
@@ -3384,7 +3384,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
33843384
var_span,
33853385
scope,
33863386
);
3387-
err.span_suggestion_verbose(
3387+
err.span_suggestion(
33883388
sugg_span,
33893389
format!(
33903390
"to force the {kind} to take ownership of {captured_var} (and any \
@@ -3795,7 +3795,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
37953795
if let Some(decl) = local_decl
37963796
&& decl.can_be_made_mutable()
37973797
{
3798-
err.span_suggestion_verbose(
3798+
err.span_suggestion(
37993799
decl.source_info.span.shrink_to_lo(),
38003800
"consider making this binding mutable",
38013801
"mut ".to_string(),
@@ -3810,7 +3810,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
38103810
}))
38113811
)
38123812
{
3813-
err.span_suggestion_verbose(
3813+
err.span_suggestion(
38143814
decl.source_info.span.shrink_to_lo(),
38153815
"to modify the original value, take a borrow instead",
38163816
"ref mut ".to_string(),

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
228228
if !multiple_borrow_span.is_some_and(|(old, new)| {
229229
old.to(info.span.shrink_to_hi()).contains(new)
230230
}) {
231-
err.span_suggestion_verbose(
231+
err.span_suggestion(
232232
info.span.shrink_to_hi(),
233233
"consider adding semicolon after the expression so its \
234234
temporaries are dropped sooner, before the local variables \
@@ -379,7 +379,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
379379
category.description(),
380380
);
381381

382-
err.span_suggestion_verbose(
382+
err.span_suggestion(
383383
span.shrink_to_hi(),
384384
msg,
385385
format!(" + {suggestable_name}"),

compiler/rustc_borrowck/src/diagnostics/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
11841184
{
11851185
// If we are in a loop this will be suggested later.
11861186
if !is_loop_move {
1187-
err.span_suggestion_verbose(
1187+
err.span_suggestion(
11881188
move_span.shrink_to_lo(),
11891189
format!(
11901190
"consider creating a fresh reborrow of {} here",
@@ -1286,11 +1286,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
12861286
)
12871287
}
12881288
};
1289-
err.multipart_suggestion_verbose(
1290-
msg,
1291-
sugg,
1292-
Applicability::MaybeIncorrect,
1293-
);
1289+
err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);
12941290
for error in errors {
12951291
if let FulfillmentErrorCode::Select(
12961292
SelectionError::Unimplemented,

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
377377
.source_map()
378378
.indentation_before(stmt.span)
379379
.unwrap_or_else(|| " ".to_string());
380-
err.multipart_suggestion_verbose(
380+
err.multipart_suggestion(
381381
"clone the value before moving it into the closure",
382382
vec![
383383
(
@@ -407,7 +407,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
407407
.source_map()
408408
.indentation_before(closure_expr.span)
409409
.unwrap_or_else(|| " ".to_string());
410-
err.multipart_suggestion_verbose(
410+
err.multipart_suggestion(
411411
"clone the value before moving it into the closure",
412412
vec![
413413
(
@@ -653,7 +653,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
653653
// If the `inner` is a raw pointer, do not suggest removing the "*", see #126863
654654
// FIXME: need to check whether the assigned object can be a raw pointer, see `tests/ui/borrowck/issue-20801.rs`.
655655
if !is_raw_ptr {
656-
err.span_suggestion_verbose(
656+
err.span_suggestion(
657657
span.with_hi(span.lo() + BytePos(1)),
658658
"consider removing the dereference here",
659659
String::new(),
@@ -662,7 +662,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
662662
}
663663
}
664664
_ => {
665-
err.span_suggestion_verbose(
665+
err.span_suggestion(
666666
span.shrink_to_lo(),
667667
"consider borrowing here",
668668
'&',
@@ -720,7 +720,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
720720
suggestions.sort_unstable_by_key(|&(span, _, _)| span);
721721
suggestions.dedup_by_key(|&mut (span, _, _)| span);
722722
for (span, msg, suggestion) in suggestions {
723-
err.span_suggestion_verbose(span, msg, suggestion, Applicability::MachineApplicable);
723+
err.span_suggestion(span, msg, suggestion, Applicability::MachineApplicable);
724724
}
725725
}
726726

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
268268

269269
let place = Place::ty_from(local, proj_base, self.body, self.infcx.tcx);
270270
if let Some(span) = get_mut_span_in_struct_field(self.infcx.tcx, place.ty, *field) {
271-
err.span_suggestion_verbose(
271+
err.span_suggestion(
272272
span,
273273
"consider changing this to be mutable",
274274
" mut ",
@@ -325,7 +325,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
325325
if snippet.starts_with("&mut ") {
326326
// We don't have access to the HIR to get accurate spans, but we can
327327
// give a best effort structured suggestion.
328-
err.span_suggestion_verbose(
328+
err.span_suggestion(
329329
source_info.span.with_hi(source_info.span.lo() + BytePos(5)),
330330
"try removing `&mut` here",
331331
"",
@@ -348,7 +348,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
348348
);
349349
err.note("however, `&mut self` expands to `self: &mut Self`, therefore `self` cannot be borrowed mutably");
350350
} else {
351-
err.span_suggestion_verbose(
351+
err.span_suggestion(
352352
decl.source_info.span.shrink_to_lo(),
353353
"consider making the binding mutable",
354354
"mut ",
@@ -408,7 +408,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
408408
fn_decl.implicit_self,
409409
hir::ImplicitSelfKind::RefImm | hir::ImplicitSelfKind::RefMut
410410
) {
411-
err.span_suggestion_verbose(
411+
err.span_suggestion(
412412
upvar_ident.span.shrink_to_lo(),
413413
"consider changing this to be mutable",
414414
"mut ",
@@ -419,7 +419,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
419419
}
420420
}
421421
} else {
422-
err.span_suggestion_verbose(
422+
err.span_suggestion(
423423
upvar_ident.span.shrink_to_lo(),
424424
"consider changing this to be mutable",
425425
"mut ",
@@ -449,7 +449,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
449449
.is_ok_and(|snippet| snippet.starts_with("&mut ")) =>
450450
{
451451
err.span_label(span, format!("cannot {act}"));
452-
err.span_suggestion_verbose(
452+
err.span_suggestion(
453453
span.with_hi(span.lo() + BytePos(5)),
454454
"try removing `&mut` here",
455455
"",
@@ -770,7 +770,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
770770
return;
771771
}
772772

773-
err.span_suggestion_verbose(
773+
err.span_suggestion(
774774
local_decl.source_info.span.shrink_to_lo(),
775775
"consider changing this to be mutable",
776776
"mut ",
@@ -915,7 +915,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
915915
}
916916
AddrOf(BorrowKind::Ref, Mutability::Not, expr) => {
917917
// We have `for _ in &i`, suggest `for _ in &mut i`.
918-
err.span_suggestion_verbose(
918+
err.span_suggestion(
919919
expr.span.shrink_to_lo(),
920920
"use a mutable iterator instead",
921921
"mut ",
@@ -1070,7 +1070,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
10701070
if let Some(mut res) = res
10711071
&& res.peek().is_some()
10721072
{
1073-
err.span_suggestion_verbose(
1073+
err.span_suggestion(
10741074
path_segment.ident.span,
10751075
"you may want to use `iter_mut` here",
10761076
"iter_mut",
@@ -1198,7 +1198,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11981198
sugg.push(s);
11991199
}
12001200

1201-
err.multipart_suggestion_verbose(
1201+
err.multipart_suggestion(
12021202
format!(
12031203
"consider changing this to be a mutable {pointer_desc}{}",
12041204
if is_trait_sig {
@@ -1330,7 +1330,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
13301330
("specifying", local.pat.span.shrink_to_hi(), format!(": {message}"))
13311331
}
13321332
};
1333-
err.span_suggestion_verbose(
1333+
err.span_suggestion(
13341334
span,
13351335
format!("consider {changing} this binding's type"),
13361336
sugg,

0 commit comments

Comments
 (0)