E0083

E0083#

Warning name: type_param_method

Calling a trait method on a type parameter through deprecated implicit method resolution.

When a method comes from a supertrait of the written constraint, or a type parameter has multiple trait bounds that could supply methods, dot syntax does not make the selected trait explicit. Use Trait::method(value, ...) instead.

Erroneous example#

///|
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()
}

Suggestion#

Qualify the method with the trait that declares it.

///|
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)
}