E1040#
这个方法被声明为 T::f
,直接通过名称 (..) 调用的语法被废弃了,使用限定语法 T::f(..)
,或者将方法声明为 fn f(self : A, ..)
。
错误示例#
type A Int
fn A::f(self : A) -> Int {
self._
}
fn main {
let _ = f(A(1))
// Warning:
// This method is declared as A::f, calling this kind of method directly via
// f(..) is deprecated, use qualified syntax A::f(..), or declare the method
// as `fn f(self : A, ..)` instead.
}
建议#
你可以在调用点修改这个函数的调用:
fn main {
let _ = A::f(A(1))
}
或者你可以将方法定义为:
fn f(self : A) -> Int {
self._
}
fn main {
let _ = f(A(1))
}