Skip to content

Don't claim that escaping value is a reference in diagnostics - #163016

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
maxdexh:if-everything-is-a-reference-then-nothing-is
Sep 21, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
maxdexh:if-everything-is-a-reference-then-nothing-is

Conversation

@maxdexh

@maxdexh maxdexh commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Changes the part of the "borrowed data escapes" diagnostic that points to the local that the region came from, by removing the claim that it is a reference, as that is not generally correct.

Fixes #162890

I considered checking if the type of the escaping value is actually a reference type (and keeping the old message if so). But with the way the code is written, that would have been non-trivial to do, and of questionable value (the type is already shown in the error).
Also, IMO the new message is more "to the point", even for references.

r? compiler

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 19, 2026
@maxdexh
maxdexh force-pushed the if-everything-is-a-reference-then-nothing-is branch from 2f6bbbb to 9bcf169 Compare September 19, 2026 14:10
@maxdexh
maxdexh marked this pull request as ready for review September 19, 2026 14:53
@rustbot

rustbot commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 19, 2026
@maxdexh

maxdexh commented Sep 19, 2026 •

Copy link
Copy Markdown
Member Author

only test output changes in clippy

@maxdexh maxdexh changed the title Don't claim that escaping value is a reference Don't claim that escaping value is a reference in diagnostics Sep 19, 2026
@estebank

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9bcf169 has been approved by estebank

It is now in the queue for this repository.

@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 Sep 20, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 20, 2026
…ce-then-nothing-is, r=estebank

Don't claim that escaping value is a reference in diagnostics

Changes the part of the "borrowed data escapes" diagnostic that points to the local that the region came from, by removing the claim that it is a reference, as that is not generally correct.

Fixes rust-lang#162890

I considered checking if the type of the escaping value is actually a reference type (and keeping the old message if so). But with the way the code is written, that would have been non-trivial to do, and of questionable value (the type is already shown in the error).
Also, IMO the new message is more "to the point", even for references.

r? compiler
rust-bors Bot pushed a commit that referenced this pull request Sep 20, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #162726 (std: fix unix socket address panic on a full sun_path)
 - #163016 (Don't claim that escaping value is a reference in diagnostics)
 - #163040 (Tweak "use array's length as const param" suggestion)
 - #163060 (Point to fields that introduce trait requirements)
 - #163066 (don't mark `f128` as reliable on AIX)
 - #162098 (Tweak `Infallible` docs)
 - #162854 (Add safety section for atomic_load/store)
 - #163015 (add `minicore::ffi::VaList`)
 - #163021 (`va_arg`: pass in `TyAndLayout`)
 - #163036 ([rustdoc] Correctly handle `dyn` trait methods linking for jump to def feature)
 - #163042 (Remove redundant output from suggestion)
 - #163046 (Use verbose suggestion for `const _`)
 - #163050 (Use verbose suggestion for similarly named label suggestion)
 - #163052 (Use verbose suggestion for wrong primitive type names)
 - #163055 (Use the full path of `bug_impl` to avoid bogus errors in rust-analyzer)
rust-bors Bot pushed a commit that referenced this pull request Sep 20, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #162726 (std: fix unix socket address panic on a full sun_path)
 - #163016 (Don't claim that escaping value is a reference in diagnostics)
 - #163040 (Tweak "use array's length as const param" suggestion)
 - #163060 (Point to fields that introduce trait requirements)
 - #163066 (don't mark `f128` as reliable on AIX)
 - #162098 (Tweak `Infallible` docs)
 - #162854 (Add safety section for atomic_load/store)
 - #163015 (add `minicore::ffi::VaList`)
 - #163021 (`va_arg`: pass in `TyAndLayout`)
 - #163036 ([rustdoc] Correctly handle `dyn` trait methods linking for jump to def feature)
 - #163042 (Remove redundant output from suggestion)
 - #163046 (Use verbose suggestion for `const _`)
 - #163050 (Use verbose suggestion for similarly named label suggestion)
 - #163052 (Use verbose suggestion for wrong primitive type names)
 - #163055 (Use the full path of `bug_impl` to avoid bogus errors in rust-analyzer)
rust-bors Bot pushed a commit that referenced this pull request Sep 21, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #162726 (std: fix unix socket address panic on a full sun_path)
 - #163016 (Don't claim that escaping value is a reference in diagnostics)
 - #163040 (Tweak "use array's length as const param" suggestion)
 - #163060 (Point to fields that introduce trait requirements)
 - #163066 (don't mark `f128` as reliable on AIX)
 - #162098 (Tweak `Infallible` docs)
 - #162854 (Add safety section for atomic_load/store)
 - #163015 (add `minicore::ffi::VaList`)
 - #163021 (`va_arg`: pass in `TyAndLayout`)
 - #163036 ([rustdoc] Correctly handle `dyn` trait methods linking for jump to def feature)
 - #163042 (Remove redundant output from suggestion)
 - #163046 (Use verbose suggestion for `const _`)
 - #163050 (Use verbose suggestion for similarly named label suggestion)
 - #163052 (Use verbose suggestion for wrong primitive type names)
 - #163055 (Use the full path of `bug_impl` to avoid bogus errors in rust-analyzer)
rust-bors Bot pushed a commit that referenced this pull request Sep 21, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #162726 (std: fix unix socket address panic on a full sun_path)
 - #163016 (Don't claim that escaping value is a reference in diagnostics)
 - #163040 (Tweak "use array's length as const param" suggestion)
 - #163060 (Point to fields that introduce trait requirements)
 - #163066 (don't mark `f128` as reliable on AIX)
 - #162098 (Tweak `Infallible` docs)
 - #162854 (Add safety section for atomic_load/store)
 - #163015 (add `minicore::ffi::VaList`)
 - #163021 (`va_arg`: pass in `TyAndLayout`)
 - #163036 ([rustdoc] Correctly handle `dyn` trait methods linking for jump to def feature)
 - #163042 (Remove redundant output from suggestion)
 - #163046 (Use verbose suggestion for `const _`)
 - #163050 (Use verbose suggestion for similarly named label suggestion)
 - #163052 (Use verbose suggestion for wrong primitive type names)
 - #163055 (Use the full path of `bug_impl` to avoid bogus errors in rust-analyzer)
@rust-bors
rust-bors Bot merged commit 9d8d4be into rust-lang:main Sep 21, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 21, 2026
Rollup merge of #163016 - maxdexh:if-everything-is-a-reference-then-nothing-is, r=estebank

Don't claim that escaping value is a reference in diagnostics

Changes the part of the "borrowed data escapes" diagnostic that points to the local that the region came from, by removing the claim that it is a reference, as that is not generally correct.

Fixes #162890

I considered checking if the type of the escaping value is actually a reference type (and keeping the old message if so). But with the way the code is written, that would have been non-trivial to do, and of questionable value (the type is already shown in the error).
Also, IMO the new message is more "to the point", even for references.

r? compiler
@maxdexh
maxdexh deleted the if-everything-is-a-reference-then-nothing-is branch September 21, 2026 08:23
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-clippy Relevant to the Clippy team. 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.

"borrowed data escapes" diagnostic claims that anything with escaping trait object is a reference

4 participants