Skip to content

Commit

Permalink
Auto merge of rust-lang#120926 - fmease:astconv-no-mo, r=oli-obk
Browse files Browse the repository at this point in the history
[MCP 723] Rename `astconv::AstConv` and related items

See rust-lang/compiler-team#723.
Corresponding rustc-dev-guide PR: rust-lang/rustc-dev-guide#1916.

Please consult the following *normative* list of changes here:
https://fmease.dev/rustc-dev/astconv-no-mo.html ([2024-03-22 archive link](https://web.archive.org/web/20240322054711/https://fmease.dev/rustc-dev/astconv-no-mo.html)).
  • Loading branch information
bors committed Mar 22, 2024
2 parents eb80be2 + 5e73a8b commit eff958c
Show file tree
Hide file tree
Showing 57 changed files with 875 additions and 830 deletions.
4 changes: 0 additions & 4 deletions compiler/rustc_ast/src/ast.rs
Expand Up @@ -303,10 +303,6 @@ impl TraitBoundModifiers {
};
}

/// The AST represents all type param bounds as types.
/// `typeck::collect::compute_bounds` matches these against
/// the "special" built-in traits (see `middle::lang_items`) and
/// detects `Copy`, `Send` and `Sync`.
#[derive(Clone, Encodable, Decodable, Debug)]
pub enum GenericBound {
Trait(PolyTraitRef, TraitBoundModifiers),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/visit.rs
Expand Up @@ -480,7 +480,7 @@ pub fn walk_use_tree<'a, V: Visitor<'a>>(
try_visit!(visitor.visit_path(&use_tree.prefix, id));
match use_tree.kind {
UseTreeKind::Simple(rename) => {
// The extra IDs are handled during HIR lowering.
// The extra IDs are handled during AST lowering.
visit_opt!(visitor, visit_ident, rename);
}
UseTreeKind::Glob => {}
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_ast_lowering/src/delegation.rs
Expand Up @@ -29,11 +29,12 @@
//! item id (`item_id`) in case of impl trait or path resolution id (`path_id`) otherwise.
//!
//! Since we do not have a proper way to obtain function type information by path resolution
//! in AST, we mark each function parameter type as `InferDelegation` and inherit it in `AstConv`.
//! in AST, we mark each function parameter type as `InferDelegation` and inherit it during
//! HIR ty lowering.
//!
//! Similarly generics, predicates and header are set to the "default" values.
//! In case of discrepancy with callee function the `NotSupportedDelegation` error will
//! also be emitted in `AstConv`.
//! also be emitted during HIR ty lowering.

use crate::{ImplTraitPosition, ResolverAstLoweringExt};

Expand Down Expand Up @@ -129,7 +130,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
) -> &'hir hir::FnDecl<'hir> {
let args_count = if let Some(local_sig_id) = sig_id.as_local() {
// Map may be filled incorrectly due to recursive delegation.
// Error will be emmited later in astconv.
// Error will be emitted later during HIR ty lowering.
self.resolver.fn_parameter_counts.get(&local_sig_id).cloned().unwrap_or_default()
} else {
self.tcx.fn_arg_names(sig_id).len()
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/item.rs
Expand Up @@ -1427,8 +1427,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
// Error if `?Trait` bounds in where clauses don't refer directly to type parameters.
// Note: we used to clone these bounds directly onto the type parameter (and avoid lowering
// these into hir when we lower thee where clauses), but this makes it quite difficult to
// keep track of the Span info. Now, `add_implicitly_sized` in `AstConv` checks both param bounds and
// where clauses for `?Sized`.
// keep track of the Span info. Now, `<dyn HirTyLowerer>::add_implicit_sized_bound`
// checks both param bounds and where clauses for `?Sized`.
for pred in &generics.where_clause.predicates {
let WherePredicate::BoundPredicate(bound_pred) = pred else {
continue;
Expand Down
8 changes: 2 additions & 6 deletions compiler/rustc_hir/src/hir.rs
Expand Up @@ -428,10 +428,6 @@ pub enum TraitBoundModifier {
MaybeConst,
}

/// The AST represents all type param bounds as types.
/// `typeck::collect::compute_bounds` matches these against
/// the "special" built-in traits (see `middle::lang_items`) and
/// detects `Copy`, `Send` and `Sync`.
#[derive(Clone, Copy, Debug, HashStable_Generic)]
pub enum GenericBound<'hir> {
Trait(PolyTraitRef<'hir>, TraitBoundModifier),
Expand Down Expand Up @@ -1860,7 +1856,7 @@ pub enum ExprKind<'hir> {
/// Wraps the expression in a terminating scope.
/// This makes it semantically equivalent to `{ let _t = expr; _t }`.
///
/// This construct only exists to tweak the drop order in HIR lowering.
/// This construct only exists to tweak the drop order in AST lowering.
/// An example of that is the desugaring of `for` loops.
DropTemps(&'hir Expr<'hir>),
/// A `let $pat = $expr` expression.
Expand Down Expand Up @@ -2293,7 +2289,7 @@ pub enum ImplItemKind<'hir> {
/// Bind a type to an associated type (i.e., `A = Foo`).
///
/// Bindings like `A: Debug` are represented as a special type `A =
/// $::Debug` that is understood by the astconv code.
/// $::Debug` that is understood by the HIR ty lowering code.
///
/// FIXME(alexreg): why have a separate type for the binding case,
/// wouldn't it be better to make the `ty` field an enum like the
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/bounds.rs
@@ -1,5 +1,5 @@
//! Bounds are restrictions applied to some types after they've been converted into the
//! `ty` form from the HIR.
//! Bounds are restrictions applied to some types after they've been lowered from the HIR to the
//! [`rustc_middle::ty`] form.

use rustc_hir::LangItem;
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/check.rs
Expand Up @@ -382,8 +382,8 @@ fn check_opaque_meets_bounds<'tcx>(
Ok(()) => {}
Err(ty_err) => {
// Some types may be left "stranded" if they can't be reached
// from an astconv'd bound but they're mentioned in the HIR. This
// will happen, e.g., when a nested opaque is inside of a non-
// from a lowered rustc_middle bound but they're mentioned in the HIR.
// This will happen, e.g., when a nested opaque is inside of a non-
// existent associated type, like `impl Trait<Missing = impl Trait>`.
// See <tests/ui/impl-trait/stranded-opaque.rs>.
let ty_err = ty_err.to_string(tcx);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Expand Up @@ -746,7 +746,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(

// We may not collect all RPITITs that we see in the HIR for a trait signature
// because an RPITIT was located within a missing item. Like if we have a sig
// returning `-> Missing<impl Sized>`, that gets converted to `-> [type error]`,
// returning `-> Missing<impl Sized>`, that gets converted to `-> {type error}`,
// and when walking through the signature we end up never collecting the def id
// of the `impl Sized`. Insert that here, so we don't ICE later.
for assoc_item in tcx.associated_types_for_impl_traits_in_associated_fn(trait_m.def_id) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/region.rs
Expand Up @@ -760,7 +760,7 @@ impl<'tcx> RegionResolutionVisitor<'tcx> {

fn enter_node_scope_with_dtor(&mut self, id: hir::ItemLocalId) {
// If node was previously marked as a terminating scope during the
// recursive visit of its parent node in the AST, then we need to
// recursive visit of its parent node in the HIR, then we need to
// account for the destruction scope representing the scope of
// the destructors that run immediately after it completes.
if self.terminating_scopes.contains(&id) {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Expand Up @@ -272,7 +272,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
}
Some(ty::ImplPolarity::Negative) => {
let ast::ImplPolarity::Negative(span) = impl_.polarity else {
bug!("impl_polarity query disagrees with impl's polarity in AST");
bug!("impl_polarity query disagrees with impl's polarity in HIR");
};
// FIXME(#27579): what amount of WF checking do we need for neg impls?
if let hir::Defaultness::Default { .. } = impl_.defaultness {
Expand Down Expand Up @@ -1866,7 +1866,7 @@ fn check_variances_for_type_defn<'tcx>(
.iter()
.filter_map(|predicate| match predicate {
hir::WherePredicate::BoundPredicate(predicate) => {
match icx.to_ty(predicate.bounded_ty).kind() {
match icx.lower_ty(predicate.bounded_ty).kind() {
ty::Param(data) => Some(Parameter(data.index)),
_ => None,
}
Expand Down

0 comments on commit eff958c

Please sign in to comment.