Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f232e01
Improve docs of traversable derivation macros
eggyal Feb 26, 2023
6c218fc
Generify traversable derivation macros
eggyal Feb 26, 2023
7e79b4c
Automatically skip traversal of trivial fields
eggyal Feb 25, 2023
15326d2
Use specialisation in explicit traversable impls
eggyal Feb 26, 2023
3020cbd
Enable skipping of derived traversals, with reason
eggyal Mar 23, 2023
07108f9
Derive traversable impls for BindingForm
eggyal Feb 25, 2023
8b4785d
Derive traversable impls for Obligation
eggyal Feb 26, 2023
a4ea3be
Derive traversable impls for GenericArgKind
eggyal Oct 29, 2023
17c69df
Simplify traversable impls in solver wrapper types
eggyal Feb 25, 2023
68b4a08
Newtype for FakeRead semi-traversable tuple
eggyal Mar 20, 2023
0fc043d
Newtype for AscribeUserType semi-traversable tuple
eggyal Mar 20, 2023
867f351
Newtype for InstanceOfArg semi-traversable tuple
eggyal Mar 20, 2023
95b0952
Remove superfluous traversable impls
eggyal Feb 25, 2023
2463fef
Remove traversable impl for mir::Local
eggyal Nov 1, 2023
73397fe
Remove traversable impl for ErrorGuaranteed
eggyal Nov 1, 2023
7106243
Remove traversable impl for bool
eggyal Feb 25, 2023
f715232
Remove traversable impl for usize
eggyal Oct 28, 2023
0b97607
Use rustc_type_ir directly in derived traversables
eggyal Feb 25, 2023
5296463
Derive traversables over generic interners
eggyal Mar 21, 2023
ea5a210
Use Spanned not semi-traversable Span tuples
eggyal Mar 20, 2023
b1f374b
Generify trivial traversables over the interner
eggyal Mar 21, 2023
361e068
Require explanation of trivial traversable derives
eggyal Mar 17, 2023
f7f7bb9
Derive traversable impls for ConstKind
eggyal Oct 29, 2023
68b69c9
Derive traversable impls for more type lib kinds
eggyal Oct 29, 2023
3858eb3
Remove TrivialTypeTraversal macros
eggyal Feb 25, 2023
cdc7218
Unimpl TypeSuperVisitable for UnevaluatedConst
eggyal Feb 26, 2023
c9a5958
Generify traversals of interned types
eggyal Feb 26, 2023
419cc6d
Enforce ClosureOutlivesSubjectTy not traversable
eggyal Oct 29, 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
Derive traversable impls for Obligation
Ever since folding was first added in c5754f3, obligations have not
folded or visited their causes the ObligationCauseCode potentially
containing types that may be of interest to a folder or visitor.

By using the derive macro to implement the visitable traits, we ensure
that all contained types of interest are folded/visited.
  • Loading branch information
eggyal committed Nov 8, 2023
commit 8b4785dd794f017225bfdfe5f23b9244c6a58054
5 changes: 4 additions & 1 deletion compiler/rustc_infer/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ pub use rustc_middle::traits::*;
/// either identifying an `impl` (e.g., `impl Eq for i32`) that
/// satisfies the obligation, or else finding a bound that is in
/// scope. The eventual result is usually a `Selection` (defined below).
#[derive(Clone)]
#[derive(Clone, TypeFoldable, TypeVisitable)]
pub struct Obligation<'tcx, T> {
/// The reason we have to prove this thing.
// FIXME: provide more detailed justification for `#[skip_traversal]`, or else remove
// see https://github.com/rust-lang/rust/pull/108214#issuecomment-1479424793
#[skip_traversal(despite_potential_miscompilation_because = "perf")]
pub cause: ObligationCause<'tcx>,

/// The environment in which we should prove this thing.
Expand Down
33 changes: 1 addition & 32 deletions compiler/rustc_infer/src/traits/structural_impls.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use crate::traits;
use crate::traits::project::Normalized;
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable};
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitor};
use rustc_middle::ty::{self, TyCtxt};
use rustc_middle::ty;

use std::fmt;
use std::ops::ControlFlow;

// Structural impls for the structs in `traits`.

Expand Down Expand Up @@ -58,31 +55,3 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
write!(f, "MismatchedProjectionTypes({:?})", self.err)
}
}

///////////////////////////////////////////////////////////////////////////
// TypeFoldable implementations.

impl<'tcx, O: TypeFoldable<TyCtxt<'tcx>>> TypeFoldable<TyCtxt<'tcx>>
for traits::Obligation<'tcx, O>
{
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Ok(traits::Obligation {
cause: self.cause,
recursion_depth: self.recursion_depth,
predicate: self.predicate.try_fold_with(folder)?,
param_env: self.param_env.try_fold_with(folder)?,
})
}
}

impl<'tcx, O: TypeVisitable<TyCtxt<'tcx>>> TypeVisitable<TyCtxt<'tcx>>
for traits::Obligation<'tcx, O>
{
fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
self.predicate.visit_with(visitor)?;
self.param_env.visit_with(visitor)
}
}