rust/tests
bors df8b2e497d Auto merge of #147056 - dianne:fcw-super-let-init-borrow-shortening, r=jackh726
[beta-1.91] Warn on future errors from temporary lifetimes shortening in Rust 1.92

Pursuant to [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/474880-t-compiler.2Fbackports/topic/.23145838.3A.20beta-nominated/near/540530631), this implements a future-compatibility warning lint `macro_extended_temporary_scopes` for errors in Rust 1.92 caused by rust-lang/rust#145838:

```
warning: temporary lifetime shortening in Rust 1.92
  --> $DIR/macro-extended-temporary-scopes.rs:54:14
   |
LL |             &struct_temp().field
   |              ^^^^^^^^^^^^^ this expression creates a temporary value...
...
LL |         } else {
   |         - ...which will be dropped at the end of this block in Rust 1.92
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see <https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#macro-extended-temporary-scopes>
   = note: consider using a `let` binding to create a longer lived value
```

Implementation-wise, this reuses the existing temporary scoping FCW machinery introduced for the `tail_expr_drop_order` edition lint: this adds `BackwardIncompatibleDropHint` statements to the MIR at the end of the shortened scopes for affected temporaries; these are then checked in borrowck to warn if the temporary is used after the future drop hint. There are trade-offs here: on one hand, I believe this gives some assurance over ad-hoc pattern-recognition that there are no false positives[^1]. On the other hand, this fails to lint on future dangling raw pointers and it complicates the potential addition of explanatory diagnostics or suggestions[^2]. I'm hopeful that the limitation around dangling pointers won't be relevant in real code, though; the only real instance we've seen of breakage so far is future errors in formatting macro invocations, which this should be able to catch.

Release logistics notes:
- This PR targets the beta branch directly, since the breakage it's a FCW for is landing in the next Rust version.
- rust-lang/rust#146098 undoes the breakage this is a FCW for. If that behavior is merged and stabilizes in Rust 1.92, this PR should be reverted (or shouldn't be merged) in order to avoid spurious warnings.

cc `@traviscross`

`@rustbot` label +T-lang

[^1]: In particular, more syntactic approaches are complicated by having to avoid warning on promoted constants; they'd either be full of holes, they'd need a lot of extra logic, or they'd need to hack more MIR-to-HIR mapping into `PromoteTemps`.
[^2]: It's definitely possible to add more context and a suggestion, but the ways I've thought of to do so are either too hacky or too complex to feel appropriate for a last-minute direct-to-beta lint.
2025-10-15 01:35:47 +00:00
..
assembly-llvm Rollup merge of #144549 - folkertdev:va-arg-arm, r=saethlin 2025-09-12 20:02:10 +10:00
auxiliary Add test for addrspacecasting global vars 2025-09-03 08:40:51 +02:00
codegen-llvm Revert "Auto merge of #144086 - clubby789:alloc-zeroed, r=nikic" 2025-09-25 16:36:51 +02:00
codegen-units pub async fn implementation coroutine (func::{closure#0}) is monomorphized, when func itself is monomorphized 2025-09-01 13:45:00 +07:00
coverage Auto merge of #143290 - azhogin:azhogin/link-pub-async-impls, r=oli-obk 2025-09-01 10:54:40 +00:00
coverage-run-rustdoc
crashes Add compiler error when trying to use concat metavar expr in repetitions 2025-09-01 08:27:30 +02:00
debuginfo tests: Ignore basic-stepping.rs on riscv64 2025-08-29 08:11:48 +00:00
incremental Bless incremental tests. 2025-07-13 13:50:01 +00:00
mir-opt don't trim paths in mir dumping when filtering and at the top of the file 2025-09-09 16:23:14 -07:00
pretty Update autodiff tests for the new intrinsics impl 2025-08-14 18:33:43 +00:00
run-make Add --print target-spec-json-schema 2025-09-12 20:53:28 +02:00
run-make-cargo tests: update test instruction in thumb-none-cortex-m 2025-09-05 21:22:51 +08:00
rustdoc Auto merge of #138736 - azhogin:azhogin/sanitizers-target-modificators, r=rcvalle 2025-09-04 22:51:33 +00:00
rustdoc-gui Ensure that --html-after-content option is used to check scrape_examples_ice rustdoc GUI test 2025-09-05 15:13:08 +02:00
rustdoc-js Add regression test for literal search on paths 2025-09-11 18:05:21 +02:00
rustdoc-js-std tests/rustdoc-js-std/parser-errors.js: remove syntax that is now valid 2025-08-21 20:50:33 -05:00
rustdoc-json Add tests for doc(attribute = "...") attribute 2025-08-28 15:56:30 +02:00
rustdoc-ui Add new ui tests for rustdoc::bare_urls 2025-09-10 18:44:20 +02:00
ui Auto merge of #147056 - dianne:fcw-super-let-init-borrow-shortening, r=jackh726 2025-10-15 01:35:47 +00:00
ui-fulldeps Strip frontmatter in fewer places 2025-09-09 19:49:40 +02:00
COMPILER_TESTS.md