Skip to content

Remove some unnecessary try-related type annotations#151887

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
scottmcm:homogeneous-try-in-compiler
Feb 8, 2026
Merged

Remove some unnecessary try-related type annotations#151887
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
scottmcm:homogeneous-try-in-compiler

Conversation

@scottmcm
Copy link
Member

I left a few, like

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.

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 seeing the type would be better.
@rustbot
Copy link
Collaborator

rustbot commented Jan 31, 2026

Some changes occurred in need_type_info.rs

cc @lcnr

@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 Jan 31, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 31, 2026

r? @jackh726

rustbot has assigned @jackh726.
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

}
}
}
.unwrap_or_default()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annot: the whitespace changed here, so you might want the ignore whitespace diff for this function.


let generics = tcx.generics_of(def_id);
let segment: Option<_> = try {
if !segment.infer_args || generics.has_impl_trait() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old code seems simpler.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this one didn't have any ? inside the try, my instinct was that just using None instead of do yeet; was more direct.

@Zalathar
Copy link
Member

I think that in a lot of the io::Result<()> cases, having the explicit type is clearer than not having it, and removing the type doesn't really gain any simplicity.

@jackh726
Copy link
Member

jackh726 commented Feb 8, 2026

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 8, 2026

📌 Commit f7931c8 has been approved by jackh726

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 8, 2026
rust-bors bot pushed a commit that referenced this pull request Feb 8, 2026
Rollup of 5 pull requests

Successful merges:

 - #150443 (Support long diff conflict markers)
 - #151887 (Remove some unnecessary `try`-related type annotations)
 - #152037 (Suppress unused_mut lint if mutation fails due to borrowck error)
 - #152067 (Weaken `assert_dep_node_not_yet_allocated_in_current_session` for multiple threads)
 - #151227 (Document `-Zcache-proc-macros`)
@rust-bors rust-bors bot merged commit 68f4a99 into rust-lang:main Feb 8, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 8, 2026
rust-timer added a commit that referenced this pull request Feb 8, 2026
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.
@scottmcm scottmcm deleted the homogeneous-try-in-compiler branch February 8, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants