Skip to content

Commit 48c9864

Browse files
authored
Rollup merge of #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(); ```
2 parents dea325e + 1350a65 commit 48c9864

File tree

1 file changed

+2
-3
lines changed
  • compiler/rustc_hir_analysis/src/hir_ty_lowering

1 file changed

+2
-3
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -959,11 +959,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
959959
\n where\n T: {qself_str},\n{}",
960960
where_bounds.join(",\n"),
961961
));
962-
}
963-
let reported = err.emit();
964-
if !where_bounds.is_empty() {
962+
let reported = err.emit();
965963
return Err(reported);
966964
}
965+
err.emit();
967966
}
968967

969968
Ok(bound)

0 commit comments

Comments
 (0)