X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;ds=sidebyside;f=compiler%2Frustc_mir_build%2Fsrc%2Fbuild%2Fmod.rs;h=9daf68a15f4b1ea4aef695c67f463e6f72514523;hb=e19ae977ec4c8eaccd92c8e16da4ca4d6ca318d5;hp=c785dfb500fc9f93d95b6d6beef972391f0ad6d1;hpb=257edf2de50c9a0d18c86146fb20aa39ff2ff89b;p=rust.git diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index c785dfb500f..1655e224ddb 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -28,10 +28,10 @@ use super::lints; -pub(crate) fn mir_built<'tcx>( - tcx: TyCtxt<'tcx>, +pub(crate) fn mir_built( + tcx: TyCtxt<'_>, def: ty::WithOptConstParam, -) -> &'tcx rustc_data_structures::steal::Steal> { +) -> &rustc_data_structures::steal::Steal> { if let Some(def) = def.try_upgrade(tcx) { return tcx.mir_built(def); } @@ -439,6 +439,10 @@ fn construct_fn<'tcx>( let fn_id = tcx.hir().local_def_id_to_hir_id(fn_def.did); let generator_kind = tcx.generator_kind(fn_def.did); + // The representation of thir for `-Zunpretty=thir-tree` relies on + // the entry expression being the last element of `thir.exprs`. + assert_eq!(expr.as_usize(), thir.exprs.len() - 1); + // Figure out what primary body this item has. let body_id = tcx.hir().body_owned_by(fn_def.did); let span_with_body = tcx.hir().span_with_body(fn_id); @@ -625,19 +629,19 @@ fn construct_const<'a, 'tcx>( /// /// This is required because we may still want to run MIR passes on an item /// with type errors, but normal MIR construction can't handle that in general. -fn construct_error<'tcx>( - tcx: TyCtxt<'tcx>, +fn construct_error( + tcx: TyCtxt<'_>, def: LocalDefId, body_owner_kind: hir::BodyOwnerKind, err: ErrorGuaranteed, -) -> Body<'tcx> { +) -> Body<'_> { let span = tcx.def_span(def); let hir_id = tcx.hir().local_def_id_to_hir_id(def); let generator_kind = tcx.generator_kind(def); let ty = tcx.ty_error(); let num_params = match body_owner_kind { - hir::BodyOwnerKind::Fn => tcx.fn_sig(def).inputs().skip_binder().len(), + hir::BodyOwnerKind::Fn => tcx.fn_sig(def).skip_binder().inputs().skip_binder().len(), hir::BodyOwnerKind::Closure => { let ty = tcx.type_of(def); match ty.kind() {