Skip to content

Commit 58a0bc5

Browse files
committed
Disarm time bomb (diagnostics)
Revert "Rollup merge of #129343 - estebank:time-version, r=jieyouxu" This reverts commit 26f75a6, reversing changes made to 2572e0e.
1 parent a522d78 commit 58a0bc5

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
@@ -1974,7 +1974,6 @@ symbols! {
19741974
three_way_compare,
19751975
thumb2,
19761976
thumb_mode: "thumb-mode",
1977-
time,
19781977
tmm_reg,
19791978
to_owned_method,
19801979
to_string,

compiler/rustc_trait_selection/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,6 @@ trait_selection_type_annotations_needed = {$source_kind ->
448448
}
449449
.label = type must be known at this point
450450
451-
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`
452-
453451
trait_selection_types_declared_different = these two types are declared with different lifetimes...
454452
455453
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;
@@ -18,7 +18,7 @@ use rustc_middle::ty::{
1818
TypeFoldable, TypeFolder, TypeSuperFoldable, TypeckResults,
1919
};
2020
use rustc_span::symbol::{Ident, sym};
21-
use rustc_span::{BytePos, DUMMY_SP, FileName, Span};
21+
use rustc_span::{BytePos, DUMMY_SP, Span};
2222
use tracing::{debug, instrument, warn};
2323

2424
use crate::error_reporting::TypeErrCtxt;
@@ -385,7 +385,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
385385
bad_label,
386386
was_written: false,
387387
path: Default::default(),
388-
time_version: false,
389388
}),
390389
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
391390
span,
@@ -576,10 +575,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
576575
}
577576
}
578577
}
579-
580-
let time_version =
581-
self.detect_old_time_crate_version(failure_span, &kind, &mut infer_subdiags);
582-
583578
match error_code {
584579
TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired {
585580
span,
@@ -591,7 +586,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
591586
bad_label: None,
592587
was_written: path.is_some(),
593588
path: path.unwrap_or_default(),
594-
time_version,
595589
}),
596590
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
597591
span,
@@ -617,42 +611,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
617611
}),
618612
}
619613
}
620-
621-
/// Detect the inference regression on crate `time` <= 0.3.35 and emit a more targeted error.
622-
/// <https://github.com/rust-lang/rust/issues/127343>
623-
// FIXME: we should figure out a more generic version of doing this, ideally in cargo itself.
624-
fn detect_old_time_crate_version(
625-
&self,
626-
span: Option<Span>,
627-
kind: &InferSourceKind<'_>,
628-
// We will clear the non-actionable suggestion from the error to reduce noise.
629-
infer_subdiags: &mut Vec<SourceKindSubdiag<'_>>,
630-
) -> bool {
631-
// FIXME(#129461): We are time-boxing this code in the compiler. It'll start failing
632-
// compilation once we promote 1.89 to beta, which will happen in 9 months from now.
633-
#[cfg(not(version("1.89")))]
634-
const fn version_check() {}
635-
#[cfg(version("1.89"))]
636-
const fn version_check() {
637-
panic!("remove this check as presumably the ecosystem has moved from needing it");
638-
}
639-
const { version_check() };
640-
// Only relevant when building the `time` crate.
641-
if self.infcx.tcx.crate_name(LOCAL_CRATE) == sym::time
642-
&& let Some(span) = span
643-
&& let InferSourceKind::LetBinding { pattern_name, .. } = kind
644-
&& let Some(name) = pattern_name
645-
&& name.as_str() == "items"
646-
&& let FileName::Real(file) = self.infcx.tcx.sess.source_map().span_to_filename(span)
647-
{
648-
let path = file.local_path_if_available().to_string_lossy();
649-
if path.contains("format_description") && path.contains("parse") {
650-
infer_subdiags.clear();
651-
return true;
652-
}
653-
}
654-
false
655-
}
656614
}
657615

658616
#[derive(Debug)]

compiler/rustc_trait_selection/src/errors.rs

-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ pub struct AnnotationRequired<'a> {
206206
#[note(trait_selection_full_type_written)]
207207
pub was_written: bool,
208208
pub path: PathBuf,
209-
#[note(trait_selection_type_annotations_needed_error_time)]
210-
pub time_version: bool,
211209
}
212210

213211
// 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)