@@ -430,7 +430,27 @@ fn gen_method_item(
430
430
// Generate the list of argument used to call the method.
431
431
let args = get_arg_list ( sig. decl . inputs . iter ( ) ) ?;
432
432
433
- // Builds turbofish with generic types (without lifetimes)
433
+ // Build the turbofish type parameters. We need to pass type parameters
434
+ // explicitly as they cannot be inferred in all cases (e.g. something like
435
+ // `mem::size_of`). However, we don't explicitly specify lifetime
436
+ // parameters. Most lifetime parameters are so called late-bound lifetimes
437
+ // (ones that stick to input parameters) and Rust prohibits us from
438
+ // specifying late-bound lifetimes explicitly (which is not a problem,
439
+ // because those can always be correctly inferred). It would be possible to
440
+ // explicitly specify early-bound lifetimes, but this is hardly useful.
441
+ // Early-bound lifetimes are lifetimes that are only attached to the return
442
+ // type. Something like:
443
+ //
444
+ // fn foo<'a>() -> &'a i32
445
+ //
446
+ // It's hard to imagine how such a function would even work. So since those
447
+ // functions are really rare and special, we won't support them. In
448
+ // particular, for us to determine if a lifetime parameter is early- or
449
+ // late-bound would be *really* difficult.
450
+ //
451
+ // So we just specify type parameters. In the future, however, we need to
452
+ // add support for const parameters. But those are not remotely stable yet,
453
+ // so we can wait a bit still.
434
454
let generic_types = sig. decl . generics
435
455
. type_params ( )
436
456
. map ( |param| {
0 commit comments