From 80417fb76dfc705a4a3d75157fb6234b9292d025 Mon Sep 17 00:00:00 2001 From: CarsonV Date: Thu, 5 Jan 2023 18:24:12 -0600 Subject: [PATCH 1/3] Enable doctests and simple fixes --- compiler/rustc_infer/Cargo.toml | 2 +- .../error_reporting/nice_region_error/different_lifetimes.rs | 2 +- .../infer/error_reporting/nice_region_error/find_anon_type.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_infer/Cargo.toml b/compiler/rustc_infer/Cargo.toml index aced787d67116..42ac9dd187b14 100644 --- a/compiler/rustc_infer/Cargo.toml +++ b/compiler/rustc_infer/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" edition = "2021" [lib] -doctest = false + [dependencies] tracing = "0.1" diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs index da0271a345e40..11e5f4fde16b6 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -21,7 +21,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// /// Consider a case where we have /// - /// ```compile_fail,E0623 + /// ```compile_fail,(E0623) /// fn foo(x: &mut Vec<&u8>, y: &u8) { /// x.push(y); /// } diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs index 39f4d5022598d..1dc9f4d030084 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -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,(E0623) /// fn foo(x: &mut Vec<&u8>, y: &u8) /// { x.push(y); } /// ``` From 64ff2478fdfb8be3f34ef713337be6f8c0583832 Mon Sep 17 00:00:00 2001 From: CarsonV Date: Thu, 5 Jan 2023 18:37:46 -0600 Subject: [PATCH 2/3] add E0283 error to doctest --- .../src/infer/error_reporting/need_type_info.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index a4c36b4c9cd59..d4ee8cbf81e12 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -32,7 +32,14 @@ pub enum TypeAnnotationNeeded { E0282, /// An implementation cannot be chosen unambiguously because of lack of information. /// ```compile_fail,E0283 - /// let _ = Default::default(); + /// struct Foo; + /// + /// impl Into for Foo { + /// fn into(self) -> u32 { 1 } + /// } + /// + /// let foo = Foo; + /// let bar: u32 = foo.into() * 1u32; /// ``` E0283, /// ```compile_fail,E0284 From 9e4b21b6fd70e7957bebfca7645e80dce62fddd6 Mon Sep 17 00:00:00 2001 From: CarsonV Date: Thu, 5 Jan 2023 20:36:18 -0600 Subject: [PATCH 3/3] cleanup last of infer doctest errors --- .../rustc_infer/src/infer/outlives/test_type_match.rs | 8 +++++--- compiler/rustc_infer/src/infer/outlives/verify.rs | 2 +- compiler/rustc_infer/src/infer/region_constraints/mod.rs | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs index 10b474efd5aeb..297cd0d7f2652 100644 --- a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs +++ b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs @@ -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) -/// } +/// ```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: diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs index 40bbec8ddd091..506b66e183796 100644 --- a/compiler/rustc_infer/src/infer/outlives/verify.rs +++ b/compiler/rustc_infer/src/infer/outlives/verify.rs @@ -288,7 +288,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { /// /// It will not, however, work for higher-ranked bounds like: /// - /// ```compile_fail,E0311 + /// ``` /// trait Foo<'a, 'b> /// where for<'x> >::Bar: 'x /// { diff --git a/compiler/rustc_infer/src/infer/region_constraints/mod.rs b/compiler/rustc_infer/src/infer/region_constraints/mod.rs index 9a427ceacd0a7..86f2cfb58e5e0 100644 --- a/compiler/rustc_infer/src/infer/region_constraints/mod.rs +++ b/compiler/rustc_infer/src/infer/region_constraints/mod.rs @@ -240,7 +240,7 @@ pub enum VerifyBound<'tcx> { /// and supplies a bound if it ended up being relevant. It's used in situations /// like this: /// -/// ```rust +/// ```ignore (pseudo-rust) /// fn foo<'a, 'b, T: SomeTrait<'a>> /// where /// >::Item: 'b @@ -255,7 +255,7 @@ pub enum VerifyBound<'tcx> { /// In the [`VerifyBound`], this struct is enclosed in `Binder to account /// for cases like /// -/// ```rust +/// ```ignore (pseudo-rust) /// where for<'a> ::Item: 'a /// ``` ///