Fix suggestion when shorthand self has erroneous type
This commit is contained in:
parent
96e51d9482
commit
05c34cc5ed
6 changed files with 127 additions and 1 deletions
|
@ -2566,6 +2566,18 @@ pub enum SelfKind {
|
|||
Explicit(P<Ty>, Mutability),
|
||||
}
|
||||
|
||||
impl SelfKind {
|
||||
pub fn to_ref_suggestion(&self) -> String {
|
||||
match self {
|
||||
SelfKind::Region(None, mutbl) => mutbl.ref_prefix_str().to_string(),
|
||||
SelfKind::Region(Some(lt), mutbl) => format!("&{lt} {}", mutbl.prefix_str()),
|
||||
SelfKind::Value(_) | SelfKind::Explicit(_, _) => {
|
||||
unreachable!("if we had an explicit self, we wouldn't be here")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type ExplicitSelf = Spanned<SelfKind>;
|
||||
|
||||
impl Param {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue