E0083

E0083#

Warning name: type_param_method

通过已弃用的隐式方法解析,在类型参数上调用 trait 方法。

当方法来自所写约束的父 trait,或者类型参数有多个可能提供方法的 trait 约束时,点语法无法明确指出选中的 trait。请改用 Trait::method(value, ...)

错误示例#

///|
pub(open) trait Position {
  fn pos(Self) -> (Int, Int)
}

///|
pub(open) trait Object: Position {}

///|
pub fn[O : Object] position_of(object : O) -> (Int, Int) {
  object.pos()
}

建议#

使用声明该方法的 trait 限定方法名。

///|
pub(open) trait Position {
  fn pos(Self) -> (Int, Int)
}

///|
pub(open) trait Object: Position {}

///|
pub fn[O : Object] position_of(object : O) -> (Int, Int) {
  Position::pos(object)
}