From 1e9d5c70c1c435cd9ae217ab0adbb053e643b01f Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Wed, 11 Nov 2020 20:16:31 -0500 Subject: [PATCH] Minor stylistic / review changes --- compiler/rustc_typeck/src/check/mod.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index 67592fa7840..04cf1bd5b25 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -525,27 +525,23 @@ fn typeck_with_fallback<'tcx>( let expected_args = if let ImplicitSelfKind::None = decl.implicit_self { 1 } else { 2 }; let err = || { - if let Node::Item(item) = tcx.hir().get(id) { - if let hir::ItemKind::Fn(header, ..) = &item.kind { - tcx.sess.span_err(header.span, "A function with the \"rust-call\" ABI must take a single non-self argument that is a tuple") - } + let item = tcx.hir().expect_item(id); + + if let hir::ItemKind::Fn(header, ..) = &item.kind { + tcx.sess.span_err(header.span, "A function with the \"rust-call\" ABI must take a single non-self argument that is a tuple") } else { - bug!("Couldn't get span of FnHeader being checked") + bug!("Item being checked wasn't a function") } }; if fn_sig.inputs().len() != expected_args { err() } else { - match fn_sig.inputs()[expected_args - 1].kind() { - ty::Tuple(_) => (), - // FIXME(CraftSpider) Add a check on parameter expansion, so we don't just make the ICE happen later on - // This will probably require wide-scale changes to support a TupleKind obligation - // We can't resolve this without knowing the type of the param - ty::Param(_) => (), - _ => { - err() - } + // FIXME(CraftSpider) Add a check on parameter expansion, so we don't just make the ICE happen later on + // This will probably require wide-scale changes to support a TupleKind obligation + // We can't resolve this without knowing the type of the param + if !matches!(fn_sig.inputs()[expected_args - 1].kind(), ty::Tuple(_) | ty::Param(_)) { + err() } } }