Skip to content

Commit 42d4bd7

Browse files
committed
Auto merge of rust-lang#107924 - eggyal:move_fold_visit_traits_to_type_lib_with_trait_alias, r=oli-obk
Move folding & visiting traits into type library This is a rework of rust-lang#107712, following feedback on that PR. In particular, this version uses trait aliases to reduce the API churn for trait consumers. Doing so requires a workaround for rust-lang#107747 until its fix in rust-lang#107803 is merged into the stage0 compiler; this workaround, which uses conditional compilation based on the `bootstrap` configuration predicate, sits in dedicated commit b409329 for ease of reversion. The possibility of the `rustc_middle` crate retaining its own distinct versions of each folding/visiting trait, blanket-implemented on all types that implement the respective trait in the type library, was also explored: however since this would necessitate making each `rustc_middle` trait a subtrait of the respective type library trait (so that such blanket implementations can delegate their generic methods), no benefit would be gained. r? types
2 parents b3077fb + 340d9e8 commit 42d4bd7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

clippy_utils/src/mir/possible_borrower.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxHashMap;
44
use rustc_index::bit_set::{BitSet, HybridBitSet};
55
use rustc_lint::LateContext;
66
use rustc_middle::mir::{self, visit::Visitor as _, Mutability};
7-
use rustc_middle::ty::{self, visit::TypeVisitor};
7+
use rustc_middle::ty::{self, visit::ir::TypeVisitor, TyCtxt};
88
use rustc_mir_dataflow::{impls::MaybeStorageLive, Analysis, ResultsCursor};
99
use std::borrow::Cow;
1010
use std::ops::ControlFlow;
@@ -136,7 +136,7 @@ impl<'a, 'b, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'b,
136136

137137
struct ContainsRegion;
138138

139-
impl TypeVisitor<'_> for ContainsRegion {
139+
impl TypeVisitor<TyCtxt<'_>> for ContainsRegion {
140140
type BreakTy = ();
141141

142142
fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<Self::BreakTy> {

clippy_utils/src/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_lint::LateContext;
1717
use rustc_middle::mir::interpret::{ConstValue, Scalar};
1818
use rustc_middle::ty::{
1919
self, AdtDef, AliasTy, AssocKind, Binder, BoundRegion, DefIdTree, FnSig, IntTy, List, ParamEnv, Predicate,
20-
PredicateKind, Region, RegionKind, SubstsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, UintTy,
20+
PredicateKind, Region, RegionKind, SubstsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, ir::TypeVisitor, UintTy,
2121
VariantDef, VariantDiscr,
2222
};
2323
use rustc_middle::ty::{GenericArg, GenericArgKind};
@@ -838,7 +838,7 @@ pub fn for_each_top_level_late_bound_region<B>(
838838
index: u32,
839839
f: F,
840840
}
841-
impl<'tcx, B, F: FnMut(BoundRegion) -> ControlFlow<B>> TypeVisitor<'tcx> for V<F> {
841+
impl<'tcx, B, F: FnMut(BoundRegion) -> ControlFlow<B>> TypeVisitor<TyCtxt<'tcx>> for V<F> {
842842
type BreakTy = B;
843843
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<Self::BreakTy> {
844844
if let RegionKind::ReLateBound(idx, bound) = r.kind() && idx.as_u32() == self.index {

0 commit comments

Comments
 (0)