Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
This commit is contained in:
commit
574830f573
116 changed files with 668 additions and 609 deletions
|
@ -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 }
|
||||
|
|
|
@ -1006,9 +1006,11 @@ impl<'a> MethodDef<'a> {
|
|||
/// }
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// // 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 @@ impl<'a> MethodDef<'a> {
|
|||
/// // 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
|
||||
/// }
|
||||
/// }
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue