Skip to content

Commit 78ee167

Browse files
committed
Rename AstConv to HIR ty lowering
This includes updating astconv-related items and a few local variables.
1 parent e61dcc7 commit 78ee167

35 files changed

+350
-381
lines changed

compiler/rustc_hir_analysis/src/astconv/bounds.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use rustc_span::{ErrorGuaranteed, Span};
99
use rustc_trait_selection::traits;
1010
use smallvec::SmallVec;
1111

12-
use crate::astconv::{AstConv, OnlySelfBounds, PredicateFilter};
12+
use crate::astconv::{HirTyLowerer, OnlySelfBounds, PredicateFilter};
1313
use crate::bounds::Bounds;
1414
use crate::errors;
1515

16-
impl<'tcx> dyn AstConv<'tcx> + '_ {
16+
impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1717
/// Sets `implicitly_sized` to true on `Bounds` if necessary
18-
pub(crate) fn add_implicitly_sized(
18+
pub(crate) fn add_sized_bound(
1919
&self,
2020
bounds: &mut Bounds<'tcx>,
2121
self_ty: Ty<'tcx>,
@@ -114,7 +114,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
114114
/// `param_ty` and `ast_bounds`. See `instantiate_poly_trait_ref`
115115
/// for more details.
116116
#[instrument(level = "debug", skip(self, ast_bounds, bounds))]
117-
pub(crate) fn add_bounds<'hir, I: Iterator<Item = &'hir hir::GenericBound<'tcx>>>(
117+
pub(crate) fn lower_poly_bounds<'hir, I: Iterator<Item = &'hir hir::GenericBound<'tcx>>>(
118118
&self,
119119
param_ty: Ty<'tcx>,
120120
ast_bounds: I,
@@ -142,7 +142,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
142142
}
143143
hir::TraitBoundModifier::Maybe => continue,
144144
};
145-
let _ = self.instantiate_poly_trait_ref(
145+
let _ = self.lower_poly_trait_ref(
146146
&poly_trait_ref.trait_ref,
147147
poly_trait_ref.span,
148148
constness,
@@ -154,7 +154,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
154154
);
155155
}
156156
hir::GenericBound::Outlives(lifetime) => {
157-
let region = self.ast_region_to_region(lifetime, None);
157+
let region = self.lower_lifetime(lifetime, None);
158158
bounds.push_region_bound(
159159
self.tcx(),
160160
ty::Binder::bind_with_vars(
@@ -184,7 +184,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
184184
/// example above, but is not true in supertrait listings like `trait Foo: Bar + Baz`.
185185
///
186186
/// `span` should be the declaration size of the parameter.
187-
pub(crate) fn compute_bounds(
187+
pub(crate) fn lower_mono_bounds(
188188
&self,
189189
param_ty: Ty<'tcx>,
190190
ast_bounds: &[hir::GenericBound<'tcx>],
@@ -199,7 +199,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
199199
PredicateFilter::SelfOnly | PredicateFilter::SelfThatDefines(_) => OnlySelfBounds(true),
200200
};
201201

202-
self.add_bounds(
202+
self.lower_poly_bounds(
203203
param_ty,
204204
ast_bounds.iter().filter(|bound| match filter {
205205
PredicateFilter::All
@@ -232,7 +232,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
232232
/// `trait_ref` here will be `for<'a> T: Iterator`. The `binding` data however is from *inside*
233233
/// the binder (e.g., `&'a u32`) and hence may reference bound regions.
234234
#[instrument(level = "debug", skip(self, bounds, speculative, dup_bindings, path_span))]
235-
pub(super) fn add_predicates_for_ast_type_binding(
235+
pub(super) fn lower_assoc_item_binding(
236236
&self,
237237
hir_ref_id: hir::HirId,
238238
trait_ref: ty::PolyTraitRef<'tcx>,
@@ -271,7 +271,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
271271
ty::AssocKind::Type
272272
};
273273

274-
let candidate = if self.trait_defines_associated_item_named(
274+
let candidate = if self.probe_trait_that_defines_assoc_item(
275275
trait_ref.def_id(),
276276
assoc_kind,
277277
binding.ident,
@@ -281,7 +281,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
281281
} else {
282282
// Otherwise, we have to walk through the supertraits to find
283283
// one that does define it.
284-
self.one_bound_for_assoc_item(
284+
self.probe_single_bound_for_assoc_item(
285285
|| traits::supertraits(tcx, trait_ref),
286286
trait_ref.skip_binder().print_only_trait_name(),
287287
None,
@@ -418,7 +418,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
418418
infer_args: false,
419419
};
420420

421-
let alias_args = self.create_args_for_associated_item(
421+
let alias_args = self.lower_generic_args_of_assoc_item(
422422
path_span,
423423
assoc_item.def_id,
424424
&item_segment,
@@ -459,7 +459,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
459459
}
460460
hir::TypeBindingKind::Equality { term } => {
461461
let term = match term {
462-
hir::Term::Ty(ty) => self.ast_ty_to_ty(ty).into(),
462+
hir::Term::Ty(ty) => self.lower_ty(ty).into(),
463463
hir::Term::Const(ct) => ty::Const::from_anon_const(tcx, ct.def_id).into(),
464464
};
465465

@@ -524,7 +524,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
524524
// for the `Self` type.
525525
if !only_self_bounds.0 {
526526
let param_ty = Ty::new_alias(tcx, ty::Projection, projection_ty.skip_binder());
527-
self.add_bounds(
527+
self.lower_poly_bounds(
528528
param_ty,
529529
ast_bounds.iter(),
530530
bounds,

compiler/rustc_hir_analysis/src/astconv/errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::astconv::AstConv;
1+
use crate::astconv::HirTyLowerer;
22
use crate::errors::{
33
self, AssocTypeBindingNotAllowed, ManualImplementation, MissingTypeParams,
44
ParenthesizedFnTraitExpansion,
@@ -22,7 +22,7 @@ use rustc_span::symbol::{sym, Ident};
2222
use rustc_span::{Span, Symbol, DUMMY_SP};
2323
use rustc_trait_selection::traits::object_safety_violations_for_assoc_item;
2424

25-
impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25+
impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
2626
/// On missing type parameters, emit an E0393 error and provide a structured suggestion using
2727
/// the type parameter's name as a placeholder.
2828
pub(crate) fn complain_about_missing_type_params(
@@ -311,7 +311,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
311311
// FIXME(associated_const_equality): This has quite a few false positives and negatives.
312312
let wrap_in_braces_sugg = if let Some(binding) = binding
313313
&& let hir::TypeBindingKind::Equality { term: hir::Term::Ty(hir_ty) } = binding.kind
314-
&& let ty = self.ast_ty_to_ty(hir_ty)
314+
&& let ty = self.lower_ty(hir_ty)
315315
&& (ty.is_enum() || ty.references_error())
316316
&& tcx.features().associated_const_equality
317317
{
@@ -918,7 +918,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
918918
}
919919

920920
/// Emits an error regarding forbidden type binding associations
921-
pub fn prohibit_assoc_ty_binding(
921+
pub fn prohibit_assoc_item_binding(
922922
tcx: TyCtxt<'_>,
923923
span: Span,
924924
segment: Option<(&hir::PathSegment<'_>, Span)>,

compiler/rustc_hir_analysis/src/astconv/generics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::IsMethodCall;
22
use crate::astconv::{
3-
errors::prohibit_assoc_ty_binding, CreateInstantiationsForGenericArgsCtxt, ExplicitLateBound,
4-
GenericArgCountMismatch, GenericArgCountResult, GenericArgPosition,
3+
errors::prohibit_assoc_item_binding, ExplicitLateBound, GenericArgCountMismatch,
4+
GenericArgCountResult, GenericArgPosition, GenericArgsLowerer,
55
};
66
use crate::structured_errors::{GenericArgsInfo, StructuredDiag, WrongNumberOfGenericArgs};
77
use rustc_ast::ast::ParamKindOrd;
@@ -170,14 +170,14 @@ fn generic_arg_mismatch_err(
170170
/// instantiate a `GenericArg`.
171171
/// - `inferred_kind`: if no parameter was provided, and inference is enabled, then
172172
/// creates a suitable inference variable.
173-
pub fn create_args_for_parent_generic_args<'tcx: 'a, 'a>(
173+
pub fn lower_generic_args<'tcx: 'a, 'a>(
174174
tcx: TyCtxt<'tcx>,
175175
def_id: DefId,
176176
parent_args: &[ty::GenericArg<'tcx>],
177177
has_self: bool,
178178
self_ty: Option<Ty<'tcx>>,
179179
arg_count: &GenericArgCountResult,
180-
ctx: &mut impl CreateInstantiationsForGenericArgsCtxt<'a, 'tcx>,
180+
ctx: &mut impl GenericArgsLowerer<'a, 'tcx>,
181181
) -> GenericArgsRef<'tcx> {
182182
// Collect the segments of the path; we need to instantiate arguments
183183
// for parameters throughout the entire path (wherever there are
@@ -458,7 +458,7 @@ pub(crate) fn check_generic_arg_count(
458458
if gen_pos != GenericArgPosition::Type
459459
&& let Some(b) = gen_args.bindings.first()
460460
{
461-
prohibit_assoc_ty_binding(tcx, b.span, None);
461+
prohibit_assoc_item_binding(tcx, b.span, None);
462462
}
463463

464464
let explicit_late_bound =

compiler/rustc_hir_analysis/src/astconv/lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use rustc_lint_defs::{builtin::BARE_TRAIT_OBJECTS, Applicability};
66
use rustc_span::Span;
77
use rustc_trait_selection::traits::error_reporting::suggestions::NextTypeParamName;
88

9-
use super::AstConv;
9+
use super::HirTyLowerer;
1010

11-
impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
11+
impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
1212
/// Make sure that we are in the condition to suggest the blanket implementation.
1313
pub(super) fn maybe_lint_blanket_trait_impl<G: EmissionGuarantee>(
1414
&self,

0 commit comments

Comments
 (0)