Change:
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

Discussion:
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 }))

tcx.fn_sig(assoc.def_id).skip_binder(), assoc.ident, tcx.predicates_of(assoc.def_id), <ins> assoc, </ins> ) } ty::AssocKind::Type => format!("type {} = Type;", assoc.ident),

const CONSTANT: u32; type Type; fn method(&self, s: String) -> Self::Type; <ins> fn method2(self: Box<Self>, s: String) -> Self::Type; fn method3(other: &Self, s: String) -> Self::Type; fn method4(&self, other: &Self) -> Self::Type; fn method5(self: &Box<Self>) -> Self::Type; </ins> }

<del> error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method` </del> <ins> error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5` </ins> --> $DIR/m2.rs:9:1 | LL | impl m1::X for X { <del> | ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method` in implementation </del> <ins> | ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5` in implementation </ins> | = help: implement the missing item: `const CONSTANT: u32 = 42;` = help: implement the missing item: `type Type = Type;` = help: implement the missing item: `fn method(&self, _: std::string::String) -> <Self as m1::X>::Type { todo!() }` <ins> = help: implement the missing item: `fn method2(self: std::boxed::Box<Self>, _: std::string::String) -> <Self as m1::X>::Type { todo!() }` = help: implement the missing item: `fn method3(_: &Self, _: std::string::String) -> <Self as m1::X>::Type { todo!() }` = help: implement the missing item: `fn method4(&self, _: &Self) -> <Self as m1::X>::Type { todo!() }` = help: implement the missing item: `fn method5(self: &std::boxed::Box<Self>) -> <Self as m1::X>::Type { todo!() }` </ins> error: aborting due to previous error