fn virtual_call_violation_for_method(self,
                                         trait_def_id: DefId,
                                         method: &ty::AssociatedItem)
                                         -> Option<MethodViolationCode>
    {
        // The method's first parameter must be something that derefs (or
        // autorefs) to `&self`. For now, we only accept `self`, `&self`
        // and `Box<Self>`.
        if !method.method_has_self_argument {
            return Some(MethodViolationCode::StaticMethod);
        }

        // The `Self` type is erased, so it should not appear in list of
        // arguments or return type apart from the receiver.
        let ref sig = self.item_type(method.def_id).fn_sig();
        for &input_ty in &sig.0.inputs[1..] {
            if self.contains_illegal_self_type_reference(trait_def_id, input_ty) {
                return Some(MethodViolationCode::ReferencesSelf);
            }
        }
        if self.contains_illegal_self_type_reference(trait_def_id, sig.0.output) {
            return Some(MethodViolationCode::ReferencesSelf);
        }

        // We can't monomorphize things like `fn foo<A>(...)`.
        if !self.item_generics(method.def_id).types.is_empty() {
            return Some(MethodViolationCode::Generic);
        }

        None
    }
/// Returns `Some(_)` if this method cannot be called on a trait
/// object; this does not necessarily imply that the enclosing trait
/// is not object safe, because the method might have a where clause
/// `Self:Sized`.
Returns `Some(_)` if this method cannot be called on a trait
object; this does not necessarily imply that the enclosing trait
is not object safe, because the method might have a where clause
`Self:Sized`.
Returns ` Some ( _ ) ` if this method cannot be called on a trait object ; this does not necessarily imply that the enclosing trait is not object safe because the method might have a where clause ` Self : Sized ` .
fn virtual_call_violation_for_method(self,
                                         trait_def_id: DefId,
                                         method: &ty::AssociatedItem)
                                         -> Option<MethodViolationCode>
    {
        // The method's first parameter must be something that derefs (or
        // autorefs) to `&self`. For now, we only accept `self`, `&self`
        // and `Box<Self>`.
        if !method.method_has_self_argument {
            return Some(MethodViolationCode::StaticMethod);
        }
        // The `Self` type is erased, so it should not appear in list of
        // arguments or return type apart from the receiver.
        let ref sig = self.item_type(method.def_id).fn_sig();
        for &input_ty in &sig.0.inputs[1..] {
            if self.contains_illegal_self_type_reference(trait_def_id, input_ty) {
                return Some(MethodViolationCode::ReferencesSelf);
            }
        }
        if self.contains_illegal_self_type_reference(trait_def_id, sig.0.output) {
            return Some(MethodViolationCode::ReferencesSelf);
        }
        // We can't monomorphize things like `fn foo<A>(...)`.
        if !self.item_generics(method.def_id).types.is_empty() {
            return Some(MethodViolationCode::Generic);
        }
        None
    }
fn virtual_call_violation_for_method ( self , trait_def_id : DefId , method : & ty :: AssociatedItem ) -> Option < MethodViolationCode > { // The method's first parameter must be something that derefs (or // autorefs) to `&self`. For now, we only accept `self`, `&self` // and `Box<Self>`. if ! method . method_has_self_argument { return Some ( MethodViolationCode :: StaticMethod ) ; } // The `Self` type is erased, so it should not appear in list of // arguments or return type apart from the receiver. let ref sig = self . item_type ( method . def_id ) . fn_sig ( ) ; for & input_ty in & sig . 0 . inputs [ 1 .. ] { if self . contains_illegal_self_type_reference ( trait_def_id , input_ty ) { return Some ( MethodViolationCode :: ReferencesSelf ) ; } } if self . contains_illegal_self_type_reference ( trait_def_id , sig . 0 . output ) { return Some ( MethodViolationCode :: ReferencesSelf ) ; } // We can't monomorphize things like `fn foo<A>(...)`. if ! self . item_generics ( method . def_id ) . types . is_empty ( ) { return Some ( MethodViolationCode :: Generic ) ; } None }
Returns `Some(_)` if this method cannot be called on a trait
object; this does not necessarily imply that the enclosing trait
is not object safe, because the method might have a where clause
`Self:Sized`.
Returns ` Some ( _ ) ` if this method cannot be called on a trait object ; this does not necessarily imply that the enclosing trait is not object safe because the method might have a where clause ` Self : Sized ` .
self
trait_def_id
DefId
method
&ty::AssociatedItem
self
trait_def_id
DefId
method
&ty::AssociatedItem