about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAman Arora <me@aman-arora.com>2020-11-15 18:06:30 -0500
committerAman Arora <me@aman-arora.com>2020-11-15 18:53:03 -0500
commit40dfe1eddd35d65348c40abe12dc5c659d068e2c (patch)
tree52fbff7b1a6975eb1a92ddb281c9f168c1a51f66
parentbb8c5e5d8b4961a26f88b320f719249a9db8225e (diff)
downloadrust-40dfe1eddd35d65348c40abe12dc5c659d068e2c.tar.gz
rust-40dfe1eddd35d65348c40abe12dc5c659d068e2c.zip
Ignore doctest for capture analysis examples
-rw-r--r--compiler/rustc_middle/src/ty/mod.rs6
-rw-r--r--compiler/rustc_typeck/src/check/upvar.rs13
-rw-r--r--compiler/rustc_typeck/src/expr_use_visitor.rs2
3 files changed, 12 insertions, 9 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index 0c786be0478..8f31c9b0fc6 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -797,12 +797,12 @@ pub struct CaptureInfo<'tcx> {
     /// None. In such case we fallback on uvpars_mentioned for span.
     ///
     /// Eg:
-    /// ```rust
-    /// let x = ...;
+    /// ```rust,no_run
+    /// let x = 5;
     ///
     /// let c = || {
     ///     let _ = x
-    /// }
+    /// };
     /// ```
     ///
     /// In this example, if `capture_disjoint_fields` is **not** set, then x will be captured,
diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs
index e0bbe3cb079..019fa78fb1e 100644
--- a/compiler/rustc_typeck/src/check/upvar.rs
+++ b/compiler/rustc_typeck/src/check/upvar.rs
@@ -333,7 +333,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     /// the required captured paths.
     ///
     /// Eg:
-    /// ```rust
+    /// ```rust,no_run
     /// struct Point { x: i32, y: i32 }
     ///
     /// let s: String;  // hir_id_s
@@ -575,7 +575,9 @@ struct InferBorrowKind<'a, 'tcx> {
     /// Consider closure where s.str1 is captured via an ImmutableBorrow and
     /// s.str2 via a MutableBorrow
     ///
-    /// ```rust
+    /// ```rust,no_run
+    /// 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") }
     ///
@@ -584,7 +586,7 @@ struct InferBorrowKind<'a, 'tcx> {
     ///     println!("Updating SomeStruct with str1=", s.str1);
     ///     // Assume that the HirId for the expression `*s.str2` is `E2`
     ///     s.str2 = new_s2;
-    /// }
+    /// };
     /// ```
     ///
     /// For closure `fix_s`, (at a high level) the map contains
@@ -931,7 +933,8 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol {
 /// `determine_capture_info(existing_info, current_info)`. This works out because the
 /// expressions that occur earlier in the closure body than the current expression are processed before.
 /// Consider the following example
-/// ```rust
+/// ```rust,no_run
+/// struct Point { x: i32, y: i32 }
 /// let mut p: Point { x: 10, y: 10 };
 ///
 /// let c = || {
@@ -942,7 +945,7 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol {
 ///     // ...
 ///     p.x += 10; // E2
 /// // ^ E2 ^
-/// }
+/// };
 /// ```
 /// `CaptureKind` associated with both `E1` and `E2` will be ByRef(MutBorrow),
 /// and both have an expression associated, however for diagnostics we prefer reporting
diff --git a/compiler/rustc_typeck/src/expr_use_visitor.rs b/compiler/rustc_typeck/src/expr_use_visitor.rs
index 72e5a7ef1b6..1b51d5e0182 100644
--- a/compiler/rustc_typeck/src/expr_use_visitor.rs
+++ b/compiler/rustc_typeck/src/expr_use_visitor.rs
@@ -611,7 +611,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
     /// In the following example the closures `c` only captures `p.x`` even though `incr`
     /// is a capture of the nested closure
     ///
-    /// ```rust
+    /// ```rust,ignore(cannot-test-this-because-pseduo-code)
     /// let p = ..;
     /// let c = || {
     ///    let incr = 10;