[RFC 2011] Library code by c410-f3r · Pull Request #97233 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation10 Commits1 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
CC #96496
Based on https://github.com/dtolnay/case-studies/tree/master/autoref-specialization.
Basically creates two traits with the same method name. One trait is generic over any T
and the other is specialized to any T: Printable
.
The compiler will then call the corresponding trait method through auto reference.
fn main() { let mut a = Capture::new(); let mut b = Capture::new();
(&Wrapper(&1i32)).try_capture(&mut a); // `try_capture` from `TryCapturePrintable`
(&Wrapper(&vec![1i32])).try_capture(&mut b); // `try_capture` from `TryCaptureGeneric`
assert_eq!(format!("{:?}", a), "1");
assert_eq!(format!("{:?}", b), "N/A");
}
r? @scottmcm
Relevant to the library team, which will review and decide on the PR/issue.
label
Hey! It looks like you've submitted a new PR for the library teams!
If this PR contains changes to any rust-lang/rust
public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs
to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.
Examples of T-libs-api
changes:
- Stabilizing library features
- Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
- Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
- Changing public documentation in ways that create new stability guarantees
- Changing observable runtime behavior of library APIs
This comment has been minimized.
Thanks for splitting this out! Looks reasonable to me, and since it's internal we can always tweak it later.
@bors r+
📌 Commit 664e8a9 has been approved by scottmcm
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
bors added a commit to rust-lang-ci/rust that referenced this pull request
Rollup of 5 pull requests
Successful merges:
- rust-lang#95953 (Modify MIR building to drop repeat expressions with length zero)
- rust-lang#96913 (RFC3239: Implement
cfg(target)
- Part 2) - rust-lang#97233 ([RFC 2011] Library code)
- rust-lang#97370 (Minor improvement on else-no-if diagnostic)
- rust-lang#97384 (Fix metadata stats.)
Failed merges:
r? @ghost
@rustbot
modify labels: rollup
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request
[RFC 2011] Basic compiler infrastructure
Splitting rust-lang#96496 into smaller pieces as was done in rust-lang#97233. Hope review will be easier.
This PR practically contains no logic and only serves as a building ground for the actual code that will be placed in a posterior step.
- Adds
context.rs
to place the newassert!
logic. Has a lot of unused elements but all of them are used by the implementation. - Creates an unstable flag because the feature is not yet complete and also to allow external feedback.
- Creates the necessary
sym
identifiers that are mostly based on the library elements -> https://github.com/rust-lang/rust/blob/master/library/core/src/asserting.rs - Modifies
assert.rs
to branch tocontext.rs
if the unstable flag is enabled. - Adds a test to satisfy tidy but the test does nothing in reality.
Labels
`#![feature(generic_assert)]`
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the library team, which will review and decide on the PR/issue.