Auto merge of #120926 - fmease:astconv-no-mo, r=oli-obk · rust-lang/rust@eff958c (original) (raw)
57 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -303,10 +303,6 @@ impl TraitBoundModifiers { | ||
303 | 303 | }; |
304 | 304 | } |
305 | 305 | |
306 | -/// The AST represents all type param bounds as types. | |
307 | -/// `typeck::collect::compute_bounds` matches these against | |
308 | -/// the "special" built-in traits (see `middle::lang_items`) and | |
309 | -/// detects `Copy`, `Send` and `Sync`. | |
310 | 306 | #[derive(Clone, Encodable, Decodable, Debug)] |
311 | 307 | pub enum GenericBound { |
312 | 308 | Trait(PolyTraitRef, TraitBoundModifiers), |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -480,7 +480,7 @@ pub fn walk_use_tree<'a, V: Visitor<'a>>( | ||
480 | 480 | try_visit!(visitor.visit_path(&use_tree.prefix, id)); |
481 | 481 | match use_tree.kind { |
482 | 482 | UseTreeKind::Simple(rename) => { |
483 | -// The extra IDs are handled during HIR lowering. | |
483 | +// The extra IDs are handled during AST lowering. | |
484 | 484 | visit_opt!(visitor, visit_ident, rename); |
485 | 485 | } |
486 | 486 | UseTreeKind::Glob => {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -29,11 +29,12 @@ | ||
29 | 29 | //! item id (`item_id`) in case of impl trait or path resolution id (`path_id`) otherwise. |
30 | 30 | //! |
31 | 31 | //! Since we do not have a proper way to obtain function type information by path resolution |
32 | -//! in AST, we mark each function parameter type as `InferDelegation` and inherit it in `AstConv`. | |
32 | +//! in AST, we mark each function parameter type as `InferDelegation` and inherit it during | |
33 | +//! HIR ty lowering. | |
33 | 34 | //! |
34 | 35 | //! Similarly generics, predicates and header are set to the "default" values. |
35 | 36 | //! In case of discrepancy with callee function the `NotSupportedDelegation` error will |
36 | -//! also be emitted in `AstConv`. | |
37 | +//! also be emitted during HIR ty lowering. | |
37 | 38 | |
38 | 39 | use crate::{ImplTraitPosition, ResolverAstLoweringExt}; |
39 | 40 | |
@@ -129,7 +130,7 @@ impl<'hir> LoweringContext<'_, 'hir> { | ||
129 | 130 | ) -> &'hir hir::FnDecl<'hir> { |
130 | 131 | let args_count = if let Some(local_sig_id) = sig_id.as_local() { |
131 | 132 | // Map may be filled incorrectly due to recursive delegation. |
132 | -// Error will be emmited later in astconv. | |
133 | +// Error will be emitted later during HIR ty lowering. | |
133 | 134 | self.resolver.fn_parameter_counts.get(&local_sig_id).cloned().unwrap_or_default() |
134 | 135 | } else { |
135 | 136 | self.tcx.fn_arg_names(sig_id).len() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1427,8 +1427,8 @@ impl<'hir> LoweringContext<'_, 'hir> { | ||
1427 | 1427 | // Error if `?Trait` bounds in where clauses don't refer directly to type parameters. |
1428 | 1428 | // Note: we used to clone these bounds directly onto the type parameter (and avoid lowering |
1429 | 1429 | // these into hir when we lower thee where clauses), but this makes it quite difficult to |
1430 | -// keep track of the Span info. Now, `add_implicitly_sized` in `AstConv` checks both param bounds and | |
1431 | -// where clauses for `?Sized`. | |
1430 | +// keep track of the Span info. Now, `::add_implicit_sized_bound` | |
1431 | +// checks both param bounds and where clauses for `?Sized`. | |
1432 | 1432 | for pred in &generics.where_clause.predicates { |
1433 | 1433 | let WherePredicate::BoundPredicate(bound_pred) = pred else { |
1434 | 1434 | continue; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -428,10 +428,6 @@ pub enum TraitBoundModifier { | ||
428 | 428 | MaybeConst, |
429 | 429 | } |
430 | 430 | |
431 | -/// The AST represents all type param bounds as types. | |
432 | -/// `typeck::collect::compute_bounds` matches these against | |
433 | -/// the "special" built-in traits (see `middle::lang_items`) and | |
434 | -/// detects `Copy`, `Send` and `Sync`. | |
435 | 431 | #[derive(Clone, Copy, Debug, HashStable_Generic)] |
436 | 432 | pub enum GenericBound<'hir> { |
437 | 433 | Trait(PolyTraitRef<'hir>, TraitBoundModifier), |
@@ -1860,7 +1856,7 @@ pub enum ExprKind<'hir> { | ||
1860 | 1856 | /// Wraps the expression in a terminating scope. |
1861 | 1857 | /// This makes it semantically equivalent to `{ let _t = expr; _t }`. |
1862 | 1858 | /// |
1863 | - /// This construct only exists to tweak the drop order in HIR lowering. | |
1859 | + /// This construct only exists to tweak the drop order in AST lowering. | |
1864 | 1860 | /// An example of that is the desugaring of `for` loops. |
1865 | 1861 | DropTemps(&'hir Expr<'hir>), |
1866 | 1862 | /// A `let pat=pat = pat=expr` expression. |
@@ -2293,7 +2289,7 @@ pub enum ImplItemKind<'hir> { | ||
2293 | 2289 | /// Bind a type to an associated type (i.e., `A = Foo`). |
2294 | 2290 | /// |
2295 | 2291 | /// Bindings like `A: Debug` are represented as a special type `A = |
2296 | -/// $::Debug` that is understood by the astconv code. | |
2292 | +/// $::Debug` that is understood by the HIR ty lowering code. | |
2297 | 2293 | /// |
2298 | 2294 | /// FIXME(alexreg): why have a separate type for the binding case, |
2299 | 2295 | /// wouldn't it be better to make the `ty` field an enum like the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
1 | -//! Bounds are restrictions applied to some types after they've been converted into the | |
2 | -//! `ty` form from the HIR. | |
1 | +//! Bounds are restrictions applied to some types after they've been lowered from the HIR to the | |
2 | +//! [`rustc_middle::ty`] form. | |
3 | 3 | |
4 | 4 | use rustc_hir::LangItem; |
5 | 5 | use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -382,8 +382,8 @@ fn check_opaque_meets_bounds<'tcx>( | ||
382 | 382 | Ok(()) => {} |
383 | 383 | Err(ty_err) => { |
384 | 384 | // Some types may be left "stranded" if they can't be reached |
385 | -// from an astconv'd bound but they're mentioned in the HIR. This | |
386 | -// will happen, e.g., when a nested opaque is inside of a non- | |
385 | +// from a lowered rustc_middle bound but they're mentioned in the HIR. | |
386 | +// This will happen, e.g., when a nested opaque is inside of a non- | |
387 | 387 | // existent associated type, like `impl Trait<Missing = impl Trait>`. |
388 | 388 | // See <tests/ui/impl-trait/stranded-opaque.rs>. |
389 | 389 | let ty_err = ty_err.to_string(tcx); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -746,7 +746,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>( | ||
746 | 746 | |
747 | 747 | // We may not collect all RPITITs that we see in the HIR for a trait signature |
748 | 748 | // because an RPITIT was located within a missing item. Like if we have a sig |
749 | -// returning `-> Missing`, that gets converted to `-> [type error]`, | |
749 | +// returning `-> Missing`, that gets converted to `-> {type error}`, | |
750 | 750 | // and when walking through the signature we end up never collecting the def id |
751 | 751 | // of the `impl Sized`. Insert that here, so we don't ICE later. |
752 | 752 | for assoc_item in tcx.associated_types_for_impl_traits_in_associated_fn(trait_m.def_id) { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -760,7 +760,7 @@ impl<'tcx> RegionResolutionVisitor<'tcx> { | ||
760 | 760 | |
761 | 761 | fn enter_node_scope_with_dtor(&mut self, id: hir::ItemLocalId) { |
762 | 762 | // If node was previously marked as a terminating scope during the |
763 | -// recursive visit of its parent node in the AST, then we need to | |
763 | +// recursive visit of its parent node in the HIR, then we need to | |
764 | 764 | // account for the destruction scope representing the scope of |
765 | 765 | // the destructors that run immediately after it completes. |
766 | 766 | if self.terminating_scopes.contains(&id) { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -272,7 +272,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<() | ||
272 | 272 | } |
273 | 273 | Some(ty::ImplPolarity::Negative) => { |
274 | 274 | let ast::ImplPolarity::Negative(span) = impl_.polarity else { |
275 | -bug!("impl_polarity query disagrees with impl's polarity in AST"); | |
275 | +bug!("impl_polarity query disagrees with impl's polarity in HIR"); | |
276 | 276 | }; |
277 | 277 | // FIXME(#27579): what amount of WF checking do we need for neg impls? |
278 | 278 | if let hir::Defaultness::Default { .. } = impl_.defaultness { |
@@ -1866,7 +1866,7 @@ fn check_variances_for_type_defn<'tcx>( | ||
1866 | 1866 | .iter() |
1867 | 1867 | .filter_map(|predicate |
1868 | 1868 | hir::WherePredicate::BoundPredicate(predicate) => { |
1869 | -match icx.to_ty(predicate.bounded_ty).kind() { | |
1869 | +match icx.lower_ty(predicate.bounded_ty).kind() { | |
1870 | 1870 | ty::Param(data) => Some(Parameter(data.index)), |
1871 | 1871 | _ => None, |
1872 | 1872 | } |