From c877ff3664abea60d69b8acf8e7dce85c2ffd859 Mon Sep 17 00:00:00 2001 From: Camelid Date: Sun, 4 Oct 2020 19:08:40 -0700 Subject: [PATCH 1/2] Fix rustdoc warnings about invalid Rust syntax --- compiler/rustc_mir/src/borrow_check/region_infer/mod.rs | 4 +++- compiler/rustc_mir/src/util/pretty.rs | 3 ++- compiler/rustc_trait_selection/src/opaque_types.rs | 7 +++++-- compiler/rustc_typeck/src/check/expr.rs | 4 ++-- compiler/rustc_typeck/src/check/pat.rs | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs b/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs index 3dc082a4413..053ca7c23d2 100644 --- a/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs @@ -1225,7 +1225,9 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// it. However, it works pretty well in practice. In particular, /// this is needed to deal with projection outlives bounds like /// - /// >::Item: '1 + /// ```ignore (MIR syntax) + /// >::Item: '1 + /// ``` /// /// In particular, this routine winds up being important when /// there are bounds like `where >::Item: 'b` in the diff --git a/compiler/rustc_mir/src/util/pretty.rs b/compiler/rustc_mir/src/util/pretty.rs index 49c644a20bf..67bc886b938 100644 --- a/compiler/rustc_mir/src/util/pretty.rs +++ b/compiler/rustc_mir/src/util/pretty.rs @@ -659,7 +659,8 @@ pub fn write_allocations<'tcx>( /// Dumps the size and metadata and content of an allocation to the given writer. /// The expectation is that the caller first prints other relevant metadata, so the exact /// format of this function is (*without* leading or trailing newline): -/// ``` +/// +/// ```text /// size: {}, align: {}) { /// /// } diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs index 28697ec4e3b..4f351ab176d 100644 --- a/compiler/rustc_trait_selection/src/opaque_types.rs +++ b/compiler/rustc_trait_selection/src/opaque_types.rs @@ -38,13 +38,16 @@ pub struct OpaqueTypeDecl<'tcx> { /// then `substs` would be `['a, T]`. pub substs: SubstsRef<'tcx>, - /// The span of this particular definition of the opaque type. So + /// The span of this particular definition of the opaque type. So /// for example: /// /// ``` /// type Foo = impl Baz; /// fn bar() -> Foo { - /// ^^^ This is the span we are looking for! + /// // ^^^ This is the span we are looking for! + /// // ... + /// # unimplemented!() + /// } /// ``` /// /// In cases where the fn returns `(impl Trait, impl Trait)` or diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index af800eab67a..179e383be2e 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -1275,7 +1275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Report an error for a struct field expression when there are fields which aren't provided. /// - /// ```ignore (diagnostic) + /// ```text /// error: missing field `you_can_use_this_field` in initializer of `foo::Foo` /// --> src/main.rs:8:5 /// | @@ -1327,7 +1327,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Report an error for a struct field expression when there are no visible fields. /// - /// ```ignore (diagnostic) + /// ```text /// error: cannot construct `Foo` with struct literal syntax due to inaccessible fields /// --> src/main.rs:8:5 /// | diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 3e431a9c000..53bc2069b76 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -1381,7 +1381,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Returns a diagnostic reporting a struct pattern which is missing an `..` due to /// inaccessible fields. /// - /// ```ignore (diagnostic) + /// ```text /// error: pattern requires `..` due to inaccessible fields /// --> src/main.rs:10:9 /// | @@ -1431,7 +1431,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Returns a diagnostic reporting a struct pattern which does not mention some fields. /// - /// ```ignore (diagnostic) + /// ```text /// error[E0027]: pattern does not mention field `you_cant_use_this_field` /// --> src/main.rs:15:9 /// | From c8d25af6985c2c6be388fc198c2c7d50eb553fc4 Mon Sep 17 00:00:00 2001 From: Camelid Date: Mon, 5 Oct 2020 15:07:27 -0700 Subject: [PATCH 2/2] Fixup --- compiler/rustc_mir/src/borrow_check/region_infer/mod.rs | 2 +- compiler/rustc_trait_selection/src/opaque_types.rs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs b/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs index 053ca7c23d2..6264f521c62 100644 --- a/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs @@ -1225,7 +1225,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// it. However, it works pretty well in practice. In particular, /// this is needed to deal with projection outlives bounds like /// - /// ```ignore (MIR syntax) + /// ```ignore (internal compiler representation so lifetime syntax is invalid) /// >::Item: '1 /// ``` /// diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs index 4f351ab176d..618f3e045e7 100644 --- a/compiler/rustc_trait_selection/src/opaque_types.rs +++ b/compiler/rustc_trait_selection/src/opaque_types.rs @@ -41,13 +41,10 @@ pub struct OpaqueTypeDecl<'tcx> { /// The span of this particular definition of the opaque type. So /// for example: /// - /// ``` + /// ```ignore (incomplete snippet) /// type Foo = impl Baz; /// fn bar() -> Foo { /// // ^^^ This is the span we are looking for! - /// // ... - /// # unimplemented!() - /// } /// ``` /// /// In cases where the fn returns `(impl Trait, impl Trait)` or