mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Don't sort span_suggestions
, leave that to caller
This commit is contained in:
parent
42aa1273b0
commit
f1ae02f4bd
@ -759,9 +759,6 @@ impl Diagnostic {
|
||||
suggestions: impl IntoIterator<Item = String>,
|
||||
applicability: Applicability,
|
||||
) -> &mut Self {
|
||||
let mut suggestions: Vec<_> = suggestions.into_iter().collect();
|
||||
suggestions.sort();
|
||||
|
||||
self.span_suggestions_with_style(
|
||||
sp,
|
||||
msg,
|
||||
@ -771,9 +768,7 @@ impl Diagnostic {
|
||||
)
|
||||
}
|
||||
|
||||
/// [`Diagnostic::span_suggestions()`] but you can set the [`SuggestionStyle`]. This version
|
||||
/// *doesn't* sort the suggestions, so the caller has control of the order in which they are
|
||||
/// presented.
|
||||
/// [`Diagnostic::span_suggestions()`] but you can set the [`SuggestionStyle`].
|
||||
pub fn span_suggestions_with_style(
|
||||
&mut self,
|
||||
sp: Span,
|
||||
|
@ -945,7 +945,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
} else {
|
||||
match (types, traits) {
|
||||
let mut types = types.to_vec();
|
||||
types.sort();
|
||||
let mut traits = traits.to_vec();
|
||||
traits.sort();
|
||||
match (&types[..], &traits[..]) {
|
||||
([], []) => {
|
||||
err.span_suggestion_verbose(
|
||||
span,
|
||||
|
@ -2703,7 +2703,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.get_field_candidates_considering_privacy(span, ty, mod_id, id)
|
||||
{
|
||||
let field_names = found_fields.iter().map(|field| field.name).collect::<Vec<_>>();
|
||||
let candidate_fields: Vec<_> = found_fields
|
||||
let mut candidate_fields: Vec<_> = found_fields
|
||||
.into_iter()
|
||||
.filter_map(|candidate_field| {
|
||||
self.check_for_nested_field_satisfying(
|
||||
@ -2724,6 +2724,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
.collect::<String>()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
candidate_fields.sort();
|
||||
|
||||
let len = candidate_fields.len();
|
||||
if len > 0 {
|
||||
|
@ -1426,6 +1426,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if !suggs.is_empty()
|
||||
&& let Some(span) = sugg_span
|
||||
{
|
||||
suggs.sort();
|
||||
err.span_suggestions(
|
||||
span.with_hi(item_name.span.lo()),
|
||||
"use fully-qualified syntax to disambiguate",
|
||||
@ -2000,8 +2001,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.tcx.get_diagnostic_item(sym::Borrow),
|
||||
self.tcx.get_diagnostic_item(sym::BorrowMut),
|
||||
];
|
||||
let candidate_fields: Vec<_> = fields
|
||||
.iter()
|
||||
let mut candidate_fields: Vec<_> = fields
|
||||
.filter_map(|candidate_field| {
|
||||
self.check_for_nested_field_satisfying(
|
||||
span,
|
||||
@ -2035,6 +2035,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
.join(".")
|
||||
})
|
||||
.collect();
|
||||
candidate_fields.sort();
|
||||
|
||||
let len = candidate_fields.len();
|
||||
if len > 0 {
|
||||
@ -2567,13 +2568,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.tcx.item_name(*trait_did),
|
||||
)
|
||||
});
|
||||
let mut sugg: Vec<_> = path_strings.chain(glob_path_strings).collect();
|
||||
sugg.sort();
|
||||
|
||||
err.span_suggestions(
|
||||
span,
|
||||
msg,
|
||||
path_strings.chain(glob_path_strings),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
err.span_suggestions(span, msg, sugg, Applicability::MaybeIncorrect);
|
||||
}
|
||||
|
||||
fn suggest_valid_traits(
|
||||
|
@ -442,12 +442,10 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
|
||||
|
||||
self.formatting_init.extend(code_init);
|
||||
Ok(quote! {
|
||||
let mut code: Vec<_> = #code_field.into_iter().collect();
|
||||
code.sort();
|
||||
#diag.span_suggestions_with_style(
|
||||
#span_field,
|
||||
crate::fluent_generated::#slug,
|
||||
code,
|
||||
#code_field,
|
||||
#applicability,
|
||||
#style
|
||||
);
|
||||
|
@ -186,6 +186,7 @@ fn emit_malformed_attribute(
|
||||
msg.push_str(&format!("`{code}`"));
|
||||
suggestions.push(code);
|
||||
}
|
||||
suggestions.sort();
|
||||
if should_warn(name) {
|
||||
sess.buffer_lint(&ILL_FORMED_ATTRIBUTE_INPUT, span, ast::CRATE_NODE_ID, msg);
|
||||
} else {
|
||||
|
@ -1639,9 +1639,10 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||
} else {
|
||||
3
|
||||
};
|
||||
return Some((order, item.name));
|
||||
}
|
||||
Some((order, item.name))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
items.sort_by_key(|(order, _)| *order);
|
||||
@ -2147,11 +2148,12 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||
if suggest_only_tuple_variants {
|
||||
// Suggest only tuple variants regardless of whether they have fields and do not
|
||||
// suggest path with added parentheses.
|
||||
let suggestable_variants = variants
|
||||
let mut suggestable_variants = variants
|
||||
.iter()
|
||||
.filter(|(.., kind)| *kind == CtorKind::Fn)
|
||||
.map(|(variant, ..)| path_names_to_string(variant))
|
||||
.collect::<Vec<_>>();
|
||||
suggestable_variants.sort();
|
||||
|
||||
let non_suggestable_variant_count = variants.len() - suggestable_variants.len();
|
||||
|
||||
@ -2202,7 +2204,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||
}
|
||||
};
|
||||
|
||||
let suggestable_variants = variants
|
||||
let mut suggestable_variants = variants
|
||||
.iter()
|
||||
.filter(|(_, def_id, kind)| !needs_placeholder(*def_id, *kind))
|
||||
.map(|(variant, _, kind)| (path_names_to_string(variant), kind))
|
||||
@ -2211,6 +2213,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||
CtorKind::Fn => format!("({variant}())"),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
suggestable_variants.sort();
|
||||
let no_suggestable_variant = suggestable_variants.is_empty();
|
||||
|
||||
if !no_suggestable_variant {
|
||||
@ -2228,7 +2231,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||
);
|
||||
}
|
||||
|
||||
let suggestable_variants_with_placeholders = variants
|
||||
let mut suggestable_variants_with_placeholders = variants
|
||||
.iter()
|
||||
.filter(|(_, def_id, kind)| needs_placeholder(*def_id, *kind))
|
||||
.map(|(variant, _, kind)| (path_names_to_string(variant), kind))
|
||||
@ -2237,6 +2240,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
suggestable_variants_with_placeholders.sort();
|
||||
|
||||
if !suggestable_variants_with_placeholders.is_empty() {
|
||||
let msg =
|
||||
|
@ -424,8 +424,9 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
|
||||
improvements.push(suggestion);
|
||||
}
|
||||
}
|
||||
let nonminimal_bool_lint = |suggestions: Vec<_>| {
|
||||
let nonminimal_bool_lint = |mut suggestions: Vec<_>| {
|
||||
if self.cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, e.hir_id).0 != Level::Allow {
|
||||
suggestions.sort();
|
||||
span_lint_hir_and_then(
|
||||
self.cx,
|
||||
NONMINIMAL_BOOL,
|
||||
|
@ -6,10 +6,10 @@ LL | fn foo(_: *()) {
|
||||
|
|
||||
help: add `mut` or `const` here
|
||||
|
|
||||
LL | fn foo(_: *const ()) {
|
||||
| +++++
|
||||
LL | fn foo(_: *mut ()) {
|
||||
| +++
|
||||
LL | fn foo(_: *const ()) {
|
||||
| +++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
@ -6,10 +6,10 @@ LL | let dptr: **const i32 = &ptr;
|
||||
|
|
||||
help: add `mut` or `const` here
|
||||
|
|
||||
LL | let dptr: *const *const i32 = &ptr;
|
||||
| +++++
|
||||
LL | let dptr: *mut *const i32 = &ptr;
|
||||
| +++
|
||||
LL | let dptr: *const *const i32 = &ptr;
|
||||
| +++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user