-
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
allow arbitrary inherent impls for builtin types in core #94963
Conversation
r? @oli-obk (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
alright, updating rustdoc should be an improvement over its current state, but it's a bit annoying. Will try to do that tomorrow |
the changes lgtm (including query & metadata changes). Try running perfbot once rustdoc builds, too |
☔ The latest upstream changes (presumably #94966) made this pull request unmergeable. Please resolve the merge conflicts. |
03e18bd
to
263003c
Compare
263003c
to
3a2df8b
Compare
r? @m-ou-se on the library part. |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit a76419df6de185959c57105a84845e1f5cd15f52 with merge c633c9f813192ee63f4cd438fdc471caf6b78c47... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
Finished benchmarking commit (3e75146): comparison url. Summary: This benchmark run did not return any relevant results. 29 results were found to be statistically significant but too small to be relevant. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Why not "simply" make |
…ochenkov generalize "incoherent impls" impl for user defined types To allow the move of `trait Error` into core. continues the work from rust-lang#94963, finishes rust-lang/compiler-team#487 r? `@petrochenkov` cc `@yaahc`
don't encode only locally used attrs Part of rust-lang/compiler-team#505. We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR. After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates. cc rust-lang#94963 (comment)
don't encode only locally used attrs Part of rust-lang/compiler-team#505. We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR. After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates. cc rust-lang/rust#94963 (comment)
|| found_assoc(tcx.types.u64) | ||
|| found_assoc(tcx.types.u128) | ||
|| found_assoc(tcx.types.f32) | ||
|| found_assoc(tcx.types.f32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line looks like a typo to me, should it be f64
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked by #114683
Part of rust-lang/compiler-team#487. Slightly adjusted after some talks with @m-ou-se about the requirements of
t-libs-api
.This adds a crate attribute
#![rustc_coherence_is_core]
which allows arbitrary impls for builtin types in core.For other library crates impls for builtin types should be avoided if possible. We do have to allow the existing stable impls however. To prevent us from accidentally adding more of these in the future, there is a second attribute
#[rustc_allow_incoherent_impl]
which has to be added to all impl items. This only supports impls for builtin types but can easily be extended to additional types in a future PR.This implementation does not check for overlaps in these impls. Perfectly checking that requires us to check the coherence of these incoherent impls in every crate, as two distinct dependencies may add overlapping methods. It should be easy enough to detect if it goes wrong and the attribute is only intended for use inside of std.
The first two commits are mostly unrelated cleanups.