@@ -212,46 +212,37 @@ pub fn analyze<Analysis>(extra: Analysis::Extra) -> Analysis::Output
212
212
/// An analysis that finds for each IR item its set of template parameters that
213
213
/// it uses.
214
214
///
215
- /// We use the following monotone constraint function:
215
+ /// We use the monotone constraint function `template_param_usage`, defined as
216
+ /// follows:
216
217
///
217
- /// ```ignore
218
- /// template_param_usage(v) =
219
- /// self_template_param_usage(v) union
220
- /// template_param_usage(w_0) union
221
- /// template_param_usage(w_1) union
222
- /// ...
223
- /// template_param_usage(w_n)
224
- /// ```
225
- ///
226
- /// Where `v` has direct edges in the IR graph to each of `w_0`, `w_1`,
227
- /// ..., `w_n` (for example, if `v` were a struct type and `x` and `y`
228
- /// were the types of two of `v`'s fields). We ignore certain edges, such
229
- /// as edges from a template declaration to its template parameters'
230
- /// definitions for this analysis. If we didn't, then we would mistakenly
231
- /// determine that ever template parameter is always used.
232
- ///
233
- /// Finally, `self_template_param_usage` is defined with the following cases:
234
- ///
235
- /// * If `T` is a template parameter:
218
+ /// * If `T` is a named template type parameter, it trivially uses itself:
236
219
///
237
220
/// ```ignore
238
- /// self_template_param_usage (T) = { T }
221
+ /// template_param_usage (T) = { T }
239
222
/// ```
240
223
///
241
224
/// * If `inst` is a template instantiation, `inst.args` are the template
242
- /// instantiation's template arguments, and `inst.decl ` is the template
243
- /// declaration being instantiated:
225
+ /// instantiation's template arguments, and `inst.def ` is the template
226
+ /// definition being instantiated:
244
227
///
245
228
/// ```ignore
246
- /// self_template_param_usage (inst) =
247
- /// { T: for T in inst.args, if T in template_param_usage(inst.decl ) }
229
+ /// template_param_usage (inst) =
230
+ /// { T: for T in inst.args, if T in template_param_usage(inst.def ) }
248
231
/// ```
249
232
///
250
- /// * And for all other IR items, the result is the empty set:
233
+ /// * Finally, for all other IR item kinds, we use our lattice's `join`
234
+ /// operation: set union with each successor of the given item's template
235
+ /// parameter usage:
251
236
///
252
237
/// ```ignore
253
- /// self_template_param_usage(_) = { }
238
+ /// template_param_usage(v) =
239
+ /// union(template_param_usage(w) for w in successors(v))
254
240
/// ```
241
+ ///
242
+ /// Note that we ignore certain edges in the graph, such as edges from a
243
+ /// template declaration to its template parameters' definitions for this
244
+ /// analysis. If we didn't, then we would mistakenly determine that ever
245
+ /// template parameter is always used.
255
246
#[ derive( Debug , Clone ) ]
256
247
pub struct UsedTemplateParameters < ' ctx , ' gen >
257
248
where ' gen : ' ctx ,
0 commit comments