Skip to content

Commit 05ce209

Browse files
committed
Rename some normalization-related items
1 parent 5af2130 commit 05ce209

File tree

6 files changed

+51
-40
lines changed

6 files changed

+51
-40
lines changed

compiler/rustc_middle/src/arena.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ macro_rules! arena_types {
4747
rustc_middle::traits::query::DropckOutlivesResult<'tcx>
4848
>
4949
>,
50-
[] normalize_projection_ty:
50+
[] normalize_canonicalized_projection_ty:
5151
rustc_middle::infer::canonical::Canonical<'tcx,
5252
rustc_middle::infer::canonical::QueryResponse<'tcx,
5353
rustc_middle::traits::query::NormalizationResult<'tcx>

compiler/rustc_middle/src/query/mod.rs

+22-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::query::plumbing::{
3131
};
3232
use crate::thir;
3333
use crate::traits::query::{
34-
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
34+
CanonicalAliasGoal, CanonicalPredicateGoal, CanonicalTyGoal,
3535
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
3636
CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, NoSolution,
3737
};
@@ -1931,29 +1931,41 @@ rustc_queries! {
19311931
arena_cache
19321932
}
19331933

1934-
/// Do not call this query directly: invoke `normalize` instead.
1935-
query normalize_projection_ty(
1936-
goal: CanonicalProjectionGoal<'tcx>
1934+
/// <div class="warning">
1935+
///
1936+
/// Do not call this query directly: Invoke `normalize` instead.
1937+
///
1938+
/// </div>
1939+
query normalize_canonicalized_projection_ty(
1940+
goal: CanonicalAliasGoal<'tcx>
19371941
) -> Result<
19381942
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
19391943
NoSolution,
19401944
> {
19411945
desc { "normalizing `{}`", goal.value.value }
19421946
}
19431947

1944-
/// Do not call this query directly: invoke `normalize` instead.
1945-
query normalize_weak_ty(
1946-
goal: CanonicalProjectionGoal<'tcx>
1948+
/// <div class="warning">
1949+
///
1950+
/// Do not call this query directly: Invoke `normalize` instead.
1951+
///
1952+
/// </div>
1953+
query normalize_canonicalized_weak_ty(
1954+
goal: CanonicalAliasGoal<'tcx>
19471955
) -> Result<
19481956
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
19491957
NoSolution,
19501958
> {
19511959
desc { "normalizing `{}`", goal.value.value }
19521960
}
19531961

1954-
/// Do not call this query directly: invoke `normalize` instead.
1955-
query normalize_inherent_projection_ty(
1956-
goal: CanonicalProjectionGoal<'tcx>
1962+
/// <div class="warning">
1963+
///
1964+
/// Do not call this query directly: Invoke `normalize` instead.
1965+
///
1966+
/// </div>
1967+
query normalize_canonicalized_inherent_projection_ty(
1968+
goal: CanonicalAliasGoal<'tcx>
19571969
) -> Result<
19581970
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
19591971
NoSolution,

compiler/rustc_middle/src/traits/query.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub mod type_op {
6767
}
6868
}
6969

70-
pub type CanonicalProjectionGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::AliasTy<'tcx>>>;
70+
pub type CanonicalAliasGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::AliasTy<'tcx>>>;
7171

7272
pub type CanonicalTyGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, Ty<'tcx>>>;
7373

@@ -177,10 +177,10 @@ pub struct MethodAutoderefBadTy<'tcx> {
177177
pub ty: Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>,
178178
}
179179

180-
/// Result from the `normalize_projection_ty` query.
180+
/// Result of the `normalize_canonicalized_{{,inherent_}projection,weak}_ty` queries.
181181
#[derive(Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
182182
pub struct NormalizationResult<'tcx> {
183-
/// Result of normalization.
183+
/// Result of the normalization.
184184
pub normalized_ty: Ty<'tcx>,
185185
}
186186

compiler/rustc_trait_selection/src/traits/normalize.rs

-2
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,6 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
355355

356356
let data = data.fold_with(self);
357357

358-
// FIXME(inherent_associated_types): Do we need to honor `self.eager_inference_replacement`
359-
// here like `ty::Projection`?
360358
project::normalize_inherent_projection(
361359
self.selcx,
362360
self.param_env,

compiler/rustc_trait_selection/src/traits/query/normalize.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Code for the 'normalization' query. This consists of a wrapper
22
//! which folds deeply, invoking the underlying
3-
//! `normalize_projection_ty` query when it encounters projections.
3+
//! `normalize_canonicalized_projection_ty` query when it encounters projections.
44
55
use crate::infer::at::At;
66
use crate::infer::canonical::OriginalQueryValues;
@@ -271,9 +271,9 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
271271
debug!("QueryNormalizer: c_data = {:#?}", c_data);
272272
debug!("QueryNormalizer: orig_values = {:#?}", orig_values);
273273
let result = match kind {
274-
ty::Projection => tcx.normalize_projection_ty(c_data),
275-
ty::Weak => tcx.normalize_weak_ty(c_data),
276-
ty::Inherent => tcx.normalize_inherent_projection_ty(c_data),
274+
ty::Projection => tcx.normalize_canonicalized_projection_ty(c_data),
275+
ty::Weak => tcx.normalize_canonicalized_weak_ty(c_data),
276+
ty::Inherent => tcx.normalize_canonicalized_inherent_projection_ty(c_data),
277277
kind => unreachable!("did not expect {kind:?} due to match arm above"),
278278
}?;
279279
// We don't expect ambiguity.
@@ -308,10 +308,10 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
308308
} else {
309309
result.normalized_ty
310310
};
311-
// `tcx.normalize_projection_ty` may normalize to a type that still has
312-
// unevaluated consts, so keep normalizing here if that's the case.
313-
// Similarly, `tcx.normalize_weak_ty` will only unwrap one layer of type
314-
// and we need to continue folding it to reveal the TAIT behind it.
311+
// `tcx.normalize_canonicalized_projection_ty` may normalize to a type that
312+
// still has unevaluated consts, so keep normalizing here if that's the case.
313+
// Similarly, `tcx.normalize_canonicalized_weak_ty` will only unwrap one layer
314+
// of type and we need to continue folding it to reveal the TAIT behind it.
315315
if res != ty
316316
&& (res.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) || kind == ty::Weak)
317317
{

compiler/rustc_traits/src/normalize_projection_ty.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,27 @@ use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
55
use rustc_trait_selection::infer::InferCtxtBuilderExt;
66
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
77
use rustc_trait_selection::traits::query::{
8-
normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution,
8+
normalize::NormalizationResult, CanonicalAliasGoal, NoSolution,
99
};
1010
use rustc_trait_selection::traits::{
1111
self, FulfillmentErrorCode, ObligationCause, SelectionContext,
1212
};
1313

1414
pub(crate) fn provide(p: &mut Providers) {
1515
*p = Providers {
16-
normalize_projection_ty,
17-
normalize_weak_ty,
18-
normalize_inherent_projection_ty,
16+
normalize_canonicalized_projection_ty,
17+
normalize_canonicalized_weak_ty,
18+
normalize_canonicalized_inherent_projection_ty,
1919
..*p
2020
};
2121
}
2222

23-
fn normalize_projection_ty<'tcx>(
23+
fn normalize_canonicalized_projection_ty<'tcx>(
2424
tcx: TyCtxt<'tcx>,
25-
goal: CanonicalProjectionGoal<'tcx>,
25+
goal: CanonicalAliasGoal<'tcx>,
2626
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution> {
27-
debug!("normalize_provider(goal={:#?})", goal);
27+
debug!("normalize_canonicalized_projection_ty(goal={:#?})", goal);
28+
2829
tcx.infer_ctxt().enter_canonical_trait_query(
2930
&goal,
3031
|ocx, ParamEnvAnd { param_env, value: goal }| {
@@ -61,19 +62,19 @@ fn normalize_projection_ty<'tcx>(
6162
return Err(NoSolution);
6263
}
6364

64-
// FIXME(associated_const_equality): All users of normalize_projection_ty expected
65-
// a type, but there is the possibility it could've been a const now. Maybe change
66-
// it to a Term later?
65+
// FIXME(associated_const_equality): All users of normalize_canonicalized_projection_ty
66+
// expected a type, but there is the possibility it could've been a const now.
67+
// Maybe change it to a Term later?
6768
Ok(NormalizationResult { normalized_ty: answer.ty().unwrap() })
6869
},
6970
)
7071
}
7172

