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
|
@ -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.
|
||||
|
|
|
@ -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 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
/// 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.
|
||||
///
|
||||
|
|
|
@ -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
|
||||
/// ```
|
||||
|
|
|
@ -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>>>`
|
||||
|
|
|
@ -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>
|
||||
/// }
|
||||
|
|
|
@ -712,9 +712,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
/// 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.
|
||||
|
|
|
@ -1891,7 +1891,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
///
|
||||
/// 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]
|
||||
|
|
|
@ -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
|
||||
/// ```
|
||||
|
|
|
@ -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 { }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue