Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fdbc432

Browse files
committedFeb 22, 2023
Auto merge of rust-lang#108340 - eggyal:remove_traversal_trait_aliases, r=oli-obk
Remove type-traversal trait aliases rust-lang#107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate. As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value. Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream). This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope. These changes also roll-back the (no-longer required) workarounds to rust-lang#107747 that were made in b409329. Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit. Let me know if you'd like it broken up. r? `@oli-obk`
2 parents b869e84 + a9b2354 commit fdbc432

File tree

192 files changed

+658
-569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+658
-569
lines changed
 

‎compiler/rustc_borrowck/src/constraint_generation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::mir::{
99
};
1010
use rustc_middle::ty::subst::SubstsRef;
1111
use rustc_middle::ty::visit::TypeVisitable;
12-
use rustc_middle::ty::{self, RegionVid, Ty};
12+
use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt};
1313

1414
use crate::{
1515
borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, nll::ToRegionVid,
@@ -165,7 +165,7 @@ impl<'cx, 'tcx> ConstraintGeneration<'cx, 'tcx> {
165165
/// `location`.
166166
fn add_regular_live_constraint<T>(&mut self, live_ty: T, location: Location)
167167
where
168-
T: TypeVisitable<'tcx>,
168+
T: TypeVisitable<TyCtxt<'tcx>>,
169169
{
170170
debug!("add_regular_live_constraint(live_ty={:?}, location={:?})", live_ty, location);
171171

‎compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
106106
}
107107
}
108108

109-
impl<'tcx, T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx> ToUniverseInfo<'tcx>
109+
impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUniverseInfo<'tcx>
110110
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize<T>>>
111111
{
112112
fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
@@ -258,7 +258,7 @@ struct NormalizeQuery<'tcx, T> {
258258

259259
impl<'tcx, T> TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T>
260260
where
261-
T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx,
261+
T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx,
262262
{
263263
fn fallback_error(
264264
&self,

0 commit comments

Comments
 (0)
Please sign in to comment.