Change:
sig: &ty::FnSig<'_>, ident: Ident, predicates: ty::GenericPredicates<'_>, <ins> assoc: &ty::AssocItem, </ins> ) -> String { let args = sig .inputs() .iter() <del> .map(|ty| { </del> <ins> .enumerate() .map(|(i, ty)| { </ins> Some(match ty.kind { <del> ty::Param(param) if param.name == kw::SelfUpper => "self".to_string(), ty::Ref(reg, ref_ty, mutability) => { </del> <ins> ty::Param(_) if assoc.fn_has_self_parameter && i == 0 => "self".to_string(), ty::Ref(reg, ref_ty, mutability) if i == 0 => { </ins> let reg = match &format!("{}", reg)[..] { "'_" | "" => String::new(), reg => format!("{} ", reg), }; <del> match ref_ty.kind { ty::Param(param) if param.name == kw::SelfUpper => { format!("&{}{}self", reg, mutability.prefix_str()) </del> <ins> if assoc.fn_has_self_parameter { match ref_ty.kind { ty::Param(param) if param.name == kw::SelfUpper => { format!("&{}{}self", reg, mutability.prefix_str()) } _ => format!("self: {}", ty), </ins> } <del> _ => format!("_: {:?}", ty), </del> <ins> } else { format!("_: {:?}", ty) } } _ => { if assoc.fn_has_self_parameter && i == 0 { format!("self: {:?}", ty) } else { format!("_: {:?}", ty) </ins> } } <del> _ => format!("_: {:?}", ty), </del> }) }) .chain(std::iter::once(if sig.c_variadic { Some("...".to_string()) } else { None }))

Discussion:
In the error message below, the first argument of is not named . () Errors: modify labels: T-compiler, A-diagnostics, C-enhancement, D-papercut, F-arbitraryselftypes. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --This issue has been assigned to via . <!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim
I managed to fix this issue by just manually checking if the argument is of type , and if it is it returns where ty is the type of the argument (in this case std::pin::Pin<&mut Self). I'm not sure if there is a better way, I'm going to make a PR tomorrow, if anyone has a better solution, please tell me.
I’m not just interested in a fix for this particular case. Types that allow dispatch can be arbitrarily nested AFAIK and also I didn’t tag for no reason - these can be extended. Furthermore the correct way to fix this is probably not to just add code but rather to change ~existing logic that must be somewhere already, for example some code currently does make , and parameters print correctly and differently from non-self parameters that have type or~...... let me double-check that.... Oh, wow, I’ll expand this bug-report. Create a binary crate named “my-crate” with: Error message is:
Makes sense as if I recall correctly (can't link files rn as I am on my phone) the code literally just checks if the type is (&/&mut)Self and if it is it prints (&/&mut)self otherwise it prints _: Type. A potential fix could be printing (&/&mut)self only if it's the first argument of the function
Won’t be enough. The first parameter of a trait fn could be of type without being named . It actually needs to check if it’s a parameter. That information should be retrievable somewhere in the compiler. Furthermore then the rest is easy: First step: check if it’s a parameter. If not: use . If it however is one, then check for the type being or or , printing , or respectively; otherwise print .

Another issue related to this is when you have a function that has a signature of The compiler suggests to implement the function using , but that doesn't work I should have fixed it, as soon as all of the tests pass I will make a PR