Rollup merge of #151887 - scottmcm:homogeneous-try-in-compiler, r=jackh726

Remove some unnecessary `try`-related type annotations

I left a few, like
```rust
let result: Result<_, ModError<'_>> = try {
```
where it felt like seeing it might still be useful for the reader.

Feel free to push back on any of these changes if you think they should be left alone.
This commit is contained in:
Stuart Cook 2026-02-08 16:58:23 +11:00 committed by GitHub
commit 68f4a99963
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 45 additions and 47 deletions

View file

@ -1844,7 +1844,7 @@ fn compare_synthetic_generics<'tcx>(
// The case where the impl method uses `impl Trait` but the trait method uses
// explicit generics
err.span_label(impl_span, "expected generic parameter, found `impl Trait`");
let _: Option<_> = try {
try {
// try taking the name from the trait impl
// FIXME: this is obviously suboptimal since the name can already be used
// as another generic argument
@ -1881,7 +1881,7 @@ fn compare_synthetic_generics<'tcx>(
// The case where the trait method uses `impl Trait`, but the impl method uses
// explicit generics.
err.span_label(impl_span, "expected `impl Trait`, found generic parameter");
let _: Option<_> = try {
try {
let impl_m = impl_m.def_id.as_local()?;
let impl_m = tcx.hir_expect_impl_item(impl_m);
let (sig, _) = impl_m.expect_fn();