Skip to content

Commit

Permalink
Don't suggest using use<> syntax to capture APITs
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed May 14, 2024
1 parent 6afe135 commit f3fb727
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions compiler/rustc_lint/src/impl_trait_overcaptures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,15 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for VisitOpaqueTypes<'tcx> {
.chain(others)
.map(|def_id| self.tcx.item_name(def_id).to_string())
.collect();
Some((
format!(" use<{}>", generics.join(", ")),
opaque_span.with_lo(opaque_span.lo() + BytePos(4)).shrink_to_lo(),
))
// Make sure that we're not trying to name any APITs
if generics.iter().all(|name| !name.starts_with("impl ")) {
Some((
format!(" use<{}>", generics.join(", ")),
opaque_span.with_lo(opaque_span.lo() + BytePos(4)).shrink_to_lo(),
))
} else {
None
}
} else {
None
};
Expand Down

0 comments on commit f3fb727

Please sign in to comment.