Skip to content

[Outreachy] alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc) - #164440

Open
Joiejoie1 wants to merge 1 commit into
rust-lang:mainfrom
Joiejoie1:test-try-clone-from-ref-in
Open

Joiejoie1 wants to merge 1 commit into
rust-lang:mainfrom
Joiejoie1:test-try-clone-from-ref-in

Conversation

@Joiejoie1

Copy link
Copy Markdown

Description:

LLM Disclosure: I used an AI assistant for local guidance while exploring the test structure and troubleshooting compiler errors (such as handling System allocator equality checks). I wrote this PR description, ran all tests, and verified the changes myself.

Summary

I added a UI test to verify try_clone_from_ref_in across Box, Arc, and Rc using the System allocator as part of the Allocators 1.0 test coverage work.

What’s included:

  • Added tests/ui/allocator/try-clone-from-ref-in.rs

  • Tested fallible cloning from references for &str and &[i32] slices with Box, Arc, and Rc

  • Verified feature gate handling (#![feature(clone_from_ref)])

  • Ran ./x.py test tests/ui/allocator/try-clone-from-ref-in.rs locally and the test passed.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 16, 2026
@rustbot

rustbot commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @mejrs (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 19 candidates

@Joiejoie1

Copy link
Copy Markdown
Author

Hi @nia-e ,

As an Outreachy Internship applicant and a first-time contributor working on Allocators 1.0 test coverage.
I built and verified a UI test for try_clone_from_ref_in across Box, Arc, and Rc.
I would truly appreciate your review of this PR!

@malezjaa

malezjaa commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Hello, congrats on your first PR! I wanted to leave a few notes.
The tests you added for try_clone_from_ref_in already largely overlap with existing doctests. The dev-guide also recommends that library tests go in the matching directory.

Tests for the alloc or core crates must go in separate crates: alloctests or coretests respectively.

The PR says: "Verified feature gate handling (#![feature(clone_from_ref)])". This is misleading. It doesn't verify the gate. To check it you'd need a test without the feature gate added. I think testing this is unnecessary here.

Afaict, testing edge cases would provide better coverage.

@mejrs

mejrs commented Oct 18, 2026

Copy link
Copy Markdown
Member

r? @nia-e

@rustbot rustbot assigned nia-e and unassigned mejrs Oct 18, 2026
@rustbot

rustbot commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

nia-e is currently at their maximum review capacity.
They may take a while to respond.

@Joiejoie1

Joiejoie1 commented Oct 19, 2026 •

Copy link
Copy Markdown
Author

Hello, congrats on your first PR! I wanted to leave a few notes. The tests you added for try_clone_from_ref_in already largely overlap with existing doctests. The dev-guide also recommends that library tests go in the matching directory.

Tests for the alloc or core crates must go in separate crates: alloctests or coretests respectively.

The PR says: "Verified feature gate handling (#![feature(clone_from_ref)])". This is misleading. It doesn't verify the gate. To check it you'd need a test without the feature gate added. I think testing this is unnecessary here.

Afaict, testing edge cases would provide better coverage.

Thanks @malezjaa for the clear feedback! I'll move the test logic into alloctests and rework it to focus on edge cases instead of overlapping with existing doctests.. This is for my Outreachy Contribution Stage.

@rust-log-analyzer

This comment has been minimized.

@Joiejoie1

Copy link
Copy Markdown
Author

Hello, congrats on your first PR! I wanted to leave a few notes. The tests you added for try_clone_from_ref_in already largely overlap with existing doctests. The dev-guide also recommends that library tests go in the matching directory.

Tests for the alloc or core crates must go in separate crates: alloctests or coretests respectively.

The PR says: "Verified feature gate handling (#![feature(clone_from_ref)])". This is misleading. It doesn't verify the gate. To check it you'd need a test without the feature gate added. I think testing this is unnecessary here.

Afaict, testing edge cases would provide better coverage.

Hi @malezjaa ,

Thank you for the helpful feedback and the warm welcome! I’ve moved the test to library/alloctests/tests/boxed.rs removed the overlapping UI test, and added a zero-sized type edge case to verify that no allocation occurs. I’ve also corrected the misleading feature-gate claim. I appreciate your guidance!

@rust-bors

This comment has been minimized.

@Joiejoie1
Joiejoie1 force-pushed the test-try-clone-from-ref-in branch from c11d302 to 8a06c6a Compare October 27, 2026 16:44
@rustbot

rustbot commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@Joiejoie1 Joiejoie1 changed the title alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc) [Outreachy] alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc) Oct 27, 2026
@nia-e

