Skip to content

Commit 10a584a

Browse files
Make precise capturing suggestion machine-applicable only if it has not APITs
1 parent 81eef2d commit 10a584a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

compiler/rustc_trait_selection/src/errors.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1907,10 +1907,18 @@ impl Subdiagnostic for AddPreciseCapturingForOvercapture {
19071907
diag: &mut Diag<'_, G>,
19081908
_f: &F,
19091909
) {
1910+
let applicability = if self.apit_spans.is_empty() {
1911+
Applicability::MachineApplicable
1912+
} else {
1913+
// If there are APIT that are converted to regular parameters,
1914+
// then this may make the API turbofishable in ways that were
1915+
// not intended.
1916+
Applicability::MaybeIncorrect
1917+
};
19101918
diag.multipart_suggestion_verbose(
19111919
fluent::trait_selection_precise_capturing_overcaptures,
19121920
self.suggs,
1913-
Applicability::MaybeIncorrect,
1921+
applicability,
19141922
);
19151923
if !self.apit_spans.is_empty() {
19161924
diag.span_note(

0 commit comments

Comments
 (0)