@@ -16,8 +16,8 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
1616use rustc_data_structures:: undo_log:: { Rollback , UndoLogs } ;
1717use rustc_data_structures:: unify as ut;
1818use rustc_errors:: { DiagCtxtHandle , ErrorGuaranteed } ;
19- use rustc_hir as hir;
2019use rustc_hir:: def_id:: { DefId , LocalDefId } ;
20+ use rustc_hir:: { self as hir, HirId } ;
2121use rustc_index:: IndexVec ;
2222use rustc_macros:: extension;
2323pub use rustc_macros:: { TypeFoldable , TypeVisitable } ;
@@ -39,6 +39,7 @@ use tracing::{debug, instrument};
3939use type_variable:: TypeVariableOrigin ;
4040
4141use crate :: infer:: snapshot:: undo_log:: UndoLog ;
42+ use crate :: infer:: type_variable:: FloatVariableOrigin ;
4243use crate :: infer:: unify_key:: { ConstVariableOrigin , ConstVariableValue , ConstVidKey } ;
4344use crate :: traits:: {
4445 self , ObligationCause , ObligationInspector , PredicateObligation , PredicateObligations ,
@@ -109,9 +110,10 @@ pub struct InferCtxtInner<'tcx> {
109110 /// Map from floating variable to the kind of float it represents.
110111 float_unification_storage : ut:: UnificationTableStorage < ty:: FloatVid > ,
111112
112- /// Map from floating variable to the origin span it came from. This is only used for the FCW
113- /// for the fallback to `f32`, so can be removed once the `f32` fallback is removed.
114- float_origin_span_storage : IndexVec < FloatVid , Span > ,
113+ /// Map from floating variable to the origin span it came from, and the HirId that should be
114+ /// used to lint at that location. This is only used for the FCW for the fallback to `f32`,
115+ /// so can be removed once the `f32` fallback is removed.
116+ float_origin_origin_storage : IndexVec < FloatVid , FloatVariableOrigin > ,
115117
116118 /// Tracks the set of region variables and the constraints between them.
117119 ///
@@ -166,7 +168,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
166168 const_unification_storage : Default :: default ( ) ,
167169 int_unification_storage : Default :: default ( ) ,
168170 float_unification_storage : Default :: default ( ) ,
169- float_origin_span_storage : Default :: default ( ) ,
171+ float_origin_origin_storage : Default :: default ( ) ,
170172 region_constraint_storage : Some ( Default :: default ( ) ) ,
171173 region_obligations : Default :: default ( ) ,
172174 region_assumptions : Default :: default ( ) ,
@@ -653,8 +655,8 @@ impl<'tcx> InferCtxt<'tcx> {
653655 /// Returns the origin of the float type variable identified by `vid`.
654656 ///
655657 /// No attempt is made to resolve `vid` to its root variable.
656- pub fn float_var_origin ( & self , vid : FloatVid ) -> Span {
657- self . inner . borrow_mut ( ) . float_origin_span_storage [ vid]
658+ pub fn float_var_origin ( & self , vid : FloatVid ) -> FloatVariableOrigin {
659+ self . inner . borrow_mut ( ) . float_origin_origin_storage [ vid]
658660 }
659661
660662 /// Returns the origin of the const variable identified by `vid`
@@ -834,10 +836,11 @@ impl<'tcx> InferCtxt<'tcx> {
834836 Ty :: new_int_var ( self . tcx , next_int_var_id)
835837 }
836838
837- pub fn next_float_var ( & self , span : Span ) -> Ty < ' tcx > {
839+ pub fn next_float_var ( & self , span : Span , lint_id : Option < HirId > ) -> Ty < ' tcx > {
838840 let mut inner = self . inner . borrow_mut ( ) ;
839841 let next_float_var_id = inner. float_unification_table ( ) . new_key ( ty:: FloatVarValue :: Unknown ) ;
840- let span_index = inner. float_origin_span_storage . push ( span) ;
842+ let origin = FloatVariableOrigin { span, lint_id } ;
843+ let span_index = inner. float_origin_origin_storage . push ( origin) ;
841844 debug_assert_eq ! ( next_float_var_id, span_index) ;
842845 Ty :: new_float_var ( self . tcx , next_float_var_id)
843846 }
0 commit comments