X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_middle%2Fsrc%2Fty%2Fsubst.rs;h=5063420e975d14663721f6adc9c0229e732130ea;hb=7907385999b4a83d37ed31d334f3ed9ca02983a1;hp=46b938ea93baa0ab7bfa5218eac13c1b7e92ef09;hpb=22d554657d08cff395911c5128be297e366899ec;p=rust.git diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index 46b938ea93b..5063420e975 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -687,17 +687,17 @@ fn const_for_param(&self, p: ParamConst, source_ct: ty::Const<'tcx>) -> ty::Cons /// /// ``` /// type Func = fn(A); - /// type MetaFunc = for<'a> fn(Func<&'a i32>) + /// type MetaFunc = for<'a> fn(Func<&'a i32>); /// ``` /// /// The type `MetaFunc`, when fully expanded, will be - /// - /// for<'a> fn(fn(&'a i32)) - /// ^~ ^~ ^~~ - /// | | | - /// | | DebruijnIndex of 2 - /// Binders - /// + /// ```ignore (illustrative) + /// for<'a> fn(fn(&'a i32)) + /// // ^~ ^~ ^~~ + /// // | | | + /// // | | DebruijnIndex of 2 + /// // Binders + /// ``` /// Here the `'a` lifetime is bound in the outer function, but appears as an argument of the /// inner one. Therefore, that appearance will have a DebruijnIndex of 2, because we must skip /// over the inner binder (remember that we count De Bruijn indices from 1). However, in the @@ -709,17 +709,17 @@ fn const_for_param(&self, p: ParamConst, source_ct: ty::Const<'tcx>) -> ty::Cons /// /// ``` /// type FuncTuple = (A,fn(A)); - /// type MetaFuncTuple = for<'a> fn(FuncTuple<&'a i32>) + /// type MetaFuncTuple = for<'a> fn(FuncTuple<&'a i32>); /// ``` /// /// Here the final type will be: - /// - /// for<'a> fn((&'a i32, fn(&'a i32))) - /// ^~~ ^~~ - /// | | - /// DebruijnIndex of 1 | - /// DebruijnIndex of 2 - /// + /// ```ignore (illustrative) + /// for<'a> fn((&'a i32, fn(&'a i32))) + /// // ^~~ ^~~ + /// // | | + /// // DebruijnIndex of 1 | + /// // DebruijnIndex of 2 + /// ``` /// As indicated in the diagram, here the same type `&'a i32` is substituted once, but in the /// first case we do not increase the De Bruijn index and in the second case we do. The reason /// is that only in the second case have we passed through a fn binder. @@ -767,7 +767,7 @@ pub struct UserSubsts<'tcx> { /// sometimes needed to constrain the type parameters on the impl. For /// example, in this code: /// -/// ``` +/// ```ignore (illustrative) /// struct Foo { } /// impl Foo { fn method() { } } /// ```