Skip to content

Commit bc9dacd

Browse files
committed
Move has_self field to hir::AssocKind::Fn.
`hir::AssocItem` currently has a boolean `fn_has_self_parameter` field, which is misplaced, because it's only relevant for associated fns, not for associated consts or types. This commit moves it (and renames it) to the `AssocKind::Fn` variant, where it belongs. This requires introducing a new C-style enum, `AssocTag`, which is like `AssocKind` but without the fields. This is because `AssocKind` values are passed to various functions like `find_by_ident_and_kind` to indicate what kind of associated item should be searched for, and having to specify `has_self` isn't relevant there. New methods: - Predicates `AssocItem::is_fn` and `AssocItem::is_method`. - `AssocItem::as_tag` which converts `AssocItem::kind` to `AssocTag`. Removed `find_by_name_and_kinds`, which is unused. `AssocItem::descr` can now distinguish between methods and associated functions, which slightly improves some error messages.
1 parent 322bba0 commit bc9dacd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main_shim.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
22
use rustc_hir::LangItem;
3-
use rustc_middle::ty::{AssocKind, GenericArg};
3+
use rustc_middle::ty::{AssocTag, GenericArg};
44
use rustc_session::config::EntryFnType;
55
use rustc_span::{DUMMY_SP, Ident};
66

@@ -107,7 +107,7 @@ pub(crate) fn maybe_create_entry_wrapper(
107107
.find_by_ident_and_kind(
108108
tcx,
109109
Ident::from_str("report"),
110-
AssocKind::Fn,
110+
AssocTag::Fn,
111111
termination_trait,
112112
)
113113
.unwrap();

0 commit comments

Comments
 (0)