nia-e commented Nov 4, 2026

Copy link
Copy Markdown
Member

lgtm :) thanks for contributing!

@bors rollup

@nia-e

nia-e commented Nov 4, 2026

Copy link
Copy Markdown
Member

@bors squash

@rust-bors

This comment has been minimized.

…Arc, Rc)

* alloc: Add test coverage for try_clone_from_ref_in
* alloc: test cloning zero-sized values from references
* alloc: format zero-sized clone test
* alloctests: remove obsolete const_btree_len feature
* alloctests: fix feature attribute formatting
@rust-bors

rust-bors Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🔨 5 commits were squashed into 0376ed9.

@rust-bors
rust-bors Bot force-pushed the test-try-clone-from-ref-in branch from 9e93560 to 0376ed9 Compare November 4, 2026 01:01
@nia-e

nia-e commented Nov 4, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0376ed9 has been tentatively approved by nia-e

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot 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 Nov 4, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 4, 2026
…in, r=nia-e

[Outreachy] alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc)

Description:

LLM Disclosure: I used an AI assistant for local guidance while exploring the test structure and troubleshooting compiler errors (such as handling System allocator equality checks). I wrote this PR description, ran all tests, and verified the changes myself.

**Summary**

I added a UI test to verify  `try_clone_from_ref_in `  across **Box, Arc, and Rc** using the System allocator as part of the Allocators 1.0 test coverage work.

What’s included:

- Added tests/ui/allocator/try-clone-from-ref-in.rs

- Tested fallible cloning from references for **&str** and **&[i32]** slices with Box, **Arc,** and **Rc**

- Verified feature gate handling (#![feature(clone_from_ref)])

- Ran  `./x.py test tests/ui/allocator/try-clone-from-ref-in.rs`  locally and the test passed.
rust-bors Bot pushed a commit that referenced this pull request Nov 4, 2026
Rollup of 9 pull requests

Successful merges:

 - #165011 (std: Clean up and improve errors for `is_*_feature_detected` macros)
 - #164482 (Remove the label starting with 0 in the test binary_asm_labels_allowed.rs)
 - #165268 (Fix constant-pattern  equality suggestion spans in macros)
 - #165318 (Fix explicit destructor-call suggestion spans in macros)
 - #164440 ([Outreachy] alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc))
 - #165001 (Document allocator swap in BinaryHeap::append)
 - #165330 (Impl read_le/read_be for f16 and f128)
 - #165414 (Remove unusued query key impl)
 - #165440 (docker: bump node to v24.22.2 in shared script)
rust-bors Bot pushed a commit that referenced this pull request Nov 4, 2026
Rollup of 9 pull requests

Successful merges:

 - #165011 (std: Clean up and improve errors for `is_*_feature_detected` macros)
 - #164482 (Remove the label starting with 0 in the test binary_asm_labels_allowed.rs)
 - #165268 (Fix constant-pattern  equality suggestion spans in macros)
 - #165318 (Fix explicit destructor-call suggestion spans in macros)
 - #164440 ([Outreachy] alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc))
 - #165001 (Document allocator swap in BinaryHeap::append)
 - #165330 (Impl read_le/read_be for f16 and f128)
 - #165414 (Remove unusued query key impl)
 - #165440 (docker: bump node to v24.22.2 in shared script)
rust-bors Bot pushed a commit that referenced this pull request Nov 4, 2026
Rollup of 9 pull requests

Successful merges:

 - #165011 (std: Clean up and improve errors for `is_*_feature_detected` macros)
 - #164482 (Remove the label starting with 0 in the test binary_asm_labels_allowed.rs)
 - #165268 (Fix constant-pattern  equality suggestion spans in macros)
 - #165318 (Fix explicit destructor-call suggestion spans in macros)
 - #164440 ([Outreachy] alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc))
 - #165001 (Document allocator swap in BinaryHeap::append)
 - #165330 (Impl read_le/read_be for f16 and f128)
 - #165414 (Remove unusued query key impl)
 - #165440 (docker: bump node to v24.22.2 in shared script)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants