diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-05-10 09:06:47 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-05-10 09:47:46 +1000 |
| commit | fe843feaabfd48fa5ed7e10f00a9d22bb64a20ef (patch) | |
| tree | cac7f74bc610e4da2445dfbcd130c2a9bb1ec03c /compiler/rustc_trait_selection/src/solve/normalize.rs | |
| parent | 11f2ca340c427e0ce5e2e0288595ae7900a5e545 (diff) | |
| download | rust-fe843feaabfd48fa5ed7e10f00a9d22bb64a20ef.tar.gz rust-fe843feaabfd48fa5ed7e10f00a9d22bb64a20ef.zip | |
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.
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve/normalize.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/normalize.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/normalize.rs b/compiler/rustc_trait_selection/src/solve/normalize.rs index 65ef4659907..cd1add9e0fa 100644 --- a/compiler/rustc_trait_selection/src/solve/normalize.rs +++ b/compiler/rustc_trait_selection/src/solve/normalize.rs @@ -3,11 +3,9 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt; use crate::traits::{BoundVarReplacer, PlaceholderReplacer}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_infer::infer::at::At; -use rustc_infer::infer::type_variable::TypeVariableOrigin; use rustc_infer::infer::InferCtxt; use rustc_infer::traits::TraitEngineExt; use rustc_infer::traits::{FulfillmentError, Obligation, TraitEngine}; -use rustc_middle::infer::unify_key::ConstVariableOrigin; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::{self, AliasTy, Ty, TyCtxt, UniverseIndex}; use rustc_middle::ty::{FallibleTypeFolder, TypeFolder, TypeSuperFoldable}; @@ -74,8 +72,7 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> { self.depth += 1; - let new_infer_ty = - infcx.next_ty_var(TypeVariableOrigin { param_def_id: None, span: self.at.cause.span }); + let new_infer_ty = infcx.next_ty_var(self.at.cause.span); let obligation = Obligation::new( tcx, self.at.cause.clone(), @@ -120,10 +117,7 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> { self.depth += 1; - let new_infer_ct = infcx.next_const_var( - ty, - ConstVariableOrigin { param_def_id: None, span: self.at.cause.span }, - ); + let new_infer_ct = infcx.next_const_var(ty, self.at.cause.span); let obligation = Obligation::new( tcx, self.at.cause.clone(), |
