Skip to content

Commit e713a31

Browse files
committed
Disarm time bomb (diagnostics)
Manually revert rust-lang#129343 `time` diagnostics, which is a temporary diagnostic to mitigate inference breakage fallout.
1 parent a7b1b24 commit e713a31

File tree

6 files changed

+2
-76
lines changed

6 files changed

+2
-76
lines changed

compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,6 @@ symbols! {
20992099
three_way_compare,
21002100
thumb2,
21012101
thumb_mode: "thumb-mode",
2102-
time,
21032102
tmm_reg,
21042103
to_owned_method,
21052104
to_string,

compiler/rustc_trait_selection/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,6 @@ trait_selection_type_annotations_needed = {$source_kind ->
452452
}
453453
.label = type must be known at this point
454454
455-
trait_selection_type_annotations_needed_error_time = this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35` by calling `cargo update`
456-
457455
trait_selection_types_declared_different = these two types are declared with different lifetimes...
458456
459457
trait_selection_unable_to_construct_constant_value = unable to construct a constant value for the unevaluated constant {$unevaluated}

compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs

+2-44
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_errors::codes::*;
66
use rustc_errors::{Diag, IntoDiagArg};
77
use rustc_hir as hir;
88
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
9-
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
9+
use rustc_hir::def_id::{DefId, LocalDefId};
1010
use rustc_hir::intravisit::{self, Visitor};
1111
use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, LetStmt, LocalSource};
1212
use rustc_middle::bug;
@@ -17,7 +17,7 @@ use rustc_middle::ty::{
1717
self, GenericArg, GenericArgKind, GenericArgsRef, InferConst, IsSuggestable, Term, TermKind,
1818
Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, TypeckResults,
1919
};
20-
use rustc_span::{BytePos, DUMMY_SP, FileName, Ident, Span, sym};
20+
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, sym};
2121
use tracing::{debug, instrument, warn};
2222

2323
use super::nice_region_error::placeholder_error::Highlighted;
@@ -438,7 +438,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
438438
bad_label,
439439
was_written: false,
440440
path: Default::default(),
441-
time_version: false,
442441
}),
443442
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
444443
span,
@@ -630,10 +629,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
630629
}
631630
}
632631
}
633-
634-
let time_version =
635-
self.detect_old_time_crate_version(failure_span, &kind, &mut infer_subdiags);
636-
637632
match error_code {
638633
TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired {
639634
span,
@@ -645,7 +640,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
645640
bad_label: None,
646641
was_written: path.is_some(),
647642
path: path.unwrap_or_default(),
648-
time_version,
649643
}),
650644
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
651645
span,
@@ -671,42 +665,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
671665
}),
672666
}
673667
}
674-
675-
/// Detect the inference regression on crate `time` <= 0.3.35 and emit a more targeted error.
676-
/// <https://github.com/rust-lang/rust/issues/127343>
677-
// FIXME: we should figure out a more generic version of doing this, ideally in cargo itself.
678-
fn detect_old_time_crate_version(
679-
&self,
680-
span: Option<Span>,
681-
kind: &InferSourceKind<'_>,
682-
// We will clear the non-actionable suggestion from the error to reduce noise.
683-
infer_subdiags: &mut Vec<SourceKindSubdiag<'_>>,
684-
) -> bool {
685-
// FIXME(#129461): We are time-boxing this code in the compiler. It'll start failing
686-
// compilation once we promote 1.89 to beta, which will happen in 9 months from now.
687-
#[cfg(not(version("1.89")))]
688-
const fn version_check() {}
689-
#[cfg(version("1.89"))]
690-
const fn version_check() {
691-
panic!("remove this check as presumably the ecosystem has moved from needing it");
692-
}
693-
const { version_check() };
694-
// Only relevant when building the `time` crate.
695-
if self.infcx.tcx.crate_name(LOCAL_CRATE) == sym::time
696-
&& let Some(span) = span
697-
&& let InferSourceKind::LetBinding { pattern_name, .. } = kind
698-
&& let Some(name) = pattern_name
699-
&& name.as_str() == "items"
700-
&& let FileName::Real(file) = self.infcx.tcx.sess.source_map().span_to_filename(span)
701-
{
702-
let path = file.local_path_if_available().to_string_lossy();
703-
if path.contains("format_description") && path.contains("parse") {
704-
infer_subdiags.clear();
705-
return true;
706-
}
707-
}
708-
false
709-
}
710668
}
711669

712670
#[derive(Debug)]

compiler/rustc_trait_selection/src/errors.rs

-2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ pub struct AnnotationRequired<'a> {
219219
#[note(trait_selection_full_type_written)]
220220
pub was_written: bool,
221221
pub path: PathBuf,
222-
#[note(trait_selection_type_annotations_needed_error_time)]
223-
pub time_version: bool,
224222
}
225223

226224
// Copy of `AnnotationRequired` for E0283

tests/ui/inference/detect-old-time-version-format_description-parse.rs

-13
This file was deleted.

tests/ui/inference/detect-old-time-version-format_description-parse.stderr

-14
This file was deleted.

0 commit comments

Comments
 (0)