72-
fn normalize_weak_ty<'tcx>(
73+
fn normalize_canonicalized_weak_ty<'tcx>(
7374
tcx: TyCtxt<'tcx>,
74-
goal: CanonicalProjectionGoal<'tcx>,
75+
goal: CanonicalAliasGoal<'tcx>,
7576
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution> {
76-
debug!("normalize_provider(goal={:#?})", goal);
77+
debug!("normalize_canonicalized_weak_ty(goal={:#?})", goal);
7778

7879
tcx.infer_ctxt().enter_canonical_trait_query(
7980
&goal,
@@ -95,11 +96,11 @@ fn normalize_weak_ty<'tcx>(
9596
)
9697
}
9798

98-
fn normalize_inherent_projection_ty<'tcx>(
99+
fn normalize_canonicalized_inherent_projection_ty<'tcx>(
99100
tcx: TyCtxt<'tcx>,
100-
goal: CanonicalProjectionGoal<'tcx>,
101+
goal: CanonicalAliasGoal<'tcx>,
101102
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution> {
102-
debug!("normalize_provider(goal={:#?})", goal);
103+
debug!("normalize_canonicalized_inherent_projection_ty(goal={:#?})", goal);
103104

104105
tcx.infer_ctxt().enter_canonical_trait_query(
105106
&goal,

0 commit comments

Comments
 (0)