Skip to content

Commit

Permalink
Unrolled build for rust-lang#128843
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#128843 - veera-sivarajan:small-cleanup, r=davidtwco

Minor Refactor: Remove a Redundant Conditional Check

The existing code checks `where_bounds.is_empty()` twice when
it can be combined into one. Now, after combining, the refactored code reads
better and feels straightforward.

The diff doesn't make it clear. So, the current code looks like this:
``` rust
    if !where_bounds.is_empty() {
        err.help(format!(
            "consider introducing a new type parameter `T` and adding `where` constraints:\
             \n    where\n        T: {qself_str},\n{}",
            where_bounds.join(",\n"),
        ));
    }
    let reported = err.emit();
    if !where_bounds.is_empty() {
        return Err(reported);
    }
```
The proposed changes:
``` rust
    if !where_bounds.is_empty() {
        err.help(format!(
            "consider introducing a new type parameter `T` and adding `where` constraints:\
             \n    where\n        T: {qself_str},\n{}",
            where_bounds.join(",\n"),
        ));
        let reported = err.emit();
        return Err(reported);
    }
    err.emit();

```
  • Loading branch information
rust-timer authored Aug 21, 2024
2 parents 982c6f8 + 1350a65 commit f0490a5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,11 +959,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
\n where\n T: {qself_str},\n{}",
where_bounds.join(",\n"),
));
}
let reported = err.emit();
if !where_bounds.is_empty() {
let reported = err.emit();
return Err(reported);
}
err.emit();
}

Ok(bound)
Expand Down

0 comments on commit f0490a5

Please sign in to comment.