Skip to content

Add new variant to iterating-updating-mutref borrowck test#159306

Open
jackh726 wants to merge 1 commit into
rust-lang:mainfrom
jackh726:iterating-updating-mutref-variant
Open

Add new variant to iterating-updating-mutref borrowck test#159306
jackh726 wants to merge 1 commit into
rust-lang:mainfrom
jackh726:iterating-updating-mutref-variant

Conversation

@jackh726

Copy link
Copy Markdown
Member

This is a useful variant to consider when porting to a-mir-formality.

r? lqd

@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 Jul 14, 2026
@lqd

lqd commented Jul 14, 2026

Copy link
Copy Markdown
Member

r=me with a comment in the test on why it's a useful variant, and the warning fixed

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

failures:

---- [ui] tests/ui/nll/polonius/iterating-updating-mutref.rs#nll stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/nll/polonius/iterating-updating-mutref.nll/iterating-updating-mutref.nll.stderr`
diff of stderr:

1 error[E0499]: cannot borrow `self.buf_read` as mutable more than once at a time
-   --> $DIR/iterating-updating-mutref.rs:61:23
+   --> $DIR/iterating-updating-mutref.rs:74:23
3    |
4 LL |     pub fn next<'a>(&'a mut self) -> &'a str {
5    |                 -- lifetime `'a` defined here
---
The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args nll/polonius/iterating-updating-mutref.rs`

error in revision `nll`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/nll/polonius/iterating-updating-mutref.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "nll" "--check-cfg" "cfg(test,FALSE,nll,polonius,legacy)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/nll/polonius/iterating-updating-mutref.nll" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0499]: cannot borrow `self.buf_read` as mutable more than once at a time
##[error]  --> /checkout/tests/ui/nll/polonius/iterating-updating-mutref.rs:74:23
   |
LL |     pub fn next<'a>(&'a mut self) -> &'a str {
   |                 -- lifetime `'a` defined here
LL |         loop {
---
------------------------------------------

---- [ui] tests/ui/nll/polonius/iterating-updating-mutref.rs#nll stdout end ----
---- [ui] tests/ui/nll/polonius/iterating-updating-mutref.rs#legacy stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/nll/polonius/iterating-updating-mutref.legacy/iterating-updating-mutref.legacy.stderr`
normalized stderr:
warning: type `List<T>` is more private than the item `to_refs3`
##[warning]  --> $DIR/iterating-updating-mutref.rs:52:1
   |
LL | pub fn to_refs3<'a, T>(list: &'a mut List<T>) -> &'a mut T {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `to_refs3` is reachable at visibility `pub`
   |
note: but type `List<T>` is only usable at visibility `pub(crate)`
  --> $DIR/iterating-updating-mutref.rs:19:1
   |
LL | struct List<T> {
---
To only update this specific test, also pass `--test-args nll/polonius/iterating-updating-mutref.rs`

error in revision `legacy`: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/nll/polonius/iterating-updating-mutref.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "legacy" "--check-cfg" "cfg(test,FALSE,nll,polonius,legacy)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/nll/polonius/iterating-updating-mutref.legacy" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "polonius=legacy"
stdout: none
--- stderr -------------------------------
warning: type `List<T>` is more private than the item `to_refs3`
##[warning]  --> /checkout/tests/ui/nll/polonius/iterating-updating-mutref.rs:52:1
   |
LL | pub fn to_refs3<'a, T>(list: &'a mut List<T>) -> &'a mut T {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `to_refs3` is reachable at visibility `pub`
   |
note: but type `List<T>` is only usable at visibility `pub(crate)`
  --> /checkout/tests/ui/nll/polonius/iterating-updating-mutref.rs:19:1
   |
LL | struct List<T> {
---
normalized stderr:
warning: type `List<T>` is more private than the item `to_refs3`
##[warning]  --> $DIR/iterating-updating-mutref.rs:52:1
   |
LL | pub fn to_refs3<'a, T>(list: &'a mut List<T>) -> &'a mut T {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `to_refs3` is reachable at visibility `pub`
   |
note: but type `List<T>` is only usable at visibility `pub(crate)`
  --> $DIR/iterating-updating-mutref.rs:19:1
   |
LL | struct List<T> {
---
The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args nll/polonius/iterating-updating-mutref.rs`

error in revision `polonius`: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/nll/polonius/iterating-updating-mutref.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "polonius" "--check-cfg" "cfg(test,FALSE,nll,polonius,legacy)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/nll/polonius/iterating-updating-mutref.polonius" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-Z" "polonius=next"
stdout: none
--- stderr -------------------------------
warning: type `List<T>` is more private than the item `to_refs3`
##[warning]  --> /checkout/tests/ui/nll/polonius/iterating-updating-mutref.rs:52:1
   |
LL | pub fn to_refs3<'a, T>(list: &'a mut List<T>) -> &'a mut T {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `to_refs3` is reachable at visibility `pub`
   |
note: but type `List<T>` is only usable at visibility `pub(crate)`
  --> /checkout/tests/ui/nll/polonius/iterating-updating-mutref.rs:19:1
   |
LL | struct List<T> {

result
}

pub fn to_refs3<'a, T>(list: &'a mut List<T>) -> &'a mut T {

@lqd lqd Jul 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably enough

Suggested change
pub fn to_refs3<'a, T>(list: &'a mut List<T>) -> &'a mut T {
fn to_refs3<'a, T>(list: &'a mut List<T>) -> &'a mut T {

View changes since the review

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants