Skip to content

Commit

Permalink
feat: Distinguish between methods and functions in error messages (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
donmai-me authored Oct 9, 2024
1 parent 160f4b5 commit 69a2ea5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ We contributors to Pavex:
* Jan Ehrhardt (@jehrhardt)
* Lukas Slanius (@bosukas)
* Ben Wishovich (@benwis)
* Donmai (@donmai-me)
12 changes: 10 additions & 2 deletions libs/pavexc/src/rustdoc/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,16 @@ impl RustdocKindExt for ItemEnum {
ItemEnum::StructField(_) => "a struct field",
ItemEnum::Enum(_) => "an enum",
ItemEnum::Variant(_) => "an enum variant",
// TODO: this could also be a method! How do we find out?
ItemEnum::Function(_) => "a function",
ItemEnum::Function(func) => {
let mut func_kind = "a function";
if let Some((param, _)) = func.decl.inputs.first() {
if param == "self" {
func_kind = "a method";
}
}

func_kind
}
ItemEnum::Trait(_) => "a trait",
ItemEnum::TraitAlias(_) => "a trait alias",
ItemEnum::Impl(_) => "an impl block",
Expand Down

0 comments on commit 69a2ea5

Please sign in to comment.