1
Fork 0

rustc_pass_by_value: handle inferred generic types (with _)

This commit is contained in:
Mahdi Dibaiee 2022-01-11 21:28:04 +00:00
parent 959bf2bc2e
commit 2728af7bc0
No known key found for this signature in database
GPG key ID: BABA115BDF0C598A
3 changed files with 25 additions and 15 deletions

View file

@ -73,19 +73,15 @@ fn gen_args(cx: &LateContext<'_>, segment: &PathSegment<'_>) -> String {
let params = args
.args
.iter()
.filter_map(|arg| match arg {
GenericArg::Lifetime(lt) => Some(lt.name.ident().to_string()),
.map(|arg| match arg {
GenericArg::Lifetime(lt) => lt.name.ident().to_string(),
GenericArg::Type(ty) => {
let snippet =
cx.tcx.sess.source_map().span_to_snippet(ty.span).unwrap_or_default();
Some(snippet)
cx.tcx.sess.source_map().span_to_snippet(ty.span).unwrap_or_default()
}
GenericArg::Const(c) => {
let snippet =
cx.tcx.sess.source_map().span_to_snippet(c.span).unwrap_or_default();
Some(snippet)
cx.tcx.sess.source_map().span_to_snippet(c.span).unwrap_or_default()
}
_ => None,
GenericArg::Infer(_) => String::from("_"),
})
.collect::<Vec<_>>();