enable rust_2018_idioms for doctests
Signed-off-by: ozkanonur <work@onurozkan.dev>
This commit is contained in:
parent
8b8110e146
commit
4e7c14fe9f
37 changed files with 125 additions and 101 deletions
|
|
@ -1474,6 +1474,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
/// Given a function definition like:
|
||||
///
|
||||
/// ```rust
|
||||
/// use std::fmt::Debug;
|
||||
///
|
||||
/// fn test<'a, T: Debug>(x: &'a T) -> impl Debug + 'a {
|
||||
/// x
|
||||
/// }
|
||||
|
|
@ -1481,13 +1483,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
///
|
||||
/// we will create a TAIT definition in the HIR like
|
||||
///
|
||||
/// ```
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// type TestReturn<'a, T, 'x> = impl Debug + 'x
|
||||
/// ```
|
||||
///
|
||||
/// and return a type like `TestReturn<'static, T, 'a>`, so that the function looks like:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// fn test<'a, T: Debug>(x: &'a T) -> TestReturn<'static, T, 'a>
|
||||
/// ```
|
||||
///
|
||||
|
|
|
|||
|
|
@ -1038,7 +1038,7 @@ impl<'a> MethodDef<'a> {
|
|||
/// `&self.x` because that might cause an unaligned ref. So for any trait
|
||||
/// method that takes a reference, we use a local block to force a copy.
|
||||
/// This requires that the field impl `Copy`.
|
||||
/// ```
|
||||
/// ```rust,ignore (example)
|
||||
/// # struct A { x: u8, y: u8 }
|
||||
/// impl PartialEq for A {
|
||||
/// fn eq(&self, other: &A) -> bool {
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@
|
|||
//! fn node_label(&self, n: &Nd) -> dot::LabelText<'_> {
|
||||
//! dot::LabelText::LabelStr(self.nodes[*n].into())
|
||||
//! }
|
||||
//! fn edge_label<'b>(&'b self, _: &Ed) -> dot::LabelText<'b> {
|
||||
//! fn edge_label(&self, _: &Ed<'_>) -> dot::LabelText<'_> {
|
||||
//! dot::LabelText::LabelStr("⊆".into())
|
||||
//! }
|
||||
//! }
|
||||
|
|
@ -177,8 +177,8 @@
|
|||
//! type Edge = Ed<'a>;
|
||||
//! fn nodes(&self) -> dot::Nodes<'a,Nd> { (0..self.nodes.len()).collect() }
|
||||
//! fn edges(&'a self) -> dot::Edges<'a,Ed<'a>> { self.edges.iter().collect() }
|
||||
//! fn source(&self, e: &Ed) -> Nd { let & &(s,_) = e; s }
|
||||
//! fn target(&self, e: &Ed) -> Nd { let & &(_,t) = e; t }
|
||||
//! fn source(&self, e: &Ed<'_>) -> Nd { let & &(s,_) = e; s }
|
||||
//! fn target(&self, e: &Ed<'_>) -> Nd { let & &(_,t) = e; t }
|
||||
//! }
|
||||
//!
|
||||
//! # pub fn main() { render_to(&mut Vec::new()) }
|
||||
|
|
@ -226,11 +226,11 @@
|
|||
//! fn node_id(&'a self, n: &Nd<'a>) -> dot::Id<'a> {
|
||||
//! dot::Id::new(format!("N{}", n.0)).unwrap()
|
||||
//! }
|
||||
//! fn node_label<'b>(&'b self, n: &Nd<'b>) -> dot::LabelText<'b> {
|
||||
//! fn node_label(&self, n: &Nd<'_>) -> dot::LabelText<'_> {
|
||||
//! let &(i, _) = n;
|
||||
//! dot::LabelText::LabelStr(self.nodes[i].into())
|
||||
//! }
|
||||
//! fn edge_label<'b>(&'b self, _: &Ed<'b>) -> dot::LabelText<'b> {
|
||||
//! fn edge_label(&self, _: &Ed<'_>) -> dot::LabelText<'_> {
|
||||
//! dot::LabelText::LabelStr("⊆".into())
|
||||
//! }
|
||||
//! }
|
||||
|
|
|
|||
|
|
@ -60,19 +60,21 @@ pub(super) fn compare_impl_method<'tcx>(
|
|||
};
|
||||
}
|
||||
|
||||
/// This function is best explained by example. Consider a trait:
|
||||
/// This function is best explained by example. Consider a trait with it's implementation:
|
||||
///
|
||||
/// trait Trait<'t, T> {
|
||||
/// // `trait_m`
|
||||
/// fn method<'a, M>(t: &'t T, m: &'a M) -> Self;
|
||||
/// }
|
||||
/// ```rust
|
||||
/// trait Trait<'t, T> {
|
||||
/// // `trait_m`
|
||||
/// fn method<'a, M>(t: &'t T, m: &'a M) -> Self;
|
||||
/// }
|
||||
///
|
||||
/// And an impl:
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl<'i, 'j, U> Trait<'j, &'i U> for Foo {
|
||||
/// // `impl_m`
|
||||
/// fn method<'b, N>(t: &'j &'i U, m: &'b N) -> Foo;
|
||||
/// }
|
||||
/// impl<'i, 'j, U> Trait<'j, &'i U> for Foo {
|
||||
/// // `impl_m`
|
||||
/// fn method<'b, N>(t: &'j &'i U, m: &'b N) -> Foo { Foo }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// We wish to decide if those two method types are compatible.
|
||||
/// For this we have to show that, assuming the bounds of the impl hold, the
|
||||
|
|
@ -82,7 +84,9 @@ pub(super) fn compare_impl_method<'tcx>(
|
|||
/// type parameters to impl type parameters. This is taken from the
|
||||
/// impl trait reference:
|
||||
///
|
||||
/// trait_to_impl_substs = {'t => 'j, T => &'i U, Self => Foo}
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// trait_to_impl_substs = {'t => 'j, T => &'i U, Self => Foo}
|
||||
/// ```
|
||||
///
|
||||
/// We create a mapping `dummy_substs` that maps from the impl type
|
||||
/// parameters to fresh types and regions. For type parameters,
|
||||
|
|
@ -91,13 +95,17 @@ pub(super) fn compare_impl_method<'tcx>(
|
|||
/// regions (Note: but only early-bound regions, i.e., those
|
||||
/// declared on the impl or used in type parameter bounds).
|
||||
///
|
||||
/// impl_to_placeholder_substs = {'i => 'i0, U => U0, N => N0 }
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// impl_to_placeholder_substs = {'i => 'i0, U => U0, N => N0 }
|
||||
/// ```
|
||||
///
|
||||
/// Now we can apply `placeholder_substs` to the type of the impl method
|
||||
/// to yield a new function type in terms of our fresh, placeholder
|
||||
/// types:
|
||||
///
|
||||
/// <'b> fn(t: &'i0 U0, m: &'b) -> Foo
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// <'b> fn(t: &'i0 U0, m: &'b) -> Foo
|
||||
/// ```
|
||||
///
|
||||
/// We now want to extract and substitute the type of the *trait*
|
||||
/// method and compare it. To do so, we must create a compound
|
||||
|
|
@ -106,11 +114,15 @@ pub(super) fn compare_impl_method<'tcx>(
|
|||
/// type parameters. We extend the mapping to also include
|
||||
/// the method parameters.
|
||||
///
|
||||
/// trait_to_placeholder_substs = { T => &'i0 U0, Self => Foo, M => N0 }
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// trait_to_placeholder_substs = { T => &'i0 U0, Self => Foo, M => N0 }
|
||||
/// ```
|
||||
///
|
||||
/// Applying this to the trait method type yields:
|
||||
///
|
||||
/// <'a> fn(t: &'i0 U0, m: &'a) -> Foo
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// <'a> fn(t: &'i0 U0, m: &'a) -> Foo
|
||||
/// ```
|
||||
///
|
||||
/// This type is also the same but the name of the bound region (`'a`
|
||||
/// vs `'b`). However, the normal subtyping rules on fn types handle
|
||||
|
|
@ -1163,7 +1175,7 @@ fn compare_self_type<'tcx>(
|
|||
/// as the number of generics on the respective assoc item in the trait definition.
|
||||
///
|
||||
/// For example this code emits the errors in the following code:
|
||||
/// ```
|
||||
/// ```rust,compile_fail
|
||||
/// trait Trait {
|
||||
/// fn foo();
|
||||
/// type Assoc<T>;
|
||||
|
|
@ -1547,7 +1559,7 @@ fn compare_synthetic_generics<'tcx>(
|
|||
/// the same kind as the respective generic parameter in the trait def.
|
||||
///
|
||||
/// For example all 4 errors in the following code are emitted here:
|
||||
/// ```
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// trait Foo {
|
||||
/// fn foo<const N: u8>();
|
||||
/// type bar<const N: u8>;
|
||||
|
|
|
|||
|
|
@ -1913,7 +1913,7 @@ fn is_late_bound_map(
|
|||
/// handles cycle detection as we go through the query system.
|
||||
///
|
||||
/// This is necessary in the first place for the following case:
|
||||
/// ```
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// type Alias<'a, T> = <T as Trait<'a>>::Assoc;
|
||||
/// fn foo<'a>(_: Alias<'a, ()>) -> Alias<'a, ()> { ... }
|
||||
/// ```
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub enum TypeAnnotationNeeded {
|
|||
/// ```
|
||||
E0282,
|
||||
/// An implementation cannot be chosen unambiguously because of lack of information.
|
||||
/// ```compile_fail,E0283
|
||||
/// ```compile_fail,E0790
|
||||
/// let _ = Default::default();
|
||||
/// ```
|
||||
E0283,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
///
|
||||
/// Consider a case where we have
|
||||
///
|
||||
/// ```compile_fail,E0623
|
||||
/// ```compile_fail
|
||||
/// fn foo(x: &mut Vec<&u8>, y: &u8) {
|
||||
/// x.push(y);
|
||||
/// }
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use rustc_middle::ty::{self, Region, TyCtxt};
|
|||
/// br - the bound region corresponding to the above region which is of type `BrAnon(_)`
|
||||
///
|
||||
/// # Example
|
||||
/// ```compile_fail,E0623
|
||||
/// ```compile_fail
|
||||
/// fn foo(x: &mut Vec<&u8>, y: &u8)
|
||||
/// { x.push(y); }
|
||||
/// ```
|
||||
|
|
|
|||
|
|
@ -13,9 +13,11 @@ use crate::infer::region_constraints::VerifyIfEq;
|
|||
|
||||
/// Given a "verify-if-eq" type test like:
|
||||
///
|
||||
/// exists<'a...> {
|
||||
/// verify_if_eq(some_type, bound_region)
|
||||
/// }
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// exists<'a...> {
|
||||
/// verify_if_eq(some_type, bound_region)
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// and the type `test_ty` that the type test is being tested against,
|
||||
/// returns:
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
|
|||
///
|
||||
/// It will not, however, work for higher-ranked bounds like:
|
||||
///
|
||||
/// ```compile_fail,E0311
|
||||
/// ```ignore(this does compile today, previously was marked as `compile_fail,E0311`)
|
||||
/// trait Foo<'a, 'b>
|
||||
/// where for<'x> <Self as Foo<'x, 'b>>::Bar: 'x
|
||||
/// {
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ pub enum VerifyBound<'tcx> {
|
|||
/// and supplies a bound if it ended up being relevant. It's used in situations
|
||||
/// like this:
|
||||
///
|
||||
/// ```rust
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// fn foo<'a, 'b, T: SomeTrait<'a>>
|
||||
/// where
|
||||
/// <T as SomeTrait<'a>>::Item: 'b
|
||||
|
|
@ -232,7 +232,7 @@ pub enum VerifyBound<'tcx> {
|
|||
/// In the [`VerifyBound`], this struct is enclosed in `Binder` to account
|
||||
/// for cases like
|
||||
///
|
||||
/// ```rust
|
||||
/// ```rust,ignore (pseudo-Rust)
|
||||
/// where for<'a> <T as SomeTrait<'a>::Item: 'a
|
||||
/// ```
|
||||
///
|
||||
|
|
|
|||
|
|
@ -333,6 +333,7 @@ declare_lint! {
|
|||
///
|
||||
/// ```rust,compile_fail
|
||||
/// #![deny(unused_extern_crates)]
|
||||
/// #![deny(warnings)]
|
||||
/// extern crate proc_macro;
|
||||
/// ```
|
||||
///
|
||||
|
|
@ -1667,6 +1668,7 @@ declare_lint! {
|
|||
///
|
||||
/// ```rust,compile_fail
|
||||
/// #![deny(elided_lifetimes_in_paths)]
|
||||
/// #![deny(warnings)]
|
||||
/// struct Foo<'a> {
|
||||
/// x: &'a u32
|
||||
/// }
|
||||
|
|
@ -2158,6 +2160,7 @@ declare_lint! {
|
|||
/// ```rust,compile_fail
|
||||
/// # #![allow(unused)]
|
||||
/// #![deny(explicit_outlives_requirements)]
|
||||
/// #![deny(warnings)]
|
||||
///
|
||||
/// struct SharedRef<'a, T>
|
||||
/// where
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue