rust-lang / rust-lang/rfcs

`#[no_override]` for default methods

Open
#291 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-attributes A-privacy A-traits A-typesystem T-lang
Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

Issue by huonw
Monday Jul 08, 2013 at 14:16 GMT

For earlier discussion, see https://github.com/rust-lang/rust/issues/7649

This issue was labelled with: A-attributes, B-RFC in the Rust repository


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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the earlier discussion in issue #7649 and the workaround context in #5898; this issue names no files, tests, or entry points. Define the attribute's behavior for default methods and the error expected when an implementation overrides one, then verify the proposal against the Rust trait example shown here.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.