Skip to content

Commit 8901392

Browse files
committed
Updated comments in auto trait machinery.
1 parent 388defa commit 8901392

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/librustc/traits/auto_trait.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,24 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
6868
AutoTraitFinder { tcx }
6969
}
7070

71-
/// Determine whether an auto trait is implemented for a type, and if this is the case if
72-
/// non-trivial bounds need to be fulfilled, invoke a callback to compute a value representing
73-
/// these in a fashion suitable for the caller.
71+
/// Make a best effort to determine whether and under which conditions an auto trait is
72+
/// implemented for a type. For example, if you have
73+
///
74+
/// ```
75+
/// struct Foo<T> { data: Box<T> }
76+
/// ```
77+
78+
/// then this might return that Foo<T>: Send if T: Send (encoded in the AutoTraitResult type).
79+
/// The analysis attempts to account for custom impls as well as other complex cases. This
80+
/// result is intended for use by rustdoc and other such consumers.
81+
82+
/// (Note that due to the coinductive nature of Send, the full and correct result is actually
83+
/// quite simple to generate. That is, when a type has no custom impl, it is Send iff its field
84+
/// types are all Send. So, in our example, we might have that Foo<T>: Send if Box<T>: Send.
85+
/// But this is often not the best way to present to the user.)
86+
87+
/// Warning: The API should be considered highly unstable, and it may be refactored or removed
88+
/// in the future.
7489
pub fn find_auto_trait_generics<A>(
7590
&self,
7691
did: DefId,

0 commit comments

Comments
 (0)