Skip to content

Make some traversable types generic over interner #108214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3c58c0e
Improve docs of traversable derivation macros
eggyal Feb 26, 2023
1a9c3e5
Generify traversable derivation macros
eggyal Feb 26, 2023
09239c2
Automatically skip traversal of boring fields
eggyal Feb 25, 2023
d2ec961
Use specialisation in ParamEnv traversable impls
eggyal Feb 26, 2023
99e070f
Derive traversable impls for UserTypeProjection
eggyal Feb 25, 2023
408ba98
Derive traversable impls for BindingForm
eggyal Feb 25, 2023
ef97776
Derive traversable impls for Obligation
eggyal Feb 26, 2023
5d4dd4b
Simplify traversable impls for ExternalConstraints
eggyal Feb 25, 2023
b75b00d
Remove superfluous traversable impls
eggyal Feb 25, 2023
8f8a920
Remove superfluous traversable impl for usize
eggyal Feb 25, 2023
4e4b936
Remove superfluous traversable impl for bool
eggyal Feb 25, 2023
e3f58d0
Newtype for FakeRead semi-traversable tuple
eggyal Mar 20, 2023
feaeef5
Newtype for AscribeUserType semi-traversable tuple
eggyal Mar 20, 2023
c79f135
Newtypes not DefId and LocalDefId traversable impl
eggyal Mar 20, 2023
6833eea
Use rustc_type_ir directly in derived traversables
eggyal Feb 25, 2023
8da36bd
Derive traversables over generic interners
eggyal Mar 21, 2023
d1cc6e5
Use Spanned not semi-traversable Span tuples
eggyal Mar 20, 2023
9b8fcc5
Make no-op traversables generic over the interner
eggyal Mar 21, 2023
85f0500
Replace TrivialTypeTraversal macros with derives
eggyal Feb 25, 2023
b0ccdac
Unimpl TypeSuperVisitable for UnevaluatedConst
eggyal Feb 26, 2023
11296fa
Generify traversals of interned types
eggyal Feb 26, 2023
bf618ac
Explain no-op traversable impls
eggyal Mar 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use specialisation in ParamEnv traversable impls
  • Loading branch information
eggyal committed Mar 21, 2023
commit d2ec961a675addb47b3307bdd2a5267e00d8cc3e
24 changes: 19 additions & 5 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1627,17 +1627,31 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ParamEnv<'tcx> {
folder: &mut F,
) -> Result<Self, F::Error> {
Ok(ParamEnv::new(
self.caller_bounds().try_fold_with(folder)?,
self.reveal().try_fold_with(folder)?,
self.constness(),
rustc_type_ir::prefer_noop_traversal_if_applicable!(
{ self.caller_bounds() }.try_fold_with(folder)
)?,
rustc_type_ir::prefer_noop_traversal_if_applicable!(
{ self.reveal() }.try_fold_with(folder)
)?,
rustc_type_ir::prefer_noop_traversal_if_applicable!(
{ self.constness() }.try_fold_with(folder)
)?,
))
}
}

impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for ParamEnv<'tcx> {
fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
self.caller_bounds().visit_with(visitor)?;
self.reveal().visit_with(visitor)
rustc_type_ir::prefer_noop_traversal_if_applicable!(
{ &self.caller_bounds() }.visit_with(visitor)
)?;
rustc_type_ir::prefer_noop_traversal_if_applicable!(
{ &self.reveal() }.visit_with(visitor)
)?;
rustc_type_ir::prefer_noop_traversal_if_applicable!(
{ &self.constness() }.visit_with(visitor)
)?;
ControlFlow::Continue(())
}
}

Expand Down