1
Fork 0

Refactor rustc lint API

This commit is contained in:
Maybe Waffle 2022-09-16 11:01:02 +04:00
parent 65445a571c
commit a8f7e244b7
64 changed files with 1760 additions and 1555 deletions

View file

@ -179,11 +179,15 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
let num_args = fn_sig.inputs().map_bound(|inputs| inputs.len()).skip_binder();
let variadic = if fn_sig.c_variadic() { ", ..." } else { "" };
let ret = if fn_sig.output().skip_binder().is_unit() { "" } else { " -> _" };
self.tcx.struct_span_lint_hir(FUNCTION_ITEM_REFERENCES, lint_root, span, |lint| {
lint.build("taking a reference to a function item does not give a function pointer")
.span_suggestion(
self.tcx.struct_span_lint_hir(
FUNCTION_ITEM_REFERENCES,
lint_root,
span,
"taking a reference to a function item does not give a function pointer",
|lint| {
lint.span_suggestion(
span,
&format!("cast `{}` to obtain a function pointer", ident),
format!("cast `{}` to obtain a function pointer", ident),
format!(
"{} as {}{}fn({}{}){}",
if params.is_empty() { ident } else { format!("{}::<{}>", ident, params) },
@ -195,7 +199,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
),
Applicability::Unspecified,
)
.emit();
});
},
);
}
}