Skip to content

Commit 61c02cb

Browse files
committed
Disarm time bomb (diagnostics)
Revert "Rollup merge of rust-lang#129343 - estebank:time-version, r=jieyouxu" This reverts commit 26f75a6, reversing changes made to 2572e0e. Imports are modified to fix merge conflicts and remove unused ones.
1 parent 30f168e commit 61c02cb

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
@@ -2041,7 +2041,6 @@ symbols! {
20412041
three_way_compare,
20422042
thumb2,
20432043
thumb_mode: "thumb-mode",
2044-
time,
20452044
tmm_reg,
20462045
to_owned_method,
20472046
to_string,

compiler/rustc_trait_selection/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,6 @@ trait_selection_type_annotations_needed = {$source_kind ->
439439
}
440440
.label = type must be known at this point
441441
442-
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`
443-
444442
trait_selection_types_declared_different = these two types are declared with different lifetimes...
445443
446444
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, Ty, TyCtxt,
1818
TypeFoldable, TypeFolder, TypeSuperFoldable, 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 rustc_type_ir::visit::TypeVisitableExt;
2222
use tracing::{debug, instrument, warn};
2323

@@ -440,7 +440,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
440440
bad_label,
441441
was_written: false,
442442
path: Default::default(),
443-
time_version: false,
444443
}),
445444
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
446445
span,
@@ -632,10 +631,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
632631
}
633632
}
634633
}
635-
636-
let time_version =
637-
self.detect_old_time_crate_version(failure_span, &kind, &mut infer_subdiags);
638-
639634
match error_code {
640635
TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired {
641636
span,
@@ -647,7 +642,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
647642
bad_label: None,
648643
was_written: path.is_some(),
649644
path: path.unwrap_or_default(),
650-
time_version,
651645
}),
652646
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
653647
span,
@@ -673,42 +667,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
673667
}),
674668
}
675669
}
676-
677-
/// Detect the inference regression on crate `time` <= 0.3.35 and emit a more targeted error.
678-
/// <https://github.com/rust-lang/rust/issues/127343>
679-
// FIXME: we should figure out a more generic version of doing this, ideally in cargo itself.
680-
fn detect_old_time_crate_version(
681-
&self,
682-
span: Option<Span>,
683-
kind: &InferSourceKind<'_>,
684-
// We will clear the non-actionable suggestion from the error to reduce noise.
685-
infer_subdiags: &mut Vec<SourceKindSubdiag<'_>>,
686-
) -> bool {
687-
// FIXME(#129461): We are time-boxing this code in the compiler. It'll start failing
688-
// compilation once we promote 1.89 to beta, which will happen in 9 months from now.
689-
#[cfg(not(version("1.89")))]
690-
const fn version_check() {}
691-
#[cfg(version("1.89"))]
692-
const fn version_check() {
693-
panic!("remove this check as presumably the ecosystem has moved from needing it");
694-
}
695-
const { version_check() };
696-
// Only relevant when building the `time` crate.
697-
if self.infcx.tcx.crate_name(LOCAL_CRATE) == sym::time
698-
&& let Some(span) = span
699-
&& let InferSourceKind::LetBinding { pattern_name, .. } = kind
700-
&& let Some(name) = pattern_name
701-
&& name.as_str() == "items"
702-
&& let FileName::Real(file) = self.infcx.tcx.sess.source_map().span_to_filename(span)
703-
{
704-
let path = file.local_path_if_available().to_string_lossy();
705-
if path.contains("format_description") && path.contains("parse") {
706-
infer_subdiags.clear();
707-
return true;
708-
}
709-
}
710-
false
711-
}
712670
}
713671

714672
#[derive(Debug)]

compiler/rustc_trait_selection/src/errors.rs

-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ pub struct AnnotationRequired<'a> {
195195
#[note(trait_selection_full_type_written)]
196196
pub was_written: bool,
197197
pub path: PathBuf,
198-
#[note(trait_selection_type_annotations_needed_error_time)]
199-
pub time_version: bool,
200198
}
201199

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