-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement #[rustc_default_body_unstable]
#96478
Implement #[rustc_default_body_unstable]
#96478
Conversation
src/test/ui/stability-attribute/default-body-stability-err.stderr
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
4d1cee1
to
35a5566
Compare
☔ The latest upstream changes (presumably #97177) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage: |
67118a6
to
6d86e5d
Compare
☔ The latest upstream changes (presumably #95956) made this pull request unmergeable. Please resolve the merge conflicts. |
6d86e5d
to
78eb420
Compare
This attribute allows to mark default body of a trait function as unstable. This means that implementing the trait without implementing the function will require enabling unstable feature. This is useful in conjunction with `#[rustc_must_implement_one_of]`, we may want to relax requirements for a trait, for example allowing implementing either of `PartialEq::{eq, ne}`, but do so in a safe way -- making implementation of only `PartialEq::ne` unstable.
78eb420
to
1e1d6fe
Compare
Sorry for the extreme delay - I had forgotten that this was assigned to me. This looks good to me overall - do we need lang-team signoff before adding this? |
I don't know, maybe 😄 |
r=me after confirmation from the libs teem that this is okay (or after an FCP if needed) |
@Aaron1011 why libs team approval is needed? This PR doesn't change any library APIs after all. Quoting
|
@bors r+ |
Rollup of 7 pull requests Successful merges: - rust-lang#96478 (Implement `#[rustc_default_body_unstable]`) - rust-lang#99787 (Rustdoc-Json: Document HRTB's on DynTrait) - rust-lang#100181 (add method to get the mutability of an AllocId) - rust-lang#100221 (Don't document impossible to call default trait items on impls) - rust-lang#100228 (Don't ICE while suggesting updating item path.) - rust-lang#100301 (Avoid `&str` to `String` conversions) - rust-lang#100305 (Suggest adding an appropriate missing pattern excluding comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This PR implements a new stability attribute —
#[rustc_default_body_unstable]
.#[rustc_default_body_unstable]
controls the stability of default bodies in traits.For example:
In order to implement
Trait
user needs to eitheritem
(even though it has a default implementation)#![feature(feat)]
This is useful in conjunction with
#[rustc_must_implement_one_of]
, we may want to relax requirements for a trait, for example allowing implementing either ofPartialEq::{eq, ne}
, but do so in a safe way — making implementation of onlyPartialEq::ne
unstable.r? @Aaron1011
cc @nrc (iirc you were interested in this wrt
read_buf
), @danielhenrymantilla (you were interested in the related#[rustc_must_implement_one_of]
)P.S. This is my first time working with stability attributes, so I'm not sure if I did everything right 😅