/// Returns whether this instance is instantiable - whether it has no unsatisfied
/// predicates.
///
/// In order to codegen an item, all of its predicates must hold, because
/// otherwise the item does not make sense. Type-checking ensures that
/// the predicates of every item that is *used by* a valid item *do*
/// hold, so we can rely on that.
///
/// However, we codegen collector roots (reachable items) and functions
/// in vtables when they are seen, even if they are not used, and so they
/// might not be instantiable. For example, a programmer can define this
/// public function:
///
///     pub fn foo<'a>(s: &'a mut ()) where &'a mut (): Clone {
///         <&mut () as Clone>::clone(&s);
///     }
///
/// That function can't be codegened, because the method `<&mut () as Clone>::clone`
/// does not exist. Luckily for us, that function can't ever be used,
/// because that would require for `&'a mut (): Clone` to hold, so we
/// can just not emit any code, or even a linker reference for it.
///
/// Similarly, if a vtable method has such a signature, and therefore can't
/// be used, we can just not emit it and have a placeholder (a null pointer,
/// which will never be accessed) in its place.
Returns whether this instance is instantiable - whether it has no unsatisfied
predicates.

In order to codegen an item, all of its predicates must hold, because
otherwise the item does not make sense. Type-checking ensures that
the predicates of every item that is *used by* a valid item *do
hold, so we can rely on that.

However, we codegen collector roots (reachable items) and functions
in vtables when they are seen, even if they are not used, and so they
might not be instantiable. For example, a programmer can define this
public function.



That function can't be codegened, because the method `<&mut () as Clone>::clone`
does not exist. Luckily for us, that function can't ever be used,
because that would require for `&'a mut (): Clone` to hold, so we
can just not emit any code, or even a linker reference for it.

Similarly, if a vtable method has such a signature, and therefore can't
be used, we can just not emit it and have a placeholder (a null pointer,
which will never be accessed) in its place.
Returns whether this instance is instantiable - whether it has no unsatisfied predicates . In order to codegen an item all of its predicates must hold because otherwise the item does not make sense . Type - checking ensures that the predicates of every item that is * used by * a valid item * do hold so we can rely on that . However we codegen collector roots ( reachable items ) and functions in vtables when they are seen even if they are not used and so they might not be instantiable . For example a programmer can define this public function . That function can ' t be codegened because the method ` <&mut () as Clone > :: clone ` does not exist . Luckily for us that function can ' t ever be used because that would require for ` & ' a mut () : Clone ` to hold so we can just not emit any code or even a linker reference for it . Similarly if a vtable method has such a signature and therefore can ' t be used we can just not emit it and have a placeholder ( a null pointer which will never be accessed ) in its place .
fn is_instantiable(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> bool {
        debug!("is_instantiable({:?})", self);
        let (def_id, substs) = match *self.as_mono_item() {
            MonoItem::Fn(ref instance) => (instance.def_id(), instance.substs),
            MonoItem::Static(def_id) => (def_id, Substs::empty()),
            // global asm never has predicates
            MonoItem::GlobalAsm(..) => return true
        };
        tcx.substitute_normalize_and_test_predicates((def_id, &substs))
    }
fn is_instantiable ( & self , tcx : TyCtxt < ' a , ' tcx , ' tcx > ) -> bool { debug ! ( " " self ) ; let ( def_id , substs ) = match * self . as_mono_item ( ) { MonoItem :: Fn ( ref instance ) => ( instance . def_id ( ) , instance . substs ) , MonoItem :: Static ( def_id ) => ( def_id , Substs :: empty ( ) ) , // global asm never has predicates MonoItem :: GlobalAsm ( .. ) => return true } ; tcx . substitute_normalize_and_test_predicates ( ( def_id , & substs ) ) }
Returns whether this instance is instantiable - whether it has no unsatisfied
predicates.
Returns whether this instance is instantiable - whether it has no unsatisfied predicates .
&self
tcx
TyCtxt<'a, 'tcx, 'tcx>