rust/tests
Guillaume Gomez 65479f7353
Rollup merge of #144917 - compiler-errors:tail-call-linked-lifetimes, r=lcnr
Enforce tail call type is related to body return type in borrowck

Like all call terminators, tail call terminators instantiate the binder of the callee signature with region variables and equate the arg operand types with that signature's args to ensure that the call is valid.

However, unlike normal call terminators, we were forgetting to also relate the return type of the call terminator to anything. In the case of tail call terminators, the correct thing is to relate it to the return type of the caller function (or in other words, the return local `_0`).

This meant that if the caller's return type had some lifetime constraint, then that constraint wouldn't flow through the signature and affect the args.

This is what's happening in the example test I committed:

```rust
fn link(x: &str) -> &'static str {
    become passthrough(x);
}

fn passthrough<T>(t: T) -> T { t }

fn main() {
    let x = String::from("hello, world");
    let s = link(&x);
    drop(x);
    println!("{s}");
}
```

Specifically, the type `x` is `'?0 str`, where `'?0` is some *universal* arg. The type of `passthrough` is `fn(&'?1 str) -> &'?1 str`. Equating the args sets `'?0 = '?1`. However, we need to also equate the return type `&'?1 str` to `&'static str` so that we eventually require that `'?0 = 'static`, which is a borrowck error!

-----

Look at the first commit for the functional change, and the second commit is just a refactor because we don't need to pass `Option<BasicBlock>` to `check_call_dest`, but just whether or not the terminator is expected to be diverging (i.e. if the return type is `!`).

Fixes rust-lang/rust#144916
2025-08-06 21:29:29 +02:00
..
assembly-llvm Rollup merge of #144395 - folkertdev:fortanix-run-make-test, r=jieyouxu 2025-08-02 11:24:23 +02:00
auxiliary So many test updates x_x 2025-07-20 10:15:14 -07:00
codegen-llvm Preserve the .debug_gdb_scripts section 2025-08-05 10:55:07 +02:00
codegen-units Auto merge of #142893 - Mark-Simulacrum:no-const-collect, r=oli-obk 2025-06-27 12:57:05 +00:00
coverage coverage: Remove -Zcoverage-options=no-mir-spans 2025-08-04 13:48:40 +10:00
coverage-run-rustdoc
crashes Auto merge of #144405 - lcnr:hir-typeck-uniquify, r=BoxyUwU 2025-07-31 00:32:55 +00:00
debuginfo Embed GDB pretty printers in rlibs and dylibs 2025-08-06 13:24:43 +02:00
incremental Bless incremental tests. 2025-07-13 13:50:01 +00:00
mir-opt Dont print arg span in MIR dump for tail call 2025-08-04 18:35:43 +00:00
pretty expand: Micro-optimize prelude injection 2025-07-28 17:35:09 +03:00
run-make Preserve the .debug_gdb_scripts section 2025-08-05 10:55:07 +02:00
rustdoc Rollup merge of #143662 - obi1kenobi:pg/unsafe-attribute-wrappers, r=t-rustdoc 2025-08-02 11:24:21 +02:00
rustdoc-gui Add GUI regression test for tooltips i icons 2025-08-04 19:17:08 +02:00
rustdoc-js Add test for aliases partial match 2025-07-16 14:27:22 +02:00
rustdoc-js-std Add test for aliases partial match 2025-07-16 14:27:22 +02:00
rustdoc-json rustdoc-json: Move #[macro_export] from Other to it's own variant 2025-07-30 19:57:32 +00:00
rustdoc-ui Rollup merge of #132748 - lolbinarycat:rustdoc-intra-doc-link-warn-more-54191, r=GuillaumeGomez 2025-08-02 11:24:20 +02:00
ui Rollup merge of #144917 - compiler-errors:tail-call-linked-lifetimes, r=lcnr 2025-08-06 21:29:29 +02:00
ui-fulldeps use RustcPublic instead of StableMir 2025-07-18 18:49:32 +00:00
COMPILER_TESTS.md