]> git.lizzy.rs Git - rust.git/commitdiff
fix most compiler/ doctests
authorElliot Roberts <Elliot0000101@gmail.com>
Fri, 15 Apr 2022 22:04:34 +0000 (15:04 -0700)
committerElliot Roberts <Elliot0000101@gmail.com>
Tue, 3 May 2022 00:40:30 +0000 (17:40 -0700)
116 files changed:
compiler/rustc_ast/src/ast.rs
compiler/rustc_ast_lowering/src/expr.rs
compiler/rustc_ast_lowering/src/lib.rs
compiler/rustc_ast_pretty/src/pp.rs
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
compiler/rustc_borrowck/src/diagnostics/region_errors.rs
compiler/rustc_borrowck/src/diagnostics/region_name.rs
compiler/rustc_borrowck/src/member_constraints.rs
compiler/rustc_borrowck/src/region_infer/mod.rs
compiler/rustc_borrowck/src/type_check/mod.rs
compiler/rustc_borrowck/src/universal_regions.rs
compiler/rustc_builtin_macros/src/deriving/encodable.rs
compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
compiler/rustc_builtin_macros/src/test_harness.rs
compiler/rustc_codegen_llvm/src/back/lto.rs
compiler/rustc_codegen_llvm/src/debuginfo/doc.md
compiler/rustc_data_structures/src/frozen.rs
compiler/rustc_data_structures/src/obligation_forest/mod.rs
compiler/rustc_data_structures/src/owning_ref/mod.rs
compiler/rustc_data_structures/src/tagged_ptr.rs
compiler/rustc_data_structures/src/transitive_relation.rs
compiler/rustc_errors/src/lib.rs
compiler/rustc_expand/src/mbe/macro_check.rs
compiler/rustc_expand/src/mbe/macro_parser.rs
compiler/rustc_hir/src/def.rs
compiler/rustc_hir/src/hir.rs
compiler/rustc_incremental/src/assert_dep_graph.rs
compiler/rustc_incremental/src/assert_module_sources.rs
compiler/rustc_infer/src/infer/at.rs
compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
compiler/rustc_infer/src/infer/combine.rs
compiler/rustc_infer/src/infer/error_reporting/mod.rs
compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs
compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs
compiler/rustc_infer/src/infer/mod.rs
compiler/rustc_infer/src/infer/opaque_types.rs
compiler/rustc_infer/src/infer/outlives/env.rs
compiler/rustc_infer/src/infer/outlives/obligations.rs
compiler/rustc_infer/src/infer/outlives/verify.rs
compiler/rustc_infer/src/infer/region_constraints/mod.rs
compiler/rustc_infer/src/infer/type_variable.rs
compiler/rustc_lint_defs/src/builtin.rs
compiler/rustc_middle/src/hir/map/mod.rs
compiler/rustc_middle/src/infer/mod.rs
compiler/rustc_middle/src/mir/interpret/allocation.rs
compiler/rustc_middle/src/mir/mod.rs
compiler/rustc_middle/src/mir/mono.rs
compiler/rustc_middle/src/mir/terminator.rs
compiler/rustc_middle/src/mir/visit.rs
compiler/rustc_middle/src/traits/mod.rs
compiler/rustc_middle/src/traits/specialization_graph.rs
compiler/rustc_middle/src/ty/adjustment.rs
compiler/rustc_middle/src/ty/adt.rs
compiler/rustc_middle/src/ty/closure.rs
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_middle/src/ty/fold.rs
compiler/rustc_middle/src/ty/inhabitedness/mod.rs
compiler/rustc_middle/src/ty/instance.rs
compiler/rustc_middle/src/ty/mod.rs
compiler/rustc_middle/src/ty/sty.rs
compiler/rustc_middle/src/ty/subst.rs
compiler/rustc_middle/src/ty/util.rs
compiler/rustc_middle/src/ty/walk.rs
compiler/rustc_mir_build/src/build/expr/as_operand.rs
compiler/rustc_mir_build/src/build/expr/as_place.rs
compiler/rustc_mir_build/src/build/matches/mod.rs
compiler/rustc_mir_build/src/build/scope.rs
compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
compiler/rustc_mir_dataflow/src/impls/mod.rs
compiler/rustc_mir_transform/src/generator.rs
compiler/rustc_mir_transform/src/match_branches.rs
compiler/rustc_mir_transform/src/simplify_comparison_integral.rs
compiler/rustc_mir_transform/src/simplify_try.rs
compiler/rustc_monomorphize/src/collector.rs
compiler/rustc_parse/src/parser/attr.rs
compiler/rustc_parse/src/parser/item.rs
compiler/rustc_parse/src/parser/ty.rs
compiler/rustc_query_system/src/dep_graph/debug.rs
compiler/rustc_resolve/src/diagnostics.rs
compiler/rustc_resolve/src/late/lifetimes.rs
compiler/rustc_span/src/hygiene.rs
compiler/rustc_span/src/source_map.rs
compiler/rustc_trait_selection/src/opaque_types.rs
compiler/rustc_trait_selection/src/traits/auto_trait.rs
compiler/rustc_trait_selection/src/traits/coherence.rs
compiler/rustc_trait_selection/src/traits/object_safety.rs
compiler/rustc_trait_selection/src/traits/project.rs
compiler/rustc_trait_selection/src/traits/select/confirmation.rs
compiler/rustc_trait_selection/src/traits/select/mod.rs
compiler/rustc_trait_selection/src/traits/specialize/mod.rs
compiler/rustc_trait_selection/src/traits/wf.rs
compiler/rustc_type_ir/src/lib.rs
compiler/rustc_typeck/src/astconv/mod.rs
compiler/rustc_typeck/src/check/closure.rs
compiler/rustc_typeck/src/check/coercion.rs
compiler/rustc_typeck/src/check/demand.rs
compiler/rustc_typeck/src/check/fallback.rs
compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs
compiler/rustc_typeck/src/check/generator_interior/drop_ranges/cfg_build.rs
compiler/rustc_typeck/src/check/inherited.rs
compiler/rustc_typeck/src/check/method/probe.rs
compiler/rustc_typeck/src/check/mod.rs
compiler/rustc_typeck/src/check/pat.rs
compiler/rustc_typeck/src/check/regionck.rs
compiler/rustc_typeck/src/check/upvar.rs
compiler/rustc_typeck/src/check/wfcheck.rs
compiler/rustc_typeck/src/collect/type_of.rs
compiler/rustc_typeck/src/constrained_generic_params.rs
compiler/rustc_typeck/src/expr_use_visitor.rs
compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
compiler/rustc_typeck/src/mem_categorization.rs
compiler/rustc_typeck/src/outlives/implicit_infer.rs
compiler/rustc_typeck/src/outlives/outlives_bounds.rs
compiler/rustc_typeck/src/variance/constraints.rs

index cdcd221e811a77c2f21888b6eccd617897b94f2f..1e2c4f31d3df34a21a5076774b3d69921aa7791d 100644 (file)
@@ -573,7 +573,7 @@ pub struct Block {
     pub span: Span,
     pub tokens: Option<LazyTokenStream>,
     /// The following *isn't* a parse error, but will cause multiple errors in following stages.
-    /// ```
+    /// ```compile_fail
     /// let x = {
     ///     foo: var
     /// };
index 37ae41fabf987bd1658983325b560ec4b650ba68..8aeeeb50eb5593c7e84761f04c9feb4319cd2c78 100644 (file)
@@ -615,7 +615,7 @@ pub(super) fn make_async_expr(
     }
 
     /// Desugar `<expr>.await` into:
-    /// ```rust
+    /// ```ignore (pseudo-rust)
     /// match ::std::future::IntoFuture::into_future(<expr>) {
     ///     mut __awaitee => loop {
     ///         match unsafe { ::std::future::Future::poll(
@@ -1325,7 +1325,7 @@ fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::Expr
     }
 
     /// Desugar `ExprForLoop` from: `[opt_ident]: for <pat> in <head> <body>` into:
-    /// ```rust
+    /// ```ignore (pseudo-rust)
     /// {
     ///     let result = match IntoIterator::into_iter(<head>) {
     ///         mut iter => {
@@ -1436,7 +1436,7 @@ fn lower_expr_for(
     }
 
     /// Desugar `ExprKind::Try` from: `<expr>?` into:
-    /// ```rust
+    /// ```ignore (pseudo-rust)
     /// match Try::branch(<expr>) {
     ///     ControlFlow::Continue(val) => #[allow(unreachable_code)] val,,
     ///     ControlFlow::Break(residual) =>
