Turn Cow::is_borrowed,is_owned into associated functions.#138217
Turn Cow::is_borrowed,is_owned into associated functions.#138217bors merged 1 commit intorust-lang:masterfrom
Cow::is_borrowed,is_owned into associated functions.#138217Conversation
|
r? @Noratrieb rustbot has assigned @Noratrieb. Use |
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? libs-api |
|
So, +1 for documenting that users might want to call the functions this way if there's a conflict and they want to be explicit, but -1 for forcing the functions to be called this way. Yes, I understand that Cow implements Deref and these would shadow inner functions. However, we already have some methods on Cow: Did a crater run turn up some issue with these two new methods? I also think these two new methods aren't especially useful if they can't be written in postfix form; at that point, you're not far off from just using |
|
☔ The latest upstream changes (presumably #138208) made this pull request unmergeable. Please resolve the merge conflicts. |
|
removing t-compiler as these changes seems completely in purview of libs team (feel free to request a review from t-compiler if this is not the case!) @rustbot label -t-compiler |
|
Nominating this for discussion. I think the two reasonable options here are:
|
|
We discussed this in today's @rust-lang/libs-api meeting. Summary:
So, path forward:
|
This is done because `Cow` implements `Deref`. Therefore, to avoid conflicts with an inner type having a method of the same name, we use an associated method, like `Box::into_raw`.
49e853b to
b335056
Compare
|
Rebased and ready for review. |
|
r? libs-api |
|
@bors r+ |
…ssociated, r=dtolnay Turn `Cow::is_borrowed,is_owned` into associated functions. This is done because `Cow` implements `Deref`. Therefore, to avoid conflicts with an inner type having a method of the same name, we use an associated method, like `Box::into_raw`. Tracking issue: rust-lang#65143
Rollup of 9 pull requests Successful merges: - #138217 (Turn `Cow::is_borrowed,is_owned` into associated functions.) - #147858 (Micro-optimization attempt in coroutine layout computation) - #147923 (Simplify rustc_public context handling) - #147935 (Add LLVM realtime sanitizer) - #148115 (rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest`) - #148137 (Couple of changes for Redox OS) - #148176 ([rustdoc] Include attribute and derive macros when filtering on "macros") - #148193 (Remove `QPath::LangItem`) - #148253 (Handle default features and -Ctarget-features in the dummy backend) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - #138217 (Turn `Cow::is_borrowed,is_owned` into associated functions.) - #147858 (Micro-optimization attempt in coroutine layout computation) - #147923 (Simplify rustc_public context handling) - #148115 (rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest`) - #148137 (Couple of changes for Redox OS) - #148176 ([rustdoc] Include attribute and derive macros when filtering on "macros") - #148253 (Handle default features and -Ctarget-features in the dummy backend) - #148272 (Align VEX V5 boot routine to 4 bytes) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #138217 - theemathas:cow_is_owned_borrowed_associated, r=dtolnay Turn `Cow::is_borrowed,is_owned` into associated functions. This is done because `Cow` implements `Deref`. Therefore, to avoid conflicts with an inner type having a method of the same name, we use an associated method, like `Box::into_raw`. Tracking issue: #65143
Rollup of 8 pull requests Successful merges: - rust-lang/rust#138217 (Turn `Cow::is_borrowed,is_owned` into associated functions.) - rust-lang/rust#147858 (Micro-optimization attempt in coroutine layout computation) - rust-lang/rust#147923 (Simplify rustc_public context handling) - rust-lang/rust#148115 (rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest`) - rust-lang/rust#148137 (Couple of changes for Redox OS) - rust-lang/rust#148176 ([rustdoc] Include attribute and derive macros when filtering on "macros") - rust-lang/rust#148253 (Handle default features and -Ctarget-features in the dummy backend) - rust-lang/rust#148272 (Align VEX V5 boot routine to 4 bytes) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - rust-lang#138217 (Turn `Cow::is_borrowed,is_owned` into associated functions.) - rust-lang#147858 (Micro-optimization attempt in coroutine layout computation) - rust-lang#147923 (Simplify rustc_public context handling) - rust-lang#148115 (rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest`) - rust-lang#148137 (Couple of changes for Redox OS) - rust-lang#148176 ([rustdoc] Include attribute and derive macros when filtering on "macros") - rust-lang#148253 (Handle default features and -Ctarget-features in the dummy backend) - rust-lang#148272 (Align VEX V5 boot routine to 4 bytes) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - rust-lang#138217 (Turn `Cow::is_borrowed,is_owned` into associated functions.) - rust-lang#147858 (Micro-optimization attempt in coroutine layout computation) - rust-lang#147923 (Simplify rustc_public context handling) - rust-lang#148115 (rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest`) - rust-lang#148137 (Couple of changes for Redox OS) - rust-lang#148176 ([rustdoc] Include attribute and derive macros when filtering on "macros") - rust-lang#148253 (Handle default features and -Ctarget-features in the dummy backend) - rust-lang#148272 (Align VEX V5 boot routine to 4 bytes) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - rust-lang/rust#138217 (Turn `Cow::is_borrowed,is_owned` into associated functions.) - rust-lang/rust#147858 (Micro-optimization attempt in coroutine layout computation) - rust-lang/rust#147923 (Simplify rustc_public context handling) - rust-lang/rust#148115 (rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest`) - rust-lang/rust#148137 (Couple of changes for Redox OS) - rust-lang/rust#148176 ([rustdoc] Include attribute and derive macros when filtering on "macros") - rust-lang/rust#148253 (Handle default features and -Ctarget-features in the dummy backend) - rust-lang/rust#148272 (Align VEX V5 boot routine to 4 bytes) r? `@ghost` `@rustbot` modify labels: rollup
…ssociated, r=dtolnay Turn `Cow::is_borrowed,is_owned` into associated functions. This is done because `Cow` implements `Deref`. Therefore, to avoid conflicts with an inner type having a method of the same name, we use an associated method, like `Box::into_raw`. Tracking issue: rust-lang#65143
This is done because
CowimplementsDeref. Therefore, to avoid conflicts with an inner type having a method of the same name, we use an associated method, likeBox::into_raw.Tracking issue: #65143