Skip to content

[RFC 2011] Library code - #97233

Merged
bors merged 1 commit into
rust-lang:masterfrom
c410-f3r:assert-lib
May 25, 2022
Merged

[RFC 2011] Library code#97233
bors merged 1 commit into
rust-lang:masterfrom
c410-f3r:assert-lib

Conversation

@c410-f3r

Copy link
Copy Markdown
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.

fnmain(){letmut a = Capture::new();letmut 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

@rustbotrustbot 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
Copy Markdown
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-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 20, 2022
Comment threadlibrary/core/src/asserting.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@bors

bors commented May 22, 2022

Copy link
Copy Markdown
Collaborator

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

Comment threadlibrary/core/src/lib.rs
@scottmcm

Copy link
Copy Markdown
Member

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

@bors r+

@bors

bors commented May 25, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 664e8a9 has been approved by scottmcm

@borsbors 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
@Dylan-DPCDylan-DPC mentioned this pull request May 25, 2022
@c410-f3r

Copy link
Copy Markdown
ContributorAuthor

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:masterMay 25, 2022
@rustbotrustbot 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.
@fmeasefmease added the F-generic_assert `#![feature(generic_assert)]` label Apr 8, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-generic_assert`#![feature(generic_assert)]`S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libsRelevant 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

@c410-f3r@rust-highfive@rust-log-analyzer@bors@scottmcm@thomcc@fmease@rustbot