index d433775f85cf3eeae2670ae182b19c7b096bdf2a..a99a155f93dd017b87ae4af7809ea3db633ff35c 100644 (file)
@@ -934,7 +934,7 @@ fn lower_token_stream(
 
     /// Given an associated type constraint like one of these:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// T: Iterator<Item: Debug>
     ///             ^^^^^^^^^^^
     /// T: Iterator<Item = Debug>
index ddce86f216538fc0732ae216bfadccf336e65889..c93022308a37dd91b46a301dc2bd8ecf6f60b0c3 100644 (file)
 //! will be made to flow subsequent breaks together onto lines. Inconsistent
 //! is the opposite. Inconsistent breaking example would be, say:
 //!
-//! ```
+//! ```ignore (illustrative)
 //! foo(hello, there, good, friends)
 //! ```
 //!
 //! breaking inconsistently to become
 //!
-//! ```
+//! ```ignore (illustrative)
 //! foo(hello, there,
 //!     good, friends);
 //! ```
 //!
 //! whereas a consistent breaking would yield:
 //!
-//! ```
+//! ```ignore (illustrative)
 //! foo(hello,
 //!     there,
 //!     good,
@@ -153,14 +153,14 @@ enum IndentStyle {
     /// Vertically aligned under whatever column this block begins at.
     ///
     ///     fn demo(arg1: usize,
-    ///             arg2: usize);
+    ///             arg2: usize) {}
     Visual,
     /// Indented relative to the indentation level of the previous line.
     ///
     ///     fn demo(
     ///         arg1: usize,
     ///         arg2: usize,
-    ///     );
+    ///     ) {}
     Block { offset: isize },
 }
 
index 3b4e9e95b0e9108db5086f244888b4bce63e041b..bbb631730d346b3c5add18042c25e9f66d70d72f 100644 (file)
@@ -896,20 +896,23 @@ fn suggest_split_at_mut_if_applicable(
     ///
     /// In the simplest case, where there are no unions involved, if a mutable borrow of `x` is
     /// attempted while a shared borrow is live, then this function will return:
-    ///
-    ///     ("x", "", "")
-    ///
+    /// ```
+    /// ("x", "", "")
+    /// # ;
+    /// ```
     /// In the simple union case, if a mutable borrow of a union field `x.z` is attempted while
     /// a shared borrow of another field `x.y`, then this function will return:
-    ///
-    ///     ("x", "x.z", "x.y")
-    ///
+    /// ```
+    /// ("x", "x.z", "x.y")
+    /// # ;
+    /// ```
     /// In the more complex union case, where the union is a field of a struct, then if a mutable
     /// borrow of a union field in a struct `x.u.z` is attempted while a shared borrow of
     /// another field `x.u.y`, then this function will return:
-    ///
-    ///     ("x.u", "x.u.z", "x.u.y")
-    ///
+    /// ```
+    /// ("x.u", "x.u.z", "x.u.y")
+    /// # ;
+    /// ```
     /// This is used when creating error messages like below:
     ///
     /// ```text
index 30fe4ea8662eb909d4fda73aeccff5d2ec769702..6f1c8daf42e3f72905546673aa9ecd16b1be5388 100644 (file)
@@ -259,7 +259,7 @@ pub(crate) fn report_region_errors(&mut self, nll_errors: RegionErrors<'tcx>) {
     /// Report an error because the universal region `fr` was required to outlive
     /// `outlived_fr` but it is not known to do so. For example:
     ///
-    /// ```
+    /// ```compile_fail,E0312
     /// fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }
     /// ```
     ///
index 459d4a783e40f06042bbd4f5660e5e35c53622a7..c4cef5710aecb4a7ce556dccd667bbdb65db78da 100644 (file)
@@ -210,7 +210,7 @@ fn synthesize_region_name(&self) -> Symbol {
     /// Suppose we are trying to give a name to the lifetime of the
     /// reference `x`:
     ///
-    /// ```
+    /// ```ignore (pseudo-rust)
     /// fn foo(x: &u32) { .. }
     /// ```
     ///
@@ -746,7 +746,7 @@ fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Opti
     /// e.g. given the function:
     ///
     /// ```
-    /// async fn foo() -> i32 {}
+    /// async fn foo() -> i32 { 2 }
     /// ```
     ///
     /// this function, given the lowered return type of `foo`, an [`OpaqueDef`] that implements `Future<Output=i32>`,
index 0fe44328fd9f189d666eb794b09ad00c452a9784..f920d9d5c3f574f6fb56eb4e6cc448fbaa5d5b83 100644 (file)
@@ -169,7 +169,7 @@ impl<R> MemberConstraintSet<'_, R>
     /// Returns the "choice regions" for a given member
     /// constraint. This is the `R1..Rn` from a constraint like:
     ///
-    /// ```
+    /// ```text
     /// R0 member of [R1..Rn]
     /// ```
     crate fn choice_regions(&self, pci: NllMemberConstraintIndex) -> &[ty::RegionVid] {
@@ -195,14 +195,14 @@ fn index(&self, i: NllMemberConstraintIndex) -> &NllMemberConstraint<'tcx> {
 ///
 /// Before:
 ///
-/// ```
+/// ```text
 /// target_list: A -> B -> C -> (None)
 /// source_list: D -> E -> F -> (None)
 /// ```
 ///
 /// After:
 ///
-/// ```
+/// ```text
 /// target_list: A -> B -> C -> D -> E -> F -> (None)
 /// ```
 fn append_list(
index cf03f34a4ec5fbb03b2a76e6e8434ea49dbdc832..b2fa16ce125af8f7c54826b8653b65b3bb1fd9bf 100644 (file)
@@ -436,14 +436,14 @@ fn compute_scc_representatives(
     /// minimum values.
     ///
     /// For example:
-    ///
-    ///     fn foo<'a, 'b>(..) where 'a: 'b
-    ///
+    /// ```
+    /// fn foo<'a, 'b>( /* ... */ ) where 'a: 'b { /* ... */ }
+    /// ```
     /// would initialize two variables like so:
-    ///
-    ///     R0 = { CFG, R0 } // 'a
-    ///     R1 = { CFG, R0, R1 } // 'b
-    ///
+    /// ```ignore (illustrative)
+    /// R0 = { CFG, R0 } // 'a
+    /// R1 = { CFG, R0, R1 } // 'b
+    /// ```
     /// Here, R0 represents `'a`, and it contains (a) the entire CFG
     /// and (b) any universally quantified regions that it outlives,
     /// which in this case is just itself. R1 (`'b`) in contrast also
@@ -1310,9 +1310,9 @@ fn eval_outlives(&self, sup_region: RegionVid, sub_region: RegionVid) -> bool {
     /// whether any of the constraints were too strong. In particular,
     /// we want to check for a case where a universally quantified
     /// region exceeded its bounds. Consider:
-    ///
-    ///     fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }
-    ///
+    /// ```compile_fail,E0312
+    /// fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }
+    /// ```
     /// In this case, returning `x` requires `&'a u32 <: &'b u32`
     /// and hence we establish (transitively) a constraint that
     /// `'a: 'b`. The `propagate_constraints` code above will
@@ -1366,9 +1366,9 @@ fn check_universal_regions(
     /// <https://smallcultfollowing.com/babysteps/blog/2019/01/17/polonius-and-region-errors/>
     ///
     /// In the canonical example
-    ///
-    ///     fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }
-    ///
+    /// ```compile_fail,E0312
+    /// fn foo<'a, 'b>(x: &'a u32) -> &'b u32 { x }
+    /// ```
     /// returning `x` requires `&'a u32 <: &'b u32` and hence we establish (transitively) a
     /// constraint that `'a: 'b`. It is an error that we have no evidence that this
     /// constraint holds.
index c4a190b44cbd4816c10bb732e84ab62f4b5a5680..4b905c23e156a069939798ea253be7aaeb8be9a1 100644 (file)
@@ -971,7 +971,7 @@ pub enum Locations {
     /// things like the type of the return slot. Consider this
     /// example:
     ///
-    /// ```
+    /// ```compile_fail,E0515
     /// fn foo<'a>(x: &'a u32) -> &'a u32 {
     ///     let y = 22;
     ///     return &y; // error
index e26adba0d3002eeb9528577f805c876e7f610bd4..c06fe881410aee4c441bb8658cc2dc30decc6971 100644 (file)
@@ -187,12 +187,12 @@ pub enum RegionClassification {
     ///
     /// Consider this example:
     ///
-    /// ```
+    /// ```ignore (pseudo-rust)
     /// fn foo<'a, 'b>(a: &'a u32, b: &'b u32, c: &'static u32) {
     ///   let closure = for<'x> |x: &'x u32| { .. };
-    ///                 ^^^^^^^ pretend this were legal syntax
-    ///                         for declaring a late-bound region in
-    ///                         a closure signature
+    ///    //           ^^^^^^^ pretend this were legal syntax
+    ///    //                   for declaring a late-bound region in
+    ///    //                   a closure signature
     /// }
     /// ```
     ///
index c5f3a9d3379a7a0b6fec04f6841b303a80d450b4..6151a80a56d58d8a05fb2aa43996b006a808ec4a 100644 (file)
@@ -5,14 +5,14 @@
 //!
 //! For example, a type like:
 //!
-//! ```
+//! ```ignore (old code)
 //! #[derive(RustcEncodable, RustcDecodable)]
 //! struct Node { id: usize }
 //! ```
 //!
 //! would generate two implementations like:
 //!
-//! ```
+//! ```ignore (old code)
 //! # struct Node { id: usize }
 //! impl<S: Encoder<E>, E> Encodable<S, E> for Node {
 //!     fn encode(&self, s: &mut S) -> Result<(), E> {
@@ -40,7 +40,7 @@
 //! Other interesting scenarios are when the item has type parameters or
 //! references other non-built-in types. A type definition like:
 //!
-//! ```
+//! ```ignore (old code)
 //! # #[derive(RustcEncodable, RustcDecodable)]
 //! # struct Span;
 //! #[derive(RustcEncodable, RustcDecodable)]
@@ -49,7 +49,7 @@
 //!
 //! would yield functions like:
 //!
-//! ```
+//! ```ignore (old code)
 //! # #[derive(RustcEncodable, RustcDecodable)]
 //! # struct Span;
 //! # struct Spanned<T> { node: T, span: Span }
index f87f4726d1c6967a05a047067ad3f450eb1f6c12..0fd23fd281e19efde74f28fb5529c07083c57de8 100644 (file)
@@ -1006,9 +1006,11 @@ fn create_method(
     ///         }
     ///     }
     /// }
-    ///
-    /// // or if A is repr(packed) - note fields are matched by-value
-    /// // instead of by-reference.
+    /// ```
+    /// or if A is repr(packed) - note fields are matched by-value
+    /// instead of by-reference.
+    /// ```
+    /// # struct A { x: i32, y: i32 }
     /// impl PartialEq for A {
     ///     fn eq(&self, other: &A) -> bool {
     ///         match *self {
@@ -1126,14 +1128,15 @@ fn expand_static_struct_method_body(
     /// // is equivalent to
     ///
     /// impl PartialEq for A {
-    ///     fn eq(&self, other: &A) -> ::bool {
+    ///     fn eq(&self, other: &A) -> bool {
+    ///         use A::*;
     ///         match (&*self, &*other) {
     ///             (&A1, &A1) => true,
     ///             (&A2(ref self_0),
     ///              &A2(ref __arg_1_0)) => (*self_0).eq(&(*__arg_1_0)),
     ///             _ => {
-    ///                 let __self_vi = match *self { A1(..) => 0, A2(..) => 1 };
-    ///                 let __arg_1_vi = match *other { A1(..) => 0, A2(..) => 1 };
+    ///                 let __self_vi = match *self { A1 => 0, A2(..) => 1 };
+    ///                 let __arg_1_vi = match *other { A1 => 0, A2(..) => 1 };
     ///                 false
     ///             }
     ///         }
index e2553ab40cad4035dbc2c8b8d5ffdbb4bbbeec89..db8dce804a31beb2fc44f293a632ee940cd0489a 100644 (file)
@@ -249,7 +249,7 @@ fn generate_test_harness(
 ///
 /// By default this expands to
 ///
-/// ```
+/// ```ignore UNSOLVED (I think I still need guidance for this one. Is it correct? Do we try to make it run? How do we nicely fill it out?)
 /// #[rustc_main]
 /// pub fn main() {
 ///     extern crate test;
index 5c63bd8c1bd8dcff95494050e9da3d96f4ec49bf..77cfdd06ef5d737dd77324022e6e6b1a24def6c1 100644 (file)
@@ -396,15 +396,15 @@ fn drop(&mut self) {
 ///
 /// At a high level Thin LTO looks like:
 ///
-///     1. Prepare a "summary" of each LLVM module in question which describes
-///        the values inside, cost of the values, etc.
-///     2. Merge the summaries of all modules in question into one "index"
-///     3. Perform some global analysis on this index
-///     4. For each module, use the index and analysis calculated previously to
-///        perform local transformations on the module, for example inlining
-///        small functions from other modules.
-///     5. Run thin-specific optimization passes over each module, and then code
-///        generate everything at the end.
+///    1. Prepare a "summary" of each LLVM module in question which describes
+///       the values inside, cost of the values, etc.
+///    2. Merge the summaries of all modules in question into one "index"
+///    3. Perform some global analysis on this index
+///    4. For each module, use the index and analysis calculated previously to
+///       perform local transformations on the module, for example inlining
+///       small functions from other modules.
+///    5. Run thin-specific optimization passes over each module, and then code
+///       generate everything at the end.
 ///
 /// The summary for each module is intended to be quite cheap, and the global
 /// index is relatively quite cheap to create as well. As a result, the goal of
index 5a8976c61662b3d3a4983f15cd9d5657f86d11e1..aaec4e68c1743f193212acdf4cfe665c59a67ecc 100644 (file)
@@ -27,9 +27,9 @@ The module is thus driven from an outside client with functions like
 Internally the module will try to reuse already created metadata by
 utilizing a cache. The way to get a shared metadata node when needed is
 thus to just call the corresponding function in this module:
-
-    let file_metadata = file_metadata(cx, file);
-
+```ignore (illustrative)
+let file_metadata = file_metadata(cx, file);
+```
 The function will take care of probing the cache for an existing node for
 that exact file path.
 
@@ -63,7 +63,7 @@ struct List {
 
 will generate the following callstack with a naive DFS algorithm:
 
-```
+```ignore (illustrative)
 describe(t = List)
   describe(t = i32)
   describe(t = Option<Box<List>>)
index 2daf5b0414172ed1cf415438a8a6df31e2e1be8b..c81e1b124f0e5f02eb4ddb904e7d97a41856226d 100644 (file)
@@ -23,7 +23,8 @@
 //! `computed` does not change accidentally (e.g. somebody might accidentally call
 //! `foo.computed.mutate()`). This is what `Frozen` is for. We can do the following:
 //!
-//! ```rust
+//! ```
+//! # struct Bar {}
 //! use rustc_data_structures::frozen::Frozen;
 //!
 //! struct Foo {
index 5fe2a1fb84bd76a8521db89806ed981c53308325..74f432a7967f9f585feec2709033b71aafd2aae0 100644 (file)
@@ -202,7 +202,7 @@ fn new(parent: Option<usize>, obligation: O, obligation_tree_id: ObligationTreeI
 /// with this node.
 ///
 /// The non-`Error` state transitions are as follows.
-/// ```
+/// ```text
 /// (Pre-creation)
 ///  |
 ///  |     register_obligation_at() (called by process_obligations() and
index e7397bf13bad43319c3ebcb0f4874dd74e3cf78e..ed5e566184f12922491d15a83544e0924d93e352 100644 (file)
@@ -25,9 +25,8 @@ fn return_owned_and_referenced<'a>() -> (Vec<u8>, &'a [u8]) {
 This library enables this safe usage by keeping the owner and the reference
 bundled together in a wrapper type that ensure that lifetime constraint:
 
-```rust
-# extern crate owning_ref;
-# use owning_ref::OwningRef;
+```
+# use rustc_data_structures::owning_ref::OwningRef;
 # fn main() {
 fn return_owned_and_referenced() -> OwningRef<Vec<u8>, [u8]> {
     let v = vec![1, 2, 3, 4];
@@ -56,8 +55,7 @@ fn return_owned_and_referenced() -> OwningRef<Vec<u8>, [u8]> {
 ## Basics
 
 ```
-extern crate owning_ref;
-use owning_ref::BoxRef;
+use rustc_data_structures::owning_ref::BoxRef;
 
 fn main() {
     // Create an array owned by a Box.
@@ -78,8 +76,7 @@ fn main() {
 ## Caching a reference to a struct field
 
 ```
-extern crate owning_ref;
-use owning_ref::BoxRef;
+use rustc_data_structures::owning_ref::BoxRef;
 
 fn main() {
     struct Foo {
@@ -106,8 +103,7 @@ struct Foo {
 ## Caching a reference to an entry in a vector
 
 ```
-extern crate owning_ref;
-use owning_ref::VecRef;
+use rustc_data_structures::owning_ref::VecRef;
 
 fn main() {
     let v = VecRef::new(vec![1, 2, 3, 4, 5]).map(|v| &v[3]);
@@ -118,8 +114,7 @@ fn main() {
 ## Caching a subslice of a String
 
 ```
-extern crate owning_ref;
-use owning_ref::StringRef;
+use rustc_data_structures::owning_ref::StringRef;
 
 fn main() {
     let s = StringRef::new("hello world".to_owned())
@@ -132,8 +127,7 @@ fn main() {
 ## Reference counted slices that share ownership of the backing storage
 
 ```
-extern crate owning_ref;
-use owning_ref::RcRef;
+use rustc_data_structures::owning_ref::RcRef;
 use std::rc::Rc;
 
 fn main() {
@@ -155,8 +149,7 @@ fn main() {
 ## Atomic reference counted slices that share ownership of the backing storage
 
 ```
-extern crate owning_ref;
-use owning_ref::ArcRef;
+use rustc_data_structures::owning_ref::ArcRef;
 use std::sync::Arc;
 
 fn main() {
@@ -188,8 +181,7 @@ fn par_sum(rc: ArcRef<[i32]>) -> i32 {
 ## References into RAII locks
 
 ```
-extern crate owning_ref;
-use owning_ref::RefRef;
+use rustc_data_structures::owning_ref::RefRef;
 use std::cell::{RefCell, Ref};
 
 fn main() {
@@ -219,8 +211,7 @@ fn main() {
 a _mutable owning reference_. (e.g., with `Box`, `RefMut`, `MutexGuard`)
 
 ```
-extern crate owning_ref;
-use owning_ref::RefMutRefMut;
+use rustc_data_structures::owning_ref::RefMutRefMut;
 use std::cell::{RefCell, RefMut};
 
 fn main() {
@@ -326,8 +317,7 @@ impl<O, T: ?Sized> OwningRef<O, T> {
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::OwningRef;
+    /// use rustc_data_structures::owning_ref::OwningRef;
     ///
     /// fn main() {
     ///     let owning_ref = OwningRef::new(Box::new(42));
@@ -362,8 +352,7 @@ pub unsafe fn new_assert_stable_address(o: O) -> Self
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::OwningRef;
+    /// use rustc_data_structures::owning_ref::OwningRef;
     ///
     /// fn main() {
     ///     let owning_ref = OwningRef::new(Box::new([1, 2, 3, 4]));
@@ -390,8 +379,7 @@ pub fn map<F, U: ?Sized>(self, f: F) -> OwningRef<O, U>
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::OwningRef;
+    /// use rustc_data_structures::owning_ref::OwningRef;
     ///
     /// fn main() {
     ///     let owning_ref = OwningRef::new(Box::new([1, 2, 3, 4]));
@@ -441,8 +429,7 @@ pub fn map_owner_box(self) -> OwningRef<Box<O>, T> {
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::{OwningRef, Erased};
+    /// use rustc_data_structures::owning_ref::{OwningRef, Erased};
     ///
     /// fn main() {
     ///     // N.B., using the concrete types here for explicitness.
@@ -460,7 +447,7 @@ pub fn map_owner_box(self) -> OwningRef<Box<O>, T> {
     ///     let owning_ref_b: OwningRef<Box<Vec<(i32, bool)>>, i32>
     ///         = owning_ref_b.map(|a| &a[1].0);
     ///
-    ///     let owning_refs: [OwningRef<Box<Erased>, i32>; 2]
+    ///     let owning_refs: [OwningRef<Box<dyn Erased>, i32>; 2]
     ///         = [owning_ref_a.erase_owner(), owning_ref_b.erase_owner()];
     ///
     ///     assert_eq!(*owning_refs[0], 1);
@@ -516,8 +503,7 @@ impl<O, T: ?Sized> OwningRefMut<O, T> {
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::OwningRefMut;
+    /// use rustc_data_structures::owning_ref::OwningRefMut;
     ///
     /// fn main() {
     ///     let owning_ref_mut = OwningRefMut::new(Box::new(42));
@@ -552,8 +538,7 @@ pub unsafe fn new_assert_stable_address(mut o: O) -> Self
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::OwningRefMut;
+    /// use rustc_data_structures::owning_ref::OwningRefMut;
     ///
     /// fn main() {
     ///     let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4]));
@@ -580,8 +565,7 @@ pub fn map<F, U: ?Sized>(mut self, f: F) -> OwningRef<O, U>
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::OwningRefMut;
+    /// use rustc_data_structures::owning_ref::OwningRefMut;
     ///
     /// fn main() {
     ///     let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4]));
@@ -608,8 +592,7 @@ pub fn map_mut<F, U: ?Sized>(mut self, f: F) -> OwningRefMut<O, U>
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::OwningRefMut;
+    /// use rustc_data_structures::owning_ref::OwningRefMut;
     ///
     /// fn main() {
     ///     let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4]));
@@ -638,8 +621,7 @@ pub fn try_map<F, U: ?Sized, E>(mut self, f: F) -> Result<OwningRef<O, U>, E>
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::OwningRefMut;
+    /// use rustc_data_structures::owning_ref::OwningRefMut;
     ///
     /// fn main() {
     ///     let owning_ref_mut = OwningRefMut::new(Box::new([1, 2, 3, 4]));
@@ -689,8 +671,7 @@ pub fn map_owner_box(self) -> OwningRefMut<Box<O>, T> {
     ///
     /// # Example
     /// ```
-    /// extern crate owning_ref;
-    /// use owning_ref::{OwningRefMut, Erased};
+    /// use rustc_data_structures::owning_ref::{OwningRefMut, Erased};
     ///
     /// fn main() {
     ///     // N.B., using the concrete types here for explicitness.
@@ -708,7 +689,7 @@ pub fn map_owner_box(self) -> OwningRefMut<Box<O>, T> {
     ///     let owning_ref_mut_b: OwningRefMut<Box<Vec<(i32, bool)>>, i32>
     ///         = owning_ref_mut_b.map_mut(|a| &mut a[1].0);
     ///
-    ///     let owning_refs_mut: [OwningRefMut<Box<Erased>, i32>; 2]
+    ///     let owning_refs_mut: [OwningRefMut<Box<dyn Erased>, i32>; 2]
     ///         = [owning_ref_mut_a.erase_owner(), owning_ref_mut_b.erase_owner()];
     ///
     ///     assert_eq!(*owning_refs_mut[0], 1);
index 324a8624dd076a2ac213e4c68f18c8402cb5f8bc..651bc556c9853608d50798b7c894fce88204ee86 100644 (file)
@@ -45,7 +45,8 @@ pub unsafe trait Pointer: Deref {
     /// case you'll need to manually figure out what the right type to pass to
     /// align_of is.
     ///
-    /// ```rust
+    /// ```ignore UNSOLVED (what to do about the Self)
+    /// # use std::ops::Deref;
     /// std::mem::align_of::<<Self as Deref>::Target>().trailing_zeros() as usize;
     /// ```
     const BITS: usize;
index 780753ed200e997abb27b87f5a28f3c162924e56..0ff64969b071c9954b5187adf209450124ee75dd 100644 (file)
@@ -282,7 +282,7 @@ pub fn minimal_upper_bounds(&self, a: T, b: T) -> Vec<T> {
     /// (where the relation is encoding the `<=` relation for the lattice).
     /// So e.g., if the relation is `->` and we have
     ///
-    /// ```
+    /// ```text
     /// a -> b -> d -> f
     /// |              ^
     /// +--> c -> e ---+
index df41fc00714b684c9a16beaaa084b7a55b3c5bd4..f83fa68ced00daa6a0e17d615cac38f8a7e79af1 100644 (file)
@@ -100,7 +100,7 @@ pub struct CodeSuggestion {
     /// `foo.bar` might be replaced with `a.b` or `x.y` by replacing
     /// `foo` and `bar` on their own:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// vec![
     ///     Substitution { parts: vec![(0..3, "a"), (4..7, "b")] },
     ///     Substitution { parts: vec![(0..3, "x"), (4..7, "y")] },
@@ -109,7 +109,7 @@ pub struct CodeSuggestion {
     ///
     /// or by replacing the entire span:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// vec![
     ///     Substitution { parts: vec![(0..7, "a.b")] },
     ///     Substitution { parts: vec![(0..7, "x.y")] },
index 35b5e0d0f2f61108b123b1bba46ba9240209ffdf..8994a2f78919f046bdad82d253460101ebb2cdbf 100644 (file)
@@ -4,7 +4,7 @@
 //!
 //! ## Meta-variables must not be bound twice
 //!
-//! ```
+//! ```compile_fail
 //! macro_rules! foo { ($x:tt $x:tt) => { $x }; }
 //! ```
 //!
@@ -604,9 +604,9 @@ fn check_ops_is_prefix(
 /// Kleene operators of its binder as a prefix.
 ///
 /// Consider $i in the following example:
-///
-///     ( $( $i:ident = $($j:ident),+ );* ) => { $($( $i += $j; )+)* }
-///
+/// ```ignore (illustrative)
+/// ( $( $i:ident = $($j:ident),+ );* ) => { $($( $i += $j; )+)* }
+/// ```
 /// It occurs under the Kleene stack ["*", "+"] and is bound under ["*"] only.
 ///
 /// Arguments:
index 8f260e1cdb5c8c04296792a237238a0b980fd6cf..29f354d572802bc0664b0df3ff79732d9e415912 100644 (file)
@@ -320,7 +320,8 @@ pub(super) fn count_metavar_decls(matcher: &[TokenTree]) -> usize {
 ///
 /// Then, the tree will have the following shape:
 ///
-/// ```rust
+/// ```ignore (private-internal)
+/// # use NamedMatch::*;
 /// MatchedSeq([
 ///   MatchedSeq([
 ///     MatchedNonterminal(a),
index 324e110005717ac6517f4f357e4b4dc7c08cc1a2..ac33a963027f91f10e227d222cb71d25588eab4b 100644 (file)
@@ -312,6 +312,7 @@ pub enum Res<Id = hir::HirId> {
     /// HACK(min_const_generics): self types also have an optional requirement to **not** mention
     /// any generic parameters to allow the following with `min_const_generics`:
     /// ```
+    /// # struct Foo;
     /// impl Foo { fn test() -> [u8; std::mem::size_of::<Self>()] { todo!() } }
     ///
     /// struct Bar([u8; baz::<Self>()]);
index dfeee3f356ffb3f8cb2a78fe8cf91a7573c0c801..4adfbdcf445d7fb4d69221334f8dd6e5fae3c573 100644 (file)
@@ -49,15 +49,15 @@ pub enum ParamName {
     /// Synthetic name generated when user elided a lifetime in an impl header.
     ///
     /// E.g., the lifetimes in cases like these:
-    ///
-    ///     impl Foo for &u32
-    ///     impl Foo<'_> for u32
-    ///
+    /// ```ignore (fragment)
+    /// impl Foo for &u32
+    /// impl Foo<'_> for u32
+    /// ```
     /// in that case, we rewrite to
-    ///
-    ///     impl<'f> Foo for &'f u32
-    ///     impl<'f> Foo<'f> for u32
-    ///
+    /// ```ignore (fragment)
+    /// impl<'f> Foo for &'f u32
+    /// impl<'f> Foo<'f> for u32
+    /// ```
     /// where `'f` is something like `Fresh(0)`. The indices are
     /// unique per impl, but not necessarily continuous.
     Fresh(LocalDefId),
@@ -1082,7 +1082,7 @@ pub enum PatKind<'hir> {
     /// If `slice` exists, then `after` can be non-empty.
     ///
     /// The representation for e.g., `[a, b, .., c, d]` is:
-    /// ```
+    /// ```ignore (illustrative)
     /// PatKind::Slice([Binding(a), Binding(b)], Some(Wild), [Binding(c), Binding(d)])
     /// ```
     Slice(&'hir [Pat<'hir>], Option<&'hir Pat<'hir>>, &'hir [Pat<'hir>]),
@@ -2247,7 +2247,7 @@ pub enum ImplItemKind<'hir> {
 /// wouldn't it be better to make the `ty` field an enum like the
 /// following?
 ///
-/// ```
+/// ```ignore (pseudo-rust)
 /// enum TypeBindingKind {
 ///    Equals(...),
 ///    Binding(...),
index 2d06c9d8ec92c60d8f6cb3d56820d56d7c0d29d7..f69ae8ebe410fd6139d7f15e4c8b3ed3b1c4befc 100644 (file)
@@ -22,7 +22,7 @@
 //!
 //! Example:
 //!
-//! ```
+//! ```ignore (needs flags)
 //! #[rustc_if_this_changed(Hir)]
 //! fn foo() { }
 //!
index 7569abfbb10e59a134acea577b2ec22e3673535e..61b1dd8cb017c57a20652f14ac857ea82035ea1c 100644 (file)
@@ -5,6 +5,7 @@
 //! The user adds annotations to the crate of the following form:
 //!
 //! ```
+//! # #![feature(rustc_attrs)]
 //! #![rustc_partition_reused(module="spike", cfg="rpass2")]
 //! #![rustc_partition_codegened(module="spike-x", cfg="rpass2")]
 //! ```
index 58c309a5c52ea7a52aa3efbe39157cc8ad225ff6..39f7d30e81aca096a4289ae588ac000ba002d0c1 100644 (file)
@@ -6,7 +6,7 @@
 //! is always the "expected" output from the POV of diagnostics.
 //!
 //! Examples:
-//!
+//! ```ignore (fragment)
 //!     infcx.at(cause, param_env).sub(a, b)
 //!     // requires that `a <: b`, with `a` considered the "expected" type
 //!
 //!
 //!     infcx.at(cause, param_env).eq(a, b)
 //!     // requires that `a == b`, with `a` considered the "expected" type
-//!
+//! ```
 //! For finer-grained control, you can also do use `trace`:
-//!
+//! ```ignore (fragment)
 //!     infcx.at(...).trace(a, b).sub(&c, &d)
-//!
+//! ```
 //! This will set `a` and `b` as the "root" values for
 //! error-reporting, but actually operate on `c` and `d`. This is
 //! sometimes useful when the types of `c` and `d` are not traceable
index 5e67c8cfa27c4a73cc0799ace0fed0efa64de974..07e51afd904418db8a86380f9f367bfe23a9947f 100644 (file)
@@ -87,9 +87,9 @@ pub fn canonicalize_query_preserving_universes<V>(
     ///
     /// with a mapping M that maps `'?0` to `'static`. But if we found that there
     /// exists only one possible impl of `Trait`, and it looks like
-    ///
-    ///     impl<T> Trait<'static> for T { .. }
-    ///
+    /// ```ignore (illustrative)
+    /// impl<T> Trait<'static> for T { .. }
+    /// ```
     /// then we would prepare a query result R that (among other
     /// things) includes a mapping to `'?0 := 'static`. When
     /// canonicalizing this query result R, we would leave this
index 0ca0fe33614f826600589d69fd0edfcea9b14d9e..aa3f0600cccc850fe1317421fde9738382392f55 100644 (file)
@@ -202,7 +202,7 @@ pub fn super_combine_consts<R>(
     ///
     /// A good example of this is the following:
     ///
-    /// ```rust
+    /// ```compile_fail,E0308
     /// #![feature(generic_const_exprs)]
     ///
     /// fn bind<const N: usize>(value: [u8; N]) -> [u8; 3 + 4] {
index 2e50dbff51089a9df7a52808e293bc115f198c27..ccd860ce2428aa33f3b214ec7abce7aaa01aed73 100644 (file)
@@ -889,7 +889,7 @@ fn highlight_outer(
     ///
     /// For the following code:
     ///
-    /// ```no_run
+    /// ```ignore (illustrative)
     /// let x: Foo<Bar<Qux>> = foo::<Bar<Qux>>();
     /// ```
     ///
@@ -1872,7 +1872,7 @@ pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Binder<'tcx, Ty<
 
     /// A possible error is to forget to add `.await` when using futures:
     ///
-    /// ```
+    /// ```compile_fail,E0308
     /// async fn make_u32() -> u32 {
     ///     22
     /// }
index be9db6aa25b75cb2c1ea13048b346a276b7c7f8d..cb72cb41a7c00540f1a4a490eeb7d891bf43a6a5 100644 (file)
@@ -18,7 +18,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
     ///
     /// Consider a case where we have
     ///
-    /// ```no_run
+    /// ```compile_fail,E0623
     /// fn foo(x: &mut Vec<&u8>, y: &u8) {
     ///     x.push(y);
     /// }
index 9c5b944c1e987b3ea5cf9e6870d84787da5ca796..e5ae835e81349c84c1e409338508dc1c82447f83 100644 (file)
@@ -14,7 +14,7 @@
 /// br - the bound region corresponding to the above region which is of type `BrAnon(_)`
 ///
 /// # Example
-/// ```
+/// ```compile_fail,E0623
 /// fn foo(x: &mut Vec<&u8>, y: &u8)
 ///    { x.push(y); }
 /// ```
index 6ec929f98950e6a64901cb84620a2f7dd41b88dd..c9121f7d348ce4cadc44ce5fcae76ff6a8ad7e92 100644 (file)
@@ -159,9 +159,9 @@ pub struct InferCtxtInner<'tcx> {
     /// outlive the lifetime 'a". These constraints derive from
     /// instantiated type parameters. So if you had a struct defined
     /// like
-    ///
+    /// ```ignore (illustrative)
     ///     struct Foo<T:'static> { ... }
-    ///
+    /// ```
     /// then in some expression `let x = Foo { ... }` it will
     /// instantiate the type parameter `T` with a fresh type `$0`. At
     /// the same time, it will record a region obligation of
index 78e6f3a05be66c58c46c54a29f59ee3a63ab264d..d25484efabc5fd613c1eb76817ab68855008177a 100644 (file)
@@ -309,14 +309,22 @@ pub fn handle_opaque_type(
     /// the same as generating an outlives constraint on `Tc` itself.
     /// For example, if we had a function like this:
     ///
-    /// ```rust
+    /// ```
+    /// # #![feature(type_alias_impl_trait)]
+    /// # fn main() {}
+    /// # trait Foo<'a> {}
+    /// # impl<'a, T> Foo<'a> for (&'a u32, T) {}
     /// fn foo<'a, T>(x: &'a u32, y: T) -> impl Foo<'a> {
     ///   (x, y)
     /// }
     ///
     /// // Equivalent to:
+    /// # mod dummy { use super::*;
     /// type FooReturn<'a, T> = impl Foo<'a>;
-    /// fn foo<'a, T>(..) -> FooReturn<'a, T> { .. }
+    /// fn foo<'a, T>(x: &'a u32, y: T) -> FooReturn<'a, T> {
+    ///   (x, y)
+    /// }
+    /// # }
     /// ```
     ///
     /// then the hidden type `Tc` would be `(&'0 u32, T)` (where `'0`
@@ -602,17 +610,17 @@ pub fn register_hidden_type(
 /// Returns `true` if `opaque_hir_id` is a sibling or a child of a sibling of `def_id`.
 ///
 /// Example:
-/// ```rust
+/// ```ignore UNSOLVED (is this a bug?)
+/// # #![feature(type_alias_impl_trait)]
 /// pub mod foo {
 ///     pub mod bar {
-///         pub trait Bar { .. }
-///
+///         pub trait Bar { /* ... */ }
 ///         pub type Baz = impl Bar;
 ///
-///         fn f1() -> Baz { .. }
+///         # impl Bar for () {}
+///         fn f1() -> Baz { /* ... */ }
 ///     }
-///
-///     fn f2() -> bar::Baz { .. }
+///     fn f2() -> bar::Baz { /* ... */ }
 /// }
 /// ```
 ///
index c8236ce79c098ad6d85ad5f9d4c741fcbb6b2a3d..9ddda7b92eb5a57f11b57b1bd37df36993e828c7 100644 (file)
@@ -103,7 +103,7 @@ pub fn region_bound_pairs_map(&self) -> &FxHashMap<hir::HirId, RegionBoundPairs<
     ///
     /// Example:
     ///
-    /// ```
+    /// ```ignore (pseudo-rust)
     /// fn foo<T>() {
     ///    callback(for<'a> |x: &'a T| {
     ///         // ^^^^^^^ not legal syntax, but probably should be
index e3312e6c6e14680c2f33736be429396d50768daf..19d03ffa6964a31171dd859ced1854cc869004bc 100644 (file)
@@ -33,9 +33,9 @@
 //! Consider:
 //!
 //! ```
-//! fn bar<T>(a: T, b: impl for<'a> Fn(&'a T));
+//! fn bar<T>(a: T, b: impl for<'a> Fn(&'a T)) {}
 //! fn foo<T>(x: T) {
-//!     bar(x, |y| { ... })
+//!     bar(x, |y| { /* ... */})
 //!          // ^ closure arg
 //! }
 //! ```
index f69212c599b6258dbb4964098c7a15749aea9e32..ab565d4396191bd60ecbd2cf7e16072870c02577 100644 (file)
@@ -313,7 +313,7 @@ fn declared_projection_bounds_from_trait(
     ///
     /// It will not, however, work for higher-ranked bounds like:
     ///
-    /// ```rust
+    /// ```compile_fail,E0311
     /// trait Foo<'a, 'b>
     /// where for<'x> <Self as Foo<'x, 'b>>::Bar: 'x
     /// {
index 4ea1c3f76c8ad415e392d44a779de1e6a443af5c..efe254387dcc94957934758af86c2c626b8ee3ae 100644 (file)
@@ -174,19 +174,19 @@ pub enum GenericKind<'tcx> {
 /// Describes the things that some `GenericKind` value `G` is known to
 /// outlive. Each variant of `VerifyBound` can be thought of as a
 /// function:
-///
-///     fn(min: Region) -> bool { .. }
-///
+/// ```ignore (pseudo-rust)
+/// fn(min: Region) -> bool { .. }
+/// ```
 /// where `true` means that the region `min` meets that `G: min`.
 /// (False means nothing.)
 ///
 /// So, for example, if we have the type `T` and we have in scope that
 /// `T: 'a` and `T: 'b`, then the verify bound might be:
-///
-///     fn(min: Region) -> bool {
-///        ('a: min) || ('b: min)
-///     }
-///
+/// ```ignore (pseudo-rust)
+/// fn(min: Region) -> bool {
+///    ('a: min) || ('b: min)
+/// }
+/// ```
 /// This is described with an `AnyRegion('a, 'b)` node.
 #[derive(Debug, Clone)]
 pub enum VerifyBound<'tcx> {
@@ -194,7 +194,7 @@ pub enum VerifyBound<'tcx> {
     /// following, where `G` is the generic for which this verify
     /// bound was created:
     ///
-    /// ```rust
+    /// ```ignore (pseudo-rust)
     /// fn(min) -> bool {
     ///     if G == K {
     ///         B(min)
@@ -218,7 +218,7 @@ pub enum VerifyBound<'tcx> {
     ///
     /// So we would compile to a verify-bound like
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// IfEq(<T as Trait<'a>>::Item, AnyRegion('a))
     /// ```
     ///
@@ -228,7 +228,7 @@ pub enum VerifyBound<'tcx> {
 
     /// Given a region `R`, expands to the function:
     ///
-    /// ```
+    /// ```ignore (pseudo-rust)
     /// fn(min) -> bool {
     ///     R: min
     /// }
@@ -243,7 +243,7 @@ pub enum VerifyBound<'tcx> {
 
     /// Given a set of bounds `B`, expands to the function:
     ///
-    /// ```rust
+    /// ```ignore (pseudo-rust)
     /// fn(min) -> bool {
     ///     exists (b in B) { b(min) }
     /// }
@@ -255,7 +255,7 @@ pub enum VerifyBound<'tcx> {
 
     /// Given a set of bounds `B`, expands to the function:
     ///
-    /// ```rust
+    /// ```ignore (pseudo-rust)
     /// fn(min) -> bool {
     ///     forall (b in B) { b(min) }
     /// }
index 74c440890452a1bbe1d1db6c243f9f3dabf1d3fe..a0e2965b605121223fdae8ee08d6749ef7411192 100644 (file)
@@ -73,10 +73,10 @@ pub struct TypeVariableStorage<'tcx> {
     /// table exists only to help with the occurs check. In particular,
     /// we want to report constraints like these as an occurs check
     /// violation:
-    ///
-    ///     ?1 <: ?3
-    ///     Box<?3> <: ?1
-    ///
+    /// ``` text
+    /// ?1 <: ?3
+    /// Box<?3> <: ?1
+    /// ```
     /// Without this second table, what would happen in a case like
     /// this is that we would instantiate `?1` with a generalized
     /// type like `Box<?6>`. We would then relate `Box<?3> <: Box<?6>`
@@ -287,8 +287,9 @@ pub fn root_var(&mut self, vid: ty::TyVid) -> ty::TyVid {
     /// related via equality or subtyping will yield the same root
     /// variable (per the union-find algorithm), so `sub_root_var(a)
     /// == sub_root_var(b)` implies that:
-    ///
-    ///     exists X. (a <: X || X <: a) && (b <: X || X <: b)
+    /// ```text
+    /// exists X. (a <: X || X <: a) && (b <: X || X <: b)
+    /// ```
     pub fn sub_root_var(&mut self, vid: ty::TyVid) -> ty::TyVid {
         self.sub_relations().find(vid)
     }
index a42e3d5d9578502a216ce6624e676498139ac99c..092cbbccd33dc5448ca93a3f0c9c84578ab9d615 100644 (file)
     ///
     /// ### Example
     ///
-    /// ```rust,compile_fail
+    /// ```compile_fail
+    /// #![deny(unaligned_references)]
     /// #[repr(packed)]
     /// pub struct Foo {
     ///     field1: u64,
index e0ed402283904a1bf99a1a9f0dbf7df8cf73bb6d..0831d7d04f5f226ad89977f7a0e04319e8d22460 100644 (file)
@@ -742,7 +742,7 @@ pub fn is_inside_const_context(self, hir_id: HirId) -> bool {
     /// }
     /// ```
     ///
-    /// ```
+    /// ```compile_fail,E0308
     /// fn foo(x: usize) -> bool {
     ///     loop {
     ///         true  // If `get_return_block` gets passed the `id` corresponding
index 497d3811f281b0af514163f092e46969f40dabc6..2350a6ab155464f5c8fa710e793f67b2e41a1c8b 100644 (file)
@@ -10,7 +10,7 @@
 /// Requires that `region` must be equal to one of the regions in `choice_regions`.
 /// We often denote this using the syntax:
 ///
-/// ```
+/// ```text
 /// R0 member of [O1..On]
 /// ```
 #[derive(Debug, Clone, HashStable, TypeFoldable, Lift)]
index 8cfc5ed0a95d06147ceab0adbbb5a6bf0670bad2..5564852f305399e6f328b0311b3fc58131499ece 100644 (file)
@@ -770,11 +770,11 @@ fn find_bit(&self, start: Size, end: Size, is_init: bool) -> Option<Size> {
         ///
         /// Note that all examples below are written with 8 (instead of 64) bit blocks for simplicity,
         /// and with the least significant bit (and lowest block) first:
-        ///
-        ///          00000000|00000000
-        ///          ^      ^ ^      ^
-        ///   index: 0      7 8      15
-        ///
+        /// ```text
+        ///        00000000|00000000
+        ///        ^      ^ ^      ^
+        /// index: 0      7 8      15
+        /// ```
         /// Also, if not stated, assume that `is_init = true`, that is, we are searching for the first 1 bit.
         fn find_bit_fast(
             init_mask: &InitMask,
index 45999f8765897f036f8521f4d69ceb739fe619c6..b357a657b5981de15a7752bfd3fd2457a8aaae37 100644 (file)
@@ -737,14 +737,14 @@ pub enum BorrowKind {
     /// This is used when lowering matches: when matching on a place we want to
     /// ensure that place have the same value from the start of the match until
     /// an arm is selected. This prevents this code from compiling:
-    ///
-    ///     let mut x = &Some(0);
-    ///     match *x {
-    ///         None => (),
-    ///         Some(_) if { x = &None; false } => (),
-    ///         Some(_) => (),
-    ///     }
-    ///
+    /// ```compile_fail,E0510
+    /// let mut x = &Some(0);
+    /// match *x {
+    ///     None => (),
+    ///     Some(_) if { x = &None; false } => (),
+    ///     Some(_) => (),
+    /// }
+    /// ```
     /// This can't be a shared borrow because mutably borrowing (*x as Some).0
     /// should not prevent `if let None = x { ... }`, for example, because the
     /// mutating `(*x as Some).0` can't affect the discriminant of `x`.
@@ -755,27 +755,30 @@ pub enum BorrowKind {
     /// cannot currently be expressed by the user and is used only in
     /// implicit closure bindings. It is needed when the closure is
     /// borrowing or mutating a mutable referent, e.g.:
-    ///
-    ///     let x: &mut isize = ...;
-    ///     let y = || *x += 5;
-    ///
+    /// ```
+    /// let mut z = 3;
+    /// let x: &mut isize = &mut z;
+    /// let y = || *x += 5;
+    /// ```
     /// If we were to try to translate this closure into a more explicit
     /// form, we'd encounter an error with the code as written:
-    ///
-    ///     struct Env { x: & &mut isize }
-    ///     let x: &mut isize = ...;
-    ///     let y = (&mut Env { &x }, fn_ptr);  // Closure is pair of env and fn
-    ///     fn fn_ptr(env: &mut Env) { **env.x += 5; }
-    ///
+    /// ```compile_fail,E0594
+    /// struct Env<'a> { x: &'a &'a mut isize }
+    /// let mut z = 3;
+    /// let x: &mut isize = &mut z;
+    /// let y = (&mut Env { x: &x }, fn_ptr);  // Closure is pair of env and fn
+    /// fn fn_ptr(env: &mut Env) { **env.x += 5; }
+    /// ```
     /// This is then illegal because you cannot mutate an `&mut` found
     /// in an aliasable location. To solve, you'd have to translate with
     /// an `&mut` borrow:
-    ///
-    ///     struct Env { x: &mut &mut isize }
-    ///     let x: &mut isize = ...;
-    ///     let y = (&mut Env { &mut x }, fn_ptr); // changed from &x to &mut x
-    ///     fn fn_ptr(env: &mut Env) { **env.x += 5; }
-    ///
+    /// ```compile_fail,E0596
+    /// struct Env<'a> { x: &'a mut &'a mut isize }
+    /// let mut z = 3;
+    /// let x: &mut isize = &mut z;
+    /// let y = (&mut Env { x: &mut x }, fn_ptr); // changed from &x to &mut x
+    /// fn fn_ptr(env: &mut Env) { **env.x += 5; }
+    /// ```
     /// Now the assignment to `**env.x` is legal, but creating a
     /// mutable pointer to `x` is not because `x` is not mutable. We
     /// could fix this by declaring `x` as `let mut x`. This is ok in
@@ -1016,7 +1019,7 @@ pub struct LocalDecl<'tcx> {
     /// ```
     /// fn foo(x: &str) {
     ///     match {
-    ///         match x.parse().unwrap() {
+    ///         match x.parse::<u32>().unwrap() {
     ///             y => y + 2
     ///         }
     ///     } {
@@ -1690,9 +1693,9 @@ pub enum StatementKind<'tcx> {
 
     /// Encodes a user's type ascription. These need to be preserved
     /// intact so that NLL can respect them. For example:
-    ///
-    ///     let a: T = y;
-    ///
+    /// ```ignore (illustrative)
+    /// let a: T = y;
+    /// ```
     /// The effect of this annotation is to relate the type `T_y` of the place `y`
     /// to the user-given type `T`. The effect depends on the specified variance:
     ///
@@ -1985,7 +1988,7 @@ pub enum ProjectionElem<V, T> {
     /// These indices are generated by slice patterns. Easiest to explain
     /// by example:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// [X, _, .._, _, _] => { offset: 0, min_length: 4, from_end: false },
     /// [_, X, .._, _, _] => { offset: 1, min_length: 4, from_end: false },
     /// [_, _, .._, X, _] => { offset: 2, min_length: 4, from_end: true },
@@ -3179,7 +3182,7 @@ fn from_opt_const_arg_anon_const(
 ///
 /// An example:
 ///
-/// ```rust
+/// ```ignore (illustrative)
 /// struct S<'a>((i32, &'a str), String);
 /// let S((_, w): (i32, &'static str), _): S = ...;
 /// //    ------  ^^^^^^^^^^^^^^^^^^^ (1)
index f76217d921d94599ebde867458c9a26503d0d963..d389fa8c0ebdde82933a106cda01409431368097 100644 (file)
@@ -438,7 +438,7 @@ pub fn new(tcx: TyCtxt<'tcx>) -> Self {
     ///
     /// This function will build CGU names of the form:
     ///
-    /// ```
+    /// ```text
     /// <crate-name>.<crate-disambiguator>[-in-<local-crate-id>](-<component>)*[.<special-suffix>]
     /// <local-crate-id> = <local-crate-name>.<local-crate-disambiguator>
     /// ```
index cc08857463d5869301f8831865d10654fa01b573..e6eb63fd3b2b8307556dff18bebe92542b26e055 100644 (file)
@@ -202,7 +202,7 @@ pub enum TerminatorKind<'tcx> {
     /// This assignment occurs both in the unwind and the regular code paths. The semantics are best
     /// explained by the elaboration:
     ///
-    /// ```
+    /// ```ignore (MIR)
     /// BB0 {
     ///   DropAndReplace(P <- V, goto BB1, unwind BB2)
     /// }
@@ -210,7 +210,7 @@ pub enum TerminatorKind<'tcx> {
     ///
     /// becomes
     ///
-    /// ```
+    /// ```ignore (MIR)
     /// BB0 {
     ///   Drop(P, goto BB1, unwind BB2)
     /// }
index 45b1ad6df8226f2118742f4c7f6e9264f99b9642..350bdfdadb25861add366e239bd332126e936358 100644 (file)
@@ -29,7 +29,7 @@
 //!
 //! For example, the `super_basic_block_data` method begins like this:
 //!
-//! ```rust
+//! ```ignore (pseudo-rust)
 //! fn super_basic_block_data(&mut self,
 //!                           block: BasicBlock,
 //!                           data: & $($mutability)? BasicBlockData<'tcx>) {
@@ -1170,10 +1170,10 @@ pub enum NonMutatingUseContext {
     AddressOf,
     /// Used as base for another place, e.g., `x` in `x.y`. Will not mutate the place.
     /// For example, the projection `x.y` is not marked as a mutation in these cases:
-    ///
-    ///     z = x.y;
-    ///     f(&x.y);
-    ///
+    /// ```ignore (illustrative)
+    /// z = x.y;
+    /// f(&x.y);
+    /// ```
     Projection,
 }
 
@@ -1199,10 +1199,10 @@ pub enum MutatingUseContext {
     AddressOf,
     /// Used as base for another place, e.g., `x` in `x.y`. Could potentially mutate the place.
     /// For example, the projection `x.y` is marked as a mutation in these cases:
-    ///
-    ///     x.y = ...;
-    ///     f(&mut x.y);
-    ///
+    /// ```ignore (illustrative)
+    /// x.y = ...;
+    /// f(&mut x.y);
+    /// ```
     Projection,
     /// Retagging, a "Stacked Borrows" shadow state operation
     Retag,
index 7c3d08b26bf54e38d46cf769f9306bdd793329a5..ffde1294ec655ffef3114f31d9d73a70a348b809 100644 (file)
@@ -47,7 +47,8 @@ pub enum Reveal {
     /// impl. Concretely, that means that the following example will
     /// fail to compile:
     ///
-    /// ```
+    /// ```compile_fail,E0308
+    /// #![feature(specialization)]
     /// trait Assoc {
     ///     type Output;
     /// }
@@ -57,7 +58,7 @@ pub enum Reveal {
     /// }
     ///
     /// fn main() {
-    ///     let <() as Assoc>::Output = true;
+    ///     let x: <() as Assoc>::Output = true;
     /// }
     /// ```
     UserFacing,
@@ -515,7 +516,7 @@ pub enum SelectionError<'tcx> {
 /// For example, the obligation may be satisfied by a specific impl (case A),
 /// or it may be relative to some bound that is in scope (case B).
 ///
-/// ```
+/// ```ignore (illustrative)
 /// impl<T:Clone> Clone<T> for Option<T> { ... } // Impl_1
 /// impl<T:Clone> Clone<T> for Box<T> { ... }    // Impl_2
 /// impl Clone for i32 { ... }                   // Impl_3
index c43ec048c3f99e2e086ac0c541229d20de268f66..ce13825b01696c7af51311dd718f4b946e232ae3 100644 (file)
@@ -180,6 +180,7 @@ pub struct LeafDef {
     /// Example:
     ///
     /// ```
+    /// #![feature(specialization)]
     /// trait Tr {
     ///     fn assoc(&self);
     /// }
index 2676b7ab521d83bfb2bc9f87493e59d94d494c10..d9332f6896af6bc0bcae9a7ea7727a7b90d02050 100644 (file)
@@ -59,7 +59,7 @@ pub enum PointerCast {
 ///    sized struct to a dynamically sized one. E.g., `&[i32; 4]` -> `&[i32]` is
 ///    represented by:
 ///
-///    ```
+///    ```ignore (illustrative)
 ///    Deref(None) -> [i32; 4],
 ///    Borrow(AutoBorrow::Ref) -> &[i32; 4],
 ///    Unsize -> &[i32],
index fc6710f07e37b655bf6aa3d1f5592e75b5ed8344..2e4c16e39eb9671ed0de6557b1bb12f3fbb03f05 100644 (file)
@@ -82,7 +82,7 @@ pub struct AdtFlags: u32 {
 ///
 /// is essentially represented with [`Ty`] as the following pseudocode:
 ///
-/// ```
+/// ```ignore (illustrative)
 /// struct S { x }
 /// ```
 ///
index 3bddf7fb6ffc4c9daa6d090a0db08418d13081eb..c88cac30a1927075f2ee503f841ea7a25413ab68 100644 (file)
@@ -293,7 +293,7 @@ pub struct CaptureInfo {
     /// let mut t = (0,1);
     ///
     /// let c = || {
-    ///     println!("{t}"); // L1
+    ///     println!("{t:?}"); // L1
     ///     t.1 = 4; // L2
     /// };
     /// ```
@@ -309,7 +309,7 @@ pub struct CaptureInfo {
     /// let x = 5;
     ///
     /// let c = || {
-    ///     let _ = x
+    ///     let _ = x;
     /// };
     /// ```
     ///
@@ -373,17 +373,19 @@ pub enum BorrowKind {
     /// is borrowing or mutating a mutable referent, e.g.:
     ///
     /// ```
-    /// let x: &mut isize = ...;
+    /// let mut z = 3;
+    /// let x: &mut isize = &mut z;
     /// let y = || *x += 5;
     /// ```
     ///
     /// If we were to try to translate this closure into a more explicit
     /// form, we'd encounter an error with the code as written:
     ///
-    /// ```
-    /// struct Env { x: & &mut isize }
-    /// let x: &mut isize = ...;
-    /// let y = (&mut Env { &x }, fn_ptr);  // Closure is pair of env and fn
+    /// ```compile_fail,E0594
+    /// struct Env<'a> { x: &'a &'a mut isize }
+    /// let mut z = 3;
+    /// let x: &mut isize = &mut z;
+    /// let y = (&mut Env { x: &x }, fn_ptr);  // Closure is pair of env and fn
     /// fn fn_ptr(env: &mut Env) { **env.x += 5; }
     /// ```
     ///
@@ -391,10 +393,11 @@ pub enum BorrowKind {
     /// in an aliasable location. To solve, you'd have to translate with
     /// an `&mut` borrow:
     ///
-    /// ```
-    /// struct Env { x: &mut &mut isize }
-    /// let x: &mut isize = ...;
-    /// let y = (&mut Env { &mut x }, fn_ptr); // changed from &x to &mut x
+    /// ```compile_fail,E0596
+    /// struct Env<'a> { x: &'a mut &'a mut isize }
+    /// let mut z = 3;
+    /// let x: &mut isize = &mut z;
+    /// let y = (&mut Env { x: &mut x }, fn_ptr); // changed from &x to &mut x
     /// fn fn_ptr(env: &mut Env) { **env.x += 5; }
     /// ```
     ///
index 30fe3ffa7e3c46c0b438269ebf430942b85397c8..cf9f229779ff89fac6635e545938eb40368ba75d 100644 (file)
@@ -455,12 +455,13 @@ pub struct TypeckResults<'tcx> {
     /// # Example
     ///
     /// ```rust
+    /// # use std::fmt::Debug;
     /// fn foo(x: &u32) -> impl Debug { *x }
     /// ```
     ///
     /// The function signature here would be:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// for<'a> fn(&'a u32) -> Foo
     /// ```
     ///
@@ -469,7 +470,7 @@ pub struct TypeckResults<'tcx> {
     ///
     /// The *liberated* form of this would be
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// fn(&'a u32) -> u32
     /// ```
     ///
index 075928c889d8320d2cef60e8f999517ca4940c64..896a8280551d2e44908165d68b870cf70f21134b 100644 (file)
@@ -41,7 +41,7 @@
 //!
 //! For example, if you have `struct S(Ty, U)` where `S: TypeFoldable` and `U:
 //! TypeFoldable`, and an instance `S(ty, u)`, it would be visited like so:
-//! ```
+//! ```text
 //! s.visit_with(visitor) calls
 //! - s.super_visit_with(visitor) calls
 //!   - ty.visit_with(visitor) calls
@@ -486,13 +486,13 @@ struct RegionVisitor<F> {
             /// traversed. If we encounter a bound region bound by this
             /// binder or one outer to it, it appears free. Example:
             ///
-            /// ```
-            ///    for<'a> fn(for<'b> fn(), T)
-            /// ^          ^          ^     ^
-            /// |          |          |     | here, would be shifted in 1
-            /// |          |          | here, would be shifted in 2
-            /// |          | here, would be `INNERMOST` shifted in by 1
-            /// | here, initially, binder would be `INNERMOST`
+            /// ```ignore (illustrative)
+            ///       for<'a> fn(for<'b> fn(), T)
+            /// // ^          ^          ^     ^
+            /// // |          |          |     | here, would be shifted in 1
+            /// // |          |          | here, would be shifted in 2
+            /// // |          | here, would be `INNERMOST` shifted in by 1
+            /// // | here, initially, binder would be `INNERMOST`
             /// ```
             ///
             /// You see that, initially, *any* bound value is free,
index 226456588e75d3c12545132f4671ce3b23ecfc9d..b8088766cca68674d3d960e5e5b5de565c14da7a 100644 (file)
@@ -56,7 +56,9 @@ impl<'tcx> TyCtxt<'tcx> {
     /// Checks whether a type is visibly uninhabited from a particular module.
     ///
     /// # Example
-    /// ```rust
+    /// ```
+    /// #![feature(never_type)]
+    /// # fn main() {}
     /// enum Void {}
     /// mod a {
     ///     pub mod b {
@@ -67,6 +69,7 @@ impl<'tcx> TyCtxt<'tcx> {
     /// }
     ///
     /// mod c {
+    ///     use super::Void;
     ///     pub struct AlsoSecretlyUninhabited {
     ///         _priv: Void,
     ///     }
@@ -84,7 +87,7 @@ impl<'tcx> TyCtxt<'tcx> {
     /// contain `Foo`.
     ///
     /// # Example
-    /// ```rust
+    /// ```ignore (illustrative)
     /// let foo_result: Result<T, Foo> = ... ;
     /// let Ok(t) = foo_result;
     /// ```
index 00b3639a99776d57aa119f1ccc01732cc348195e..03d3a4a8c5f3c4263ef5d7286c2c5714be3ec35c 100644 (file)
@@ -337,7 +337,7 @@ pub fn def_id(&self) -> DefId {
     /// Returns `Ok(None)` if we cannot resolve `Instance` to a specific instance.
     /// For example, in a context like this,
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// fn foo<T: Debug>(t: T) { ... }
     /// ```
     ///
index ec416722c214e6018bc9f566c7e2aa065292b4c4..0ad1775d3b54e61b435bf7006810daeb48822d99 100644 (file)
@@ -1012,9 +1012,9 @@ pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
 /// their values.
 ///
 /// Example:
-///
-///     struct Foo<T, U: Bar<T>> { ... }
-///
+/// ```ignore (illustrative)
+/// struct Foo<T, U: Bar<T>> { ... }
+/// ```
 /// Here, the `GenericPredicates` for `Foo` would contain a list of bounds like
 /// `[[], [U:Bar<T>]]`. Now if there were some particular reference
 /// like `Foo<isize,usize>`, then the `InstantiatedPredicates` would be `[[],
@@ -1072,9 +1072,9 @@ pub struct OpaqueHiddenType<'tcx> {
     /// The type variable that represents the value of the opaque type
     /// that we require. In other words, after we compile this function,
     /// we will be created a constraint like:
-    ///
-    ///     Foo<'a, T> = ?C
-    ///
+    /// ```ignore (pseudo-rust)
+    /// Foo<'a, T> = ?C
+    /// ```
     /// where `?C` is the value of this type variable. =) It may
     /// naturally refer to the type and lifetime parameters in scope
     /// in this function, though ultimately it should only reference
@@ -1115,7 +1115,7 @@ pub fn report_mismatch(&self, other: &Self, tcx: TyCtxt<'tcx>) {
     ///
     /// To make this more concrete, consider this program:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// struct Foo { }
     /// fn bar<T>(x: T) {
     ///   let y: for<'a> fn(&'a u8, Foo) = ...;
@@ -1154,7 +1154,7 @@ impl UniverseIndex {
     /// corresponds to entering a `forall` quantifier. So, for
     /// example, suppose we have this type in universe `U`:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// for<'a> fn(&'a u32)
     /// ```
     ///
@@ -1941,7 +1941,7 @@ pub enum ImplOverlapKind {
     /// The widely-used version 0.1.0 of the crate `traitobject` had accidentally relied
     /// that difference, making what reduces to the following set of impls:
     ///
-    /// ```
+    /// ```compile_fail,(E0119)
     /// trait Trait {}
     /// impl Trait for dyn Send + Sync {}
     /// impl Trait for dyn Sync + Send {}
index 1509de0e93070aa44ce92a9e13bbe6e64bb845d8..a2e19761d93e8b5009423a0e5c59380e9e1d25a7 100644 (file)
@@ -187,12 +187,14 @@ pub enum TyKind<'tcx> {
     /// Looking at the following example, the witness for this generator
     /// may end up as something like `for<'a> [Vec<i32>, &'a Vec<i32>]`:
     ///
-    /// ```rust
+    /// ```ignore UNSOLVED (ask @compiler-errors, should this error? can we just swap the yields?)
+    /// #![feature(generators)]
     /// |a| {
     ///     let x = &vec![3];
     ///     yield a;
     ///     yield x[0];
     /// }
+    /// # ;
     /// ```
     GeneratorWitness(Binder<'tcx, &'tcx List<Ty<'tcx>>>),
 
@@ -276,9 +278,9 @@ pub fn article(&self) -> &'static str {
 static_assert_size!(TyKind<'_>, 32);
 
 /// A closure can be modeled as a struct that looks like:
-///
-///     struct Closure<'l0...'li, T0...Tj, CK, CS, U>(...U);
-///
+/// ```ignore (illustrative)
+/// struct Closure<'l0...'li, T0...Tj, CK, CS, U>(...U);
+/// ```
 /// where:
 ///
 /// - 'l0...'li and T0...Tj are the generic parameters
@@ -295,25 +297,25 @@ pub fn article(&self) -> &'static str {
 ///    and the up-var has the type `Foo`, then that field of U will be `&Foo`).
 ///
 /// So, for example, given this function:
-///
-///     fn foo<'a, T>(data: &'a mut T) {
-///          do(|| data.count += 1)
-///     }
-///
+/// ```ignore (illustrative)
+/// fn foo<'a, T>(data: &'a mut T) {
+///      do(|| data.count += 1)
+/// }
+/// ```
 /// the type of the closure would be something like:
-///
-///     struct Closure<'a, T, U>(...U);
-///
+/// ```ignore (illustrative)
+/// struct Closure<'a, T, U>(...U);
+/// ```
 /// Note that the type of the upvar is not specified in the struct.
 /// You may wonder how the impl would then be able to use the upvar,
 /// if it doesn't know it's type? The answer is that the impl is
 /// (conceptually) not fully generic over Closure but rather tied to
 /// instances with the expected upvar types:
-///
-///     impl<'b, 'a, T> FnMut() for Closure<'a, T, (&'b mut &'a mut T,)> {
-///         ...
-///     }
-///
+/// ```ignore (illustrative)
+/// impl<'b, 'a, T> FnMut() for Closure<'a, T, (&'b mut &'a mut T,)> {
+///     ...
+/// }
+/// ```
 /// You can see that the *impl* fully specified the type of the upvar
 /// and thus knows full well that `data` has type `&'b mut &'a mut T`.
 /// (Here, I am assuming that `data` is mut-borrowed.)
@@ -760,9 +762,9 @@ pub fn tupled_upvars_ty(self) -> Ty<'tcx> {
 }
 
 /// An inline const is modeled like
-///
-///     const InlineConst<'l0...'li, T0...Tj, R>: R;
-///
+/// ```ignore (illustrative)
+/// const InlineConst<'l0...'li, T0...Tj, R>: R;
+/// ```
 /// where:
 ///
 /// - 'l0...'li and T0...Tj are the generic parameters
@@ -936,9 +938,9 @@ pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item = DefId> + 'a {
 
 /// A complete reference to a trait. These take numerous guises in syntax,
 /// but perhaps the most recognizable form is in a where-clause:
-///
-///     T: Foo<U>
-///
+/// ```ignore (illustrative)
+/// T: Foo<U>
+/// ```
 /// This would be represented by a trait-reference where the `DefId` is the
 /// `DefId` for the trait `Foo` and the substs define `T` as parameter 0,
 /// and `U` as parameter 1.
@@ -1012,9 +1014,9 @@ pub fn to_poly_trait_predicate_negative_polarity(&self) -> ty::PolyTraitPredicat
 
 /// An existential reference to a trait, where `Self` is erased.
 /// For example, the trait object `Trait<'a, 'b, X, Y>` is:
-///
-///     exists T. T: Trait<'a, 'b, X, Y>
-///
+/// ```ignore (illustrative)
+/// exists T. T: Trait<'a, 'b, X, Y>
+/// ```
 /// The substitutions don't include the erased `Self`, only trait
 /// type and lifetime parameters (`[X, Y]` and `['a, 'b]` above).
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
@@ -1434,7 +1436,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 ///
 /// In general, the region lattice looks like
 ///
-/// ```
+/// ```text
 /// static ----------+-----...------+       (greatest)
 /// |                |              |
 /// early-bound and  |              |
@@ -1780,14 +1782,14 @@ pub fn type_flags(self) -> TypeFlags {
     /// Given an early-bound or free region, returns the `DefId` where it was bound.
     /// For example, consider the regions in this snippet of code:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// impl<'a> Foo {
-    ///      ^^ -- early bound, declared on an impl
+    /// //   ^^ -- early bound, declared on an impl
     ///
     ///     fn bar<'b, 'c>(x: &self, y: &'b u32, z: &'c u64) where 'static: 'c
-    ///            ^^  ^^     ^ anonymous, late-bound
-    ///            |   early-bound, appears in where-clauses
-    ///            late-bound, appears only in fn args
+    /// //         ^^  ^^     ^ anonymous, late-bound
+    /// //         |   early-bound, appears in where-clauses
+    /// //         late-bound, appears only in fn args
     ///     {..}
     /// }
     /// ```
index 46b938ea93baa0ab7bfa5218eac13c1b7e92ef09..5063420e975d14663721f6adc9c0229e732130ea 100644 (file)
@@ -687,17 +687,17 @@ fn const_for_param(&self, p: ParamConst, source_ct: ty::Const<'tcx>) -> ty::Cons
     ///
     /// ```
     /// type Func<A> = 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> = (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<T> { }
 /// impl<A> Foo<A> { fn method() { } }
 /// ```
index 918fe49e8e3fc6dad1b3d0ed645cfc531477d6b9..40e449cf10efc675ee1116b76057e6977c7360ee 100644 (file)
@@ -975,7 +975,7 @@ impl<'tcx> ExplicitSelf<'tcx> {
     ///
     /// Examples:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// impl<'a> Foo for &'a T {
     ///     // Legal declarations:
     ///     fn method1(self: &&'a T); // ExplicitSelf::ByReference
index 9f57e1a977a93ecff4ecb94d3ccd8ac20913c286..09946f02448d6a5f95d7545b121375089475acbe 100644 (file)
@@ -34,7 +34,7 @@ pub fn new(root: GenericArg<'tcx>) -> Self {
     ///
     /// Example: Imagine you are walking `Foo<Bar<i32>, usize>`.
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// let mut iter: TypeWalker = ...;
     /// iter.next(); // yields Foo
     /// iter.next(); // yields Bar<i32>
index b627b0763a286c2822d250178d73b05e12bb733c..7358fa62863674eb0a5d81e510a9270c37b2e963 100644 (file)
@@ -42,15 +42,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
     /// We tweak the handling of parameters of unsized type slightly to avoid the need to create a
     /// local variable of unsized type. For example, consider this program:
     ///
-    /// ```rust
-    /// fn foo(p: dyn Debug) { ... }
+    /// ```
+    /// #![feature(unsized_locals, unsized_fn_params)]
+    /// # use core::fmt::Debug;
+    /// fn foo(p: dyn Debug) { dbg!(p); }
     ///
-    /// fn bar(box_p: Box<dyn Debug>) { foo(*p); }
+    /// fn bar(box_p: Box<dyn Debug>) { foo(*box_p); }
     /// ```
     ///
     /// Ordinarily, for sized types, we would compile the call `foo(*p)` like so:
     ///
-    /// ```rust
+    /// ```ignore (illustrative)
     /// let tmp0 = *box_p; // tmp0 would be the operand returned by this function call
     /// foo(tmp0)
     /// ```
@@ -60,7 +62,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
     /// that we create *stores the entire box*, and the parameter to the call itself will be
     /// `*tmp0`:
     ///
-    /// ```rust
+    /// ```ignore (illustrative)
     /// let tmp0 = box_p; call foo(*tmp0)
     /// ```
     ///
index 3b3120cf04b7f64715385bef22ca7e3057b08899..fa1bb0622bd11ac36ad3fcdf54430f1fccbae3e9 100644 (file)
@@ -37,7 +37,7 @@
     ///
     /// Consider the following example
     /// ```rust
-    /// let t = (10, (10, (10, 10)));
+    /// let t = (((10, 10), 10), 10);
     ///
     /// let c = || {
     ///     println!("{}", t.0.0.0);
@@ -45,7 +45,7 @@
     /// ```
     /// Here the THIR expression for `t.0.0.0` will be something like
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// * Field(0)
     ///     * Field(0)
     ///         * Field(0)
index d45ae19752e8c0f0019166c143ffdc60c7a95426..8594d0806bbdd9b34c2b02c9b291e13718349edd 100644 (file)
@@ -1032,11 +1032,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
     /// exhaustive match, consider:
     ///
     /// ```
+    /// # fn foo(x: (bool, bool)) {
     /// match x {
     ///     (true, true) => (),
     ///     (_, false) => (),
     ///     (false, true) => (),
     /// }
+    /// # }
     /// ```
     ///
     /// For this match, we check if `x.0` matches `true` (for the first
@@ -1157,7 +1159,7 @@ fn match_simplified_candidates(
     ///
     /// For example, if we have something like this:
     ///
-    /// ```rust
+    /// ```ignore (illustrative)
     /// ...
     /// Some(x) if cond1 => ...
     /// Some(x) => ...
@@ -1481,11 +1483,12 @@ fn merge_trivial_subcandidates(
     /// ```
     /// # let (x, y, z) = (true, true, true);
     /// match (x, y, z) {
-    ///     (true, _, true) => true,    // (0)
-    ///     (_, true, _) => true,       // (1)
-    ///     (false, false, _) => false, // (2)
-    ///     (true, _, false) => false,  // (3)
+    ///     (true , _    , true ) => true,  // (0)
+    ///     (_    , true , _    ) => true,  // (1)
+    ///     (false, false, _    ) => false, // (2)
+    ///     (true , _    , false) => false, // (3)
     /// }
+    /// # ;
     /// ```
     ///
     /// In that case, after we test on `x`, there are 2 overlapping candidate
@@ -1502,14 +1505,14 @@ fn merge_trivial_subcandidates(
     /// with precisely the reachable arms being reachable - but that problem
     /// is trivially NP-complete:
     ///
-    /// ```rust
-    ///     match (var0, var1, var2, var3, ...) {
-    ///         (true, _, _, false, true, ...) => false,
-    ///         (_, true, true, false, _, ...) => false,
-    ///         (false, _, false, false, _, ...) => false,
-    ///         ...
-    ///         _ => true
-    ///     }
+    /// ```ignore (illustrative)
+    /// match (var0, var1, var2, var3, ...) {
+    ///     (true , _   , _    , false, true, ...) => false,
+    ///     (_    , true, true , false, _   , ...) => false,
+    ///     (false, _   , false, false, _   , ...) => false,
+    ///     ...
+    ///     _ => true
+    /// }
     /// ```
     ///
     /// Here the last arm is reachable only if there is an assignment to
@@ -1520,7 +1523,7 @@ fn merge_trivial_subcandidates(
     /// our simplistic treatment of constants and guards would make it occur
     /// in very common situations - for example [#29740]:
     ///
-    /// ```rust
+    /// ```ignore (illustrative)
     /// match x {
     ///     "foo" if foo_guard => ...,
     ///     "bar" if bar_guard => ...,
index d96534fe3e0a879e6f7287dbf19ec36ee9478b03..465bd62406efe92e8eafcabe18e6148f3a02ae6b 100644 (file)
@@ -803,16 +803,16 @@ fn leave_top_scope(&mut self, block: BasicBlock) -> BasicBlock {
     /// scope (which can be larger or smaller).
     ///
     /// Consider:
-    ///
-    ///     let x = foo(bar(X, Y));
-    ///
+    /// ```ignore (illustrative)
+    /// let x = foo(bar(X, Y));
+    /// ```
     /// We wish to pop the storage for X and Y after `bar()` is
     /// called, not after the whole `let` is completed.
     ///
     /// As another example, if the second argument diverges:
-    ///
-    ///     foo(Box::new(2), panic!())
-    ///
+    /// ```ignore (illustrative)
+    /// foo(Box::new(2), panic!())
+    /// ```
     /// We would allocate the box but then free it on the unwinding
     /// path; we would also emit a free on the 'success' path from
     /// panic, but that will turn out to be removed as dead-code.
@@ -944,7 +944,7 @@ fn leave_top_scope(&mut self, block: BasicBlock) -> BasicBlock {
     ///
     /// Example: when compiling the call to `foo` here:
     ///
-    /// ```rust
+    /// ```ignore (illustrative)
     /// foo(bar(), ...)
     /// ```
     ///
@@ -955,7 +955,7 @@ fn leave_top_scope(&mut self, block: BasicBlock) -> BasicBlock {
     /// dropped). However, if no unwind occurs, then `_X` will be
     /// unconditionally consumed by the `call`:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// bb {
     ///   ...
     ///   _R = CALL(foo, _X, ...)
index 72f0d07c260cac3aeb878d7949af6c08043d04a0..60eead69a1b05445f80c696832b7dcb682fa22bb 100644 (file)
@@ -13,7 +13,7 @@
 //! Instead of listing all those constructors (which is intractable), we group those value
 //! constructors together as much as possible. Example:
 //!
-//! ```
+//! ```compile_fail,E0004
 //! match (0, false) {
 //!     (0 ..=100, true) => {} // `p_1`
 //!     (50..=150, false) => {} // `p_2`
@@ -344,13 +344,13 @@ enum IntBorder {
 /// straddles the boundary of one of the inputs.
 ///
 /// The following input:
-/// ```
+/// ```text
 ///   |-------------------------| // `self`
 /// |------|  |----------|   |----|
 ///    |-------| |-------|
 /// ```
 /// would be iterated over as follows:
-/// ```
+/// ```text
 ///   ||---|--||-|---|---|---|--|
 /// ```
 #[derive(Debug, Clone)]
@@ -492,14 +492,17 @@ fn is_covered_by(self, other: Self) -> bool {
 ///
 /// Let's look at an example, where we are trying to split the last pattern:
 /// ```
+/// # fn foo(x: &[bool]) {
 /// match x {
 ///     [true, true, ..] => {}
 ///     [.., false, false] => {}
 ///     [..] => {}
 /// }
+/// # }
 /// ```
 /// Here are the results of specialization for the first few lengths:
 /// ```
+/// # fn foo(x: &[bool]) { match x {
 /// // length 0
 /// [] => {}
 /// // length 1
@@ -520,6 +523,8 @@ fn is_covered_by(self, other: Self) -> bool {
 /// [true, true, _, _,     _    ] => {}
 /// [_,    _,    _, false, false] => {}
 /// [_,    _,    _, _,     _    ] => {}
+/// # _ => {}
+/// # }}
 /// ```
 ///
 /// If we went above length 5, we would simply be inserting more columns full of wildcards in the
@@ -1128,7 +1133,8 @@ pub(super) fn iter_missing<'a, 'p>(
 /// In the following example `Fields::wildcards` returns `[_, _, _, _]`. Then in
 /// `extract_pattern_arguments` we fill some of the entries, and the result is
 /// `[Some(0), _, _, _]`.
-/// ```rust
+/// ```compile_fail,E0004
+/// # fn foo() -> [Option<u8>; 4] { [None; 4] }
 /// let x: [Option<u8>; 4] = foo();
 /// match x {
 ///     [Some(0), ..] => {}
index 687b2e23c9fcb01cbf455addae52954f5a4955d2..4e96cfd9bbd501191157dc7f64a3fc8ae456dd3c 100644 (file)
 //! This is enough to compute reachability: a pattern in a `match` expression is reachable iff it
 //! is useful w.r.t. the patterns above it:
 //! ```rust
+//! # fn foo(x: Option<i32>) {
 //! match x {
-//!     Some(_) => ...,
-//!     None => ..., // reachable: `None` is matched by this but not the branch above
-//!     Some(0) => ..., // unreachable: all the values this matches are already matched by
-//!                     // `Some(_)` above
+//!     Some(_) => {},
+//!     None => {},    // reachable: `None` is matched by this but not the branch above
+//!     Some(0) => {}, // unreachable: all the values this matches are already matched by
+//!                    // `Some(_)` above
 //! }
+//! # }
 //! ```
 //!
 //! This is also enough to compute exhaustiveness: a match is exhaustive iff the wildcard `_`
 //! pattern is _not_ useful w.r.t. the patterns in the match. The values returned by `usefulness`
 //! are used to tell the user which values are missing.
-//! ```rust
+//! ```compile_fail,E0004
+//! # fn foo(x: Option<i32>) {
 //! match x {
-//!     Some(0) => ...,
-//!     None => ...,
+//!     Some(0) => {},
+//!     None => {},
 //!     // not exhaustive: `_` is useful because it matches `Some(1)`
 //! }
+//! # }
 //! ```
 //!
 //! The entrypoint of this file is the [`compute_match_usefulness`] function, which computes
 //! say from knowing only the first constructor of our candidate value.
 //!
 //! Let's take the following example:
-//! ```
+//! ```compile_fail,E0004
+//! # enum Enum { Variant1(()), Variant2(Option<bool>, u32)}
+//! # fn foo(x: Enum) {
 //! match x {
 //!     Enum::Variant1(_) => {} // `p1`
 //!     Enum::Variant2(None, 0) => {} // `p2`
 //!     Enum::Variant2(Some(_), 0) => {} // `q`
 //! }
+//! # }
 //! ```
 //!
 //! We can easily see that if our candidate value `v` starts with `Variant1` it will not match `q`.
 //! and `v1`. In fact, such a `v` will be a witness of usefulness of `q` exactly when the tuple
 //! `(v0, v1)` is a witness of usefulness of `q'` in the following reduced match:
 //!
-//! ```
+//! ```compile_fail,E0004
+//! # fn foo(x: (Option<bool>, u32)) {
 //! match x {
 //!     (None, 0) => {} // `p2'`
 //!     (Some(_), 0) => {} // `q'`
 //! }
+//! # }
 //! ```
 //!
 //! This motivates a new step in computing usefulness, that we call _specialization_.
 //! like a stack. We note a pattern-stack simply with `[p_1 ... p_n]`.
 //! Here's a sequence of specializations of a list of pattern-stacks, to illustrate what's
 //! happening:
-//! ```
+//! ```ignore (illustrative)
 //! [Enum::Variant1(_)]
 //! [Enum::Variant2(None, 0)]
 //! [Enum::Variant2(Some(_), 0)]
 //!     - We return the concatenation of all the witnesses found, if any.
 //!
 //! Example:
-//! ```
+//! ```ignore (illustrative)
 //! [Some(true)] // p_1
 //! [None] // p_2
 //! [Some(_)] // q
@@ -659,13 +668,15 @@ enum ArmType {
 ///
 /// For example, if we are constructing a witness for the match against
 ///
-/// ```
+/// ```compile_fail,E0004
+/// # #![feature(type_ascription)]
 /// struct Pair(Option<(u32, u32)>, bool);
-///
+/// # fn foo(p: Pair) {
 /// match (p: Pair) {
 ///    Pair(None, _) => {}
 ///    Pair(_, false) => {}
 /// }
+/// # }
 /// ```
 ///
 /// We'll perform the following steps:
index d90ead3228c2dc7b7a804b6b25f4b0af03b9eb9b..c9722a6df77dbef683c933f10981d0f5121e29e9 100644 (file)
 ///
 /// ```rust
 /// struct S;
-/// fn foo(pred: bool) {                       // maybe-init:
-///                                            // {}
-///     let a = S; let b = S; let c; let d;    // {a, b}
+/// fn foo(pred: bool) {                        // maybe-init:
+///                                             // {}
+///     let a = S; let mut b = S; let c; let d; // {a, b}
 ///
 ///     if pred {
-///         drop(a);                           // {   b}
-///         b = S;                             // {   b}
+///         drop(a);                            // {   b}
+///         b = S;                              // {   b}
 ///
 ///     } else {
-///         drop(b);                           // {a}
-///         d = S;                             // {a,       d}
+///         drop(b);                            // {a}
+///         d = S;                              // {a,       d}
 ///
-///     }                                      // {a, b,    d}
+///     }                                       // {a, b,    d}
 ///
-///     c = S;                                 // {a, b, c, d}
+///     c = S;                                  // {a, b, c, d}
 /// }
 /// ```
 ///
@@ -90,21 +90,21 @@ fn move_data(&self) -> &MoveData<'tcx> {
 ///
 /// ```rust
 /// struct S;
-/// fn foo(pred: bool) {                       // maybe-uninit:
-///                                            // {a, b, c, d}
-///     let a = S; let b = S; let c; let d;    // {      c, d}
+/// fn foo(pred: bool) {                        // maybe-uninit:
+///                                             // {a, b, c, d}
+///     let a = S; let mut b = S; let c; let d; // {      c, d}
 ///
 ///     if pred {
-///         drop(a);                           // {a,    c, d}
-///         b = S;                             // {a,    c, d}
+///         drop(a);                            // {a,    c, d}
+///         b = S;                              // {a,    c, d}
 ///
 ///     } else {
-///         drop(b);                           // {   b, c, d}
-///         d = S;                             // {   b, c   }
+///         drop(b);                            // {   b, c, d}
+///         d = S;                              // {   b, c   }
 ///
-///     }                                      // {a, b, c, d}
+///     }                                       // {a, b, c, d}
 ///
-///     c = S;                                 // {a, b,    d}
+///     c = S;                                  // {a, b,    d}
 /// }
 /// ```
 ///
@@ -155,21 +155,21 @@ fn move_data(&self) -> &MoveData<'tcx> {
 ///
 /// ```rust
 /// struct S;
-/// fn foo(pred: bool) {                       // definite-init:
-///                                            // {          }
-///     let a = S; let b = S; let c; let d;    // {a, b      }
+/// fn foo(pred: bool) {                        // definite-init:
+///                                             // {          }
+///     let a = S; let mut b = S; let c; let d; // {a, b      }
 ///
 ///     if pred {
-///         drop(a);                           // {   b,     }
-///         b = S;                             // {   b,     }
+///         drop(a);                            // {   b,     }
+///         b = S;                              // {   b,     }
 ///
 ///     } else {
-///         drop(b);                           // {a,        }
-///         d = S;                             // {a,       d}
+///         drop(b);                            // {a,        }
+///         d = S;                              // {a,       d}
 ///
-///     }                                      // {          }
+///     }                                       // {          }
 ///
-///     c = S;                                 // {       c  }
+///     c = S;                                  // {       c  }
 /// }
 /// ```
 ///
@@ -210,21 +210,21 @@ fn move_data(&self) -> &MoveData<'tcx> {
 ///
 /// ```rust
 /// struct S;
-/// fn foo(pred: bool) {                       // ever-init:
-///                                            // {          }
-///     let a = S; let b = S; let c; let d;    // {a, b      }
+/// fn foo(pred: bool) {                        // ever-init:
+///                                             // {          }
+///     let a = S; let mut b = S; let c; let d; // {a, b      }
 ///
 ///     if pred {
-///         drop(a);                           // {a, b,     }
-///         b = S;                             // {a, b,     }
+///         drop(a);                            // {a, b,     }
+///         b = S;                              // {a, b,     }
 ///
 ///     } else {
-///         drop(b);                           // {a, b,      }
-///         d = S;                             // {a, b,    d }
+///         drop(b);                            // {a, b,      }
+///         d = S;                              // {a, b,    d }
 ///
-///     }                                      // {a, b,    d }
+///     }                                       // {a, b,    d }
 ///
-///     c = S;                                 // {a, b, c, d }
+///     c = S;                                  // {a, b, c, d }
 /// }
 /// ```
 pub struct EverInitializedPlaces<'a, 'tcx> {
index 144ea0ec61931c377bffa6f53fe8e0c881a01ed1..d5d4bfa255bd98fab46b686ab2fd8c896ac2d047 100644 (file)
 //!     First upvars are stored
 //!     It is followed by the generator state field.
 //!     Then finally the MIR locals which are live across a suspension point are stored.
-//!
+//!     ```ignore (illustrative)
 //!     struct Generator {
 //!         upvars...,
 //!         state: u32,
 //!         mir_locals...,
 //!     }
-//!
+//!     ```
 //! This pass computes the meaning of the state field and the MIR locals which are live
 //! across a suspension point. There are however three hardcoded generator states:
 //!     0 - Generator have not been resumed yet
index 3c14a324c36ff2bacac3a60ee3e41efa393429da..7cd7d26328a1a722cee058a6486a40cc7ddd4e92 100644 (file)
@@ -14,7 +14,7 @@
 ///
 /// For example:
 ///
-/// ```rust
+/// ```ignore (MIR)
 /// bb0: {
 ///     switchInt(move _3) -> [42_isize: bb1, otherwise: bb2];
 /// }
@@ -32,7 +32,7 @@
 ///
 /// into:
 ///
-/// ```rust
+/// ```ignore (MIR)
 /// bb0: {
 ///    _2 = Eq(move _3, const 42_isize);
 ///    goto -> bb3;
index da683a33651d69c4e5f41cf3961d68398da5c3b5..bbfaace7041ecb77667fc6cdc2f4d93cbe9686fa 100644 (file)
@@ -12,7 +12,7 @@
 /// Pass to convert `if` conditions on integrals into switches on the integral.
 /// For an example, it turns something like
 ///
-/// ```
+/// ```ignore (MIR)
 /// _3 = Eq(move _4, const 43i32);
 /// StorageDead(_4);
 /// switchInt(_3) -> [false: bb2, otherwise: bb3];
@@ -20,7 +20,7 @@
 ///
 /// into:
 ///
-/// ```
+/// ```ignore (MIR)
 /// switchInt(_4) -> [43i32: bb3, otherwise: bb2];
 /// ```
 pub struct SimplifyComparisonIntegral;
index ce4b45062e8de7d0ca9ab61351245ea7cb7c07b4..b3d45c7a22155c19e1a7e96794545b6ea3c73675 100644 (file)
@@ -1,10 +1,12 @@
 //! The general point of the optimizations provided here is to simplify something like:
 //!
 //! ```rust
+//! # fn foo<T, E>(x: Result<T, E>) -> Result<T, E> {
 //! match x {
 //!     Ok(x) => Ok(x),
 //!     Err(x) => Err(x)
 //! }
+//! # }
 //! ```
 //!
 //! into just `x`.
@@ -23,7 +25,7 @@
 ///
 /// This is done by transforming basic blocks where the statements match:
 ///
-/// ```rust
+/// ```ignore (MIR)
 /// _LOCAL_TMP = ((_LOCAL_1 as Variant ).FIELD: TY );
 /// _TMP_2 = _LOCAL_TMP;
 /// ((_LOCAL_0 as Variant).FIELD: TY) = move _TMP_2;
@@ -32,7 +34,7 @@
 ///
 /// into:
 ///
-/// ```rust
+/// ```ignore (MIR)
 /// _LOCAL_0 = move _LOCAL_1
 /// ```
 pub struct SimplifyArmIdentity;
@@ -472,7 +474,7 @@ fn visit_local(&mut self, local: &Local, context: PlaceContext, _location: Locat
 }
 
 /// Match on:
-/// ```rust
+/// ```ignore (MIR)
 /// _LOCAL_INTO = ((_LOCAL_FROM as Variant).FIELD: TY);
 /// ```
 fn match_get_variant_field<'tcx>(
@@ -492,7 +494,7 @@ fn match_get_variant_field<'tcx>(
 }
 
 /// Match on:
-/// ```rust
+/// ```ignore (MIR)
 /// ((_LOCAL_FROM as Variant).FIELD: TY) = move _LOCAL_INTO;
 /// ```
 fn match_set_variant_field<'tcx>(stmt: &Statement<'tcx>) -> Option<(Local, Local, VarField<'tcx>)> {
@@ -507,7 +509,7 @@ fn match_set_variant_field<'tcx>(stmt: &Statement<'tcx>) -> Option<(Local, Local
 }
 
 /// Match on:
-/// ```rust
+/// ```ignore (MIR)
 /// discriminant(_LOCAL_TO_SET) = VAR_IDX;
 /// ```
 fn match_set_discr(stmt: &Statement<'_>) -> Option<(Local, VariantIdx)> {
@@ -690,7 +692,7 @@ fn find(&self) -> Vec<SimplifyBranchSameOptimization> {
     ///
     /// Statements can be trivially equal if the kinds match.
     /// But they can also be considered equal in the following case A:
-    /// ```
+    /// ```ignore (MIR)
     /// discriminant(_0) = 0;   // bb1
     /// _0 = move _1;           // bb2
     /// ```
index 0e0a4fbc2155641b87a080983c72fae181044db1..39040ab77bc512d9149278997c904bba4ae73929 100644 (file)
 //! another function. It suffices to just take a reference in order to introduce
 //! an edge. Consider the following example:
 //!
-//! ```rust
+//! ```
+//! # use core::fmt::Display;
 //! fn print_val<T: Display>(x: T) {
 //!     println!("{}", x);
 //! }
 //!
-//! fn call_fn(f: &Fn(i32), x: i32) {
+//! fn call_fn(f: &dyn Fn(i32), x: i32) {
 //!     f(x);
 //! }
 //!
index 358b01df3b983523d00191c26fe7469ec4970881..2f90a7c54aba6f4454aa182075d2d3b6dcf305f1 100644 (file)
@@ -371,9 +371,10 @@ pub fn parse_cfg_attr(&mut self) -> PResult<'a, (ast::MetaItem, Vec<(ast::AttrIt
     }
 
     /// Matches the following grammar (per RFC 1559).
-    ///
-    ///     meta_item : PATH ( '=' UNSUFFIXED_LIT | '(' meta_item_inner? ')' )? ;
-    ///     meta_item_inner : (meta_item | UNSUFFIXED_LIT) (',' meta_item_inner)? ;
+    /// ```ebnf
+    /// meta_item : PATH ( '=' UNSUFFIXED_LIT | '(' meta_item_inner? ')' )? ;
+    /// meta_item_inner : (meta_item | UNSUFFIXED_LIT) (',' meta_item_inner)? ;
+    /// ```
     pub fn parse_meta_item(&mut self) -> PResult<'a, ast::MetaItem> {
         let nt_meta = match self.token.kind {
             token::Interpolated(ref nt) => match **nt {
index 10f1daf11295107540cd1d6d180741c3db06c49d..56757c1d903518780c5d0f7ccee9994912f54c8f 100644 (file)
@@ -485,7 +485,7 @@ fn parse_polarity(&mut self) -> ast::ImplPolarity {
 
     /// Parses an implementation item.
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// impl<'a, T> TYPE { /* impl items */ }
     /// impl<'a, T> TRAIT for TYPE { /* impl items */ }
     /// impl<'a, T> !TRAIT for TYPE { /* impl items */ }
@@ -493,7 +493,7 @@ fn parse_polarity(&mut self) -> ast::ImplPolarity {
     /// ```
     ///
     /// We actually parse slightly more relaxed grammar for better error reporting and recovery.
-    /// ```
+    /// ```ebnf
     /// "impl" GENERICS "const"? "!"? TYPE "for"? (TYPE | "..") ("where" PREDICATES)? "{" BODY "}"
     /// "impl" GENERICS "const"? "!"? TYPE ("where" PREDICATES)? "{" BODY "}"
     /// ```
@@ -806,7 +806,7 @@ fn parse_assoc_item(
     }
 
     /// Parses a `type` alias with the following grammar:
-    /// ```
+    /// ```ebnf
     /// TypeAlias = "type" Ident Generics {":" GenericBounds}? {"=" Ty}? ";" ;
     /// ```
     /// The `"type"` has already been eaten.
@@ -930,7 +930,7 @@ fn parse_ident_or_underscore(&mut self) -> PResult<'a, Ident> {
     ///
     /// # Examples
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// extern crate foo;
     /// extern crate bar as foo;
     /// ```
@@ -1630,7 +1630,7 @@ fn parse_field_ident(&mut self, adt_ty: &str, lo: Span) -> PResult<'a, Ident> {
 
     /// Parses a declarative macro 2.0 definition.
     /// The `macro` keyword has already been parsed.
-    /// ```
+    /// ```ebnf
     /// MacBody = "{" TOKEN_STREAM "}" ;
     /// MacParams = "(" TOKEN_STREAM ")" ;
     /// DeclMac = "macro" Ident MacParams? MacBody ;
index 9e771a8af1a4e0a3368b4c4b5a7409fa05fafa00..b0439a5987afa6dd37fc08256932d4005b019053 100644 (file)
@@ -52,7 +52,7 @@ pub(super) enum RecoverQuestionMark {
 /// Signals whether parsing a type should recover `->`.
 ///
 /// More specifically, when parsing a function like:
-/// ```rust
+/// ```compile_fail
 /// fn foo() => u8 { 0 }
 /// fn bar(): u8 { 0 }
 /// ```
@@ -499,12 +499,12 @@ fn parse_typeof_ty(&mut self) -> PResult<'a, TyKind> {
     }
 
     /// Parses a function pointer type (`TyKind::BareFn`).
-    /// ```
-    /// [unsafe] [extern "ABI"] fn (S) -> T
-    ///  ^~~~~^          ^~~~^     ^~^    ^
-    ///    |               |        |     |
-    ///    |               |        |   Return type
-    /// Function Style    ABI  Parameter types
+    /// ```ignore (illustrative)
+    ///    [unsafe] [extern "ABI"] fn (S) -> T
+    /// //  ^~~~~^          ^~~~^     ^~^    ^
+    /// //    |               |        |     |
+    /// //    |               |        |   Return type
+    /// // Function Style    ABI  Parameter types
     /// ```
     /// We actually parse `FnHeader FnDecl`, but we error on `const` and `async` qualifiers.
     fn parse_ty_bare_fn(
@@ -707,7 +707,7 @@ fn error_negative_bounds(
     }
 
     /// Parses a bound according to the grammar:
-    /// ```
+    /// ```ebnf
     /// BOUND = TY_BOUND | LT_BOUND
     /// ```
     fn parse_generic_bound(&mut self) -> PResult<'a, Result<GenericBound, Span>> {
@@ -729,7 +729,7 @@ fn parse_generic_bound(&mut self) -> PResult<'a, Result<GenericBound, Span>> {
     }
 
     /// Parses a lifetime ("outlives") bound, e.g. `'a`, according to:
-    /// ```
+    /// ```ebnf
     /// LT_BOUND = LIFETIME
     /// ```
     fn parse_generic_lt_bound(
@@ -787,7 +787,7 @@ fn recover_paren_lifetime(&mut self, lo: Span, inner_lo: Span) -> PResult<'a, ()
     ///
     /// If no modifiers are present, this does not consume any tokens.
     ///
-    /// ```
+    /// ```ebnf
     /// TY_BOUND_MODIFIERS = ["~const"] ["?"]
     /// ```
     fn parse_ty_bound_modifiers(&mut self) -> PResult<'a, BoundModifiers> {
@@ -807,7 +807,7 @@ fn parse_ty_bound_modifiers(&mut self) -> PResult<'a, BoundModifiers> {
     }
 
     /// Parses a type bound according to:
-    /// ```
+    /// ```ebnf
     /// TY_BOUND = TY_BOUND_NOPAREN | (TY_BOUND_NOPAREN)
     /// TY_BOUND_NOPAREN = [TY_BOUND_MODIFIERS] [for<LT_PARAM_DEFS>] SIMPLE_PATH
     /// ```
index a544ac2c343aeeab2d5fbd4e9e60061a1f88cdd0..f9f3169af69c9e5a18465f6133a36196d4f6e7e0 100644 (file)
@@ -7,9 +7,9 @@
 
 /// A dep-node filter goes from a user-defined string to a query over
 /// nodes. Right now the format is like this:
-///
-///     x & y & z
-///
+/// ```ignore (illustrative)
+/// x & y & z
+/// ```
 /// where the format-string of the dep-node must contain `x`, `y`, and
 /// `z`.
 #[derive(Debug)]
index e0a83ba8c0d4ac95ce65bcd3983dbdb3ca1314c3..555a3382acfe9ef575e1207f753385e7340161eb 100644 (file)
@@ -2273,16 +2273,16 @@ pub(crate) fn check_for_module_export_macro(
 
 /// Given a `binding_span` of a binding within a use statement:
 ///
-/// ```
+/// ```ignore (illustrative)
 /// use foo::{a, b, c};
-///              ^
+/// //           ^
 /// ```
 ///
 /// then return the span until the next binding or the end of the statement:
 ///
-/// ```
+/// ```ignore (illustrative)
 /// use foo::{a, b, c};
-///              ^^^
+/// //           ^^^
 /// ```
 fn find_span_of_binding_until_next_binding(
     sess: &Session,
@@ -2326,14 +2326,14 @@ fn find_span_of_binding_until_next_binding(
 /// Given a `binding_span`, return the span through to the comma or opening brace of the previous
 /// binding.
 ///
-/// ```
+/// ```ignore (illustrative)
 /// use foo::a::{a, b, c};
-///               ^^--- binding span
-///               |
-///               returned span
+/// //            ^^--- binding span
+/// //            |
+/// //            returned span
 ///
 /// use foo::{a, b, c};
-///           --- binding span
+/// //        --- binding span
 /// ```
 fn extend_span_to_previous_binding(sess: &Session, binding_span: Span) -> Option<Span> {
     let source_map = sess.source_map();
@@ -2369,15 +2369,15 @@ fn extend_span_to_previous_binding(sess: &Session, binding_span: Span) -> Option
 /// Given a `use_span` of a binding within a use statement, returns the highlighted span and if
 /// it is a nested use tree.
 ///
-/// ```
+/// ```ignore (illustrative)
 /// use foo::a::{b, c};
-///          ^^^^^^^^^^ // false
+/// //       ^^^^^^^^^^ -- false
 ///
 /// use foo::{a, b, c};
-///          ^^^^^^^^^^ // true
+/// //       ^^^^^^^^^^ -- true
 ///
 /// use foo::{a, b::{c, d}};
-///          ^^^^^^^^^^^^^^^ // true
+/// //       ^^^^^^^^^^^^^^^ -- true
 /// ```
 fn find_span_immediately_after_crate_name(
     sess: &Session,
index 787536d2a38ed04ecf40649f7dbcb809f1ef0bc6..0db0b9d67d4091d8448532943f509c97c9296095 100644 (file)
@@ -401,7 +401,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
 /// The reason for this separate call is to resolve what would otherwise
 /// be a cycle. Consider this example:
 ///
-/// ```rust
+/// ```ignore UNSOLVED (maybe @jackh726 knows what lifetime parameter to give Sub)
 /// trait Base<'a> {
 ///     type BaseItem;
 /// }
@@ -2552,7 +2552,7 @@ fn visit_segment_args(
     /// Returns all the late-bound vars that come into scope from supertrait HRTBs, based on the
     /// associated type name and starting trait.
     /// For example, imagine we have
-    /// ```rust
+    /// ```ignore (illustrative)
     /// trait Foo<'a, 'b> {
     ///   type As;
     /// }
index 3889639b50f454bf232b430c17bbf9ff86397db1..687d7471b25b2f9212b82b8aa165f4f01304e7b2 100644 (file)
@@ -686,7 +686,7 @@ pub const fn root() -> Self {
     /// context up one macro definition level. That is, if we have a nested macro
     /// definition as follows:
     ///
-    /// ```rust
+    /// ```ignore (illustrative)
     /// macro_rules! f {
     ///    macro_rules! g {
     ///        ...
@@ -710,6 +710,7 @@ pub fn marks(self) -> Vec<(ExpnId, Transparency)> {
     /// For example, consider the following three resolutions of `f`:
     ///
     /// ```rust
+    /// #![feature(decl_macro)]
     /// mod foo { pub fn f() {} } // `f`'s `SyntaxContext` is empty.
     /// m!(f);
     /// macro m($f:ident) {
@@ -746,7 +747,8 @@ pub fn normalize_to_macros_2_0_and_adjust(&mut self, expn_id: ExpnId) -> Option<
     /// via a glob import with the given `SyntaxContext`.
     /// For example:
     ///
-    /// ```rust
+    /// ```compile_fail,E0425
+    /// #![feature(decl_macro)]
     /// m!(f);
     /// macro m($i:ident) {
     ///     mod foo {
@@ -786,7 +788,7 @@ pub fn glob_adjust(&mut self, expn_id: ExpnId, glob_span: Span) -> Option<Option
 
     /// Undo `glob_adjust` if possible:
     ///
-    /// ```rust
+    /// ```ignore (illustrative)
     /// if let Some(privacy_checking_scope) = self.reverse_glob_adjust(expansion, glob_ctxt) {
     ///     assert!(self.glob_adjust(expansion, glob_ctxt) == Some(privacy_checking_scope));
     /// }
index 460b5c18fc1b4838089ef11fe9d422e95ef44bf9..505c0af953af1e85e0921b636bb35ef799848162 100644 (file)
@@ -1058,10 +1058,11 @@ pub fn stmt_span(&self, stmt_span: Span, block_span: Span) -> Span {
 
     /// Tries to find the span of the semicolon of a macro call statement.
     /// The input must be the *call site* span of a statement from macro expansion.
-    ///
-    ///           v output
-    ///     mac!();
-    ///     ^^^^^^ input
+    /// ```ignore (illustrative)
+    /// //       v output
+    ///    mac!();
+    /// // ^^^^^^ input
+    /// ```
     pub fn mac_call_stmt_semi_span(&self, mac_call: Span) -> Option<Span> {
         let span = self.span_extend_while(mac_call, char::is_whitespace).ok()?;
         let span = span.shrink_to_hi().with_hi(BytePos(span.hi().0.checked_add(1)?));
index 4b949ff8b95de3710ffd4fcd18fdf40d68f7122f..5bd49dd21e73ceef324a090b99734188a210308d 100644 (file)
@@ -22,11 +22,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
     /// (*), computes the "definition type" for an opaque type
     /// definition -- that is, the inferred value of `Foo1<'x>` or
     /// `Foo2<'x>` that we would conceptually use in its definition:
-    ///
-    ///     type Foo1<'x> = impl Bar<'x> = AAA; <-- this type AAA
-    ///     type Foo2<'x> = impl Bar<'x> = BBB; <-- or this type BBB
-    ///     fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
-    ///
+    /// ```ignore (illustrative)
+    /// type Foo1<'x> = impl Bar<'x> = AAA;  // <-- this type AAA
+    /// type Foo2<'x> = impl Bar<'x> = BBB;  // <-- or this type BBB
+    /// fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }
+    /// ```
     /// Note that these values are defined in terms of a distinct set of
     /// generic parameters (`'x` instead of `'a`) from C1 or C2. The main
     /// purpose of this function is to do that translation.
index d95512bb88f36973e64f458fd41d0f2555aacdc8..79e9635f90ef6db3dcfeafd8d842f5e082b4e1d6 100644 (file)
@@ -255,9 +255,9 @@ impl<'tcx> AutoTraitFinder<'tcx> {
     /// `FulfillmentContext` will drive `SelectionContext` to consider that impl before giving up.
     /// If we were to rely on `FulfillmentContext`s decision, we might end up synthesizing an impl
     /// like this:
-    ///
-    ///     impl<T> Send for Foo<T> where T: IntoIterator
-    ///
+    /// ```ignore (illustrative)
+    /// impl<T> Send for Foo<T> where T: IntoIterator
+    /// ```
     /// While it might be technically true that Foo implements Send where `T: IntoIterator`,
     /// the bound is overly restrictive - it's really only necessary that `T: Iterator`.
     ///
@@ -420,10 +420,10 @@ fn evaluate_predicates(
     /// two trait predicates that differ only in their region parameters:
     /// one containing a HRTB lifetime parameter, and one containing a 'normal'
     /// lifetime parameter. For example:
-    ///
-    ///     T as MyTrait<'a>
-    ///     T as MyTrait<'static>
-    ///
+    /// ```ignore (illustrative)
+    /// T as MyTrait<'a>
+    /// T as MyTrait<'static>
+    /// ```
     /// If we put both of these predicates in our computed `ParamEnv`, we'll
     /// confuse `SelectionContext`, since it will (correctly) view both as being applicable.
     ///
index 40c3f4047ae6efc1732354fa2bb795b13e12fc61..24110d30a8456e0da2e9ba274d21542e4680c57f 100644 (file)
@@ -547,7 +547,7 @@ pub fn orphan_check(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Result<(), OrphanChe
 /// 2. They ground negative reasoning for coherence. If a user wants to
 ///    write both a conditional blanket impl and a specific impl, we need to
 ///    make sure they do not overlap. For example, if we write
-///    ```
+///    ```ignore (illustrative)
 ///    impl<T> IntoIterator for Vec<T>
 ///    impl<T: Iterator> IntoIterator for T
 ///    ```
index b39310d12942d752979f2d78b3ff464ff8e146df..e1b6ed92269ca7b1833930bf2f9e95afa8c4a458 100644 (file)
@@ -595,7 +595,7 @@ fn object_ty_for_trait<'tcx>(
 /// - let `Receiver` be the type of the `self` argument, i.e `Self`, `&Self`, `Rc<Self>`,
 /// - require the following bound:
 ///
-///   ```
+///   ```ignore (not-rust)
 ///   Receiver[Self => T]: DispatchFromDyn<Receiver[Self => dyn Trait]>
 ///   ```
 ///
@@ -621,13 +621,13 @@ fn object_ty_for_trait<'tcx>(
 /// Instead, we fudge a little by introducing a new type parameter `U` such that
 /// `Self: Unsize<U>` and `U: Trait + ?Sized`, and use `U` in place of `dyn Trait`.
 /// Written as a chalk-style query:
-///
-///     forall (U: Trait + ?Sized) {
-///         if (Self: Unsize<U>) {
-///             Receiver: DispatchFromDyn<Receiver[Self => U]>
-///         }
+/// ```ignore (not-rust)
+/// forall (U: Trait + ?Sized) {
+///     if (Self: Unsize<U>) {
+///         Receiver: DispatchFromDyn<Receiver[Self => U]>
 ///     }
-///
+/// }
+/// ```
 /// for `self: &'a mut Self`, this means `&'a mut Self: DispatchFromDyn<&'a mut U>`
 /// for `self: Rc<Self>`, this means `Rc<Self>: DispatchFromDyn<Rc<U>>`
 /// for `self: Pin<Box<Self>>`, this means `Pin<Box<Self>>: DispatchFromDyn<Pin<Box<U>>>`
index c7a61cbe25a1aed118e1a7441ab08b2bace4d540..be4d734b964b8fb45d35c70e4ebe87c21ddf3d02 100644 (file)
@@ -158,9 +158,9 @@ pub(super) enum ProjectAndUnifyResult<'tcx> {
 }
 
 /// Evaluates constraints of the form:
-///
-///     for<...> <T as Trait>::U == V
-///
+/// ```ignore (not-rust)
+/// for<...> <T as Trait>::U == V
+/// ```
 /// If successful, this may result in additional obligations. Also returns
 /// the projection cache key used to track these additional obligations.
 ///
@@ -224,9 +224,9 @@ pub(super) fn poly_project_and_unify_type<'cx, 'tcx>(
 }
 
 /// Evaluates constraints of the form:
-///
-///     <T as Trait>::U == V
-///
+/// ```ignore (not-rust)
+/// <T as Trait>::U == V
+/// ```
 /// If successful, this may result in additional obligations.
 ///
 /// See [poly_project_and_unify_type] for an explanation of the return value.
@@ -1258,7 +1258,7 @@ fn assemble_candidates_from_param_env<'cx, 'tcx>(
 /// In the case of a nested projection like <<A as Foo>::FooT as Bar>::BarT, we may find
 /// that the definition of `Foo` has some clues:
 ///
-/// ```
+/// ```ignore (illustrative)
 /// trait Foo {
 ///     type FooT : Bar<BarT=i32>
 /// }
index b97ab39d991fee4dd05b23d2f0f9d46bfe254379..771a3072af5d94475aa29de59fbecdeb82a7f852 100644 (file)
@@ -712,9 +712,9 @@ fn confirm_closure_candidate(
     /// and we desugared it so that the type of the expression is
     /// `Closure`, and `Closure` expects `i32` as argument. Then it
     /// is "as if" the compiler generated this impl:
-    ///
-    ///     impl Fn(i32) for Closure { ... }
-    ///
+    /// ```ignore (illustrative)
+    /// impl Fn(i32) for Closure { ... }
+    /// ```
     /// Now imagine our obligation is `Closure: Fn(usize)`. So far
     /// we have matched the self type `Closure`. At this point we'll
     /// compare the `i32` to `usize` and generate an error.
index e69bf6eca90ef04baaf42a32c16f8c3fd1ad48c5..612091d5ab7de70d1d26b0efc5f6b9ee66ae395e 100644 (file)
@@ -1933,7 +1933,7 @@ fn copy_clone_conditions(
     ///
     /// Here are some (simple) examples:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// (i32, u32) -> [i32, u32]
     /// Foo where struct Foo { x: i32, y: u32 } -> [i32, u32]
     /// Bar<i32> where struct Bar<T> { x: T, y: u32 } -> [i32, u32]
index 328e0d2e0e90a859ca51248c684fc3ccf6fd955a..49c8c56083f0816f75d5fcdbdef13da6bdcb29d4 100644 (file)
@@ -52,7 +52,7 @@ pub struct OverlapError {
 ///
 /// For example, consider the following scenario:
 ///
-/// ```rust
+/// ```ignore (illustrative)
 /// trait Foo { ... }
 /// impl<T, U> Foo for (T, U) { ... }  // target impl
 /// impl<V> Foo for (V, V) { ... }     // source impl
@@ -64,7 +64,7 @@ pub struct OverlapError {
 /// where-clauses add some trickiness here, because they can be used to "define"
 /// an argument indirectly:
 ///
-/// ```rust
+/// ```ignore (illustrative)
 /// impl<'a, I, T: 'a> Iterator for Cloned<I>
 ///    where I: Iterator<Item = &'a T>, T: Clone
 /// ```
index b4ed5b95b10473046e42665872548e633561f4d6..de0ade64247dfa2638229bb92746f7ced70a8bf3 100644 (file)
@@ -170,7 +170,7 @@ struct WfPredicates<'a, 'tcx> {
 /// predicates. This is a kind of hack to address #43784. The
 /// underlying problem in that issue was a trait structure like:
 ///
-/// ```
+/// ```ignore (illustrative)
 /// trait Foo: Copy { }
 /// trait Bar: Foo { }
 /// impl<T: Bar> Foo for T { }
index b015e40b6836fea3991eaaaf524f7da3ffd2e6c2..c63e9c31d535c44cc62698280f26cf5a61ab7dca 100644 (file)
@@ -122,16 +122,16 @@ pub struct TypeFlags: u32 {
     /// A [De Bruijn index][dbi] is a standard means of representing
     /// regions (and perhaps later types) in a higher-ranked setting. In
     /// particular, imagine a type like this:
-    ///
-    ///     for<'a> fn(for<'b> fn(&'b isize, &'a isize), &'a char)
-    ///     ^          ^            |          |           |
-    ///     |          |            |          |           |
-    ///     |          +------------+ 0        |           |
-    ///     |                                  |           |
-    ///     +----------------------------------+ 1         |
-    ///     |                                              |
-    ///     +----------------------------------------------+ 0
-    ///
+    /// ```ignore (illustrative)
+    ///    for<'a> fn(for<'b> fn(&'b isize, &'a isize), &'a char)
+    /// // ^          ^            |          |           |
+    /// // |          |            |          |           |
+    /// // |          +------------+ 0        |           |
+    /// // |                                  |           |
+    /// // +----------------------------------+ 1         |
+    /// // |                                              |
+    /// // +----------------------------------------------+ 0
+    /// ```
     /// In this type, there are two binders (the outer fn and the inner
     /// fn). We need to be able to determine, for any given region, which
     /// fn type it is bound by, the inner or the outer one. There are
@@ -203,7 +203,7 @@ pub fn shift_out(&mut self, amount: u32) {
     /// it will now be bound at INNERMOST. This is an appropriate thing to do
     /// when moving a region out from inside binders:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     ///             for<'a>   fn(for<'b>   for<'c>   fn(&'a u32), _)
     /// // Binder:  D3           D2        D1            ^^
     /// ```
@@ -471,9 +471,9 @@ impl Variance {
     /// variance with which the argument appears.
     ///
     /// Example 1:
-    ///
-    ///     *mut Vec<i32>
-    ///
+    /// ```ignore (illustrative)
+    /// *mut Vec<i32>
+    /// ```
     /// Here, the "ambient" variance starts as covariant. `*mut T` is
     /// invariant with respect to `T`, so the variance in which the
     /// `Vec<i32>` appears is `Covariant.xform(Invariant)`, which
@@ -483,9 +483,9 @@ impl Variance {
     /// (again) in `Invariant`.
     ///
     /// Example 2:
-    ///
-    ///     fn(*const Vec<i32>, *mut Vec<i32)
-    ///
+    /// ```ignore (illustrative)
+    /// fn(*const Vec<i32>, *mut Vec<i32)
+    /// ```
     /// The ambient variance is covariant. A `fn` type is
     /// contravariant with respect to its parameters, so the variance
     /// within which both pointer types appear is
index b8422ce3208f136b18b458c011a5f4e9e3f080df..2303e64e1007456e76f2343d6215cf3fe4caf676 100644 (file)
@@ -294,9 +294,9 @@ pub fn ast_path_substs_for_ty(
     ///
     /// Example:
     ///
-    /// ```
-    /// T: std::ops::Index<usize, Output = u32>
-    /// ^1 ^^^^^^^^^^^^^^2 ^^^^3  ^^^^^^^^^^^4
+    /// ```ignore (illustrative)
+    ///    T: std::ops::Index<usize, Output = u32>
+    /// // ^1 ^^^^^^^^^^^^^^2 ^^^^3  ^^^^^^^^^^^4
     /// ```
     ///
     /// 1. The `self_ty` here would refer to the type `T`.
@@ -310,7 +310,7 @@ pub fn ast_path_substs_for_ty(
     ///
     /// For (generic) associated types
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// <Vec<u8> as Iterable<u8>>::Iter::<'a>
     /// ```
     ///
@@ -756,7 +756,7 @@ fn instantiate_poly_trait_ref_inner(
     ///
     /// Example:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// poly_trait_ref = Iterator<Item = u32>
     /// self_ty = Foo
     /// ```
@@ -1021,10 +1021,10 @@ pub(crate) fn add_bounds<'hir, I: Iterator<Item = &'hir hir::GenericBound<'hir>>
     ///
     /// Example:
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// fn foo<T: Bar + Baz>() { }
-    ///        ^  ^^^^^^^^^ ast_bounds
-    ///        param_ty
+    /// //     ^  ^^^^^^^^^ ast_bounds
+    /// //     param_ty
     /// ```
     ///
     /// The `sized_by_default` parameter indicates if, in this context, the `param_ty` should be
index 320be9b44d4410df41d770523ff6364fae58e2e9..50e55bdc4af30c5ac9e9823f27509c051248e409 100644 (file)
@@ -371,7 +371,7 @@ fn sig_of_closure_no_expectation(
     ///
     /// # Examples
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// fn with_closure<F>(_: F)
     ///   where F: Fn(&u32) -> &u32 { .. }
     ///
index b44baf83cbe1e61fecbf61c6e31debf86eb6f6c7..c563d57ed96bbc7c988c3c579b177b0c1bb81aed 100644 (file)
@@ -21,7 +21,7 @@
 //! When inferring the generic arguments of functions, the argument
 //! order is relevant, which can lead to the following edge case:
 //!
-//! ```rust
+//! ```ignore (illustrative)
 //! fn foo<T>(a: T, b: T) {
 //!     // ...
 //! }
@@ -1210,7 +1210,7 @@ fn try_find_coercion_lub<E>(
 ///
 /// Example:
 ///
-/// ```
+/// ```ignore (illustrative)
 /// let mut coerce = CoerceMany::new(expected_ty);
 /// for expr in exprs {
 ///     let expr_ty = fcx.check_expr_with_expectation(expr, expected);
index f377cf3678e40e7a3e0e92d39cd0c2b15869e848..bfd2c32fd7e3c9bbae62bca713eed7cdd6e867a2 100644 (file)
@@ -439,7 +439,7 @@ fn has_only_self_parameter(&self, method: &AssocItem) -> bool {
     /// Identify some cases where `as_ref()` would be appropriate and suggest it.
     ///
     /// Given the following code:
-    /// ```
+    /// ```compile_fail,E0308
     /// struct Foo;
     /// fn takes_ref(_: &Foo) {}
     /// let ref opt = Some(Foo);
@@ -449,7 +449,7 @@ fn has_only_self_parameter(&self, method: &AssocItem) -> bool {
     /// Suggest using `opt.as_ref().map(|param| takes_ref(param));` instead.
     ///
     /// It only checks for `Option` and `Result` and won't work with
-    /// ```
+    /// ```ignore (illustrative)
     /// opt.map(|param| { takes_ref(param) });
     /// ```
     fn can_use_as_ref(&self, expr: &hir::Expr<'_>) -> Option<(Span, &'static str, String)> {
@@ -566,7 +566,7 @@ fn can_use_as_ref(&self, expr: &hir::Expr<'_>) -> Option<(Span, &'static str, St
     /// This function is used to determine potential "simple" improvements or users' errors and
     /// provide them useful help. For example:
     ///
-    /// ```
+    /// ```compile_fail,E0308
     /// fn some_fn(s: &str) {}
     ///
     /// let x = "hey!".to_owned();
index 85132317824076160bf8b538e3d2f0ab582625fc..15788f410f1951bf92733bd0ad8bfdc8df2fdb49 100644 (file)
@@ -144,6 +144,7 @@ fn fallback_if_possible(
     /// code. The most common case is something like this:
     ///
     /// ```rust
+    /// # fn foo() -> i32 { 4 }
     /// match foo() {
     ///     22 => Default::default(), // call this type `?D`
     ///     _ => return, // return has type `!`
@@ -168,7 +169,7 @@ fn fallback_if_possible(
     /// fallback to use based on whether there is a coercion pattern
     /// like this:
     ///
-    /// ```
+    /// ```ignore (not-rust)
     /// ?Diverging -> ?V
     /// ?NonDiverging -> ?V
     /// ?V != ?NonDiverging
index 616aa11f00a6b638870cfa61e6f9bf4c7463ee9f..d7a817f67e0cd1f94791d5f8dbb82c9c910bbd6d 100644 (file)
@@ -1467,7 +1467,7 @@ pub(in super::super) fn check_block_with_expected(
 
     /// A common error is to add an extra semicolon:
     ///
-    /// ```
+    /// ```compile_fail,E0308
     /// fn foo() -> usize {
     ///     22;
     /// }
index 681d1e37f86f1317486616e91aa7b887a29f7ca8..ecb0004c334340cc458d8463b98bb5e892b6e8bc 100644 (file)
@@ -72,7 +72,7 @@ pub fn suggest_mismatched_types_on_tail(
 
     /// When encountering an fn-like ctor that needs to unify with a value, check whether calling
     /// the ctor would successfully solve the type mismatch and if so, suggest it:
-    /// ```
+    /// ```compile_fail,E0308
     /// fn foo(x: usize) -> usize { x }
     /// let x: usize = foo;  // suggest calling the `foo` function: `foo(42)`
     /// ```
@@ -463,7 +463,8 @@ pub(in super::super) fn suggest_calling_boxed_future_when_appropriate(
 
     /// A common error is to forget to add a semicolon at the end of a block, e.g.,
     ///
-    /// ```
+    /// ```compile_fail,E0308
+    /// # fn bar_that_returns_u32() -> u32 { 4 }
     /// fn foo() {
     ///     bar_that_returns_u32()
     /// }
@@ -504,7 +505,8 @@ fn suggest_missing_semicolon(
 
     /// A possible error is to forget to add a return type that is needed:
     ///
-    /// ```
+    /// ```compile_fail,E0308
+    /// # fn bar_that_returns_u32() -> u32 { 4 }
     /// fn foo() {
     ///     bar_that_returns_u32()
     /// }
@@ -569,7 +571,7 @@ pub(in super::super) fn suggest_missing_return_type(
     /// check whether the return type is a generic type with a trait bound
     /// only suggest this if the generic param is not present in the arguments
     /// if this is true, hint them towards changing the return type to `impl Trait`
-    /// ```
+    /// ```compile_fail,E0308
     /// fn cant_name_it<T: Fn() -> u32>() -> T {
     ///     || 3
     /// }
index 721f251650f54656a68497be907d8abfa01561b0..df8db0da6448259d24591d2afa036d52c38f5026 100644 (file)
@@ -71,7 +71,7 @@ pub(super) fn build_control_flow_graph<'tcx>(
 /// ```
 ///
 /// Rule 3:
-/// ```rust
+/// ```compile_fail,E0382
 /// let mut a = (vec![0], vec![0]);
 /// drop(a);
 /// a.1 = vec![1];
index 62ca728868b45595cf57a788b65882982a8c0c44..5cd63cae8ad9b8534cfd3d39a3a98d94241843b3 100644 (file)
 use std::ops::Deref;
 
 /// Closures defined within the function. For example:
-///
-///     fn foo() {
-///         bar(move|| { ... })
-///     }
-///
+/// ```ignore (illustrative)
+/// fn foo() {
+///     bar(move|| { ... })
+/// }
+/// ```
 /// Here, the function `foo()` and the closure passed to
 /// `bar()` will each have their own `FnCtxt`, but they will
 /// share the inherited fields.
index e04cc42b6d7e5f56631bde132508a0dffbc6148d..a46be244e39a0fbb0894f4434236b25e09250e60 100644 (file)
@@ -200,8 +200,9 @@ pub struct Pick<'tcx> {
     pub import_ids: SmallVec<[LocalDefId; 1]>,
 
     /// Indicates that the source expression should be autoderef'd N times
-    ///
-    ///     A = expr | *expr | **expr | ...
+    /// ```ignore (not-rust)
+    /// A = expr | *expr | **expr | ...
+    /// ```
     pub autoderefs: usize,
 
     /// Indicates that we want to add an autoref (and maybe also unsize it), or if the receiver is
@@ -1631,7 +1632,7 @@ fn consider_probe(
     ///
     /// Example (`src/test/ui/method-two-trait-defer-resolution-1.rs`):
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// trait Foo { ... }
     /// impl Foo for Vec<i32> { ... }
     /// impl Foo for Vec<usize> { ... }
index 76c955d6f690d672319217ce765caf9cf3ae6206..e82a454e30d4d5dbd67653065d82809b4d37ec03 100644 (file)
@@ -891,16 +891,19 @@ fn report_unexpected_variant_res(tcx: TyCtxt<'_>, res: Res, span: Span) {
 /// Tupling means that all call-side arguments are packed into a tuple and
 /// passed as a single parameter. For example, if tupling is enabled, this
 /// function:
-///
-///     fn f(x: (isize, isize))
-///
+/// ```
+/// fn f(x: (isize, isize)) {}
+/// ```
 /// Can be called as:
-///
-///     f(1, 2);
-///
+/// ```ignore UNSOLVED (can this be done in user code?)
+/// # fn f(x: (isize, isize)) {}
+/// f(1, 2);
+/// ```
 /// Instead of:
-///
-///     f((1, 2));
+/// ```
+/// # fn f(x: (isize, isize)) {}
+/// f((1, 2));
+/// ```
 #[derive(Clone, Eq, PartialEq)]
 enum TupleArgumentsFlag {
     DontTupleArguments,
index 356763fab5e3b35e2b612bfa6905940c693cef68..5eba95b495dd70c53f1bd3d80212adcd138ded7b 100644 (file)
@@ -1894,7 +1894,7 @@ fn new_ref_ty(&self, span: Span, mutbl: hir::Mutability, ty: Ty<'tcx>) -> Ty<'tc
     ///
     /// Syntactically, these look like `[pat_0, ..., pat_n]`.
     /// Semantically, we are type checking a pattern with structure:
-    /// ```
+    /// ```ignore (not-rust)
     /// [before_0, ..., before_n, (slice, after_0, ... after_n)?]
     /// ```
     /// The type of `slice`, if it is present, depends on the `expected` type.
index e37e83e748733ac9b074b9ac15fb7bfc234fb886..20456cc427c52a529f645a7b342b215c77eee9a4 100644 (file)
@@ -269,7 +269,7 @@ pub fn new(
     ///
     /// Consider this silly example:
     ///
-    /// ```
+    /// ```ignore UNSOLVED (does replacing @i32 with Box<i32> preserve the desired semantics for the example?)
     /// fn borrow(x: &i32) -> &i32 {x}
     /// fn foo(x: @i32) -> i32 {  // block: B
     ///     let b = borrow(x);    // region: <R0>
index 9dbb813293263af994eb12d4f17997860c482cbc..cac9899ecd4b2ce7a036814b0d66749886eb4e5e 100644 (file)
@@ -5,9 +5,9 @@
 //! immutable "borrow kind" (see `ty::BorrowKind` for details) and then
 //! "escalating" the kind as needed. The borrow kind proceeds according to
 //! the following lattice:
-//!
-//!     ty::ImmBorrow -> ty::UniqueImmBorrow -> ty::MutBorrow
-//!
+//! ```ignore (not-rust)
+//! ty::ImmBorrow -> ty::UniqueImmBorrow -> ty::MutBorrow
+//! ```
 //! So, for example, if we see an assignment `x = 5` to an upvar `x`, we
 //! will promote its borrow kind to mutable borrow. If we see an `&mut x`
 //! we'll do the same. Naturally, this applies not just to the upvar, but
@@ -447,16 +447,17 @@ fn process_collected_capture_information(
     ///       the existing min_capture map that is stored in TypeckResults.
     ///
     /// Eg:
-    /// ```rust,no_run
+    /// ```
+    /// #[derive(Debug)]
     /// struct Point { x: i32, y: i32 }
     ///
-    /// let s: String;  // hir_id_s
-    /// let mut p: Point; // his_id_p
+    /// let s = String::from("s");  // hir_id_s
+    /// let mut p = Point { x: 2, y: -2 }; // his_id_p
     /// let c = || {
-    ///        println!("{s}");  // L1
+    ///        println!("{s:?}");  // L1
     ///        p.x += 10;  // L2
     ///        println!("{}" , p.y); // L3
-    ///        println!("{p}"); // L4
+    ///        println!("{p:?}"); // L4
     ///        drop(s);   // L5
     /// };
     /// ```
@@ -465,7 +466,7 @@ fn process_collected_capture_information(
     ///
     /// InferBorrowKind results in a structure like this:
     ///
-    /// ```text
+    /// ```ignore (illustrative)
     /// {
     ///       Place(base: hir_id_s, projections: [], ....) -> {
     ///                                                            capture_kind_expr: hir_id_L5,
@@ -490,7 +491,7 @@ fn process_collected_capture_information(
     /// ```
     ///
     /// After the min capture analysis, we get:
-    /// ```text
+    /// ```ignore (illustrative)
     /// {
     ///       hir_id_s -> [
     ///            Place(base: hir_id_s, projections: [], ....) -> {
@@ -1281,27 +1282,27 @@ fn compute_2229_migrations(
     /// - Ty(place): Type of place
     /// - `(a, b)`: Represents the function parameters `base_path_ty` and `captured_by_move_projs`
     /// respectively.
-    /// ```
+    /// ```ignore (illustrative)
     ///                  (Ty(w), [ &[p, x], &[c] ])
-    ///                                 |
-    ///                    ----------------------------
-    ///                    |                          |
-    ///                    v                          v
+    /// //                              |
+    /// //                 ----------------------------
+    /// //                 |                          |
+    /// //                 v                          v
     ///        (Ty(w.p), [ &[x] ])          (Ty(w.c), [ &[] ]) // I(1)
-    ///                    |                          |
-    ///                    v                          v
+    /// //                 |                          |
+    /// //                 v                          v
     ///        (Ty(w.p), [ &[x] ])                 false
-    ///                    |
-    ///                    |
-    ///          -------------------------------
-    ///          |                             |
-    ///          v                             v
+    /// //                 |
+    /// //                 |
+    /// //       -------------------------------
+    /// //       |                             |
+    /// //       v                             v
     ///     (Ty((w.p).x), [ &[] ])     (Ty((w.p).y), []) // IMP 2
-    ///          |                             |
-    ///          v                             v
+    /// //       |                             |
+    /// //       v                             v
     ///        false              NeedsSignificantDrop(Ty(w.p.y))
-    ///                                        |
-    ///                                        v
+    /// //                                     |
+    /// //                                     v
     ///                                      true
     /// ```
     ///
@@ -1319,7 +1320,7 @@ fn compute_2229_migrations(
     ///
     /// Consider another example:
     ///
-    /// ```rust
+    /// ```ignore (pseudo-rust)
     /// struct X;
     /// impl Drop for X {}
     ///
@@ -1724,14 +1725,14 @@ struct InferBorrowKind<'a, 'tcx> {
     /// s.str2 via a MutableBorrow
     ///
     /// ```rust,no_run
-    /// struct SomeStruct { str1: String, str2: String }
+    /// struct SomeStruct { str1: String, str2: String };
     ///
     /// // Assume that the HirId for the variable definition is `V1`
-    /// let mut s = SomeStruct { str1: format!("s1"), str2: format!("s2") }
+    /// let mut s = SomeStruct { str1: format!("s1"), str2: format!("s2") };
     ///
     /// let fix_s = |new_s2| {
     ///     // Assume that the HirId for the expression `s.str1` is `E1`
-    ///     println!("Updating SomeStruct with str1=", s.str1);
+    ///     println!("Updating SomeStruct with str1={0}", s.str1);
     ///     // Assume that the HirId for the expression `*s.str2` is `E2`
     ///     s.str2 = new_s2;
     /// };
@@ -1739,7 +1740,7 @@ struct InferBorrowKind<'a, 'tcx> {
     ///
     /// For closure `fix_s`, (at a high level) the map contains
     ///
-    /// ```
+    /// ```ignore (illustrative)
     /// Place { V1, [ProjectionKind::Field(Index=0, Variant=0)] } : CaptureKind { E1, ImmutableBorrow }
     /// Place { V1, [ProjectionKind::Field(Index=1, Variant=0)] } : CaptureKind { E2, MutableBorrow }
     /// ```
@@ -2067,7 +2068,7 @@ fn migration_suggestion_for_2229(
 /// Consider the following example
 /// ```rust,no_run
 /// struct Point { x: i32, y: i32 }
-/// let mut p: Point { x: 10, y: 10 };
+/// let mut p = Point { x: 10, y: 10 };
 ///
 /// let c = || {
 ///     p.x     += 10;
@@ -2213,7 +2214,10 @@ fn determine_place_ancestry_relation<'tcx>(
 ///
 /// Reason we only drop the last deref is because of the following edge case:
 ///
-/// ```rust
+/// ```
+/// # struct A { field_of_a: Box<i32> }
+/// # struct B {}
+/// # struct C<'a>(&'a i32);
 /// struct MyStruct<'a> {
 ///    a: &'static A,
 ///    b: B,
@@ -2221,7 +2225,7 @@ fn determine_place_ancestry_relation<'tcx>(
 /// }
 ///
 /// fn foo<'a, 'b>(m: &'a MyStruct<'b>) -> impl FnMut() + 'static {
-///     let c = || drop(&*m.a.field_of_a);
+///     || drop(&*m.a.field_of_a)
 ///     // Here we really do want to capture `*m.a` because that outlives `'static`
 ///
 ///     // If we capture `m`, then the closure no longer outlives `'static'
index ec2b7c13ff33c5325ae7ddeed69ab67ae8eaea8e..829485367e0a4ee9481a7fdca20fec61cb987f2c 100644 (file)
@@ -37,7 +37,7 @@
 /// Helper type of a temporary returned by `.for_item(...)`.
 /// This is necessary because we can't write the following bound:
 ///
-/// ```rust
+/// ```ignore (illustrative)
 /// F: for<'b, 'tcx> where 'tcx FnOnce(FnCtxt<'b, 'tcx>)
 /// ```
 struct CheckWfFcxBuilder<'tcx> {
index 495b8d3b4eeb38470a3a3976f35884d56d658f29..5bb3f92e2f80b2ed5800c1a5a6d54bbc70f31412 100644 (file)
@@ -531,7 +531,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
 /// In particular, definitions of opaque types can only use other generics as arguments,
 /// and they cannot repeat an argument. Example:
 ///
-/// ```rust
+/// ```ignore (illustrative)
 /// type Foo<A, B> = impl Bar<A, B>;
 ///
 /// // Okay -- `Foo` is applied to two distinct, generic types.
index 909c99adab5d2d91f6162e86d206896e145f8e3b..d406d08cd9508253a536a120c81063f8e2b9ccfb 100644 (file)
@@ -109,9 +109,9 @@ pub fn identify_constrained_generic_params<'tcx>(
 /// constrained before it is used, if that is possible, and add the
 /// parameters so constrained to `input_parameters`. For example,
 /// imagine the following impl:
-///
-///     impl<T: Debug, U: Iterator<Item = T>> Trait for U
-///
+/// ```ignore (illustrative)
+/// impl<T: Debug, U: Iterator<Item = T>> Trait for U
+/// ```
 /// The impl's predicates are collected from left to right. Ignoring
 /// the implicit `Sized` bounds, these are
 ///   * T: Debug
index 2bcf2d3b2ed71aabc5a68172464226e808ce06bc..e69ba99dcef4266b8ced208ef4f1806b83115111 100644 (file)
@@ -698,12 +698,13 @@ fn walk_pat(&mut self, discr_place: &PlaceWithHirId<'tcx>, pat: &hir::Pat<'_>) {
     /// In the following example the closures `c` only captures `p.x` even though `incr`
     /// is a capture of the nested closure
     ///
-    /// ```rust,ignore(cannot-test-this-because-pseudo-code)
-    /// let p = ..;
+    /// ```
+    /// struct P { x: i32 }
+    /// let mut p = P { x: 4 };
     /// let c = || {
     ///    let incr = 10;
     ///    let nested = || p.x += incr;
-    /// }
+    /// };
     /// ```
     ///
     /// - When reporting the Place back to the Delegate, ensure that the UpvarId uses the enclosing
index 6cef3e9d9409eb1750595df7047d20b8240a6ed7..22db15f4d4e8e77ceb058aaa75fed098fa1aac9f 100644 (file)
@@ -29,7 +29,7 @@
 //!
 //! Suppose we have the following always applicable impl:
 //!
-//! ```rust
+//! ```ignore (illustrative)
 //! impl<T> SpecExtend<T> for std::vec::IntoIter<T> { /* specialized impl */ }
 //! impl<T, I: Iterator<Item=T>> SpecExtend<T> for I { /* default impl */ }
 //! ```
index 85e9a670ffbf16de5502c2a581ec0ccb3a9c8e90..3d7b6593a645559c19452d2138e10de5a3c398e2 100644 (file)
@@ -9,12 +9,12 @@
 //! expressions of the following forms (the actual enum has many more
 //! possibilities, naturally, but they are all variants of these base
 //! forms):
-//!
-//!     E = rvalue    // some computed rvalue
-//!       | x         // address of a local variable or argument
-//!       | *E        // deref of a ptr
-//!       | E.comp    // access to an interior component
-//!
+//! ```ignore (not-rust)
+//! E = rvalue    // some computed rvalue
+//!   | x         // address of a local variable or argument
+//!   | *E        // deref of a ptr
+//!   | E.comp    // access to an interior component
+//! ```
 //! Imagine a routine ToAddr(Expr) that evaluates an expression and returns an
 //! address where the result is to be found. If Expr is a place, then this
 //! is the address of the place. If `Expr` is an rvalue, this is the address of
index 6f842c6e71a5b5aaf399f55a6a240f90f3e40cb8..b2cf64393a402e66d993380de24e1d7be6f7f548 100644 (file)
@@ -211,15 +211,15 @@ fn insert_required_predicates_to_be_wf<'tcx>(
 
 /// We also have to check the explicit predicates
 /// declared on the type.
+/// ```ignore (illustrative)
+/// struct Foo<'a, T> {
+///     field1: Bar<T>
+/// }
 ///
-///     struct Foo<'a, T> {
-///         field1: Bar<T>
-///     }
-///
-///     struct Bar<U> where U: 'static, U: Foo {
-///         ...
-///     }
-///
+/// struct Bar<U> where U: 'static, U: Foo {
+///     ...
+/// }
+/// ```
 /// Here, we should fetch the explicit predicates, which
 /// will give us `U: 'static` and `U: Foo`. The latter we
 /// can ignore, but we will want to process `U: 'static`,
index 435df9c00f466aa5e8d45d1e2ed00aa72d320888..87f844fafe67f1001bcbbc3e0a72f9da0879f9cf 100644 (file)
@@ -26,9 +26,9 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
     /// calling that fn, and hence the *callee* can assume that its
     /// argument types are well-formed. This may imply certain relationships
     /// between generic parameters. For example:
-    ///
-    ///     fn foo<'a,T>(x: &'a T)
-    ///
+    /// ```
+    /// fn foo<'a,T>(x: &'a T) {}
+    /// ```
     /// can only be called with a `'a` and `T` such that `&'a T` is WF.
     /// For `&'a T` to be WF, `T: 'a` must hold. So we can assume `T: 'a`.
     ///
index 76755de4964e1435bf1e4b6335519b953034ac5c..81d3dfae626fe723e7aa802d276bf681b93bdd9a 100644 (file)
@@ -34,11 +34,11 @@ pub struct Constraint<'a> {
 
 /// To build constraints, we visit one item (type, trait) at a time
 /// and look at its contents. So e.g., if we have
-///
-///     struct Foo<T> {
-///         b: Bar<T>
-///     }
-///
+/// ```ignore (illustrative)
+/// struct Foo<T> {
+///     b: Bar<T>
+/// }
+/// ```
 /// then while we are visiting `Bar<T>`, the `CurrentItem` would have
 /// the `DefId` and the start of `Foo`'s inferreds.
 pub struct CurrentItem {