impl<'tcx> LateLintPass<'tcx> for Ptr {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Fn(ref sig, _, body_id) = item.kind {
- check_fn(cx, &sig.decl, item.hir_id, Some(body_id));
+ check_fn(cx, &sig.decl, item.hir_id(), Some(body_id));
}
}
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
if let ImplItemKind::Fn(ref sig, body_id) = item.kind {
- let parent_item = cx.tcx.hir().get_parent_item(item.hir_id);
+ let parent_item = cx.tcx.hir().get_parent_item(item.hir_id());
if let Some(Node::Item(it)) = cx.tcx.hir().find(parent_item) {
if let ItemKind::Impl(Impl { of_trait: Some(_), .. }) = it.kind {
return; // ignore trait impls
}
}
- check_fn(cx, &sig.decl, item.hir_id, Some(body_id));
+ check_fn(cx, &sig.decl, item.hir_id(), Some(body_id));
}
}
} else {
None
};
- check_fn(cx, &sig.decl, item.hir_id, body_id);
+ check_fn(cx, &sig.decl, item.hir_id(), body_id);
}
}
PTR_ARG,
arg.span,
"writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used \
- with non-Vec-based slices.",
+ with non-Vec-based slices",
|diag| {
if let Some(ref snippet) = get_only_generic_arg_snippet(cx, arg) {
diag.span_suggestion(
cx,
PTR_ARG,
arg.span,
- "writing `&String` instead of `&str` involves a new object where a slice will do.",
+ "writing `&String` instead of `&str` involves a new object where a slice will do",
|diag| {
diag.span_suggestion(arg.span, "change this to", "&str".into(), Applicability::Unspecified);
for (clonespan, suggestion) in spans {
},
);
}
- } else if match_type(cx, ty, &paths::PATH_BUF) {
+ } else if is_type_diagnostic_item(cx, ty, sym::PathBuf) {
if let Some(spans) = get_spans(cx, opt_body_id, idx, &[("clone", ".to_path_buf()"), ("as_path", "")]) {
span_lint_and_then(
cx,
PTR_ARG,
arg.span,
- "writing `&PathBuf` instead of `&Path` involves a new object where a slice will do.",
+ "writing `&PathBuf` instead of `&Path` involves a new object where a slice will do",
|diag| {
diag.span_suggestion(
arg.span,
cx,
PTR_ARG,
arg.span,
- "using a reference to `Cow` is not recommended.",
+ "using a reference to `Cow` is not recommended",
"change this to",
"&".to_owned() + &r,
Applicability::Unspecified,