128
128
//! #### Unsizing Casts
129
129
//! A subtle way of introducing neighbor edges is by casting to a trait object.
130
130
//! Since the resulting fat-pointer contains a reference to a vtable, we need to
131
- //! instantiate all object-save methods of the trait, as we need to store
131
+ //! instantiate all object-safe methods of the trait, as we need to store
132
132
//! pointers to these functions even if they never get called anywhere. This can
133
133
//! be seen as a special case of taking a function reference.
134
134
//!
@@ -1044,10 +1044,12 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
1044
1044
/// them.
1045
1045
///
1046
1046
/// For example, the source type might be `&SomeStruct` and the target type
1047
- /// might be `&SomeTrait` in a cast like:
1047
+ /// might be `&dyn SomeTrait` in a cast like:
1048
1048
///
1049
+ /// ```rust,ignore (not real code)
1049
1050
/// let src: &SomeStruct = ...;
1050
- /// let target = src as &SomeTrait;
1051
+ /// let target = src as &dyn SomeTrait;
1052
+ /// ```
1051
1053
///
1052
1054
/// Then the output of this function would be (SomeStruct, SomeTrait) since for
1053
1055
/// constructing the `target` fat-pointer we need the vtable for that pair.
@@ -1068,8 +1070,10 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) ->
1068
1070
/// for the pair of `T` (which is a trait) and the concrete type that `T` was
1069
1071
/// originally coerced from:
1070
1072
///
1073
+ /// ```rust,ignore (not real code)
1071
1074
/// let src: &ComplexStruct<SomeStruct> = ...;
1072
- /// let target = src as &ComplexStruct<SomeTrait>;
1075
+ /// let target = src as &ComplexStruct<dyn SomeTrait>;
1076
+ /// ```
1073
1077
///
1074
1078
/// Again, we want this `find_vtable_types_for_unsizing()` to provide the pair
1075
1079
/// `(SomeStruct, SomeTrait)`.
0 commit comments