Skip to content

Commit 28eb2a8

Browse files
committed
Auto merge of #120926 - fmease:astconv-no-mo, r=oli-obk
[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)).
2 parents f58a392 + 6308c00 commit 28eb2a8

File tree

10 files changed

+25
-25
lines changed

10 files changed

+25
-25
lines changed

book/src/development/type_checking.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ Here the HIR sees the types without "thinking" about them, it knows that the fun
118118
an `u32`. As far as `hir::Ty` is concerned those might be different types. But at the `ty::Ty` level the compiler
119119
understands that they're the same type, in-depth lifetimes, etc...
120120

121-
To get from a `hir::Ty` to a `ty::Ty`, you can use the [`hir_ty_to_ty`][hir_ty_to_ty] function outside of bodies or
121+
To get from a `hir::Ty` to a `ty::Ty`, you can use the [`lower_ty`][lower_ty] function outside of bodies or
122122
the [`TypeckResults::node_type()`][node_type] method inside of bodies.
123123

124-
> **Warning**: Don't use `hir_ty_to_ty` inside of bodies, because this can cause ICEs.
124+
> **Warning**: Don't use `lower_ty` inside of bodies, because this can cause ICEs.
125125
126126
## Creating Types programmatically
127127

@@ -162,6 +162,6 @@ in this chapter:
162162
[Ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html
163163
[TyKind]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_type_ir/ty_kind/enum.TyKind.html
164164
[TypeckResults]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html
165-
[middle_ty]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/ty/struct.Ty.html
166-
[hir_ty]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_hir/struct.Ty.html
167-
[hir_ty_to_ty]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_hir_analysis/fn.hir_ty_to_ty.html
165+
[middle_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html
166+
[hir_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Ty.html
167+
[lower_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/fn.lower_ty.html

clippy_lints/src/implicit_hasher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_errors::Diag;
55
use rustc_hir as hir;
66
use rustc_hir::intravisit::{walk_body, walk_expr, walk_inf, walk_ty, Visitor};
77
use rustc_hir::{Body, Expr, ExprKind, GenericArg, Item, ItemKind, QPath, TyKind};
8-
use rustc_hir_analysis::hir_ty_to_ty;
8+
use rustc_hir_analysis::lower_ty;
99
use rustc_lint::{LateContext, LateLintPass};
1010
use rustc_middle::hir::nested_filter;
1111
use rustc_middle::ty::{Ty, TypeckResults};
@@ -227,7 +227,7 @@ impl<'tcx> ImplicitHasherType<'tcx> {
227227
.collect();
228228
let params_len = params.len();
229229

230-
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
230+
let ty = lower_ty(cx.tcx, hir_ty);
231231

232232
if is_type_diagnostic_item(cx, ty, sym::HashMap) && params_len == 2 {
233233
Some(ImplicitHasherType::HashMap(

clippy_lints/src/implied_bounds_in_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_hir::{
66
GenericArg, GenericBound, GenericBounds, ItemKind, PredicateOrigin, TraitBoundModifier, TyKind, TypeBinding,
77
WherePredicate,
88
};
9-
use rustc_hir_analysis::hir_ty_to_ty;
9+
use rustc_hir_analysis::lower_ty;
1010
use rustc_lint::{LateContext, LateLintPass};
1111
use rustc_middle::ty::{self, ClauseKind, Generics, Ty, TyCtxt};
1212
use rustc_session::declare_lint_pass;
@@ -146,7 +146,7 @@ fn try_resolve_type<'tcx>(
146146
index: usize,
147147
) -> Option<Ty<'tcx>> {
148148
match args.get(index - 1) {
149-
Some(GenericArg::Type(ty)) => Some(hir_ty_to_ty(tcx, ty)),
149+
Some(GenericArg::Type(ty)) => Some(lower_ty(tcx, ty)),
150150
Some(_) => None,
151151
None => Some(tcx.type_of(generics.params[index].def_id).skip_binder()),
152152
}

clippy_lints/src/types/redundant_allocation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::{path_def_id, qpath_generic_tys};
44
use rustc_errors::Applicability;
55
use rustc_hir::def_id::DefId;
66
use rustc_hir::{self as hir, QPath, TyKind};
7-
use rustc_hir_analysis::hir_ty_to_ty;
7+
use rustc_hir_analysis::lower_ty;
88
use rustc_lint::LateContext;
99
use rustc_middle::ty::TypeVisitableExt;
1010
use rustc_span::symbol::sym;
@@ -56,10 +56,10 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, hir_ty: &hir::Ty<'tcx>, qpath:
5656
};
5757
let inner_span = match qpath_generic_tys(inner_qpath).next() {
5858
Some(hir_ty) => {
59-
// Reallocation of a fat pointer causes it to become thin. `hir_ty_to_ty` is safe to use
59+
// Reallocation of a fat pointer causes it to become thin. `lower_ty` is safe to use
6060
// here because `mod.rs` guarantees this lint is only run on types outside of bodies and
6161
// is not run on locals.
62-
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
62+
let ty = lower_ty(cx.tcx, hir_ty);
6363
if ty.has_escaping_bound_vars() || !ty.is_sized(cx.tcx, cx.param_env) {
6464
return false;
6565
}

clippy_lints/src/types/vec_box.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::source::snippet;
44
use rustc_errors::Applicability;
55
use rustc_hir::def_id::DefId;
66
use rustc_hir::{self as hir, GenericArg, LangItem, QPath, TyKind};
7-
use rustc_hir_analysis::hir_ty_to_ty;
7+
use rustc_hir_analysis::lower_ty;
88
use rustc_lint::LateContext;
99
use rustc_middle::ty::layout::LayoutOf;
1010
use rustc_middle::ty::TypeVisitableExt;
@@ -35,7 +35,7 @@ pub(super) fn check<'tcx>(
3535
&& let Some(GenericArg::Type(boxed_ty)) = last.args.first()
3636
// extract allocator from the Box for later
3737
&& let boxed_alloc_ty = last.args.get(1)
38-
&& let ty_ty = hir_ty_to_ty(cx.tcx, boxed_ty)
38+
&& let ty_ty = lower_ty(cx.tcx, boxed_ty)
3939
&& !ty_ty.has_escaping_bound_vars()
4040
&& ty_ty.is_sized(cx.tcx, cx.param_env)
4141
&& let Ok(ty_ty_size) = cx.layout_of(ty_ty).map(|l| l.size.bytes())
@@ -55,7 +55,7 @@ pub(super) fn check<'tcx>(
5555
}
5656
},
5757
(Some(GenericArg::Type(l)), Some(GenericArg::Type(r))) =>
58-
hir_ty_to_ty(cx.tcx, l) == hir_ty_to_ty(cx.tcx, r),
58+
lower_ty(cx.tcx, l) == lower_ty(cx.tcx, r),
5959
_ => false
6060
}
6161
{

clippy_lints/src/unconditional_recursion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::def::{DefKind, Res};
77
use rustc_hir::def_id::{DefId, LocalDefId};
88
use rustc_hir::intravisit::{walk_body, walk_expr, FnKind, Visitor};
99
use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId, Item, ItemKind, Node, QPath, TyKind};
10-
use rustc_hir_analysis::hir_ty_to_ty;
10+
use rustc_hir_analysis::lower_ty;
1111
use rustc_lint::{LateContext, LateLintPass};
1212
use rustc_middle::hir::map::Map;
1313
use rustc_middle::hir::nested_filter;
@@ -74,7 +74,7 @@ fn get_hir_ty_def_id<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: rustc_hir::Ty<'tcx>) -> Op
7474
match qpath {
7575
QPath::Resolved(_, path) => path.res.opt_def_id(),
7676
QPath::TypeRelative(_, _) => {
77-
let ty = hir_ty_to_ty(tcx, &hir_ty);
77+
let ty = lower_ty(tcx, &hir_ty);
7878

7979
match ty.kind() {
8080
ty::Alias(ty::Projection, proj) => {

clippy_lints/src/uninhabited_references.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint;
22
use rustc_hir::intravisit::FnKind;
33
use rustc_hir::{Body, Expr, ExprKind, FnDecl, FnRetTy, TyKind, UnOp};
4-
use rustc_hir_analysis::hir_ty_to_ty;
4+
use rustc_hir_analysis::lower_ty;
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_middle::lint::in_external_macro;
77
use rustc_session::declare_lint_pass;
@@ -71,7 +71,7 @@ impl LateLintPass<'_> for UninhabitedReferences {
7171
}
7272
if let FnRetTy::Return(hir_ty) = fndecl.output
7373
&& let TyKind::Ref(_, mut_ty) = hir_ty.kind
74-
&& hir_ty_to_ty(cx.tcx, mut_ty.ty).is_privately_uninhabited(cx.tcx, cx.param_env)
74+
&& lower_ty(cx.tcx, mut_ty.ty).is_privately_uninhabited(cx.tcx, cx.param_env)
7575
{
7676
span_lint(
7777
cx,

clippy_lints/src/use_self.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::{
1111
self as hir, Expr, ExprKind, FnRetTy, FnSig, GenericArgsParentheses, GenericParam, GenericParamKind, HirId, Impl,
1212
ImplItemKind, Item, ItemKind, Pat, PatKind, Path, QPath, Ty, TyKind,
1313
};
14-
use rustc_hir_analysis::hir_ty_to_ty;
14+
use rustc_hir_analysis::lower_ty;
1515
use rustc_lint::{LateContext, LateLintPass};
1616
use rustc_middle::ty::Ty as MiddleTy;
1717
use rustc_session::impl_lint_pass;
@@ -193,7 +193,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
193193
}
194194

195195
fn check_body(&mut self, _: &LateContext<'_>, _: &hir::Body<'_>) {
196-
// `hir_ty_to_ty` cannot be called in `Body`s or it will panic (sometimes). But in bodies
196+
// `lower_ty` cannot be called in `Body`s or it will panic (sometimes). But in bodies
197197
// we can use `cx.typeck_results.node_type(..)` to get the `ty::Ty` from a `hir::Ty`.
198198
// However the `node_type()` method can *only* be called in bodies.
199199
if let Some(&mut StackItem::Check { ref mut in_body, .. }) = self.stack.last_mut() {
@@ -224,7 +224,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
224224
&& let ty = if in_body > 0 {
225225
cx.typeck_results().node_type(hir_ty.hir_id)
226226
} else {
227-
hir_ty_to_ty(cx.tcx, hir_ty)
227+
lower_ty(cx.tcx, hir_ty)
228228
}
229229
&& let impl_ty = cx.tcx.type_of(impl_id).instantiate_identity()
230230
&& same_type_and_consts(ty, impl_ty)

clippy_lints/src/zero_sized_map_values.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::ty::{is_normalizable, is_type_diagnostic_item};
33
use rustc_hir::{self as hir, HirId, ItemKind, Node};
4-
use rustc_hir_analysis::hir_ty_to_ty;
4+
use rustc_hir_analysis::lower_ty;
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_middle::ty::layout::LayoutOf as _;
77
use rustc_middle::ty::{Adt, Ty, TypeVisitableExt};
@@ -91,5 +91,5 @@ fn ty_from_hir_ty<'tcx>(cx: &LateContext<'tcx>, hir_ty: &hir::Ty<'tcx>) -> Ty<'t
9191
None
9292
}
9393
})
94-
.unwrap_or_else(|| hir_ty_to_ty(cx.tcx, hir_ty))
94+
.unwrap_or_else(|| lower_ty(cx.tcx, hir_ty))
9595
}

tests/ui/crashes/ice-6179.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! This is a minimal reproducer for the ICE in https://github.com/rust-lang/rust-clippy/pull/6179.
2-
//! The ICE is mainly caused by using `hir_ty_to_ty`. See the discussion in the PR for details.
2+
//! The ICE is mainly caused by using `lower_ty`. See the discussion in the PR for details.
33
44
#![warn(clippy::use_self)]
55
#![allow(dead_code, clippy::let_with_type_underscore)]

0 commit comments

Comments
 (0)