From 2c4b0b29cf5bcfe6f2d21be5f5ad27d832eb85f3 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 6 Nov 2022 18:11:32 +0000 Subject: [PATCH] Make user_provided_sigs a LocalDefIdMap. --- compiler/rustc_borrowck/src/type_check/input_output.rs | 7 +++---- compiler/rustc_hir_typeck/src/closure.rs | 5 ++++- compiler/rustc_hir_typeck/src/writeback.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs index a66ddd27dbb..62c6f958137 100644 --- a/compiler/rustc_borrowck/src/type_check/input_output.rs +++ b/compiler/rustc_borrowck/src/type_check/input_output.rs @@ -42,8 +42,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { user_provided_sig = None; } else { let typeck_results = self.tcx().typeck(mir_def_id); - user_provided_sig = typeck_results.user_provided_sigs.get(&mir_def_id.to_def_id()).map( - |user_provided_poly_sig| { + user_provided_sig = + typeck_results.user_provided_sigs.get(&mir_def_id).map(|user_provided_poly_sig| { // Instantiate the canonicalized variables from // user-provided signature (e.g., the `_` in the code // above) with fresh variables. @@ -60,8 +60,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { LateBoundRegionConversionTime::FnCall, poly_sig, ) - }, - ); + }); } debug!(?normalized_input_tys, ?body.local_decls); diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index 3001e799476..7a881acee42 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -664,7 +664,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let result = self.normalize_associated_types_in(self.tcx.hir().span(hir_id), result); let c_result = self.inh.infcx.canonicalize_response(result); - self.typeck_results.borrow_mut().user_provided_sigs.insert(expr_def_id, c_result); + self.typeck_results + .borrow_mut() + .user_provided_sigs + .insert(expr_def_id.expect_local(), c_result); result } diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index 1e26daa9c2c..2eca40d678a 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -514,7 +514,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { for (&def_id, c_sig) in fcx_typeck_results.user_provided_sigs.iter() { if cfg!(debug_assertions) && c_sig.needs_infer() { span_bug!( - self.fcx.tcx.hir().span_if_local(def_id).unwrap(), + self.fcx.tcx.def_span(def_id), "writeback: `{:?}` has inference variables", c_sig ); diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 8f96f5a9eb3..1c714f59425 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -41,7 +41,7 @@ use rustc_errors::{ }; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE}; +use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, LOCAL_CRATE}; use rustc_hir::definitions::Definitions; use rustc_hir::hir_id::OwnerId; use rustc_hir::intravisit::Visitor; @@ -443,7 +443,7 @@ pub struct TypeckResults<'tcx> { /// Stores the canonicalized types provided by the user. See also /// `AscribeUserType` statement in MIR. - pub user_provided_sigs: DefIdMap>, + pub user_provided_sigs: LocalDefIdMap>, adjustments: ItemLocalMap>>,