rust/tests
Michael Goulet ca9f615525
Rollup merge of #137303 - compiler-errors:maybe-forgor, r=cjgillot
Remove `MaybeForgetReturn` suggestion

#115196 implemented a suggestion to add a missing `return` when there is an ambiguity error, when that ambiguity error could be constrained by the return type of the function.

I initially reviewed it and thought it could be useful; however, looking back at that code now, I feel like it's a bit too much of a hack to be worth keeping around in typeck, especially given how rare it's expected to fire in practice. This is especially true because it depends on `StashKey::MaybeForgetReturn`, which is only stashed when we have *Sized* obligation ambiguity errors. Let's remove it for now.

I'd like to note that it's basically impossible to get this suggestion to apply in its current state except for what I'd consider somewhat artificial examples, involving no generic trait bounds. For example, it's not triggered for:

```rust
struct W<T>(T);

fn bar<T: Default>() -> W<T> { todo!() }

fn foo() -> W<i32> {
    if true {
        bar();
    }
    W(0)
}
```

Nor is it triggered for:

```
fn foo() -> i32 {
    if true {
        Default::default();
    }
    0
}
```

It's basically only triggered iff there's only one ambiguity error on the type, which is `Sized`.

Generally, suggesting something that affects control flow is a pretty dramatic suggestion; therefore, both the accuracy and precision of this diagnostic should be pretty high.

One other, somewhat unrelated observation is that this might be using stashed diagnostics incorrectly (or at least unnecessarily). Stashed diagnostics are used when error detection is fragmented over several major stages of the compiler, like a parse or resolver error which later can be recovered in typeck. However, this one is a bit different since it is fully handled within typeck -- perhaps that suggests that if this were to be reimplemented, it wouldn't need to be so complicated of an implementation.
2025-03-06 12:22:10 -05:00
..
assembly Rollup merge of #136938 - mustartt:fix-stack-protector-filecheck, r=Mark-Simulacrum 2025-03-03 10:40:58 +01:00
auxiliary tests: use minicore more 2025-02-24 09:26:54 +00:00
codegen Hide the end of ranges in pretty printing if it's also the maximum of the type 2025-03-06 10:50:23 +00:00
codegen-units Remove -Zinline-in-all-cgus and clean up CGU partitioning tests 2025-01-27 23:48:47 -05:00
coverage coverage: Add some more cases to tests/coverage/holes.rs 2025-02-19 13:56:20 +11:00
coverage-run-rustdoc
crashes Rollup merge of #138028 - workingjubilee:is-rustic-abi, r=compiler-errors 2025-03-05 21:46:46 +08:00
debuginfo Delete tuple unsizing 2025-02-27 10:26:33 +00:00
incremental remove most simd_ intrinsic declaration in tests 2025-02-27 12:22:59 +01:00
mir-opt Hide the end of ranges in pretty printing if it's also the maximum of the type 2025-03-06 10:50:23 +00:00
pretty Implement &pin const self and &pin mut self sugars 2025-03-05 22:37:53 +08:00
run-make Rollup merge of #136581 - jieyouxu:makefile-be-gone, r=Kobzol 2025-03-05 21:46:32 +08:00
rustdoc Move "unused_exter_crate" test from rustdoc-ui to rustdoc 2025-02-27 13:22:46 +00:00
rustdoc-gui Rollup merge of #137539 - GuillaumeGomez:copy-content-tests, r=notriddle 2025-02-25 13:07:34 +01:00
rustdoc-js Rollup merge of #134277 - notriddle:notriddle/inline-into, r=GuillaumeGomez 2024-12-16 20:00:20 +01:00
rustdoc-js-std Remove the common prelude module 2025-02-11 13:04:27 -08:00
rustdoc-json Always allow rustdoc-json tests to contain long lines 2025-03-03 19:59:54 +01:00
rustdoc-ui Don't typeck during WF, instead check outside of WF in check_crate 2025-03-03 23:09:42 +00:00
ui Rollup merge of #137303 - compiler-errors:maybe-forgor, r=cjgillot 2025-03-06 12:22:10 -05:00
ui-fulldeps Rollup merge of #136865 - jieyouxu:long-type-path-compare-mode, r=lqd 2025-03-05 21:46:35 +08:00
COMPILER_TESTS.md