Use fewer origins when creating type variables.
`InferCtxt::next_{ty,const}_var*` all take an origin, but the
`param_def_id` is almost always `None`. This commit changes them to just
take a `Span` and build the origin within the method, and adds new
methods for the rare cases where `param_def_id` might not be `None`.
This avoids a lot of tedious origin building.
Specifically:
- next_ty_var{,_id_in_universe,_in_universe}: now take `Span` instead of
`TypeVariableOrigin`
- next_ty_var_with_origin: added
- next_const_var{,_in_universe}: takes Span instead of ConstVariableOrigin
- next_const_var_with_origin: added
- next_region_var, next_region_var_in_universe: these are unchanged,
still take RegionVariableOrigin
The API inconsistency (ty/const vs region) seems worth it for the
large conciseness improvements.
This commit is contained in:
@@ -18,7 +18,6 @@ use rustc_middle::traits::ImplSource;
|
||||
use rustc_middle::traits::ImplSourceUserDefinedData;
|
||||
|
||||
use crate::errors::InherentProjectionNormalizationOverflow;
|
||||
use crate::infer::type_variable::TypeVariableOrigin;
|
||||
use crate::infer::{BoundRegionConversionTime, InferOk};
|
||||
use crate::traits::normalize::normalize_with_depth;
|
||||
use crate::traits::normalize::normalize_with_depth_to;
|
||||
@@ -521,10 +520,7 @@ fn normalize_to_error<'a, 'tcx>(
|
||||
predicate: trait_ref.to_predicate(selcx.tcx()),
|
||||
};
|
||||
let tcx = selcx.infcx.tcx;
|
||||
let new_value = selcx.infcx.next_ty_var(TypeVariableOrigin {
|
||||
param_def_id: None,
|
||||
span: tcx.def_span(projection_ty.def_id),
|
||||
});
|
||||
let new_value = selcx.infcx.next_ty_var(tcx.def_span(projection_ty.def_id));
|
||||
Normalized { value: new_value, obligations: vec![trait_obligation] }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user