Skip to content

Commit b4db342

Browse files
Rollup merge of #79325 - LingMan:try_op, r=jonas-schievink
Reduce boilerplate with the `?` operator `@rustbot` modify labels to +C-cleanup.
2 parents 32be3ae + e0871cc commit b4db342

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

compiler/rustc_builtin_macros/src/format_foreign.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -649,17 +649,13 @@ pub mod shell {
649649
impl<'a> Iterator for Substitutions<'a> {
650650
type Item = Substitution<'a>;
651651
fn next(&mut self) -> Option<Self::Item> {
652-
match parse_next_substitution(self.s) {
653-
Some((mut sub, tail)) => {
654-
self.s = tail;
655-
if let Some(InnerSpan { start, end }) = sub.position() {
656-
sub.set_position(start + self.pos, end + self.pos);
657-
self.pos += end;
658-
}
659-
Some(sub)
660-
}
661-
None => None,
652+
let (mut sub, tail) = parse_next_substitution(self.s)?;
653+
self.s = tail;
654+
if let Some(InnerSpan { start, end }) = sub.position() {
655+
sub.set_position(start + self.pos, end + self.pos);
656+
self.pos += end;
662657
}
658+
Some(sub)
663659
}
664660

665661
fn size_hint(&self) -> (usize, Option<usize>) {

compiler/rustc_trait_selection/src/traits/select/mod.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -2372,13 +2372,9 @@ impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
23722372
type Item = &'o TraitObligationStack<'o, 'tcx>;
23732373

23742374
fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
2375-
match self.head {
2376-
Some(o) => {
2377-
*self = o.previous;
2378-
Some(o)
2379-
}
2380-
None => None,
2381-
}
2375+
let o = self.head?;
2376+
*self = o.previous;
2377+
Some(o)
23822378
}
23832379
}
23842380

0 commit comments

Comments
 (0)