Skip to content

Commit 4dc876c

Browse files
committed
Rename AstConv to HIR/ty lowering
1 parent 0cbef48 commit 4dc876c

34 files changed

+271
-283
lines changed

compiler/rustc_hir_analysis/src/astconv/bounds.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use rustc_trait_selection::traits;
1010
use smallvec::SmallVec;
1111

1212
use crate::astconv::{
13-
AstConv, ConvertedBinding, ConvertedBindingKind, OnlySelfBounds, PredicateFilter,
13+
HirTyLowerer, LoweredBinding, LoweredBindingKind, OnlySelfBounds, PredicateFilter,
1414
};
1515
use crate::bounds::Bounds;
1616
use crate::errors;
1717

18-
impl<'tcx> dyn AstConv<'tcx> + '_ {
18+
impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1919
/// Sets `implicitly_sized` to true on `Bounds` if necessary
2020
pub(crate) fn add_implicitly_sized(
2121
&self,
@@ -156,7 +156,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
156156
);
157157
}
158158
hir::GenericBound::Outlives(lifetime) => {
159-
let region = self.ast_region_to_region(lifetime, None);
159+
let region = self.lower_region(lifetime, None);
160160
bounds.push_region_bound(
161161
self.tcx(),
162162
ty::Binder::bind_with_vars(
@@ -234,11 +234,11 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
234234
/// `trait_ref` here will be `for<'a> T: Iterator`. The `binding` data however is from *inside*
235235
/// the binder (e.g., `&'a u32`) and hence may reference bound regions.
236236
#[instrument(level = "debug", skip(self, bounds, speculative, dup_bindings, path_span))]
237-
pub(super) fn add_predicates_for_ast_type_binding(
237+
pub(super) fn lower_type_bindings_to_predicates(
238238
&self,
239239
hir_ref_id: hir::HirId,
240240
trait_ref: ty::PolyTraitRef<'tcx>,
241-
binding: &ConvertedBinding<'_, 'tcx>,
241+
binding: &LoweredBinding<'_, 'tcx>,
242242
bounds: &mut Bounds<'tcx>,
243243
speculative: bool,
244244
dup_bindings: &mut FxHashMap<DefId, Span>,
@@ -266,15 +266,15 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
266266
let assoc_kind =
267267
if binding.gen_args.parenthesized == hir::GenericArgsParentheses::ReturnTypeNotation {
268268
ty::AssocKind::Fn
269-
} else if let ConvertedBindingKind::Equality(term) = binding.kind
269+
} else if let LoweredBindingKind::Equality(term) = binding.kind
270270
&& let ty::TermKind::Const(_) = term.node.unpack()
271271
{
272272
ty::AssocKind::Const
273273
} else {
274274
ty::AssocKind::Type
275275
};
276276

277-
let candidate = if self.trait_defines_associated_item_named(
277+
let candidate = if self.trait_defines_assoc_item_named(
278278
trait_ref.def_id(),
279279
assoc_kind,
280280
binding.item_name,
@@ -420,7 +420,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
420420
infer_args: false,
421421
};
422422

423-
let args_trait_ref_and_assoc_item = self.create_args_for_associated_item(
423+
let args_trait_ref_and_assoc_item = self.lower_args_for_assoc_item(
424424
path_span,
425425
assoc_item.def_id,
426426
&item_segment,
@@ -441,7 +441,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
441441
//
442442
// for<'a> <T as Iterator>::Item = &'a str // <-- 'a is bad
443443
// for<'a> <T as FnMut<(&'a u32,)>>::Output = &'a str // <-- 'a is ok
444-
if let ConvertedBindingKind::Equality(ty) = binding.kind {
444+
if let LoweredBindingKind::Equality(ty) = binding.kind {
445445
let late_bound_in_trait_ref =
446446
tcx.collect_constrained_late_bound_regions(&projection_ty);
447447
let late_bound_in_ty =
@@ -471,12 +471,12 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
471471
}
472472

473473
match binding.kind {
474-
ConvertedBindingKind::Equality(..) if let ty::AssocKind::Fn = assoc_kind => {
474+
LoweredBindingKind::Equality(..) if let ty::AssocKind::Fn = assoc_kind => {
475475
return Err(self.tcx().dcx().emit_err(
476476
crate::errors::ReturnTypeNotationEqualityBound { span: binding.span },
477477
));
478478
}
479-
ConvertedBindingKind::Equality(term) => {
479+
LoweredBindingKind::Equality(term) => {
480480
// "Desugar" a constraint like `T: Iterator<Item = u32>` this to
481481
// the "projection predicate" for:
482482
//
@@ -490,7 +490,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
490490
binding.span,
491491
);
492492
}
493-
ConvertedBindingKind::Constraint(ast_bounds) => {
493+
LoweredBindingKind::Constraint(ast_bounds) => {
494494
// "Desugar" a constraint like `T: Iterator<Item: Debug>` to
495495
//
496496
// `<T as Iterator>::Item: Debug`

compiler/rustc_hir_analysis/src/astconv/errors.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::astconv::{AstConv, ConvertedBindingKind};
1+
use crate::astconv::{HirTyLowerer, LoweredBindingKind};
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(
@@ -111,7 +111,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
111111
assoc_kind: ty::AssocKind,
112112
assoc_name: Ident,
113113
span: Span,
114-
binding: Option<&super::ConvertedBinding<'_, 'tcx>>,
114+
binding: Option<&super::LoweredBinding<'_, 'tcx>>,
115115
) -> ErrorGuaranteed
116116
where
117117
I: Iterator<Item = ty::PolyTraitRef<'tcx>>,
@@ -289,13 +289,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
289289
assoc_kind: ty::AssocKind,
290290
ident: Ident,
291291
span: Span,
292-
binding: Option<&super::ConvertedBinding<'_, 'tcx>>,
292+
binding: Option<&super::LoweredBinding<'_, 'tcx>>,
293293
) -> ErrorGuaranteed {
294294
let tcx = self.tcx();
295295

296296
let bound_on_assoc_const_label = if let ty::AssocKind::Const = assoc_item.kind
297297
&& let Some(binding) = binding
298-
&& let ConvertedBindingKind::Constraint(_) = binding.kind
298+
&& let LoweredBindingKind::Constraint(_) = binding.kind
299299
{
300300
let lo = if binding.gen_args.span_ext.is_dummy() {
301301
ident.span
@@ -309,7 +309,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
309309

310310
// FIXME(associated_const_equality): This has quite a few false positives and negatives.
311311
let wrap_in_braces_sugg = if let Some(binding) = binding
312-
&& let ConvertedBindingKind::Equality(term) = binding.kind
312+
&& let LoweredBindingKind::Equality(term) = binding.kind
313313
&& let ty::TermKind::Ty(ty) = term.node.unpack()
314314
&& (ty.is_enum() || ty.references_error())
315315
&& tcx.features().associated_const_equality
@@ -325,7 +325,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
325325
// For equality bounds, we want to blame the term (RHS) instead of the item (LHS) since
326326
// one can argue that that's more “untuitive” to the user.
327327
let (span, expected_because_label, expected, got) = if let Some(binding) = binding
328-
&& let ConvertedBindingKind::Equality(term) = binding.kind
328+
&& let LoweredBindingKind::Equality(term) = binding.kind
329329
{
330330
(term.span, Some(ident.span), assoc_item.kind, assoc_kind)
331331
} else {

compiler/rustc_hir_analysis/src/astconv/generics.rs

Lines changed: 3 additions & 3 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, CreateSubstsForGenericArgsCtxt, ExplicitLateBound,
4-
GenericArgCountMismatch, GenericArgCountResult, GenericArgPosition,
3+
errors::prohibit_assoc_ty_binding, ExplicitLateBound, GenericArgCountMismatch,
4+
GenericArgCountResult, GenericArgPosition, GenericArgsLowerer,
55
};
66
use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
77
use rustc_ast::ast::ParamKindOrd;
@@ -177,7 +177,7 @@ pub fn create_args_for_parent_generic_args<'tcx: 'a, 'a>(
177177
has_self: bool,
178178
self_ty: Option<Ty<'tcx>>,
179179
arg_count: &GenericArgCountResult,
180-
ctx: &mut impl CreateSubstsForGenericArgsCtxt<'a, 'tcx>,
180+
ctx: &mut impl GenericArgsLowerer<'a, 'tcx>,
181181
) -> GenericArgsRef<'tcx> {
182182
// Collect the segments of the path; we need to substitute arguments
183183
// for parameters throughout the entire path (wherever there are

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(
1414
&self,

0 commit comments

Comments
 (0)