-
- Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
fn foo(r: &mut i32) -> &i32 { &r }Current output
error[E0515]: cannot return reference to function parameter `r` --> src/bin/main.rs:4:5 | 4 | &r | ^^ returns a reference to data owned by the current function For more information about this error, try `rustc --explain E0515`. error: could not compile `quick-rs` (bin "main") due to 1 previous errorDesired output
error[E0515]: cannot return reference to function parameter `r` --> src/bin/main.rs:4:5 | 4 | &r | ^ help: remove this ref | ^^ returns a reference to data owned by the current function For more information about this error, try `rustc --explain E0515`. error: could not compile `quick-rs` (bin "main") due to 1 previous errorRationale and extra context
No response
Other cases
Rust Version
rustc 1.91.0-nightly (040a98af7 2025-08-20) binary: rustc commit-hash: 040a98af70f0a7da03f3d5356531b28a2a7a77e4 commit-date: 2025-08-20 host: aarch64-unknown-linux-gnu release: 1.91.0-nightly LLVM version: 21.1.0Anything else?
No response
098orin
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.