Make user_provided_sigs a LocalDefIdMap.

This commit is contained in:
Camille GILLOT 2022-11-06 18:11:32 +00:00
parent 290f0781b4
commit 2c4b0b29cf
4 changed files with 10 additions and 8 deletions

View File

@ -42,8 +42,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
user_provided_sig = None; user_provided_sig = None;
} else { } else {
let typeck_results = self.tcx().typeck(mir_def_id); 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_sig =
|user_provided_poly_sig| { typeck_results.user_provided_sigs.get(&mir_def_id).map(|user_provided_poly_sig| {
// Instantiate the canonicalized variables from // Instantiate the canonicalized variables from
// user-provided signature (e.g., the `_` in the code // user-provided signature (e.g., the `_` in the code
// above) with fresh variables. // above) with fresh variables.
@ -60,8 +60,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
LateBoundRegionConversionTime::FnCall, LateBoundRegionConversionTime::FnCall,
poly_sig, poly_sig,
) )
}, });
);
} }
debug!(?normalized_input_tys, ?body.local_decls); debug!(?normalized_input_tys, ?body.local_decls);

View File

@ -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 result = self.normalize_associated_types_in(self.tcx.hir().span(hir_id), result);
let c_result = self.inh.infcx.canonicalize_response(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 result
} }

View File

@ -514,7 +514,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
for (&def_id, c_sig) in fcx_typeck_results.user_provided_sigs.iter() { for (&def_id, c_sig) in fcx_typeck_results.user_provided_sigs.iter() {
if cfg!(debug_assertions) && c_sig.needs_infer() { if cfg!(debug_assertions) && c_sig.needs_infer() {
span_bug!( span_bug!(
self.fcx.tcx.hir().span_if_local(def_id).unwrap(), self.fcx.tcx.def_span(def_id),
"writeback: `{:?}` has inference variables", "writeback: `{:?}` has inference variables",
c_sig c_sig
); );

View File

@ -41,7 +41,7 @@ use rustc_errors::{
}; };
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res}; 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::definitions::Definitions;
use rustc_hir::hir_id::OwnerId; use rustc_hir::hir_id::OwnerId;
use rustc_hir::intravisit::Visitor; use rustc_hir::intravisit::Visitor;
@ -443,7 +443,7 @@ pub struct TypeckResults<'tcx> {
/// Stores the canonicalized types provided by the user. See also /// Stores the canonicalized types provided by the user. See also
/// `AscribeUserType` statement in MIR. /// `AscribeUserType` statement in MIR.
pub user_provided_sigs: DefIdMap<CanonicalPolyFnSig<'tcx>>, pub user_provided_sigs: LocalDefIdMap<CanonicalPolyFnSig<'tcx>>,
adjustments: ItemLocalMap<Vec<ty::adjustment::Adjustment<'tcx>>>, adjustments: ItemLocalMap<Vec<ty::adjustment::Adjustment<'tcx>>>,