Rollup merge of #139654 - nnethercote:AssocKind-descr, r=compiler-errors
Improve `AssocItem::descr`. The commit adds "associated" to the description of associated types and associated consts, to match the description of associated functions. This increases error message precision and consistency with `AssocKind::fmt`. The commit also notes an imperfection in `AssocKind::fmt`; fixing this imperfection is possible but beyond the scope of this PR. r? `@estebank`
This commit is contained in:
commit
96d282c87b
21 changed files with 53 additions and 51 deletions
|
@ -98,10 +98,10 @@ impl AssocItem {
|
|||
|
||||
pub fn descr(&self) -> &'static str {
|
||||
match self.kind {
|
||||
ty::AssocKind::Const => "const",
|
||||
ty::AssocKind::Const => "associated const",
|
||||
ty::AssocKind::Fn if self.fn_has_self_parameter => "method",
|
||||
ty::AssocKind::Fn => "associated function",
|
||||
ty::AssocKind::Type => "type",
|
||||
ty::AssocKind::Type => "associated type",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,6 +155,8 @@ impl AssocKind {
|
|||
impl std::fmt::Display for AssocKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
// FIXME: fails to distinguish between "associated function" and
|
||||
// "method" because `has_self` isn't known here.
|
||||
AssocKind::Fn => write!(f, "method"),
|
||||
AssocKind::Const => write!(f, "associated const"),
|
||||
AssocKind::Type => write!(f, "associated type"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue