Rollup merge of #132938 - compiler-errors:ed2024-apit-sugg, r=chenyukang
Make precise capturing suggestion machine-applicable only if it has no APITs cc https://github.com/rust-lang/rust/issues/132932 The only case where this suggestion is not machine-applicable is when we suggest turning arg-position impl trait into type parameters, which may expose type parameters that were not turbofishable before.
This commit is contained in:
commit
11c7b01aa7
4 changed files with 61 additions and 1 deletions
|
@ -1907,10 +1907,18 @@ impl Subdiagnostic for AddPreciseCapturingForOvercapture {
|
|||
diag: &mut Diag<'_, G>,
|
||||
_f: &F,
|
||||
) {
|
||||
let applicability = if self.apit_spans.is_empty() {
|
||||
Applicability::MachineApplicable
|
||||
} else {
|
||||
// If there are APIT that are converted to regular parameters,
|
||||
// then this may make the API turbofishable in ways that were
|
||||
// not intended.
|
||||
Applicability::MaybeIncorrect
|
||||
};
|
||||
diag.multipart_suggestion_verbose(
|
||||
fluent::trait_selection_precise_capturing_overcaptures,
|
||||
self.suggs,
|
||||
Applicability::MaybeIncorrect,
|
||||
applicability,
|
||||
);
|
||||
if !self.apit_spans.is_empty() {
|
||||
diag.span_note(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue