Skip to content

Conversation

@dciug
Copy link

@dciug dciug commented Nov 2, 2025

No description provided.

@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 Nov 2, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 2, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@JonathanBrouwer
Copy link
Contributor

JonathanBrouwer commented Nov 2, 2025

Hi there, thanks for the fix!
It looks like your change also changed the output of the uitests, causing CI to fail.
See here for help on how to bless them: https://rustc-dev-guide.rust-lang.org/tests/running.html#editing-and-updating-the-reference-files
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 2, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
63 LL |     let x = &x as *const u8;
64    |             -- dangling pointer created here
65 LL |     x as *const u8

73 LL | fn return_with_complex_cast() -> *mut u8 {
74    |                                  ------- return type of the function is `*mut u8`
75 LL |     let mut x = 0u8;
-    |         ----- `x` is part the function and will be dropped at the end of the function
+    |         ----- `x` is part of the function and will be dropped at the end of the function
77 LL |     return &mut x as *mut u8 as *const u8 as *mut u8;
78    |            ------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79    |            |

87 LL | fn with_block() -> *const u8 {
88    |                    --------- return type of the function is `*const u8`
---
144 LL |         return &x;
145    |                ^^
146    |

152 LL | fn vector<T: Default>() -> *const Vec<T> {
153    |                            ------------- return type of the function is `*const Vec<T>`
154 LL |     let x = vec![T::default()];
-    |         - `x` is part the function and will be dropped at the end of the function
+    |         - `x` is part of the function and will be dropped at the end of the function
156 LL |     &x
157    |     ^^
158    |

164 LL | fn local_adt() -> *const Adt {
165    |                   ---------- return type of the function is `*const Adt`
166 LL |     let x = Adt(5);
-    |         - `x` is part the function and will be dropped at the end of the function
+    |         - `x` is part of the function and will be dropped at the end of the function
168 LL |     return &x;
169    |            ^^
170    |

176 LL |     let _x = || -> *const u8 {
177    |                    --------- return type of the closure is `*const u8`
---
182    |

189    |                ----------------- return type of the function is `*const fn() -> u8`
190 ...
191 LL |     let x = ret_u8 as fn() -> u8;
-    |         - `x` is part the function and will be dropped at the end of the function
+    |         - `x` is part of the function and will be dropped at the end of the function
193 LL |     &x
194    |     ^^
195    |

201 LL | fn as_arg(a: Adt) -> *const Adt {
202    |           -          ---------- return type of the function is `*const Adt`
203    |           |
-    |           `a` is part the function and will be dropped at the end of the function
+    |           `a` is part of the function and will be dropped at the end of the function
205 LL |     &a
206    |     ^^
207    |

213 LL | fn fn_ptr_as_arg(a: fn() -> u8) -> *const fn() -> u8 {
214    |                  -                 ----------------- return type of the function is `*const fn() -> u8`
215    |                  |
-    |                  `a` is part the function and will be dropped at the end of the function
+    |                  `a` is part of the function and will be dropped at the end of the function
217 LL |     &a
218    |     ^^
219    |

225 LL | fn ptr_as_arg(a: *const Adt) -> *const *const Adt {
226    |               -                 ----------------- return type of the function is `*const *const Adt`
227    |               |
-    |               `a` is part the function and will be dropped at the end of the function
+    |               `a` is part of the function and will be dropped at the end of the function
229 LL |     &a
230    |     ^^
231    |

237 LL | fn adt_as_arg(a: &Adt) -> *const &Adt {
238    |               -           ----------- return type of the function is `*const &Adt`
239    |               |
-    |               `a` is part the function and will be dropped at the end of the function
+    |               `a` is part of the function and will be dropped at the end of the function
241 LL |     &a
242    |     ^^
---
To only update this specific test, also pass `--test-args lint/dangling-pointers-from-locals.rs`

error: 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/lint/dangling-pointers-from-locals.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" "--check-cfg" "cfg(test,FALSE)" "--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/lint/dangling-pointers-from-locals" "-A" "unused" "-W" "unused_attributes" "-A" "internal_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 -------------------------------
warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:10:5
   |
LL | fn simple() -> *const u8 {
   |                --------- return type of the function is `*const u8`
LL |     let x = 0;
   |         - `x` is part of the function and will be dropped at the end of the function
LL |     &x
   |     ^^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned
   = note: `#[warn(dangling_pointers_from_locals)]` on by default

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:17:5
   |
LL | fn bindings() -> *const u8 {
---
   |             -- dangling pointer created here
LL |     x
   |     ^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:24:12
   |
LL | fn bindings_with_return() -> *const u8 {
---
   |             -- dangling pointer created here
LL |     return y;
   |            ^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:30:5
   |
LL | fn with_simple_cast() -> *const u8 {
---
   |     --^^^^^^^^^^^^^
   |     |
   |     dangling pointer created here
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:37:5
   |
LL | fn bindings_and_casts() -> *const u8 {
---
   |             -- dangling pointer created here
LL |     x as *const u8
   |     ^^^^^^^^^^^^^^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:43:12
   |
LL | fn return_with_complex_cast() -> *mut u8 {
   |                                  ------- return type of the function is `*mut u8`
LL |     let mut x = 0u8;
   |         ----- `x` is part of the function and will be dropped at the end of the function
LL |     return &mut x as *mut u8 as *const u8 as *mut u8;
   |            ------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |            |
   |            dangling pointer created here
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:49:5
   |
LL | fn with_block() -> *const u8 {
   |                    --------- return type of the function is `*const u8`
LL |     let x = 0;
   |         - `x` is part of the function and will be dropped at the end of the function
LL |     &{ x }
   |     ^^^^^^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:57:13
   |
LL |   fn with_many_blocks() -> *const u8 {
---
LL | |                 { x }
LL | |             }
   | |_____________^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:67:12
   |
LL | fn simple_return() -> *const u8 {
   |                       --------- return type of the function is `*const u8`
LL |     let x = 0;
   |         - `x` is part of the function and will be dropped at the end of the function
LL |     return &x;
   |            ^^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:73:12
   |
LL | fn return_mut() -> *mut u8 {
   |                    ------- return type of the function is `*mut u8`
LL |     let mut x = 0;
   |         ----- `x` is part of the function and will be dropped at the end of the function
LL |     return &mut x;
   |            ^^^^^^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:80:16
   |
LL | fn const_and_flow() -> *const u8 {
   |                        --------- return type of the function is `*const u8`
LL |     if false {
LL |         let x = 8;
   |             - `x` is part of the function and will be dropped at the end of the function
LL |         return &x;
   |                ^^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:88:5
   |
LL | fn vector<T: Default>() -> *const Vec<T> {
   |                            ------------- return type of the function is `*const Vec<T>`
LL |     let x = vec![T::default()];
   |         - `x` is part of the function and will be dropped at the end of the function
LL |     &x
   |     ^^
   |
   = note: pointers do not have a lifetime; after returning, the `Vec<T>` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:94:12
   |
LL | fn local_adt() -> *const Adt {
   |                   ---------- return type of the function is `*const Adt`
LL |     let x = Adt(5);
   |         - `x` is part of the function and will be dropped at the end of the function
LL |     return &x;
   |            ^^
   |
   = note: pointers do not have a lifetime; after returning, the `Adt` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:101:16
   |
LL |     let _x = || -> *const u8 {
   |                    --------- return type of the closure is `*const u8`
LL |         let x = 8;
   |             - `x` is part of the closure and will be dropped at the end of the closure
LL |         return &x;
   |                ^^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the closure because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `x` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:113:5
   |
LL | fn fn_ptr() -> *const fn() -> u8 {
   |                ----------------- return type of the function is `*const fn() -> u8`
...
LL |     let x = ret_u8 as fn() -> u8;
   |         - `x` is part of the function and will be dropped at the end of the function
LL |     &x
   |     ^^
   |
   = note: pointers do not have a lifetime; after returning, the `fn() -> u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `a` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:118:5
   |
LL | fn as_arg(a: Adt) -> *const Adt {
   |           -          ---------- return type of the function is `*const Adt`
   |           |
   |           `a` is part of the function and will be dropped at the end of the function
LL |     &a
   |     ^^
   |
   = note: pointers do not have a lifetime; after returning, the `Adt` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `a` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:123:5
   |
LL | fn fn_ptr_as_arg(a: fn() -> u8) -> *const fn() -> u8 {
   |                  -                 ----------------- return type of the function is `*const fn() -> u8`
   |                  |
   |                  `a` is part of the function and will be dropped at the end of the function
LL |     &a
   |     ^^
   |
   = note: pointers do not have a lifetime; after returning, the `fn() -> u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `a` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:128:5
   |
LL | fn ptr_as_arg(a: *const Adt) -> *const *const Adt {
   |               -                 ----------------- return type of the function is `*const *const Adt`
   |               |
   |               `a` is part of the function and will be dropped at the end of the function
LL |     &a
   |     ^^
   |
   = note: pointers do not have a lifetime; after returning, the `*const Adt` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: a dangling pointer will be produced because the local variable `a` will be dropped
##[warning]  --> /checkout/tests/ui/lint/dangling-pointers-from-locals.rs:133:5
   |
LL | fn adt_as_arg(a: &Adt) -> *const &Adt {
   |               -           ----------- return type of the function is `*const &Adt`
   |               |
   |               `a` is part of the function and will be dropped at the end of the function
LL |     &a
   |     ^^
   |
   = note: pointers do not have a lifetime; after returning, the `&Adt` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned

warning: 19 warnings emitted
------------------------------------------

---- [ui] tests/ui/lint/dangling-pointers-from-locals.rs stdout end ----

@Urgau
Copy link
Member

Urgau commented Nov 2, 2025

We are changing the lint output in #148348, this typo should not exist after that.

@JonathanBrouwer
Copy link
Contributor

Good find, then lets close this PR in favour of #148348

@dciug Thanks a lot for the contribution, regardless!

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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