From 02005e9f22bf06e74c3ed6ce56be112d7366bd15 Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Wed, 11 Jan 2023 22:46:14 +1300 Subject: [PATCH] remove unreachable error code `E0490` --- compiler/rustc_error_codes/src/error_codes.rs | 2 +- .../locales/en-US/infer.ftl | 1 - .../src/infer/error_reporting/note.rs | 35 ------------------- .../src/infer/lexical_region_resolve/mod.rs | 23 ++---------- compiler/rustc_infer/src/infer/mod.rs | 4 --- src/tools/tidy/src/error_codes.rs | 6 ++-- 6 files changed, 5 insertions(+), 66 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 686c22bc386..d09463aad76 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -618,7 +618,7 @@ E0791: include_str!("./error_codes/E0791.md"), // E0487, // unsafe use of destructor: destructor might be called while... // E0488, // lifetime of variable does not enclose its declaration // E0489, // type/lifetime parameter not in scope here - E0490, // a value of type `..` is borrowed for too long +// E0490, // removed: unreachable E0523, // two dependencies have same (crate-name, disambiguator) but different SVH // E0526, // shuffle indices are not constant // E0540, // multiple rustc_deprecated attributes diff --git a/compiler/rustc_error_messages/locales/en-US/infer.ftl b/compiler/rustc_error_messages/locales/en-US/infer.ftl index c1cb07cf0df..ae0091b0373 100644 --- a/compiler/rustc_error_messages/locales/en-US/infer.ftl +++ b/compiler/rustc_error_messages/locales/en-US/infer.ftl @@ -101,7 +101,6 @@ infer_subtype_2 = ...so that {$requirement -> infer_reborrow = ...so that reference does not outlive borrowed content infer_reborrow_upvar = ...so that closure can access `{$name}` infer_relate_object_bound = ...so that it can be closed over into an object -infer_data_borrowed = ...so that the type `{$name}` is not borrowed for too long infer_reference_outlives_referent = ...so that the reference type `{$name}` does not outlive the data it points at infer_relate_param_bound = ...so that the type `{$name}` will meet its required lifetime bounds{$continues -> [true] ... diff --git a/compiler/rustc_infer/src/infer/error_reporting/note.rs b/compiler/rustc_infer/src/infer/error_reporting/note.rs index 7bb79d7bda8..7504ed094a3 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/note.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/note.rs @@ -29,15 +29,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { RegionOriginNote::Plain { span, msg: fluent::infer_relate_object_bound } .add_to_diagnostic(err); } - infer::DataBorrowed(ty, span) => { - RegionOriginNote::WithName { - span, - msg: fluent::infer_data_borrowed, - name: &self.ty_to_string(ty), - continues: false, - } - .add_to_diagnostic(err); - } infer::ReferenceOutlivesReferent(ty, span) => { RegionOriginNote::WithName { span, @@ -227,32 +218,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ); err } - infer::DataBorrowed(ty, span) => { - let mut err = struct_span_err!( - self.tcx.sess, - span, - E0490, - "a value of type `{}` is borrowed for too long", - self.ty_to_string(ty) - ); - note_and_explain_region( - self.tcx, - &mut err, - "the type is valid for ", - sub, - "", - None, - ); - note_and_explain_region( - self.tcx, - &mut err, - "but the borrow lasts for ", - sup, - "", - None, - ); - err - } infer::ReferenceOutlivesReferent(ty, span) => { let mut err = struct_span_err!( self.tcx.sess, diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs index da2c6fbc05f..897545046c3 100644 --- a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs +++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs @@ -702,26 +702,8 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { // Obtain the spans for all the places that can // influence the constraints on this value for // richer diagnostics in `static_impl_trait`. - let influences: Vec = self - .data - .constraints - .iter() - .filter_map(|(constraint, origin)| match (constraint, origin) { - ( - Constraint::VarSubVar(_, sup), - SubregionOrigin::DataBorrowed(_, sp), - ) if sup == &node_vid => Some(*sp), - _ => None, - }) - .collect(); - self.collect_error_for_expanding_node( - graph, - &mut dup_vec, - node_vid, - errors, - influences, - ); + self.collect_error_for_expanding_node(graph, &mut dup_vec, node_vid, errors); } } } @@ -775,7 +757,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { dup_vec: &mut IndexVec>, node_idx: RegionVid, errors: &mut Vec>, - influences: Vec, ) { // Errors in expanding nodes result from a lower-bound that is // not contained by an upper-bound. @@ -830,7 +811,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { lower_bound.region, upper_bound.origin.clone(), upper_bound.region, - influences, + vec![], )); return; } diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 6bef3f000a5..0e355b6d1ee 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -410,9 +410,6 @@ pub enum SubregionOrigin<'tcx> { /// Creating a pointer `b` to contents of another reference Reborrow(Span), - /// Data with type `Ty<'tcx>` was borrowed - DataBorrowed(Ty<'tcx>, Span), - /// (&'a &'b T) where a >= b ReferenceOutlivesReferent(Ty<'tcx>, Span), @@ -1974,7 +1971,6 @@ impl<'tcx> SubregionOrigin<'tcx> { RelateParamBound(a, ..) => a, RelateRegionParamBound(a) => a, Reborrow(a) => a, - DataBorrowed(_, a) => a, ReferenceOutlivesReferent(_, a) => a, CompareImplItemObligation { span, .. } => span, AscribeUserTypeProvePredicate(span) => span, diff --git a/src/tools/tidy/src/error_codes.rs b/src/tools/tidy/src/error_codes.rs index 9aacc07e0ab..8b44a09fdf0 100644 --- a/src/tools/tidy/src/error_codes.rs +++ b/src/tools/tidy/src/error_codes.rs @@ -31,10 +31,8 @@ const IGNORE_DOCTEST_CHECK: &[&str] = &["E0208", "E0464", "E0570", "E0601", "E0602", "E0640", "E0717"]; // 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", "E0490", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729", - "E0789", -]; +const IGNORE_UI_TEST_CHECK: &[&str] = + &["E0461", "E0465", "E0476", "E0514", "E0523", "E0554", "E0640", "E0717", "E0729", "E0789"]; macro_rules! verbose_print { ($verbose:expr, $($fmt:tt)*) => {