@@ -147,21 +147,25 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
147147 /// Let's work through an example to explain how it works. Assume
148148 /// the current function is as follows:
149149 ///
150- /// fn foo<'a, 'b>(..) -> (impl Bar<'a>, impl Bar<'b>)
150+ /// ```text
151+ /// fn foo<'a, 'b>(..) -> (impl Bar<'a>, impl Bar<'b>)
152+ /// ```
151153 ///
152154 /// Here, we have two `impl Trait` types whose values are being
153155 /// inferred (the `impl Bar<'a>` and the `impl
154156 /// Bar<'b>`). Conceptually, this is sugar for a setup where we
155157 /// define underlying abstract types (`Foo1`, `Foo2`) and then, in
156158 /// the return type of `foo`, we *reference* those definitions:
157159 ///
158- /// abstract type Foo1<'x>: Bar<'x>;
159- /// abstract type Foo2<'x>: Bar<'x>;
160- /// fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
161- /// // ^^^^ ^^
162- /// // | |
163- /// // | substs
164- /// // def_id
160+ /// ```text
161+ /// abstract type Foo1<'x>: Bar<'x>;
162+ /// abstract type Foo2<'x>: Bar<'x>;
163+ /// fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
164+ /// // ^^^^ ^^
165+ /// // | |
166+ /// // | substs
167+ /// // def_id
168+ /// ```
165169 ///
166170 /// As indicating in the comments above, each of those references
167171 /// is (in the compiler) basically a substitution (`substs`)
@@ -175,8 +179,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
175179 /// `Foo2`. That is, this gives rise to higher-order (pattern) unification
176180 /// constraints like:
177181 ///
178- /// for<'a> (Foo1<'a> = C1)
179- /// for<'b> (Foo1<'b> = C2)
182+ /// ```text
183+ /// for<'a> (Foo1<'a> = C1)
184+ /// for<'b> (Foo1<'b> = C2)
185+ /// ```
180186 ///
181187 /// For these equation to be satisfiable, the types `C1` and `C2`
182188 /// can only refer to a limited set of regions. For example, `C1`
@@ -189,15 +195,19 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
189195 /// regions. In fact, it is fairly likely that they do! Consider
190196 /// this possible definition of `foo`:
191197 ///
192- /// fn foo<'a, 'b>(x: &'a i32, y: &'b i32) -> (impl Bar<'a>, impl Bar<'b>) {
198+ /// ```text
199+ /// fn foo<'a, 'b>(x: &'a i32, y: &'b i32) -> (impl Bar<'a>, impl Bar<'b>) {
193200 /// (&*x, &*y)
194201 /// }
202+ /// ```
195203 ///
196204 /// Here, the values for the concrete types of the two impl
197205 /// traits will include inference variables:
198206 ///
199- /// &'0 i32
200- /// &'1 i32
207+ /// ```text
208+ /// &'0 i32
209+ /// &'1 i32
210+ /// ```
201211 ///
202212 /// Ordinarily, the subtyping rules would ensure that these are
203213 /// sufficiently large. But since `impl Bar<'a>` isn't a specific
@@ -207,7 +217,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
207217 /// inferred type are regions that could validly appear.
208218 ///
209219 /// This is actually a bit of a tricky constraint in general. We
210- /// want to say that each variable (e.g., `'0`` ) can only take on
220+ /// want to say that each variable (e.g., `'0`) can only take on
211221 /// values that were supplied as arguments to the abstract type
212222 /// (e.g., `'a` for `Foo1<'a>`) or `'static`, which is always in
213223 /// scope. We don't have a constraint quite of this kind in the current
@@ -225,7 +235,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
225235 ///
226236 /// In some cases, there is no minimum. Consider this example:
227237 ///
228- /// fn baz<'a, 'b>() -> impl Trait<'a, 'b> { ... }
238+ /// ```text
239+ /// fn baz<'a, 'b>() -> impl Trait<'a, 'b> { ... }
240+ /// ```
229241 ///
230242 /// Here we would report an error, because `'a` and `'b` have no
231243 /// relation to one another.
@@ -245,8 +257,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
245257 /// which is the current function. It also means that we can
246258 /// take "implied bounds" into account in some cases:
247259 ///
248- /// trait SomeTrait<'a, 'b> { }
249- /// fn foo<'a, 'b>(_: &'a &'b u32) -> impl SomeTrait<'a, 'b> { .. }
260+ /// ```text
261+ /// trait SomeTrait<'a, 'b> { }
262+ /// fn foo<'a, 'b>(_: &'a &'b u32) -> impl SomeTrait<'a, 'b> { .. }
263+ /// ```
250264 ///
251265 /// Here, the fact that `'b: 'a` is known only because of the
252266 /// implied bounds from the `&'a &'b u32` parameter, and is not
0 commit comments