Extract function trait_may_define_assoc_type
This commit is contained in:
parent
b60a214c51
commit
c0007a2d7e
3 changed files with 13 additions and 24 deletions
|
@ -51,7 +51,7 @@ use rustc_session::config::{BorrowckMode, CrateType, OutputFilenames};
|
|||
use rustc_session::lint::{Level, Lint};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::source_map::MultiSpan;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_target::abi::{Layout, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::spec::abi;
|
||||
|
@ -2085,6 +2085,16 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
self.mk_fn_ptr(sig.map_bound(|sig| ty::FnSig { unsafety: hir::Unsafety::Unsafe, ..sig }))
|
||||
}
|
||||
|
||||
/// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
|
||||
/// returns true if the `trait_def_id` defines an associated item of name `assoc_name`.
|
||||
pub fn trait_may_define_assoc_type(self, trait_def_id: DefId, assoc_name: Ident) -> bool {
|
||||
self.super_traits_of(trait_def_id).iter().any(|trait_did| {
|
||||
self.associated_items(*trait_did)
|
||||
.find_by_name_and_kind(self, assoc_name, ty::AssocKind::Type, *trait_did)
|
||||
.is_some()
|
||||
})
|
||||
}
|
||||
|
||||
/// Given a closure signature, returns an equivalent fn signature. Detuples
|
||||
/// and so forth -- so e.g., if we have a sig with `Fn<(u32, i32)>` then
|
||||
/// you would get a `fn(u32, i32)`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue