From cd9419b5d9d2b40316175d8db7c78bef7813534c Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Sat, 14 Jan 2023 21:39:15 +1300 Subject: [PATCH] remove unreachable error code `E0476` --- compiler/rustc_error_codes/src/error_codes.rs | 2 +- .../src/coherence/builtin.rs | 4 +-- .../src/infer/error_reporting/note.rs | 30 ------------------- compiler/rustc_infer/src/infer/mod.rs | 5 ---- src/tools/tidy/src/error_codes.rs | 2 +- 5 files changed, 3 insertions(+), 40 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 24258974bb97c..d95d4d2dffc30 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -607,7 +607,7 @@ E0791: include_str!("./error_codes/E0791.md"), // E0473, // dereference of reference outside its lifetime // E0474, // captured variable `..` does not outlive the enclosing closure // E0475, // index of slice outside its lifetime - E0476, // lifetime of the source pointer does not outlive lifetime bound... +// E0476, // removed: unreachable // E0479, // the type `..` (provided as the value of a type parameter) is... // E0480, // lifetime of method receiver does not outlive the method call // E0481, // lifetime of function argument does not outlive the function call diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs index 2e2c1591e9b44..cb51a73335335 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs @@ -7,7 +7,6 @@ use rustc_hir as hir; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::lang_items::LangItem; use rustc_hir::ItemKind; -use rustc_infer::infer; use rustc_infer::infer::outlives::env::OutlivesEnvironment; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::ty::adjustment::CoerceUnsizedInfo; @@ -386,8 +385,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn (mt_a.ty, mt_b.ty, unsize_trait, None) }; let (source, target, trait_def_id, kind) = match (source.kind(), target.kind()) { - (&ty::Ref(r_a, ty_a, mutbl_a), &ty::Ref(r_b, ty_b, mutbl_b)) => { - infcx.sub_regions(infer::RelateObjectBound(span), r_b, r_a); + (&ty::Ref(_, ty_a, mutbl_a), &ty::Ref(r_b, ty_b, mutbl_b)) => { let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a }; let mt_b = ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b }; check_mutbl(mt_a, mt_b, &|ty| tcx.mk_imm_ref(r_b, ty)) diff --git a/compiler/rustc_infer/src/infer/error_reporting/note.rs b/compiler/rustc_infer/src/infer/error_reporting/note.rs index 7504ed094a3d4..8cccf68535dda 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note.rs @@ -25,10 +25,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { infer::Reborrow(span) => { RegionOriginNote::Plain { span, msg: fluent::infer_reborrow }.add_to_diagnostic(err) } - infer::RelateObjectBound(span) => { - RegionOriginNote::Plain { span, msg: fluent::infer_relate_object_bound } - .add_to_diagnostic(err); - } infer::ReferenceOutlivesReferent(ty, span) => { RegionOriginNote::WithName { span, @@ -143,32 +139,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ); err } - infer::RelateObjectBound(span) => { - let mut err = struct_span_err!( - self.tcx.sess, - span, - E0476, - "lifetime of the source pointer does not outlive lifetime bound of the \ - object type" - ); - note_and_explain_region( - self.tcx, - &mut err, - "object type is valid for ", - sub, - "", - None, - ); - note_and_explain_region( - self.tcx, - &mut err, - "source pointer is only valid for ", - sup, - "", - None, - ); - err - } infer::RelateParamBound(span, ty, opt_span) => { let mut err = struct_span_err!( self.tcx.sess, diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 4acd0d0edfec7..6423c171d790a 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -395,10 +395,6 @@ pub enum SubregionOrigin<'tcx> { /// Arose from a subtyping relation Subtype(Box>), - /// When casting `&'a T` to an `&'b Trait` object, - /// relating `'a` to `'b` - RelateObjectBound(Span), - /// Some type parameter was instantiated with the given type, /// and that type must outlive some region. RelateParamBound(Span, Ty<'tcx>, Option), @@ -1971,7 +1967,6 @@ impl<'tcx> SubregionOrigin<'tcx> { pub fn span(&self) -> Span { match *self { Subtype(ref a) => a.span(), - RelateObjectBound(a) => a, RelateParamBound(a, ..) => a, RelateRegionParamBound(a) => a, Reborrow(a) => a, diff --git a/src/tools/tidy/src/error_codes.rs b/src/tools/tidy/src/error_codes.rs index bc9fd35ecde37..cfd9c4d909f9a 100644 --- a/src/tools/tidy/src/error_codes.rs +++ b/src/tools/tidy/src/error_codes.rs @@ -32,7 +32,7 @@ const IGNORE_DOCTEST_CHECK: &[&str] = // Error codes that don't yet have a UI test. This list will eventually be removed. const IGNORE_UI_TEST_CHECK: &[&str] = - &["E0461", "E0465", "E0476", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729", "E0789"]; + &["E0461", "E0465", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729", "E0789"]; macro_rules! verbose_print { ($verbose:expr, $($fmt:tt)*) => {