Advertisement
vincenzopalazzo

Untitled

May 14th, 2022
1,537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.22 KB | None | 0 0
  1. if is_local {
  2.                     let parent_id = tcx.hir().get_parent_node(self_ty.hir_id);
  3.                     if let hir::Node::Item(_) = tcx.hir().get_by_def_id(parent_id.owner) {
  4.                         let blanket_msg = "for local traits use the blanket implementation";
  5.                         let blanket_sugg = vec![
  6.                             (self_ty.span.shrink_to_lo(), "impl <T: ".to_owned()),
  7.                             //(self_ty.span.shrink_to_lo(), "> for T".to_owned()),
  8.                         ];
  9.                         tcx.struct_span_lint_hir(
  10.                             BARE_TRAIT_OBJECTS,
  11.                             self_ty.hir_id,
  12.                             self_ty.span,
  13.                             |lint| {
  14.                                 lint.build(blanket_msg)
  15.                                     .multipart_suggestion_verbose(
  16.                                         "use blanket impl",
  17.                                         blanket_sugg,
  18.                                         Applicability::Unspecified,
  19.                                     )
  20.                                     .emit();
  21.                             },
  22.                         );
  23.                     }
  24.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement