Skip to content

Commit 40dfe1e

Browse files
committedNov 15, 2020
Ignore doctest for capture analysis examples
1 parent bb8c5e5 commit 40dfe1e

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed
 

‎compiler/rustc_middle/src/ty/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -797,12 +797,12 @@ pub struct CaptureInfo<'tcx> {
797797
/// None. In such case we fallback on uvpars_mentioned for span.
798798
///
799799
/// Eg:
800-
/// ```rust
801-
/// let x = ...;
800+
/// ```rust,no_run
801+
/// let x = 5;
802802
///
803803
/// let c = || {
804804
/// let _ = x
805-
/// }
805+
/// };
806806
/// ```
807807
///
808808
/// In this example, if `capture_disjoint_fields` is **not** set, then x will be captured,

‎compiler/rustc_typeck/src/check/upvar.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
333333
/// the required captured paths.
334334
///
335335
/// Eg:
336-
/// ```rust
336+
/// ```rust,no_run
337337
/// struct Point { x: i32, y: i32 }
338338
///
339339
/// let s: String; // hir_id_s
@@ -575,7 +575,9 @@ struct InferBorrowKind<'a, 'tcx> {
575575
/// Consider closure where s.str1 is captured via an ImmutableBorrow and
576576
/// s.str2 via a MutableBorrow
577577
///
578-
/// ```rust
578+
/// ```rust,no_run
579+
/// struct SomeStruct { str1: String, str2: String }
580+
///
579581
/// // Assume that the HirId for the variable definition is `V1`
580582
/// let mut s = SomeStruct { str1: format!("s1"), str2: format!("s2") }
581583
///
@@ -584,7 +586,7 @@ struct InferBorrowKind<'a, 'tcx> {
584586
/// println!("Updating SomeStruct with str1=", s.str1);
585587
/// // Assume that the HirId for the expression `*s.str2` is `E2`
586588
/// s.str2 = new_s2;
587-
/// }
589+
/// };
588590
/// ```
589591
///
590592
/// 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 {
931933
/// `determine_capture_info(existing_info, current_info)`. This works out because the
932934
/// expressions that occur earlier in the closure body than the current expression are processed before.
933935
/// Consider the following example
934-
/// ```rust
936+
/// ```rust,no_run
937+
/// struct Point { x: i32, y: i32 }
935938
/// let mut p: Point { x: 10, y: 10 };
936939
///
937940
/// let c = || {
@@ -942,7 +945,7 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol {
942945
/// // ...
943946
/// p.x += 10; // E2
944947
/// // ^ E2 ^
945-
/// }
948+
/// };
946949
/// ```
947950
/// `CaptureKind` associated with both `E1` and `E2` will be ByRef(MutBorrow),
948951
/// and both have an expression associated, however for diagnostics we prefer reporting

‎compiler/rustc_typeck/src/expr_use_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
611611
/// In the following example the closures `c` only captures `p.x`` even though `incr`
612612
/// is a capture of the nested closure
613613
///
614-
/// ```rust
614+
/// ```rust,ignore(cannot-test-this-because-pseduo-code)
615615
/// let p = ..;
616616
/// let c = || {
617617
/// let incr = 10;

0 commit comments

Comments
 (0)
Please sign in to comment.