Skip to content

Make inline suggestions no longer be the default #127282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 3 additions & 4 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub struct MisplacedImplTrait<'a> {
pub struct MisplacedAssocTyBinding {
#[primary_span]
pub span: Span,
#[suggestion(code = " = impl", applicability = "maybe-incorrect", style = "verbose")]
#[suggestion(code = " = impl", applicability = "maybe-incorrect")]
pub suggestion: Option<Span>,
}

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

Expand Down Expand Up @@ -301,7 +301,6 @@ pub struct SubTupleBinding<'a> {
#[label]
#[suggestion(
ast_lowering_sub_tuple_binding_suggestion,
style = "verbose",
code = "..",
applicability = "maybe-incorrect"
)]
Expand Down Expand Up @@ -448,6 +447,6 @@ pub(crate) struct NoPreciseCapturesOnRpitit {
pub(crate) struct YieldInClosure {
#[primary_span]
pub span: Span,
#[suggestion(code = "#[coroutine] ", applicability = "maybe-incorrect", style = "verbose")]
#[suggestion(code = "#[coroutine] ", applicability = "maybe-incorrect")]
pub suggestion: Option<Span>,
}
17 changes: 4 additions & 13 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub enum ExternBlockSuggestion {
pub struct InvalidSafetyOnExtern {
#[primary_span]
pub item_span: Span,
#[suggestion(code = "unsafe ", applicability = "machine-applicable", style = "verbose")]
#[suggestion(code = "unsafe ", applicability = "machine-applicable")]
pub block: Option<Span>,
}

Expand Down Expand Up @@ -380,7 +380,7 @@ pub struct ArgsBeforeConstraint {
pub constraints: Span,
#[label(ast_passes_args)]
pub args: Span,
#[suggestion(code = "{suggestion}", applicability = "machine-applicable", style = "verbose")]
#[suggestion(code = "{suggestion}", applicability = "machine-applicable")]
pub data: Span,
pub suggestion: String,
pub constraint_len: usize,
Expand Down Expand Up @@ -550,11 +550,7 @@ pub enum WhereClauseBeforeTypeAliasSugg {
#[primary_span]
span: Span,
},
#[multipart_suggestion(
ast_passes_move_suggestion,
applicability = "machine-applicable",
style = "verbose"
)]
#[multipart_suggestion(ast_passes_move_suggestion, applicability = "machine-applicable")]
Move {
#[suggestion_part(code = "")]
left: Span,
Expand Down Expand Up @@ -722,12 +718,7 @@ pub struct EqualityInWhere {
}

#[derive(Subdiagnostic)]
#[suggestion(
ast_passes_suggestion,
code = "{param}: {path}",
style = "verbose",
applicability = "maybe-incorrect"
)]
#[suggestion(ast_passes_suggestion, code = "{param}: {path}", applicability = "maybe-incorrect")]
pub struct AssociatedSuggestion {
#[primary_span]
pub span: Span,
Expand Down
26 changes: 13 additions & 13 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
if is_loop_move & !in_pattern && !matches!(use_spans, UseSpans::ClosureUse { .. }) {
if let ty::Ref(_, _, hir::Mutability::Mut) = ty.kind() {
// We have a `&mut` ref, we need to reborrow on each iteration (#62112).
err.span_suggestion_verbose(
err.span_suggestion(
span.shrink_to_lo(),
format!(
"consider creating a fresh reborrow of {} here",
Expand Down Expand Up @@ -500,7 +500,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
if let Some(pat) = finder.parent_pat {
sugg.insert(0, (pat.span.shrink_to_lo(), "ref ".to_string()));
}
err.multipart_suggestion_verbose(
err.multipart_suggestion(
"borrow this binding in the pattern to avoid moving the value",
sugg,
Applicability::MachineApplicable,
Expand Down Expand Up @@ -680,7 +680,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
return;
};

err.span_suggestion_verbose(
err.span_suggestion(
sugg_span.shrink_to_hi(),
"consider assigning a value",
format!(" = {assign_value}"),
Expand Down Expand Up @@ -748,7 +748,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
(move_span.shrink_to_lo(), suggestion)
})
.collect();
err.multipart_suggestion_verbose(
err.multipart_suggestion(
format!("consider {}borrowing {value_name}", borrow_level.mutably_str()),
sugg,
Applicability::MaybeIncorrect,
Expand Down Expand Up @@ -1071,7 +1071,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
"{prefix}clone the value from the field instead of using the functional record update \
syntax",
);
err.span_suggestion_verbose(span, msg, sugg, Applicability::MachineApplicable);
err.span_suggestion(span, msg, sugg, Applicability::MachineApplicable);
}

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

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

err.multipart_suggestion_verbose(
err.multipart_suggestion(
"try explicitly pass `&Self` into the Closure as an argument",
sugg,
Applicability::MachineApplicable,
Expand Down Expand Up @@ -3164,7 +3164,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
&& path.ident.name == sym::iter
&& let Some(ty) = expr_ty
{
err.span_suggestion_verbose(
err.span_suggestion(
path.ident.span,
format!(
"consider consuming the `{ty}` when turning it into an \
Expand All @@ -3176,7 +3176,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
}
if !is_format_arguments_item {
let addition = format!("let binding = {};\n{}", s, " ".repeat(p));
err.multipart_suggestion_verbose(
err.multipart_suggestion(
msg,
vec![
(stmt.span.shrink_to_lo(), addition),
Expand Down Expand Up @@ -3297,7 +3297,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
.type_implements_trait(iter_trait, [return_ty], self.param_env)
.must_apply_modulo_regions()
{
err.span_suggestion_hidden(
err.span_suggestion(
return_span.shrink_to_hi(),
"use `.collect()` to allocate the iterator",
".collect::<Vec<_>>()",
Expand Down Expand Up @@ -3384,7 +3384,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
var_span,
scope,
);
err.span_suggestion_verbose(
err.span_suggestion(
sugg_span,
format!(
"to force the {kind} to take ownership of {captured_var} (and any \
Expand Down Expand Up @@ -3795,7 +3795,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
if let Some(decl) = local_decl
&& decl.can_be_made_mutable()
{
err.span_suggestion_verbose(
err.span_suggestion(
decl.source_info.span.shrink_to_lo(),
"consider making this binding mutable",
"mut ".to_string(),
Expand All @@ -3810,7 +3810,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
}))
)
{
err.span_suggestion_verbose(
err.span_suggestion(
decl.source_info.span.shrink_to_lo(),
"to modify the original value, take a borrow instead",
"ref mut ".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
if !multiple_borrow_span.is_some_and(|(old, new)| {
old.to(info.span.shrink_to_hi()).contains(new)
}) {
err.span_suggestion_verbose(
err.span_suggestion(
info.span.shrink_to_hi(),
"consider adding semicolon after the expression so its \
temporaries are dropped sooner, before the local variables \
Expand Down Expand Up @@ -379,7 +379,7 @@ impl<'tcx> BorrowExplanation<'tcx> {
category.description(),
);

err.span_suggestion_verbose(
err.span_suggestion(
span.shrink_to_hi(),
msg,
format!(" + {suggestable_name}"),
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
{
// If we are in a loop this will be suggested later.
if !is_loop_move {
err.span_suggestion_verbose(
err.span_suggestion(
move_span.shrink_to_lo(),
format!(
"consider creating a fresh reborrow of {} here",
Expand Down Expand Up @@ -1286,11 +1286,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
)
}
};
err.multipart_suggestion_verbose(
msg,
sugg,
Applicability::MaybeIncorrect,
);
err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);
for error in errors {
if let FulfillmentErrorCode::Select(
SelectionError::Unimplemented,
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
.source_map()
.indentation_before(stmt.span)
.unwrap_or_else(|| " ".to_string());
err.multipart_suggestion_verbose(
err.multipart_suggestion(
"clone the value before moving it into the closure",
vec![
(
Expand Down Expand Up @@ -407,7 +407,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
.source_map()
.indentation_before(closure_expr.span)
.unwrap_or_else(|| " ".to_string());
err.multipart_suggestion_verbose(
err.multipart_suggestion(
"clone the value before moving it into the closure",
vec![
(
Expand Down Expand Up @@ -653,7 +653,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
// If the `inner` is a raw pointer, do not suggest removing the "*", see #126863
// FIXME: need to check whether the assigned object can be a raw pointer, see `tests/ui/borrowck/issue-20801.rs`.
if !is_raw_ptr {
err.span_suggestion_verbose(
err.span_suggestion(
span.with_hi(span.lo() + BytePos(1)),
"consider removing the dereference here",
String::new(),
Expand All @@ -662,7 +662,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
}
}
_ => {
err.span_suggestion_verbose(
err.span_suggestion(
span.shrink_to_lo(),
"consider borrowing here",
'&',
Expand Down Expand Up @@ -720,7 +720,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
suggestions.sort_unstable_by_key(|&(span, _, _)| span);
suggestions.dedup_by_key(|&mut (span, _, _)| span);
for (span, msg, suggestion) in suggestions {
err.span_suggestion_verbose(span, msg, suggestion, Applicability::MachineApplicable);
err.span_suggestion(span, msg, suggestion, Applicability::MachineApplicable);
}
}

Expand Down
22 changes: 11 additions & 11 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {

let place = Place::ty_from(local, proj_base, self.body, self.infcx.tcx);
if let Some(span) = get_mut_span_in_struct_field(self.infcx.tcx, place.ty, *field) {
err.span_suggestion_verbose(
err.span_suggestion(
span,
"consider changing this to be mutable",
" mut ",
Expand Down Expand Up @@ -325,7 +325,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
if snippet.starts_with("&mut ") {
// We don't have access to the HIR to get accurate spans, but we can
// give a best effort structured suggestion.
err.span_suggestion_verbose(
err.span_suggestion(
source_info.span.with_hi(source_info.span.lo() + BytePos(5)),
"try removing `&mut` here",
"",
Expand All @@ -348,7 +348,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
);
err.note("however, `&mut self` expands to `self: &mut Self`, therefore `self` cannot be borrowed mutably");
} else {
err.span_suggestion_verbose(
err.span_suggestion(
decl.source_info.span.shrink_to_lo(),
"consider making the binding mutable",
"mut ",
Expand Down Expand Up @@ -408,7 +408,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
fn_decl.implicit_self,
hir::ImplicitSelfKind::RefImm | hir::ImplicitSelfKind::RefMut
) {
err.span_suggestion_verbose(
err.span_suggestion(
upvar_ident.span.shrink_to_lo(),
"consider changing this to be mutable",
"mut ",
Expand All @@ -419,7 +419,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
}
}
} else {
err.span_suggestion_verbose(
err.span_suggestion(
upvar_ident.span.shrink_to_lo(),
"consider changing this to be mutable",
"mut ",
Expand Down Expand Up @@ -449,7 +449,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
.is_ok_and(|snippet| snippet.starts_with("&mut ")) =>
{
err.span_label(span, format!("cannot {act}"));
err.span_suggestion_verbose(
err.span_suggestion(
span.with_hi(span.lo() + BytePos(5)),
"try removing `&mut` here",
"",
Expand Down Expand Up @@ -770,7 +770,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
return;
}

err.span_suggestion_verbose(
err.span_suggestion(
local_decl.source_info.span.shrink_to_lo(),
"consider changing this to be mutable",
"mut ",
Expand Down Expand Up @@ -915,7 +915,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
}
AddrOf(BorrowKind::Ref, Mutability::Not, expr) => {
// We have `for _ in &i`, suggest `for _ in &mut i`.
err.span_suggestion_verbose(
err.span_suggestion(
expr.span.shrink_to_lo(),
"use a mutable iterator instead",
"mut ",
Expand Down Expand Up @@ -1070,7 +1070,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
if let Some(mut res) = res
&& res.peek().is_some()
{
err.span_suggestion_verbose(
err.span_suggestion(
path_segment.ident.span,
"you may want to use `iter_mut` here",
"iter_mut",
Expand Down Expand Up @@ -1198,7 +1198,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
sugg.push(s);
}

err.multipart_suggestion_verbose(
err.multipart_suggestion(
format!(
"consider changing this to be a mutable {pointer_desc}{}",
if is_trait_sig {
Expand Down Expand Up @@ -1330,7 +1330,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
("specifying", local.pat.span.shrink_to_hi(), format!(": {message}"))
}
};
err.span_suggestion_verbose(
err.span_suggestion(
span,
format!("consider {changing} this binding's type"),
sugg,
Expand Down
Loading
Loading