Skip to content

[RFC 2011] Library code #97233

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 25, 2022
Merged

[RFC 2011] Library code #97233

merged 1 commit into from
May 25, 2022

Conversation

c410-f3r
Copy link
Contributor

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

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 20, 2022
@rust-highfive
Copy link
Contributor

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 20, 2022
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 22, 2022

☔ The latest upstream changes (presumably #94119) made this pull request unmergeable. Please resolve the merge conflicts.

@scottmcm
Copy link
Member

Thanks for splitting this out! Looks reasonable to me, and since it's internal we can always tweak it later.

@bors r+

@bors
Copy link
Collaborator

bors commented May 25, 2022

📌 Commit 664e8a9 has been approved by scottmcm

@bors 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 May 25, 2022
@c410-f3r
Copy link
Contributor Author

Thank you @scottmcm !

bors added a commit to rust-lang-ci/rust that referenced this pull request May 25, 2022
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
@bors bors merged commit ca269b1 into rust-lang:master May 25, 2022
@rustbot rustbot added this to the 1.63.0 milestone May 25, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jun 2, 2022
[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 new `assert!` 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 to `context.rs` if the unstable flag is enabled.
* Adds a test to satisfy tidy but the test does nothing in reality.
@fmease fmease added the F-generic_assert `#![feature(generic_assert)]` label Apr 8, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
F-generic_assert `#![feature(generic_assert)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants