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/inspect | |
| 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/inspect')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/inspect/analyse.rs | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs index fa4323a3a94..e6760837937 100644 --- a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs +++ b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs @@ -12,10 +12,8 @@ use rustc_ast_ir::try_visit; use rustc_ast_ir::visit::VisitorResult; use rustc_infer::infer::resolve::EagerResolver; -use rustc_infer::infer::type_variable::TypeVariableOrigin; use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk}; use rustc_macros::extension; -use rustc_middle::infer::unify_key::ConstVariableOrigin; use rustc_middle::traits::query::NoSolution; use rustc_middle::traits::solve::{inspect, QueryResult}; use rustc_middle::traits::solve::{Certainty, Goal}; @@ -201,15 +199,8 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> { .map(|(source, goal)| match goal.predicate.kind().no_bound_vars() { Some(ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })) => { let unconstrained_term = match term.unpack() { - ty::TermKind::Ty(_) => infcx - .next_ty_var(TypeVariableOrigin { param_def_id: None, span }) - .into(), - ty::TermKind::Const(ct) => infcx - .next_const_var( - ct.ty(), - ConstVariableOrigin { param_def_id: None, span }, - ) - .into(), + ty::TermKind::Ty(_) => infcx.next_ty_var(span).into(), + ty::TermKind::Const(ct) => infcx.next_const_var(ct.ty(), span).into(), }; let goal = goal.with(infcx.tcx, ty::NormalizesTo { alias, term: unconstrained_term }); |
