Skip to content

Commit 1f2b8f9

Browse files
committed
canonical no type foldable :<
1 parent a932eb3 commit 1f2b8f9

File tree

5 files changed

+4
-26
lines changed

5 files changed

+4
-26
lines changed

compiler/rustc_hir_typeck/src/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
12131213
debug!("pick_all_method: step={:?}", step);
12141214
// skip types that are from a type error or that would require dereferencing
12151215
// a raw pointer
1216-
!step.self_ty.references_error() && !step.from_unsafe_deref
1216+
!step.self_ty.value.references_error() && !step.from_unsafe_deref
12171217
})
12181218
.find_map(|step| {
12191219
let InferOk { value: self_ty, obligations: _ } = self

compiler/rustc_hir_typeck/src/writeback.rs

+1-21
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_errors::ErrorGuaranteed;
99
use rustc_hir::intravisit::{self, InferKind, Visitor};
1010
use rustc_hir::{self as hir, AmbigArg, HirId};
1111
use rustc_infer::traits::solve::Goal;
12-
use rustc_middle::span_bug;
1312
use rustc_middle::traits::ObligationCause;
1413
use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
1514
use rustc_middle::ty::{
@@ -513,15 +512,6 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
513512
self.typeck_results.user_provided_types_mut().extend(
514513
fcx_typeck_results.user_provided_types().items().map(|(local_id, c_ty)| {
515514
let hir_id = HirId { owner: common_hir_owner, local_id };
516-
517-
if cfg!(debug_assertions) && c_ty.has_infer() {
518-
span_bug!(
519-
hir_id.to_span(self.fcx.tcx),
520-
"writeback: `{:?}` has inference variables",
521-
c_ty
522-
);
523-
};
524-
525515
(hir_id, *c_ty)
526516
}),
527517
);
@@ -532,17 +522,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
532522
assert_eq!(fcx_typeck_results.hir_owner, self.typeck_results.hir_owner);
533523

534524
self.typeck_results.user_provided_sigs.extend_unord(
535-
fcx_typeck_results.user_provided_sigs.items().map(|(&def_id, c_sig)| {
536-
if cfg!(debug_assertions) && c_sig.has_infer() {
537-
span_bug!(
538-
self.fcx.tcx.def_span(def_id),
539-
"writeback: `{:?}` has inference variables",
540-
c_sig
541-
);
542-
};
543-
544-
(def_id, *c_sig)
545-
}),
525+
fcx_typeck_results.user_provided_sigs.items().map(|(def_id, c_sig)| (*def_id, *c_sig)),
546526
);
547527
}
548528

compiler/rustc_middle/src/ty/structural_impls.rs

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_type_ir::{ConstKind, TypeFolder, VisitorResult, try_visit};
1313

1414
use super::print::PrettyPrinter;
1515
use super::{GenericArg, GenericArgKind, Pattern, Region};
16-
use crate::infer::canonical::CanonicalVarInfos;
1716
use crate::mir::PlaceElem;
1817
use crate::ty::print::{FmtPrinter, Printer, with_no_trimmed_paths};
1918
use crate::ty::{
@@ -779,5 +778,4 @@ list_fold! {
779778
ty::Clauses<'tcx> : mk_clauses,
780779
&'tcx ty::List<ty::PolyExistentialPredicate<'tcx>> : mk_poly_existential_predicates,
781780
&'tcx ty::List<PlaceElem<'tcx>> : mk_place_elems,
782-
CanonicalVarInfos<'tcx> : mk_canonical_var_infos,
783781
}

compiler/rustc_middle/src/ty/typeck_results.rs

+2
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,8 @@ pub type CanonicalUserTypeAnnotations<'tcx> =
701701

702702
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)]
703703
pub struct CanonicalUserTypeAnnotation<'tcx> {
704+
#[type_foldable(identity)]
705+
#[type_visitable(ignore)]
704706
pub user_ty: Box<CanonicalUserType<'tcx>>,
705707
pub span: Span,
706708
pub inferred_ty: Ty<'tcx>,

compiler/rustc_type_ir/src/canonical.rs

-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pub struct CanonicalQueryInput<I: Interner, V> {
3434
#[derive_where(Eq; I: Interner, V: Eq)]
3535
#[derive_where(Debug; I: Interner, V: fmt::Debug)]
3636
#[derive_where(Copy; I: Interner, V: Copy)]
37-
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
3837
#[cfg_attr(
3938
feature = "nightly",
4039
derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
@@ -147,7 +146,6 @@ impl<I: Interner> CanonicalVarInfo<I> {
147146
/// in the type-theory sense of the term -- i.e., a "meta" type system
148147
/// that analyzes type-like values.
149148
#[derive_where(Clone, Copy, Hash, PartialEq, Eq, Debug; I: Interner)]
150-
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
151149
#[cfg_attr(
152150
feature = "nightly",
153151
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)

0 commit comments

Comments
 (0)