Skip to content

Commit aa536f4

Browse files
authored
Rollup merge of #42497 - qnighy:just-use-try-in-three-places, r=eddyb
Replace some matches with try. This patch just replaces `match`es with `?` in the compiler, which I came across when I'm reading the parser.
2 parents 3ce88c7 + ab72611 commit aa536f4

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

src/librustc_resolve/macros.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,7 @@ impl<'a> base::Resolver for Resolver<'a> {
285285
-> Result<Option<Rc<SyntaxExtension>>, Determinacy> {
286286
let def = match invoc.kind {
287287
InvocationKind::Attr { attr: None, .. } => return Ok(None),
288-
_ => match self.resolve_invoc_to_def(invoc, scope, force) {
289-
Ok(def) => def,
290-
Err(determinacy) => return Err(determinacy),
291-
},
288+
_ => self.resolve_invoc_to_def(invoc, scope, force)?,
292289
};
293290

294291
self.macro_defs.insert(invoc.expansion_data.mark, def.def_id());

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,10 +1249,7 @@ impl<'a> Parser<'a> {
12491249
let mac = respan(lo.to(self.prev_span), Mac_ { path: pth, tts: tts });
12501250
(keywords::Invalid.ident(), ast::TraitItemKind::Macro(mac))
12511251
} else {
1252-
let (constness, unsafety, abi) = match self.parse_fn_front_matter() {
1253-
Ok(cua) => cua,
1254-
Err(e) => return Err(e),
1255-
};
1252+
let (constness, unsafety, abi) = self.parse_fn_front_matter()?;
12561253

12571254
let ident = self.parse_ident()?;
12581255
let mut generics = self.parse_generics()?;

src/libsyntax/ptr.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,7 @@ impl<T: Encodable> Encodable for P<[T]> {
211211

212212
impl<T: Decodable> Decodable for P<[T]> {
213213
fn decode<D: Decoder>(d: &mut D) -> Result<P<[T]>, D::Error> {
214-
Ok(P::from_vec(match Decodable::decode(d) {
215-
Ok(t) => t,
216-
Err(e) => return Err(e)
217-
}))
214+
Ok(P::from_vec(Decodable::decode(d)?))
218215
}
219216
}
220217

0 commit comments

Comments
 (0)