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:
@@ -1,5 +1,4 @@
|
||||
use rustc_infer::infer::at::At;
|
||||
use rustc_infer::infer::type_variable::TypeVariableOrigin;
|
||||
use rustc_infer::traits::{FulfillmentError, TraitEngine};
|
||||
use rustc_macros::extension;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
@@ -20,9 +19,7 @@ impl<'tcx> At<'_, 'tcx> {
|
||||
return Ok(ty);
|
||||
};
|
||||
|
||||
let new_infer_ty = self
|
||||
.infcx
|
||||
.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.cause.span });
|
||||
let new_infer_ty = self.infcx.next_ty_var(self.cause.span);
|
||||
|
||||
// We simply emit an `alias-eq` goal here, since that will take care of
|
||||
// normalizing the LHS of the projection until it is a rigid projection
|
||||
|
||||
Reference in New Issue
Block a user