Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f3fb727

Browse files
committedMay 14, 2024
Don't suggest using use<> syntax to capture APITs
1 parent 6afe135 commit f3fb727

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
 

‎compiler/rustc_lint/src/impl_trait_overcaptures.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,15 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for VisitOpaqueTypes<'tcx> {
194194
.chain(others)
195195
.map(|def_id| self.tcx.item_name(def_id).to_string())
196196
.collect();
197-
Some((
198-
format!(" use<{}>", generics.join(", ")),
199-
opaque_span.with_lo(opaque_span.lo() + BytePos(4)).shrink_to_lo(),
200-
))
197+
// Make sure that we're not trying to name any APITs
198+
if generics.iter().all(|name| !name.starts_with("impl ")) {
199+
Some((
200+
format!(" use<{}>", generics.join(", ")),
201+
opaque_span.with_lo(opaque_span.lo() + BytePos(4)).shrink_to_lo(),
202+
))
203+
} else {
204+
None
205+
}
201206
} else {
202207
None
203208
};

0 commit comments

Comments
 (0)
Failed to load comments.