Skip to content

#[no_override] for default methods #7649

Closed
@huonw

Description

@huonw

If there was a #[no_override] attribute that made it impossible to override a default method, there would be very little need for the FooUtil traits (with this attribute default methods would have almost exactly the same properties as *Util, except the seperate trait can be imported separately). i.e.

trait Foo {
  fn bar(&self);

  #[no_override]
  fn call_bar(&self) { self.bar(); }
}
impl Foo for int {
  fn bar(&self) {}

  fn call_bar(&self) {} // error!
}

This would provide a workaround for #5898 that is a proper solution in its own right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions